From 9c31f61db4955c940756230b89a9cebabfdca3a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 19 Feb 2020 20:26:11 +0100 Subject: [PATCH] sectorset updates --- api/api_full.go | 5 ++--- chain/gen/gen.go | 9 +++++++-- chain/gen/genesis/miners.go | 6 ++++++ chain/stmgr/utils.go | 25 ++++++++++++++++++------- go.mod | 2 +- go.sum | 2 ++ 6 files changed, 36 insertions(+), 13 deletions(-) diff --git a/api/api_full.go b/api/api_full.go index 18bc92434..62c8c60db 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -192,9 +192,8 @@ type Message struct { } type ChainSectorInfo struct { - SectorID abi.SectorNumber - CommD []byte - CommR []byte + Info miner.SectorOnChainInfo + ID abi.SectorNumber } type ActorState struct { diff --git a/chain/gen/gen.go b/chain/gen/gen.go index 8a7c4df72..1547a9c10 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -9,6 +9,7 @@ import ( "io/ioutil" "sync/atomic" + commcid "github.com/filecoin-project/go-fil-commcid" "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-actors/actors/crypto" block "github.com/ipfs/go-block-format" @@ -532,10 +533,14 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round int64, miner add var sinfos []ffi.PublicSectorInfo for _, s := range pset { + cr, err := commcid.CIDToReplicaCommitmentV1(s.Info.Info.SealedCID) + if err != nil { + return nil, err + } var commRa [32]byte - copy(commRa[:], s.CommR) + copy(commRa[:], cr) sinfos = append(sinfos, ffi.PublicSectorInfo{ - SectorNum: s.SectorID, + SectorNum: s.ID, CommR: commRa, }) } diff --git a/chain/gen/genesis/miners.go b/chain/gen/genesis/miners.go index acdf126ab..51fe74f00 100644 --- a/chain/gen/genesis/miners.go +++ b/chain/gen/genesis/miners.go @@ -151,6 +151,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid for pi, preseal := range m.Sectors { // TODO: Maybe check seal (Can just be snark inputs, doesn't go into the genesis file) + // check deals, get dealWeight dealWeight := big.Zero() { params := &market.VerifyDealsOnSectorProveCommitParams{ @@ -167,6 +168,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid } } + // update power claims pledge := big.Zero() { err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error { @@ -189,6 +191,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid } } + // Put sectors to miner sector sets { newSectorInfo := &miner.SectorOnChainInfo{ Info: miner.SectorPreCommitInfo{ @@ -213,6 +216,9 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid st.ProvingSet = st.Sectors return nil }) + if err != nil { + return cid.Cid{}, xerrors.Errorf("put to sset: %w", err) + } } { diff --git a/chain/stmgr/utils.go b/chain/stmgr/utils.go index 4b945e860..fef31a844 100644 --- a/chain/stmgr/utils.go +++ b/chain/stmgr/utils.go @@ -4,6 +4,7 @@ import ( "context" amt "github.com/filecoin-project/go-amt-ipld/v2" + commcid "github.com/filecoin-project/go-fil-commcid" "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-actors/actors/abi/big" "github.com/filecoin-project/specs-actors/actors/builtin/market" @@ -149,10 +150,14 @@ func GetSectorsForElectionPost(ctx context.Context, sm *StateManager, ts *types. var uselessOtherArray []ffi.PublicSectorInfo for _, s := range sectors { + cr, err := commcid.CIDToReplicaCommitmentV1(s.Info.Info.SealedCID) + if err != nil { + return nil, err + } var uselessBuffer [32]byte - copy(uselessBuffer[:], s.CommR) + copy(uselessBuffer[:], cr) uselessOtherArray = append(uselessOtherArray, ffi.PublicSectorInfo{ - SectorNum: s.SectorID, + SectorNum: s.ID, CommR: uselessBuffer, }) } @@ -262,14 +267,20 @@ func LoadSectorsFromSet(ctx context.Context, bs blockstore.Blockstore, ssc cid.C var sset []*api.ChainSectorInfo if err := a.ForEach(ctx, func(i uint64, v *cbg.Deferred) error { - var comms [][]byte - if err := cbor.DecodeInto(v.Raw, &comms); err != nil { + var oci miner.SectorOnChainInfo + if err := cbor.DecodeInto(v.Raw, &oci); err != nil { return err } sset = append(sset, &api.ChainSectorInfo{ - SectorID: abi.SectorNumber(i), - CommR: comms[0], - CommD: comms[1], + Info: miner.SectorOnChainInfo{ + Info: miner.SectorPreCommitInfo{}, + ActivationEpoch: 0, + DealWeight: abi.DealWeight{}, + PledgeRequirement: abi.TokenAmount{}, + DeclaredFaultEpoch: 0, + DeclaredFaultDuration: 0, + }, + ID: abi.SectorNumber(i), }) return nil }); err != nil { diff --git a/go.mod b/go.mod index 9bef620e7..415df7fc8 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/filecoin-project/go-paramfetch v0.0.1 github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200210220012-eb75ec747d6b github.com/filecoin-project/go-statestore v0.1.0 - github.com/filecoin-project/specs-actors v0.0.0-20200218211922-372fea3f131f + github.com/filecoin-project/specs-actors v0.0.0-20200219191759-7e15e5c89659 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 github.com/go-ole/go-ole v1.2.4 // indirect github.com/gorilla/mux v1.7.3 diff --git a/go.sum b/go.sum index 89cb4d124..e5febe8ee 100644 --- a/go.sum +++ b/go.sum @@ -130,6 +130,8 @@ github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf h1:f github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA= github.com/filecoin-project/specs-actors v0.0.0-20200218211922-372fea3f131f h1:xfjeZfwhrNlp9/71gprhfC+HL8htJukplomyGxrdkBY= github.com/filecoin-project/specs-actors v0.0.0-20200218211922-372fea3f131f/go.mod h1:Ecx+3v6Bn4exCS0NbPu7VjrDCu2J+t1PdEpYin1/qOU= +github.com/filecoin-project/specs-actors v0.0.0-20200219191759-7e15e5c89659 h1:qHn5166bAy0dVEZr1Z4TPoveZNEEcFVz+RumCSM6QqA= +github.com/filecoin-project/specs-actors v0.0.0-20200219191759-7e15e5c89659/go.mod h1:Ecx+3v6Bn4exCS0NbPu7VjrDCu2J+t1PdEpYin1/qOU= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 h1:EzDjxMg43q1tA2c0MV3tNbaontnHLplHyFF6M5KiVP0=