From 1e0679c7e2c1018e91fd79e36520f51cb243c198 Mon Sep 17 00:00:00 2001 From: 0xSHKWON Date: Tue, 4 Aug 2026 16:55:36 +0900 Subject: [PATCH] core, core/state: fix preimage recording in parallel block execution (#35459) --- core/state/statedb.go | 8 ++++++++ core/state_processor_parallel.go | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/core/state/statedb.go b/core/state/statedb.go index 09a896a89a..3994489833 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -291,6 +291,14 @@ func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte) { } } +// AddPreimages adopts the SHA3 preimages recorded by another state, e.g. the +// ephemeral per-transaction states of parallel block execution. Unlike +// AddPreimage the slices are taken as-is instead of copied, so the caller must +// not retain or mutate them. +func (s *StateDB) AddPreimages(preimages map[common.Hash][]byte) { + maps.Copy(s.preimages, preimages) +} + // Preimages returns a list of SHA3 preimages that have been submitted. func (s *StateDB) Preimages() map[common.Hash][]byte { return s.preimages diff --git a/core/state_processor_parallel.go b/core/state_processor_parallel.go index 9b04a79a9c..224d27e558 100644 --- a/core/state_processor_parallel.go +++ b/core/state_processor_parallel.go @@ -79,6 +79,10 @@ type txExecResult struct { // gas contributions to the two block-inclusion dimensions. execution uint64 state uint64 + + // preimages are the SHA3 preimages the transaction's EVM recorded into its + // ephemeral state. + preimages map[common.Hash][]byte } // processParallel executes the block's transactions concurrently using the @@ -226,6 +230,11 @@ func (p *StateProcessor) processParallel(ctx context.Context, block *types.Block if err := wg.Wait(); err != nil { return nil, err } + statedb.AddPreimages(preState.Preimages()) + for i := range results { + statedb.AddPreimages(results[i].preimages) + } + statedb.AddPreimages(postState.Preimages()) parallelSystemExecTimer.Update(systemExec) parallelTxExecTimer.Update(txExec) parallelStateHashTimer.Update(stateHash) @@ -316,6 +325,7 @@ func (p *StateProcessor) executeTransactionsParallel(block *types.Block, parentR accessList: accessList, execution: gp.CumulativeExecution(), state: gp.CumulativeState(), + preimages: sdb.Preimages(), } } })