Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: panic in api-test because of Commit Batcher #12244

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
aarshkshah1992 marked this conversation as resolved.
Show resolved Hide resolved

## New features

Expand Down
18 changes: 9 additions & 9 deletions storage/pipeline/commit_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
10 changes: 7 additions & 3 deletions storage/pipeline/sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),

Expand All @@ -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{
Expand Down
Loading