core: exit prefetch just after block processed

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2025-05-26 12:18:49 +08:00
parent 9fd3f8a0dd
commit 6721d8cbcd

View file

@ -1912,7 +1912,6 @@ func (bc *BlockChain) processBlock(parentRoot common.Hash, block *types.Block, s
statedb *state.StateDB statedb *state.StateDB
interrupt atomic.Bool interrupt atomic.Bool
) )
defer interrupt.Store(true) // terminate the prefetch at the end
if bc.cacheConfig.TrieCleanNoPrefetch { if bc.cacheConfig.TrieCleanNoPrefetch {
statedb, err = state.New(parentRoot, bc.statedb) statedb, err = state.New(parentRoot, bc.statedb)
@ -1984,6 +1983,8 @@ func (bc *BlockChain) processBlock(parentRoot common.Hash, block *types.Block, s
// Process block using the parent state as reference point // Process block using the parent state as reference point
pstart := time.Now() pstart := time.Now()
res, err := bc.processor.Process(block, statedb, bc.vmConfig) res, err := bc.processor.Process(block, statedb, bc.vmConfig)
// Terminate the prefetch immediately after the block has been processed
interrupt.Store(true)
if err != nil { if err != nil {
bc.reportBlock(block, res, err) bc.reportBlock(block, res, err)
return nil, err return nil, err