From d8546e5711f7398f74c7e93a8aeb345721df19b6 Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Tue, 16 Jul 2024 12:26:53 +0400 Subject: [PATCH 1/2] NewCommitBatcher now has an additional error return to deal with errors arising from fetching the sealing config. --- CHANGELOG.md | 2 +- storage/pipeline/commit_batch.go | 18 +++++++++--------- storage/pipeline/sealing.go | 10 +++++++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15521cfc805..46eb6aea10d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ - This Lotus release includes some correctness improvements to the events subsystem, impacting RPC APIs including `GetActorEventsRaw`, `SubscribeActorEventsRaw`, `eth_getLogs` and the `eth` filter APIs. Part of these improvements involve an events database migration that may take some time to complete on nodes with extensive event databases. See [filecoin-project/lotus#12080](https://github.com/filecoin-project/lotus/pull/12080) for details. -- Breaking change in public APIs `storage/pipeline.NewPreCommitBatcher` and `storage/pipeline.New`. They now have an additional error return to deal with errors arising from fetching the sealing config. +- Breaking change in public APIs `storage/pipeline.NewPreCommitBatcher` and `storage/pipeline.New` and `sealing.NewCommitBatcher`. They now have an additional error return to deal with errors arising from fetching the sealing config. ## New features diff --git a/storage/pipeline/commit_batch.go b/storage/pipeline/commit_batch.go index ba09ef38f50..e1e1e8f0902 100644 --- a/storage/pipeline/commit_batch.go +++ b/storage/pipeline/commit_batch.go @@ -83,7 +83,7 @@ type CommitBatcher struct { lk sync.Mutex } -func NewCommitBatcher(mctx context.Context, maddr address.Address, api CommitBatcherApi, addrSel AddressSelector, feeCfg config.MinerFeeConfig, getConfig dtypes.GetSealingConfigFunc, prov storiface.Prover) *CommitBatcher { +func NewCommitBatcher(mctx context.Context, maddr address.Address, api CommitBatcherApi, addrSel AddressSelector, feeCfg config.MinerFeeConfig, getConfig dtypes.GetSealingConfigFunc, prov storiface.Prover) (*CommitBatcher, error) { b := &CommitBatcher{ api: api, maddr: maddr, @@ -103,20 +103,20 @@ func NewCommitBatcher(mctx context.Context, maddr address.Address, api CommitBat stopped: make(chan struct{}), } - go b.run() + cfg, err := b.getConfig() + if err != nil { + return nil, err + } + + go b.run(cfg) - return b + return b, nil } -func (b *CommitBatcher) run() { +func (b *CommitBatcher) run(cfg sealiface.Config) { var forceRes chan []sealiface.CommitBatchRes var lastMsg []sealiface.CommitBatchRes - cfg, err := b.getConfig() - if err != nil { - panic(err) - } - timer := time.NewTimer(b.batchWait(cfg.CommitBatchWait, cfg.CommitBatchSlack)) for { if forceRes != nil { diff --git a/storage/pipeline/sealing.go b/storage/pipeline/sealing.go index c111565efea..fe25e15e64b 100644 --- a/storage/pipeline/sealing.go +++ b/storage/pipeline/sealing.go @@ -258,9 +258,7 @@ func New(mctx context.Context, sapi SealingAPI, fc config.MinerFeeConfig, events addrSel: addrSel, terminator: NewTerminationBatcher(mctx, maddr, sapi, addrSel, fc, gc), - commiter: NewCommitBatcher(mctx, maddr, sapi, addrSel, fc, gc, prov), - - getConfig: gc, + getConfig: gc, legacySc: storedcounter.New(ds, datastore.NewKey(StorageCounterDSPrefix)), @@ -275,6 +273,12 @@ func New(mctx context.Context, sapi SealingAPI, fc config.MinerFeeConfig, events } s.precommiter = pc + cc, err := NewCommitBatcher(mctx, maddr, sapi, addrSel, fc, gc, prov) + if err != nil { + return nil, err + } + s.commiter = cc + s.notifee = func(before, after SectorInfo) { s.journal.RecordEvent(s.sealingEvtType, func() interface{} { return SealingStateEvt{ From 93b36b50db5c7019db0c519a4b889a36077df102 Mon Sep 17 00:00:00 2001 From: Aarsh Shah Date: Tue, 16 Jul 2024 12:31:51 +0400 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Rod Vagg --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46eb6aea10d..d1b9401f1fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ - This Lotus release includes some correctness improvements to the events subsystem, impacting RPC APIs including `GetActorEventsRaw`, `SubscribeActorEventsRaw`, `eth_getLogs` and the `eth` filter APIs. Part of these improvements involve an events database migration that may take some time to complete on nodes with extensive event databases. See [filecoin-project/lotus#12080](https://github.com/filecoin-project/lotus/pull/12080) for details. -- Breaking change in public APIs `storage/pipeline.NewPreCommitBatcher` and `storage/pipeline.New` and `sealing.NewCommitBatcher`. They now have an additional error return to deal with errors arising from fetching the sealing config. +- Breaking change in public APIs `storage/pipeline.NewPreCommitBatcher`, `sealing.NewCommitBatcher` and `storage/pipeline.New`. They now have an additional error return to deal with errors arising from fetching the sealing config. ## New features