diff --git a/CHANGELOG.md b/CHANGELOG.md index fa8131d25c0..62979834247 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - The minimum supported Golang version is now `1.24.7` - feat(gateway): expose StateGetRandomnessDigestFromBeacon ([filecoin-project/lotus#13339](https://github.com/filecoin-project/lotus/pull/13339)) - chore(deps): update of quic-go to v0.54.1 and go-libp2p to v0.43.0 ([filecoin-project/lotus#13361](https://github.com/filecoin-project/lotus/pull/13361)) +- feat(spcli): add a `deposit-margin-factor` option to `lotus-miner actor new` and `lotus-shed miner create` so the sent deposit still covers the on-chain requirement if it rises between lookup and execution # Node and Miner v1.34.0 / 2025-09-11 diff --git a/cli/spcli/actor.go b/cli/spcli/actor.go index dc40448f219..ed4ce2fe280 100644 --- a/cli/spcli/actor.go +++ b/cli/spcli/actor.go @@ -1491,6 +1491,11 @@ var ActorNewMinerCmd = &cli.Command{ Usage: "number of block confirmations to wait for", Value: int(buildconstants.MessageConfidence), }, + &cli.Float64Flag{ + Name: "deposit-margin-factor", + Usage: "Multiplier (>=1.0) to scale the suggested deposit for on-chain variance (e.g. 1.01 adds 1%)", + Value: 1.01, + }, }, Action: func(cctx *cli.Context) error { ctx := cctx.Context @@ -1538,7 +1543,7 @@ var ActorNewMinerCmd = &cli.Command{ } ssize := abi.SectorSize(sectorSizeInt) - _, err = createminer.CreateStorageMiner(ctx, full, owner, worker, sender, ssize, cctx.Uint64("confidence")) + _, err = createminer.CreateStorageMiner(ctx, full, owner, worker, sender, ssize, cctx.Uint64("confidence"), cctx.Float64("deposit-margin-factor")) if err != nil { return err } diff --git a/cli/spcli/createminer/create_miner.go b/cli/spcli/createminer/create_miner.go index 6240f9b8f33..4ed574d10e3 100644 --- a/cli/spcli/createminer/create_miner.go +++ b/cli/spcli/createminer/create_miner.go @@ -19,7 +19,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -func CreateStorageMiner(ctx context.Context, fullNode v1api.FullNode, owner, worker, sender address.Address, ssize abi.SectorSize, confidence uint64) (address.Address, error) { +func CreateStorageMiner(ctx context.Context, fullNode v1api.FullNode, owner, worker, sender address.Address, ssize abi.SectorSize, confidence uint64, depositMarginFactor float64) (address.Address, error) { // make sure the sender account exists on chain _, err := fullNode.StateLookupID(ctx, owner, types.EmptyTSK) if err != nil { @@ -93,15 +93,21 @@ func CreateStorageMiner(ctx context.Context, fullNode v1api.FullNode, owner, wor return address.Undef, err } + if depositMarginFactor < 1 { + return address.Undef, xerrors.Errorf("deposit margin factor must be greater than 1") + } + deposit, err := fullNode.StateMinerCreationDeposit(ctx, types.EmptyTSK) if err != nil { return address.Undef, xerrors.Errorf("getting miner creation deposit: %w", err) } + scaledDeposit := types.BigDiv(types.BigMul(deposit, types.NewInt(uint64(depositMarginFactor*100))), types.NewInt(100)) + createStorageMinerMsg := &types.Message{ To: power.Address, From: sender, - Value: deposit, + Value: scaledDeposit, Method: power.Methods.CreateMiner, Params: params, diff --git a/cmd/lotus-shed/miner.go b/cmd/lotus-shed/miner.go index 722b9a6c4db..43493d8c4bf 100644 --- a/cmd/lotus-shed/miner.go +++ b/cmd/lotus-shed/miner.go @@ -238,6 +238,11 @@ var minerCreateCmd = &cli.Command{ Usage: "number of block confirmations to wait for", Value: int(buildconstants.MessageConfidence), }, + &cli.Float64Flag{ + Name: "deposit-margin-factor", + Usage: "Multiplier (>=1.0) to scale the suggested deposit for on-chain variance (e.g. 1.01 adds 1%)", + Value: 1.01, + }, }, Action: func(cctx *cli.Context) error { wapi, closer, err := lcli.GetFullNodeAPIV1(cctx) @@ -348,16 +353,23 @@ var minerCreateCmd = &cli.Command{ return err } + depositMarginFactor := cctx.Float64("deposit-margin-factor") + if depositMarginFactor < 1 { + return xerrors.Errorf("deposit margin factor must be greater than 1") + } + // Calculate miner creation deposit according to FIP-0077 deposit, err := wapi.StateMinerCreationDeposit(ctx, types.EmptyTSK) if err != nil { return xerrors.Errorf("getting miner creation deposit: %w", err) } + scaledDeposit := types.BigDiv(types.BigMul(deposit, types.NewInt(uint64(depositMarginFactor*100))), types.NewInt(100)) + createStorageMinerMsg := &types.Message{ To: power.Address, From: sender, - Value: deposit, + Value: scaledDeposit, Method: power.Methods.CreateMiner, Params: params,