Skip to content

Commit

Permalink
add an initial CCC check to block close to HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfirmak committed Aug 30, 2024
1 parent 268814c commit b852b87
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions miner/scroll_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,28 @@ func (w *worker) close() {
w.wg.Wait()
}

// checkHeadRowConsumption will start some initial workers to CCC check block close to the HEAD
func (w *worker) checkHeadRowConsumption() error {
checkBoundry := uint64(1)
numOfBlockToCheck := uint64(w.config.CCCMaxWorkers + 1)
head := w.chain.CurrentHeader()
if head.Number.Uint64() > numOfBlockToCheck {
checkBoundry = head.Number.Uint64() - numOfBlockToCheck
}

for i := uint64(0); i < numOfBlockToCheck; i++ {
block := w.chain.GetBlockByNumber(checkBoundry + i)
// only spawn CCC checkers for blocks with no row consumption data stored in DB
if rawdb.ReadBlockRowConsumption(w.chain.Database(), block.Hash()) == nil {
if err := w.asyncChecker.Check(block); err != nil {
return err
}
}
}

return nil
}

// mainLoop is a standalone goroutine to regenerate the sealing task based on the received event.
func (w *worker) mainLoop() {
defer w.wg.Done()
Expand Down Expand Up @@ -322,6 +344,11 @@ func (w *worker) mainLoop() {

select {
case <-w.startCh:
if err := w.checkHeadRowConsumption(); err != nil {
log.Error("failed to start head checkers", "err", err)
return
}

_, err = w.tryCommitNewWork(time.Now(), w.chain.CurrentHeader().Hash(), nil)
case trigger := <-w.reorgCh:
err = w.handleReorg(&trigger)
Expand Down

0 comments on commit b852b87

Please sign in to comment.