core: attach the precompile cache in parallel block execution (#35443)

This commit is contained in:
0xSHKWON 2026-08-04 16:35:12 +09:00 committed by GitHub
parent 6434bc91d4
commit c42d4e4177
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View file

@ -66,7 +66,7 @@ func (p *StateProcessor) chainConfig() *params.ChainConfig {
// transactions failed to execute due to insufficient gas it will return an error.
func (p *StateProcessor) Process(ctx context.Context, block *types.Block, statedb *state.StateDB, jumpDestCache vm.JumpDestCache, precompileCache *vm.PrecompileCache, cfg vm.Config, execIndex *atomic.Int64) (*ProcessResult, error) {
if supportsParallelExecution(block, p.chainConfig(), statedb.Witness() != nil, cfg.Tracer != nil, cfg.DisableParallelExecution) {
return p.processParallel(ctx, block, statedb, jumpDestCache, cfg)
return p.processParallel(ctx, block, statedb, jumpDestCache, precompileCache, cfg)
}
var (
config = p.chainConfig()

View file

@ -83,7 +83,7 @@ type txExecResult struct {
// processParallel executes the block's transactions concurrently using the
// block-level access list.
func (p *StateProcessor) processParallel(ctx context.Context, block *types.Block, statedb *state.StateDB, jumpDestCache vm.JumpDestCache, cfg vm.Config) (*ProcessResult, error) {
func (p *StateProcessor) processParallel(ctx context.Context, block *types.Block, statedb *state.StateDB, jumpDestCache vm.JumpDestCache, precompileCache *vm.PrecompileCache, cfg vm.Config) (*ProcessResult, error) {
var (
config = p.chainConfig()
header = block.Header()
@ -155,6 +155,9 @@ func (p *StateProcessor) processParallel(ctx context.Context, block *types.Block
if jumpDestCache != nil {
preEVM.SetJumpDestCache(jumpDestCache)
}
if precompileCache != nil {
preEVM.SetPrecompileCache(precompileCache)
}
blockAccessList.Merge(PreExecution(ctx, block.BeaconRoot(), parent, config, preEVM, header.Number, header.Time))
preEVM.Release()
systemExec += time.Since(preStart)
@ -163,7 +166,7 @@ func (p *StateProcessor) processParallel(ctx context.Context, block *types.Block
// own ephemeral state instance, whose reads are served from the block-level
// access list overlaid on the parent state.
txStart := time.Now()
results, err := p.executeTransactionsParallel(block, parentRoot, db, base, lookup, signer, jumpDestCache, cfg)
results, err := p.executeTransactionsParallel(block, parentRoot, db, base, lookup, signer, jumpDestCache, precompileCache, cfg)
if err != nil {
return nil, err
}
@ -207,6 +210,9 @@ func (p *StateProcessor) processParallel(ctx context.Context, block *types.Block
if jumpDestCache != nil {
postEVM.SetJumpDestCache(jumpDestCache)
}
if precompileCache != nil {
postEVM.SetPrecompileCache(precompileCache)
}
requests, postBAL, err := PostExecution(ctx, config, header.Number, header.Time, allLogs, postEVM, postIndex)
postEVM.Release()
if err != nil {
@ -249,7 +255,7 @@ func newAccessListState(db state.Database, parentRoot common.Hash, base state.Re
// executeTransactionsParallel applies all transactions to independent,
// access-list-backed state instances using a pool of workers, and returns
// the per-transaction results in block order.
func (p *StateProcessor) executeTransactionsParallel(block *types.Block, parentRoot common.Hash, db state.Database, base state.Reader, lookup *bal.Lookup, signer types.Signer, jumpDestCache vm.JumpDestCache, cfg vm.Config) ([]txExecResult, error) {
func (p *StateProcessor) executeTransactionsParallel(block *types.Block, parentRoot common.Hash, db state.Database, base state.Reader, lookup *bal.Lookup, signer types.Signer, jumpDestCache vm.JumpDestCache, precompileCache *vm.PrecompileCache, cfg vm.Config) ([]txExecResult, error) {
var (
config = p.chainConfig()
header = block.Header()
@ -273,6 +279,9 @@ func (p *StateProcessor) executeTransactionsParallel(block *types.Block, parentR
if jumpDestCache != nil {
evm.SetJumpDestCache(jumpDestCache)
}
if precompileCache != nil {
evm.SetPrecompileCache(precompileCache)
}
defer evm.Release()
for {