diff --git a/core/blockchain.go b/core/blockchain.go index 5d1cf533fc..6ab30b8d1d 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1793,21 +1793,19 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error) // transactions and probabilistically some of the account/storage trie nodes. var followupInterrupt atomic.Bool if !bc.cacheConfig.TrieCleanNoPrefetch { - if followup, err := it.peek(); followup != nil && err == nil { - throwaway, _ := state.New(parent.Root, bc.statedb) + followup := block + throwaway, _ := state.New(parent.Root, bc.statedb) + go func(start time.Time, followup *types.Block, throwaway *state.StateDB) { + // Disable tracing for prefetcher executions. + vmCfg := bc.vmConfig + vmCfg.Tracer = nil + bc.prefetcher.Prefetch(followup, throwaway, vmCfg, &followupInterrupt) - go func(start time.Time, followup *types.Block, throwaway *state.StateDB) { - // Disable tracing for prefetcher executions. - vmCfg := bc.vmConfig - vmCfg.Tracer = nil - bc.prefetcher.Prefetch(followup, throwaway, vmCfg, &followupInterrupt) - - blockPrefetchExecuteTimer.Update(time.Since(start)) - if followupInterrupt.Load() { - blockPrefetchInterruptMeter.Mark(1) - } - }(time.Now(), followup, throwaway) - } + blockPrefetchExecuteTimer.Update(time.Since(start)) + if followupInterrupt.Load() { + blockPrefetchInterruptMeter.Mark(1) + } + }(time.Now(), followup, throwaway) } // The traced section of block import. diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index 31405fa078..31df626194 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -53,8 +53,10 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c signer = types.MakeSigner(p.config, header.Number, header.Time) ) // Iterate over and process the individual transactions - byzantium := p.config.IsByzantium(block.Number()) - for i, tx := range block.Transactions() { + txs := block.Transactions() + // Skip the first third of transactions, prefetch the latter two thirds of the transactions + for i := (len(txs) * 2) / 3; i < len(txs); i++ { + tx := txs[i] // If block precaching was interrupted, abort if interrupt != nil && interrupt.Load() { return @@ -68,14 +70,6 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c if err := precacheTransaction(msg, p.config, gaspool, statedb, header, evm); err != nil { return // Ugh, something went horribly wrong, bail out } - // If we're pre-byzantium, pre-load trie nodes for the intermediate root - if !byzantium { - statedb.IntermediateRoot(true) - } - } - // If were post-byzantium, pre-load trie nodes for the final root hash - if byzantium { - statedb.IntermediateRoot(true) } }