Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion cli/spcli/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
10 changes: 8 additions & 2 deletions cli/spcli/createminer/create_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 13 additions & 1 deletion cmd/lotus-shed/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down