diff --git a/core/blockchain.go b/core/blockchain.go index 22d36e76c4..59f5716638 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -683,6 +683,9 @@ func (bc *BlockChain) processBlockWithAccessList(parentRoot common.Hash, block * // Sum read times across per-tx execution, BAL state-transition, and // prefetcher async fetches. Sum-of-CPU-time, not wall-clock. + if w, ok := prefetchReader.(interface{ WaitPrefetch() }); ok { + w.WaitPrefetch() // ensure all prefetcher reads are accounted for + } var prefetchAccountReads, prefetchStorageReads time.Duration if pr, ok := prefetchReader.(interface { PrefetchReadTimes() (time.Duration, time.Duration) diff --git a/core/state/reader.go b/core/state/reader.go index b184c75aeb..2128773ddf 100644 --- a/core/state/reader.go +++ b/core/state/reader.go @@ -576,3 +576,11 @@ func (r *reader) PrefetchReadTimes() (account, storage time.Duration) { } return 0, 0 } + +// WaitPrefetch blocks until the wrapped prefetcher (if any) finishes its +// task list. No-op for non-prefetch readers. +func (r *reader) WaitPrefetch() { + if pr, ok := r.StateReader.(interface{ Wait() error }); ok { + _ = pr.Wait() + } +}