core, core/state: fix preimage recording in parallel block execution (#35459)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

This commit is contained in:
0xSHKWON 2026-08-04 16:55:36 +09:00 committed by GitHub
parent c42d4e4177
commit 1e0679c7e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View file

@ -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

View file

@ -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(),
}
}
})