From ab90a3b2bc3d09ab3d615cb7b07cb876d823979f Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Sat, 16 Jan 2021 01:42:56 -0500 Subject: [PATCH] Actors update: MinerInfo.SealProofType has been removed --- chain/actors/builtin/miner/miner.go | 20 +++++++++++++++++++- chain/actors/builtin/miner/v0.go | 7 ++++++- chain/actors/builtin/miner/v2.go | 7 ++++++- chain/stmgr/utils.go | 7 +------ cmd/lotus-storage-miner/proving.go | 7 +------ extern/storage-sealing/sealing.go | 2 +- markets/storageadapter/provider.go | 4 +++- node/impl/client/client.go | 9 ++++++++- node/impl/full/state.go | 5 ----- node/modules/storageminer.go | 4 +++- storage/miner.go | 7 +------ storage/wdpost_sched.go | 7 +------ 12 files changed, 50 insertions(+), 36 deletions(-) diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index 248412b90..cb147bf45 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -143,6 +143,24 @@ type DeclareFaultsRecoveredParams = miner0.DeclareFaultsRecoveredParams type SubmitWindowedPoStParams = miner0.SubmitWindowedPoStParams type ProveCommitSectorParams = miner0.ProveCommitSectorParams +// TODO: This may need to be epoch-sensitive +func PreferredSealProofTypeFromWindowPoStType(proof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) { + switch proof { + case abi.RegisteredPoStProof_StackedDrgWindow2KiBV1: + return abi.RegisteredSealProof_StackedDrg2KiBV1_1, nil + case abi.RegisteredPoStProof_StackedDrgWindow8MiBV1: + return abi.RegisteredSealProof_StackedDrg8MiBV1_1, nil + case abi.RegisteredPoStProof_StackedDrgWindow512MiBV1: + return abi.RegisteredSealProof_StackedDrg512MiBV1_1, nil + case abi.RegisteredPoStProof_StackedDrgWindow32GiBV1: + return abi.RegisteredSealProof_StackedDrg32GiBV1_1, nil + case abi.RegisteredPoStProof_StackedDrgWindow64GiBV1: + return abi.RegisteredSealProof_StackedDrg64GiBV1_1, nil + default: + return -1, xerrors.Errorf("unrecognized window post type: %d", proof) + } +} + type MinerInfo struct { Owner address.Address // Must be an ID-address. Worker address.Address // Must be an ID-address. @@ -151,7 +169,7 @@ type MinerInfo struct { WorkerChangeEpoch abi.ChainEpoch PeerId *peer.ID Multiaddrs []abi.Multiaddrs - SealProofType abi.RegisteredSealProof + WindowPoStProofType abi.RegisteredPoStProof SectorSize abi.SectorSize WindowPoStPartitionSectors uint64 ConsensusFaultElapsed abi.ChainEpoch diff --git a/chain/actors/builtin/miner/v0.go b/chain/actors/builtin/miner/v0.go index 7967a5fc3..2795d6d70 100644 --- a/chain/actors/builtin/miner/v0.go +++ b/chain/actors/builtin/miner/v0.go @@ -297,6 +297,11 @@ func (s *state0) Info() (MinerInfo, error) { pid = &peerID } + wpp, err := info.SealProofType.RegisteredWindowPoStProof() + if err != nil { + return MinerInfo{}, err + } + mi := MinerInfo{ Owner: info.Owner, Worker: info.Worker, @@ -307,7 +312,7 @@ func (s *state0) Info() (MinerInfo, error) { PeerId: pid, Multiaddrs: info.Multiaddrs, - SealProofType: info.SealProofType, + WindowPoStProofType: wpp, SectorSize: info.SectorSize, WindowPoStPartitionSectors: info.WindowPoStPartitionSectors, ConsensusFaultElapsed: -1, diff --git a/chain/actors/builtin/miner/v2.go b/chain/actors/builtin/miner/v2.go index 5130a218e..854aa6ab7 100644 --- a/chain/actors/builtin/miner/v2.go +++ b/chain/actors/builtin/miner/v2.go @@ -296,6 +296,11 @@ func (s *state2) Info() (MinerInfo, error) { pid = &peerID } + wpp, err := info.SealProofType.RegisteredWindowPoStProof() + if err != nil { + return MinerInfo{}, err + } + mi := MinerInfo{ Owner: info.Owner, Worker: info.Worker, @@ -306,7 +311,7 @@ func (s *state2) Info() (MinerInfo, error) { PeerId: pid, Multiaddrs: info.Multiaddrs, - SealProofType: info.SealProofType, + WindowPoStProofType: wpp, SectorSize: info.SectorSize, WindowPoStPartitionSectors: info.WindowPoStPartitionSectors, ConsensusFaultElapsed: info.ConsensusFaultElapsed, diff --git a/chain/stmgr/utils.go b/chain/stmgr/utils.go index 1e29e72d8..ce0384842 100644 --- a/chain/stmgr/utils.go +++ b/chain/stmgr/utils.go @@ -207,17 +207,12 @@ func GetSectorsForWinningPoSt(ctx context.Context, nv network.Version, pv ffiwra return nil, xerrors.Errorf("getting miner info: %w", err) } - wpt, err := info.SealProofType.RegisteredWinningPoStProof() - if err != nil { - return nil, xerrors.Errorf("getting window proof type: %w", err) - } - mid, err := address.IDFromAddress(maddr) if err != nil { return nil, xerrors.Errorf("getting miner ID: %w", err) } - ids, err := pv.GenerateWinningPoStSectorChallenge(ctx, wpt, abi.ActorID(mid), rand, numProvSect) + ids, err := pv.GenerateWinningPoStSectorChallenge(ctx, info.WindowPoStProofType, abi.ActorID(mid), rand, numProvSect) if err != nil { return nil, xerrors.Errorf("generating winning post challenges: %w", err) } diff --git a/cmd/lotus-storage-miner/proving.go b/cmd/lotus-storage-miner/proving.go index 6f379e99c..3d60f4b76 100644 --- a/cmd/lotus-storage-miner/proving.go +++ b/cmd/lotus-storage-miner/proving.go @@ -430,11 +430,6 @@ var provingCheckProvableCmd = &cli.Command{ return err } - pf, err := info.SealProofType.RegisteredWindowPoStProof() - if err != nil { - return err - } - partitions, err := api.StateMinerPartitions(ctx, addr, dlIdx, types.EmptyTSK) if err != nil { return err @@ -463,7 +458,7 @@ var provingCheckProvableCmd = &cli.Command{ }) } - bad, err := sapi.CheckProvable(ctx, pf, tocheck, cctx.Bool("slow")) + bad, err := sapi.CheckProvable(ctx, info.WindowPoStProofType, tocheck, cctx.Bool("slow")) if err != nil { return err } diff --git a/extern/storage-sealing/sealing.go b/extern/storage-sealing/sealing.go index 96d63efdc..2219d9d2c 100644 --- a/extern/storage-sealing/sealing.go +++ b/extern/storage-sealing/sealing.go @@ -475,7 +475,7 @@ func (m *Sealing) currentSealProof(ctx context.Context) (abi.RegisteredSealProof return 0, err } - return mi.SealProofType, nil + return miner.PreferredSealProofTypeFromWindowPoStType(mi.WindowPoStProofType) } func (m *Sealing) minerSector(spt abi.RegisteredSealProof, num abi.SectorNumber) storage.SectorRef { diff --git a/markets/storageadapter/provider.go b/markets/storageadapter/provider.go index 085888ee3..6a06c46e3 100644 --- a/markets/storageadapter/provider.go +++ b/markets/storageadapter/provider.go @@ -7,6 +7,8 @@ import ( "io" "time" + miner2 "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" "golang.org/x/xerrors" @@ -179,7 +181,7 @@ func (n *ProviderNodeAdapter) GetProofType(ctx context.Context, miner address.Ad if err != nil { return 0, err } - return mi.SealProofType, nil + return miner2.PreferredSealProofTypeFromWindowPoStType(mi.WindowPoStProofType) } func (n *ProviderNodeAdapter) SignBytes(ctx context.Context, signer address.Address, b []byte) (*crypto.Signature, error) { diff --git a/node/impl/client/client.go b/node/impl/client/client.go index e90a31a80..3868e69ea 100644 --- a/node/impl/client/client.go +++ b/node/impl/client/client.go @@ -7,6 +7,8 @@ import ( "io" "os" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "golang.org/x/xerrors" "github.com/filecoin-project/go-padreader" @@ -157,6 +159,11 @@ func (a *API) ClientStartDeal(ctx context.Context, params *api.StartDealParams) dealStart = ts.Height() + abi.ChainEpoch(dealStartBufferHours*blocksPerHour) // TODO: Get this from storage ask } + st, err := miner.PreferredSealProofTypeFromWindowPoStType(mi.WindowPoStProofType) + if err != nil { + return nil, xerrors.Errorf("failed to get seal proof type: %w", err) + } + result, err := a.SMDealClient.ProposeStorageDeal(ctx, storagemarket.ProposeStorageDealParams{ Addr: params.Wallet, Info: &providerInfo, @@ -165,7 +172,7 @@ func (a *API) ClientStartDeal(ctx context.Context, params *api.StartDealParams) EndEpoch: calcDealExpiration(params.MinBlocksDuration, md, dealStart), Price: params.EpochPrice, Collateral: params.ProviderCollateral, - Rt: mi.SealProofType, + Rt: st, FastRetrieval: params.FastRetrieval, VerifiedDeal: params.VerifiedDeal, StoreID: storeID, diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 784bb890d..cecf8ef55 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -140,15 +140,10 @@ func (m *StateModule) StateMinerInfo(ctx context.Context, actor address.Address, return miner.MinerInfo{}, xerrors.Errorf("failed to load miner actor state: %w", err) } - // TODO: You know, this is terrible. - // I mean, we _really_ shouldn't do this. Maybe we should convert somewhere else? info, err := mas.Info() if err != nil { return miner.MinerInfo{}, err } - if m.StateManager.GetNtwkVersion(ctx, ts.Height()) >= network.Version7 && info.SealProofType < abi.RegisteredSealProof_StackedDrg2KiBV1_1 { - info.SealProofType += abi.RegisteredSealProof_StackedDrg2KiBV1_1 - } return info, nil } diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index 30f84aeaf..165e98e01 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -10,6 +10,8 @@ import ( "path/filepath" "time" + miner2 "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "go.uber.org/fx" "go.uber.org/multierr" "golang.org/x/xerrors" @@ -128,7 +130,7 @@ func SealProofType(maddr dtypes.MinerAddress, fnapi lapi.FullNode) (abi.Register return 0, err } - return mi.SealProofType, nil + return miner2.PreferredSealProofTypeFromWindowPoStType(mi.WindowPoStProofType) } type sidsc struct { diff --git a/storage/miner.go b/storage/miner.go index 752d7ff42..425664991 100644 --- a/storage/miner.go +++ b/storage/miner.go @@ -225,18 +225,13 @@ func NewWinningPoStProver(api api.FullNode, prover storage.Prover, verifier ffiw return nil, xerrors.Errorf("getting sector size: %w", err) } - wpt, err := mi.SealProofType.RegisteredWinningPoStProof() - if err != nil { - return nil, err - } - if build.InsecurePoStValidation { log.Warn("*****************************************************************************") log.Warn(" Generating fake PoSt proof! You should only see this while running tests! ") log.Warn("*****************************************************************************") } - return &StorageWpp{prover, verifier, abi.ActorID(miner), wpt}, nil + return &StorageWpp{prover, verifier, abi.ActorID(miner), mi.WindowPoStProofType}, nil } var _ gen.WinningPoStProver = (*StorageWpp)(nil) diff --git a/storage/wdpost_sched.go b/storage/wdpost_sched.go index f81a60a1e..3d6073a63 100644 --- a/storage/wdpost_sched.go +++ b/storage/wdpost_sched.go @@ -47,18 +47,13 @@ func NewWindowedPoStScheduler(api storageMinerApi, fc config.MinerFeeConfig, as return nil, xerrors.Errorf("getting sector size: %w", err) } - rt, err := mi.SealProofType.RegisteredWindowPoStProof() - if err != nil { - return nil, err - } - return &WindowPoStScheduler{ api: api, feeCfg: fc, addrSel: as, prover: sb, faultTracker: ft, - proofType: rt, + proofType: mi.WindowPoStProofType, partitionSectors: mi.WindowPoStPartitionSectors, actor: actor,