Skip to content

Commit

Permalink
make onBlockFailing callback synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfirmak committed Sep 2, 2024
1 parent e8b4e10 commit 6abc581
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions miner/scroll_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus
chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize),
exitCh: make(chan struct{}),
startCh: make(chan struct{}, 1),
reorgCh: make(chan reorgTrigger, 1),
reorgCh: make(chan reorgTrigger, 2*(config.CCCMaxWorkers+1)),
}
worker.asyncChecker = ccc.NewAsyncChecker(worker.chain, config.CCCMaxWorkers, false).WithOnFailingBlock(worker.onBlockFailingCCC)

Expand Down Expand Up @@ -975,14 +975,10 @@ func (w *worker) skip(txHash common.Hash) {
// onBlockFailingCCC is called when block produced by worker fails CCC
func (w *worker) onBlockFailingCCC(failingBlock *types.Block, err error) {
log.Warn("block failed CCC", "hash", failingBlock.Hash().Hex(), "number", failingBlock.NumberU64(), "err", err)
// w.asyncChecker.Check() might block until this callback returns and if the write to reorgCh
// below blocks, we have a deadlock. Make sure this callback can never block.
go func() {
w.reorgCh <- reorgTrigger{
block: failingBlock,
reason: err,
}
}()
w.reorgCh <- reorgTrigger{
block: failingBlock,
reason: err,
}
}

// handleReorg reorgs all blocks following the trigger block
Expand Down

0 comments on commit 6abc581

Please sign in to comment.