Skip to content

Commit

Permalink
Add feature to stagger sector prove commit submission (#10543)
Browse files Browse the repository at this point in the history
* Add feature to stagger sector prove commit submission

* make gen and docsgen as usual

* address comments and lint

* Update comment

Co-authored-by: Łukasz Magiera <magik6k@users.noreply.github.com>

* make gen for stupid comment

* make docsgen

* address comments

---------

Co-authored-by: Łukasz Magiera <magik6k@users.noreply.github.com>
  • Loading branch information
shrenujbansal and magik6k authored Apr 1, 2023
1 parent 3b0d4f2 commit 2278a20
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 10 deletions.
10 changes: 10 additions & 0 deletions documentation/en/default-lotus-miner-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,16 @@
# env var: LOTUS_SEALING_AGGREGATEABOVEBASEFEE
#AggregateAboveBaseFee = "0.00000000032 FIL"

# When submitting several sector prove commit messages simultaneously, this option allows you to
# stagger the number of prove commits submitted per epoch
# This is done because gas estimates for ProveCommits are non deterministic and increasing as a large
# number of sectors get committed within the same epoch resulting in occasionally failed msgs.
# Submitting a smaller number of prove commits per epoch would reduce the possibility of failed msgs
#
# type: uint64
# env var: LOTUS_SEALING_MAXSECTORPROVECOMMITSSUBMITTEDPEREPOCH
#MaxSectorProveCommitsSubmittedPerEpoch = 0

# type: uint64
# env var: LOTUS_SEALING_TERMINATEBATCHMAX
#TerminateBatchMax = 100
Expand Down
10 changes: 10 additions & 0 deletions node/config/doc_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,13 @@ type SealingConfig struct {
// submitting proofs to the chain individually
AggregateAboveBaseFee types.FIL

// When submitting several sector prove commit messages simultaneously, this option allows you to
// stagger the number of prove commits submitted per epoch
// This is done because gas estimates for ProveCommits are non deterministic and increasing as a large
// number of sectors get committed within the same epoch resulting in occasionally failed msgs.
// Submitting a smaller number of prove commits per epoch would reduce the possibility of failed msgs
MaxSectorProveCommitsSubmittedPerEpoch uint64

TerminateBatchMax uint64
TerminateBatchMin uint64
TerminateBatchWait Duration
Expand Down
22 changes: 12 additions & 10 deletions node/modules/storageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1014,9 +1014,10 @@ func NewSetSealConfigFunc(r repo.LockedRepo) (dtypes.SetSealingConfigFunc, error
AggregateAboveBaseFee: types.FIL(cfg.AggregateAboveBaseFee),
BatchPreCommitAboveBaseFee: types.FIL(cfg.BatchPreCommitAboveBaseFee),

TerminateBatchMax: cfg.TerminateBatchMax,
TerminateBatchMin: cfg.TerminateBatchMin,
TerminateBatchWait: config.Duration(cfg.TerminateBatchWait),
TerminateBatchMax: cfg.TerminateBatchMax,
TerminateBatchMin: cfg.TerminateBatchMin,
TerminateBatchWait: config.Duration(cfg.TerminateBatchWait),
MaxSectorProveCommitsSubmittedPerEpoch: cfg.MaxSectorProveCommitsSubmittedPerEpoch,
}
c.SetSealingConfig(newCfg)
})
Expand Down Expand Up @@ -1051,13 +1052,14 @@ func ToSealingConfig(dealmakingCfg config.DealmakingConfig, sealingCfg config.Se
PreCommitBatchWait: time.Duration(sealingCfg.PreCommitBatchWait),
PreCommitBatchSlack: time.Duration(sealingCfg.PreCommitBatchSlack),

AggregateCommits: sealingCfg.AggregateCommits,
MinCommitBatch: sealingCfg.MinCommitBatch,
MaxCommitBatch: sealingCfg.MaxCommitBatch,
CommitBatchWait: time.Duration(sealingCfg.CommitBatchWait),
CommitBatchSlack: time.Duration(sealingCfg.CommitBatchSlack),
AggregateAboveBaseFee: types.BigInt(sealingCfg.AggregateAboveBaseFee),
BatchPreCommitAboveBaseFee: types.BigInt(sealingCfg.BatchPreCommitAboveBaseFee),
AggregateCommits: sealingCfg.AggregateCommits,
MinCommitBatch: sealingCfg.MinCommitBatch,
MaxCommitBatch: sealingCfg.MaxCommitBatch,
CommitBatchWait: time.Duration(sealingCfg.CommitBatchWait),
CommitBatchSlack: time.Duration(sealingCfg.CommitBatchSlack),
AggregateAboveBaseFee: types.BigInt(sealingCfg.AggregateAboveBaseFee),
BatchPreCommitAboveBaseFee: types.BigInt(sealingCfg.BatchPreCommitAboveBaseFee),
MaxSectorProveCommitsSubmittedPerEpoch: sealingCfg.MaxSectorProveCommitsSubmittedPerEpoch,

TerminateBatchMax: sealingCfg.TerminateBatchMax,
TerminateBatchMin: sealingCfg.TerminateBatchMin,
Expand Down
22 changes: 22 additions & 0 deletions storage/pipeline/commit_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ func (b *CommitBatcher) processBatch(cfg sealiface.Config) ([]sealiface.CommitBa
}

func (b *CommitBatcher) processIndividually(cfg sealiface.Config) ([]sealiface.CommitBatchRes, error) {

mi, err := b.api.StateMinerInfo(b.mctx, b.maddr, types.EmptyTSK)
if err != nil {
return nil, xerrors.Errorf("couldn't get miner info: %w", err)
Expand All @@ -414,12 +415,31 @@ func (b *CommitBatcher) processIndividually(cfg sealiface.Config) ([]sealiface.C

var res []sealiface.CommitBatchRes

sectorsProcessed := 0

for sn, info := range b.todo {
r := sealiface.CommitBatchRes{
Sectors: []abi.SectorNumber{sn},
FailedSectors: map[abi.SectorNumber]string{},
}

if cfg.MaxSectorProveCommitsSubmittedPerEpoch > 0 &&
uint64(sectorsProcessed) >= cfg.MaxSectorProveCommitsSubmittedPerEpoch {

tmp := ts
for tmp.Height() <= ts.Height() {
tmp, err = b.api.ChainHead(b.mctx)
if err != nil {
log.Errorf("getting chain head: %+v", err)
return nil, err
}
time.Sleep(3 * time.Second)
}

sectorsProcessed = 0
ts = tmp
}

mcid, err := b.processSingle(cfg, mi, &avail, sn, info, ts.Key())
if err != nil {
log.Errorf("process single error: %+v", err) // todo: return to user
Expand All @@ -429,6 +449,8 @@ func (b *CommitBatcher) processIndividually(cfg sealiface.Config) ([]sealiface.C
}

res = append(res, r)

sectorsProcessed++
}

return res, nil
Expand Down
2 changes: 2 additions & 0 deletions storage/pipeline/sealiface/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type Config struct {
AggregateAboveBaseFee abi.TokenAmount
BatchPreCommitAboveBaseFee abi.TokenAmount

MaxSectorProveCommitsSubmittedPerEpoch uint64

TerminateBatchMax uint64
TerminateBatchMin uint64
TerminateBatchWait time.Duration
Expand Down

0 comments on commit 2278a20

Please sign in to comment.