From 855690523a6bd98ce2eef9489d9f76cf2bc3868c Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Fri, 14 Feb 2020 09:54:02 +0100 Subject: [PATCH] core: ensure state exists for prefetcher (#20627) --- core/blockchain.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index f083f53e04..d7fcbd5e31 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1654,18 +1654,17 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er // If we have a followup block, run that against the current state to pre-cache // transactions and probabilistically some of the account/storage trie nodes. var followupInterrupt uint32 - if !bc.cacheConfig.TrieCleanNoPrefetch { if followup, err := it.peek(); followup != nil && err == nil { - go func(start time.Time) { - throwaway, _ := state.New(parent.Root, bc.stateCache) - bc.prefetcher.Prefetch(followup, throwaway, bc.vmConfig, &followupInterrupt) + throwaway, _ := state.New(parent.Root, bc.stateCache) + go func(start time.Time, followup *types.Block, throwaway *state.StateDB, interrupt *uint32) { + bc.prefetcher.Prefetch(followup, throwaway, bc.vmConfig, interrupt) blockPrefetchExecuteTimer.Update(time.Since(start)) - if atomic.LoadUint32(&followupInterrupt) == 1 { + if atomic.LoadUint32(interrupt) == 1 { blockPrefetchInterruptMeter.Mark(1) } - }(time.Now()) + }(time.Now(), followup, throwaway, &followupInterrupt) } } // Process block using the parent state as reference point