Skip to content

Commit

Permalink
Merge pull request #9364 from filecoin-project/asr/miner-init-fix
Browse files Browse the repository at this point in the history
fix: miner: init miner's with 32GiB sectors by default
  • Loading branch information
arajasek authored Sep 23, 2022
2 parents 4aa5323 + 72b6768 commit ba89d2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions cmd/lotus-miner/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ var initCmd = &cli.Command{
&cli.StringFlag{
Name: "sector-size",
Usage: "specify sector size to use",
Value: units.BytesSize(float64(abi.SectorSize(2048))),
},
&cli.StringSliceFlag{
Name: "pre-sealed-sectors",
Expand Down Expand Up @@ -129,11 +128,18 @@ var initCmd = &cli.Command{
Action: func(cctx *cli.Context) error {
log.Info("Initializing lotus miner")

sectorSizeInt, err := units.RAMInBytes(cctx.String("sector-size"))
ssize, err := abi.RegisteredSealProof_StackedDrg32GiBV1.SectorSize()
if err != nil {
return err
return xerrors.Errorf("failed to calculate default sector size: %w", err)
}

if cctx.IsSet("sector-size") {
sectorSizeInt, err := units.RAMInBytes(cctx.String("sector-size"))
if err != nil {
return err
}
ssize = abi.SectorSize(sectorSizeInt)
}
ssize := abi.SectorSize(sectorSizeInt)

gasPrice, err := types.BigFromString(cctx.String("gas-premium"))
if err != nil {
Expand Down Expand Up @@ -541,7 +547,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api v1api.FullNode

addr = a
} else {
a, err := createStorageMiner(ctx, api, peerid, gasPrice, cctx)
a, err := createStorageMiner(ctx, api, ssize, peerid, gasPrice, cctx)
if err != nil {
return xerrors.Errorf("creating miner failed: %w", err)
}
Expand Down Expand Up @@ -621,7 +627,7 @@ func configureStorageMiner(ctx context.Context, api v1api.FullNode, addr address
return nil
}

func createStorageMiner(ctx context.Context, api v1api.FullNode, peerid peer.ID, gasPrice types.BigInt, cctx *cli.Context) (address.Address, error) {
func createStorageMiner(ctx context.Context, api v1api.FullNode, ssize abi.SectorSize, peerid peer.ID, gasPrice types.BigInt, cctx *cli.Context) (address.Address, error) {
var err error
var owner address.Address
if cctx.String("owner") != "" {
Expand All @@ -633,11 +639,6 @@ func createStorageMiner(ctx context.Context, api v1api.FullNode, peerid peer.ID,
return address.Undef, err
}

ssize, err := units.RAMInBytes(cctx.String("sector-size"))
if err != nil {
return address.Undef, fmt.Errorf("failed to parse sector size: %w", err)
}

worker := owner
if cctx.String("worker") != "" {
worker, err = address.NewFromString(cctx.String("worker"))
Expand Down Expand Up @@ -712,7 +713,7 @@ func createStorageMiner(ctx context.Context, api v1api.FullNode, peerid peer.ID,
}

// Note: the correct thing to do would be to call SealProofTypeFromSectorSize if actors version is v3 or later, but this still works
spt, err := miner.WindowPoStProofTypeFromSectorSize(abi.SectorSize(ssize))
spt, err := miner.WindowPoStProofTypeFromSectorSize(ssize)
if err != nil {
return address.Undef, xerrors.Errorf("getting post proof type: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion documentation/en/cli-lotus-miner.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ OPTIONS:
--create-worker-key create separate worker key (default: false)
--worker value, -w value worker key to use (overrides --create-worker-key)
--owner value, -o value owner key to use
--sector-size value specify sector size to use (default: "2KiB")
--sector-size value specify sector size to use
--pre-sealed-sectors value specify set of presealed sectors for starting as a genesis miner (accepts multiple inputs)
--pre-sealed-metadata value specify the metadata file for the presealed sectors
--nosync don't check full-node sync status (default: false)
Expand Down

0 comments on commit ba89d2c

Please sign in to comment.