From 43b91b39f60d9fb565f534e0a26b3786ebabb767 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Tue, 16 Apr 2024 11:32:53 +0200 Subject: [PATCH] fix traceChain beacon root --- eth/tracers/api.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 5019780559..7a4c4b1862 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -376,14 +376,13 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed failed = err break } - - if beaconRoot := block.BeaconRoot(); beaconRoot != nil { - context := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) + // Insert block's parent beacon block root in the state + // as per EIP-4788. + if beaconRoot := next.BeaconRoot(); beaconRoot != nil { + context := core.NewEVMBlockContext(next.Header(), api.chainContext(ctx), nil) vmenv := vm.NewEVM(context, vm.TxContext{}, statedb, api.backend.ChainConfig(), vm.Config{}) - - core.ProcessBeaconBlockRoot(*block.BeaconRoot(), vmenv, statedb) + core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb) } - // Clean out any pending release functions of trace state. Note this // step must be done after constructing tracing state, because the // tracing state of block next depends on the parent state and construction