From 32d50f55b75651021f036d0e5d4703ed46557e73 Mon Sep 17 00:00:00 2001 From: flywukong <19421226+flywukong@users.noreply.github.com> Date: Wed, 12 Nov 2025 17:24:12 +0800 Subject: [PATCH 1/2] eth: improve prefetch by using cached reader --- core/state_prefetcher.go | 2 +- miner/bid_simulator.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index 4f71e33cb1..20925560ca 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -66,7 +66,7 @@ func (p *statePrefetcher) Prefetch(transactions types.Transactions, header *type // Iterate over and process the individual transactions for i, tx := range transactions { - stateCpy := statedb.CopyDoPrefetch() // closure + stateCpy := statedb.StateForPrefetch() // lightweight state for prefetch with shared cache workers.Go(func() error { // If block precaching was interrupted, abort if interrupt != nil && interrupt.Load() { diff --git a/miner/bid_simulator.go b/miner/bid_simulator.go index b81ab2614e..9bcb6a1da3 100644 --- a/miner/bid_simulator.go +++ b/miner/bid_simulator.go @@ -771,8 +771,7 @@ func (b *bidSimulator) simBid(interruptCh chan int32, bidRuntime *BidRuntime) { if len(bidRuntime.bid.Txs) > prefetchTxNumber { var interrupt atomic.Bool defer interrupt.Store(true) // terminate the prefetch at the end - // TODO(Nathan): use ReadersWithCacheStats to accelerate - throwaway := bidRuntime.env.state.CopyDoPrefetch() + throwaway := bidRuntime.env.state.StateForPrefetch() // Disable tracing for prefetcher executions. vmCfg := *b.chain.GetVMConfig() vmCfg.Tracer = nil From d3e91a65e41f969790b260c8b862661fb1d8b3fe Mon Sep 17 00:00:00 2001 From: flywukong <19421226+flywukong@users.noreply.github.com> Date: Wed, 19 Nov 2025 17:23:52 +0800 Subject: [PATCH 2/2] revert the copyDoPrefetch --- core/state_prefetcher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index 20925560ca..68fb444188 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -66,7 +66,7 @@ func (p *statePrefetcher) Prefetch(transactions types.Transactions, header *type // Iterate over and process the individual transactions for i, tx := range transactions { - stateCpy := statedb.StateForPrefetch() // lightweight state for prefetch with shared cache + stateCpy := statedb.CopyDoPrefetch() workers.Go(func() error { // If block precaching was interrupted, abort if interrupt != nil && interrupt.Load() {