diff --git a/chain/actors/builtin/miner/utils.go b/chain/actors/builtin/miner/utils.go index f9c6b3da3..2f24e8454 100644 --- a/chain/actors/builtin/miner/utils.go +++ b/chain/actors/builtin/miner/utils.go @@ -4,6 +4,8 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/go-bitfield" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/network" ) func AllPartSectors(mas State, sget func(Partition) (bitfield.BitField, error)) (bitfield.BitField, error) { @@ -26,3 +28,42 @@ func AllPartSectors(mas State, sget func(Partition) (bitfield.BitField, error)) return bitfield.MultiMerge(parts...) } + +// SealProofTypeFromSectorSize returns preferred seal proof type for creating +// new miner actors and new sectors +func SealProofTypeFromSectorSize(ssize abi.SectorSize, nv network.Version) (abi.RegisteredSealProof, error) { + switch { + case nv < network.Version7: + switch ssize { + case 2 << 10: + return abi.RegisteredSealProof_StackedDrg2KiBV1, nil + case 8 << 20: + return abi.RegisteredSealProof_StackedDrg8MiBV1, nil + case 512 << 20: + return abi.RegisteredSealProof_StackedDrg512MiBV1, nil + case 32 << 30: + return abi.RegisteredSealProof_StackedDrg32GiBV1, nil + case 64 << 30: + return abi.RegisteredSealProof_StackedDrg64GiBV1, nil + default: + return 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize) + } + case nv >= network.Version7: + switch ssize { + case 2 << 10: + return abi.RegisteredSealProof_StackedDrg2KiBV1_1, nil + case 8 << 20: + return abi.RegisteredSealProof_StackedDrg8MiBV1_1, nil + case 512 << 20: + return abi.RegisteredSealProof_StackedDrg512MiBV1_1, nil + case 32 << 30: + return abi.RegisteredSealProof_StackedDrg32GiBV1_1, nil + case 64 << 30: + return abi.RegisteredSealProof_StackedDrg64GiBV1_1, nil + default: + return 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize) + } + } + + return 0, xerrors.Errorf("unsupported network version") +} diff --git a/chain/actors/version.go b/chain/actors/version.go index fe16d521e..1cafa45c9 100644 --- a/chain/actors/version.go +++ b/chain/actors/version.go @@ -18,7 +18,7 @@ func VersionForNetwork(version network.Version) Version { switch version { case network.Version0, network.Version1, network.Version2, network.Version3: return Version0 - case network.Version4, network.Version5, network.Version6: + case network.Version4, network.Version5, network.Version6, network.Version7, network.Version8: return Version2 default: panic(fmt.Sprintf("unsupported network version %d", version)) diff --git a/cmd/lotus-seal-worker/main.go b/cmd/lotus-seal-worker/main.go index 520964867..1f20bffbd 100644 --- a/cmd/lotus-seal-worker/main.go +++ b/cmd/lotus-seal-worker/main.go @@ -32,7 +32,6 @@ import ( "github.com/filecoin-project/lotus/build" lcli "github.com/filecoin-project/lotus/cli" sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage" - "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" "github.com/filecoin-project/lotus/extern/sector-storage/sealtasks" "github.com/filecoin-project/lotus/extern/sector-storage/stores" "github.com/filecoin-project/lotus/lib/lotuslog" @@ -356,11 +355,6 @@ var runCmd = &cli.Command{ } // Setup remote sector store - spt, err := ffiwrapper.SealProofTypeFromSectorSize(ssize) - if err != nil { - return xerrors.Errorf("getting proof type: %w", err) - } - sminfo, err := lcli.GetAPIInfo(cctx, repo.StorageMiner) if err != nil { return xerrors.Errorf("could not get api info: %w", err) @@ -374,7 +368,6 @@ var runCmd = &cli.Command{ workerApi := &worker{ LocalWorker: sectorstorage.NewLocalWorker(sectorstorage.WorkerConfig{ - SealProof: spt, TaskTypes: taskTypes, NoSwap: cctx.Bool("no-swap"), }, remote, localStore, nodeApi, nodeApi, wsts), diff --git a/cmd/lotus-storage-miner/init.go b/cmd/lotus-storage-miner/init.go index a7fcd722a..008b2ea15 100644 --- a/cmd/lotus-storage-miner/init.go +++ b/cmd/lotus-storage-miner/init.go @@ -433,11 +433,6 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode, return err } - spt, err := ffiwrapper.SealProofTypeFromSectorSize(ssize) - if err != nil { - return err - } - mid, err := address.IDFromAddress(a) if err != nil { return xerrors.Errorf("getting id address: %w", err) @@ -451,9 +446,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode, wsts := statestore.New(namespace.Wrap(mds, modules.WorkerCallsPrefix)) smsts := statestore.New(namespace.Wrap(mds, modules.ManagerWorkPrefix)) - smgr, err := sectorstorage.New(ctx, lr, stores.NewIndex(), &ffiwrapper.Config{ - SealProofType: spt, - }, sectorstorage.SealerConfig{ + smgr, err := sectorstorage.New(ctx, lr, stores.NewIndex(), sectorstorage.SealerConfig{ ParallelFetchLimit: 10, AllowAddPiece: true, AllowPreCommit1: true, @@ -657,9 +650,14 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID, } } - spt, err := ffiwrapper.SealProofTypeFromSectorSize(abi.SectorSize(ssize)) + nv, err := api.StateNetworkVersion(ctx, types.EmptyTSK) if err != nil { - return address.Undef, err + return address.Undef, xerrors.Errorf("getting network version: %w", err) + } + + spt, err := miner.SealProofTypeFromSectorSize(abi.SectorSize(ssize), nv) + if err != nil { + return address.Undef, xerrors.Errorf("getting seal proof type: %w", err) } params, err := actors.SerializeParams(&power2.CreateMinerParams{ diff --git a/extern/sector-storage/ffiwrapper/config.go b/extern/sector-storage/ffiwrapper/config.go deleted file mode 100644 index a7669b8bd..000000000 --- a/extern/sector-storage/ffiwrapper/config.go +++ /dev/null @@ -1,24 +0,0 @@ -package ffiwrapper - -import ( - "golang.org/x/xerrors" - - "github.com/filecoin-project/go-state-types/abi" -) - -func SealProofTypeFromSectorSizea(ssize abi.SectorSize) (abi.RegisteredSealProof, error) { - switch ssize { - case 2 << 10: - return abi.RegisteredSealProof_StackedDrg2KiBV1, nil - case 8 << 20: - return abi.RegisteredSealProof_StackedDrg8MiBV1, nil - case 512 << 20: - return abi.RegisteredSealProof_StackedDrg512MiBV1, nil - case 32 << 30: - return abi.RegisteredSealProof_StackedDrg32GiBV1, nil - case 64 << 30: - return abi.RegisteredSealProof_StackedDrg64GiBV1, nil - default: - return 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize) - } -}