Skip to content

Commit 3bc4ec0

Browse files
easyfoldzfy0701
authored andcommitted
eth/tracers: do system contract processing prior to parallel-tracing (ethereum#30520)
This fixes `debug_traceBlock` methods for JS tracers in that it correctly applies the beacon block root processing to the state.
1 parent 9e59189 commit 3bc4ec0

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

eth/tracers/api.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,17 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
603603
return nil, err
604604
}
605605
defer release()
606+
607+
blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
608+
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
609+
vmenv := vm.NewEVM(blockCtx, vm.TxContext{}, statedb, api.backend.ChainConfig(), vm.Config{})
610+
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb)
611+
}
612+
if api.backend.ChainConfig().IsPrague(block.Number(), block.Time()) {
613+
vmenv := vm.NewEVM(blockCtx, vm.TxContext{}, statedb, api.backend.ChainConfig(), vm.Config{})
614+
core.ProcessParentBlockHash(block.ParentHash(), vmenv, statedb)
615+
}
616+
606617
// JS tracers have high overhead. In this case run a parallel
607618
// process that generates states in one thread and traces txes
608619
// in separate worker threads.
@@ -615,18 +626,9 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
615626
var (
616627
txs = block.Transactions()
617628
blockHash = block.Hash()
618-
blockCtx = core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
619629
signer = types.MakeSigner(api.backend.ChainConfig(), block.Number(), block.Time())
620630
results = make([]*txTraceResult, len(txs))
621631
)
622-
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
623-
vmenv := vm.NewEVM(blockCtx, vm.TxContext{}, statedb, api.backend.ChainConfig(), vm.Config{})
624-
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb)
625-
}
626-
if api.backend.ChainConfig().IsPrague(block.Number(), block.Time()) {
627-
vmenv := vm.NewEVM(blockCtx, vm.TxContext{}, statedb, api.backend.ChainConfig(), vm.Config{})
628-
core.ProcessParentBlockHash(block.ParentHash(), vmenv, statedb)
629-
}
630632
for i, tx := range txs {
631633
// Generate the next state snapshot fast without tracing
632634
msg, _ := core.TransactionToMessage(tx, signer, block.BaseFee())

0 commit comments

Comments
 (0)