mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 00:43:46 +00:00
core, core/state: fix preimage recording in parallel block execution (#35459)
This commit is contained in:
parent
c42d4e4177
commit
1e0679c7e2
2 changed files with 18 additions and 0 deletions
|
|
@ -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.
|
// Preimages returns a list of SHA3 preimages that have been submitted.
|
||||||
func (s *StateDB) Preimages() map[common.Hash][]byte {
|
func (s *StateDB) Preimages() map[common.Hash][]byte {
|
||||||
return s.preimages
|
return s.preimages
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,10 @@ type txExecResult struct {
|
||||||
// gas contributions to the two block-inclusion dimensions.
|
// gas contributions to the two block-inclusion dimensions.
|
||||||
execution uint64
|
execution uint64
|
||||||
state 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
|
// 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 {
|
if err := wg.Wait(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
statedb.AddPreimages(preState.Preimages())
|
||||||
|
for i := range results {
|
||||||
|
statedb.AddPreimages(results[i].preimages)
|
||||||
|
}
|
||||||
|
statedb.AddPreimages(postState.Preimages())
|
||||||
parallelSystemExecTimer.Update(systemExec)
|
parallelSystemExecTimer.Update(systemExec)
|
||||||
parallelTxExecTimer.Update(txExec)
|
parallelTxExecTimer.Update(txExec)
|
||||||
parallelStateHashTimer.Update(stateHash)
|
parallelStateHashTimer.Update(stateHash)
|
||||||
|
|
@ -316,6 +325,7 @@ func (p *StateProcessor) executeTransactionsParallel(block *types.Block, parentR
|
||||||
accessList: accessList,
|
accessList: accessList,
|
||||||
execution: gp.CumulativeExecution(),
|
execution: gp.CumulativeExecution(),
|
||||||
state: gp.CumulativeState(),
|
state: gp.CumulativeState(),
|
||||||
|
preimages: sdb.Preimages(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue