diff --git a/core/state_processor.go b/core/state_processor.go index 08961ba74f..2ae39dab29 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -208,8 +208,10 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo // contract. This method is exported to be used in tests. func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *state.StateDB) { if tracer := vmenv.Config.Tracer; tracer != nil { - if tracer.OnSystemCallStart != nil { - tracer.OnSystemCallStart(vmenv.GetVMContext()) + if tracer.OnSystemCallStartV2 != nil { + tracer.OnSystemCallStartV2(vmenv.GetVMContext()) + } else if tracer.OnSystemCallStart != nil { + tracer.OnSystemCallStart() } if tracer.OnSystemCallEnd != nil { defer tracer.OnSystemCallEnd() @@ -237,8 +239,10 @@ func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *stat // as per EIP-2935. func ProcessParentBlockHash(prevHash common.Hash, vmenv *vm.EVM, statedb *state.StateDB) { if tracer := vmenv.Config.Tracer; tracer != nil { - if tracer.OnSystemCallStart != nil { - tracer.OnSystemCallStart(vmenv.GetVMContext()) + if tracer.OnSystemCallStartV2 != nil { + tracer.OnSystemCallStartV2(vmenv.GetVMContext()) + } else if tracer.OnSystemCallStart != nil { + tracer.OnSystemCallStart() } if tracer.OnSystemCallEnd != nil { defer tracer.OnSystemCallEnd() diff --git a/core/tracing/hooks.go b/core/tracing/hooks.go index 51bac8e7a6..5ddba2b74b 100644 --- a/core/tracing/hooks.go +++ b/core/tracing/hooks.go @@ -148,7 +148,11 @@ type ( // // Note that system call happens outside normal transaction execution, so the `OnTxStart/OnTxEnd` hooks // will not be invoked. - OnSystemCallStartHook = func(vm *VMContext) + OnSystemCallStartHook = func() + + // OnSystemCallStartHookV2 is called when a system call is about to be executed. Refer + // to `OnSystemCallStartHook` for more information. + OnSystemCallStartHookV2 = func(vm *VMContext) // OnSystemCallEndHook is called when a system call has finished executing. Today, // this hook is invoked when the EIP-4788 system call is about to be executed to set the @@ -206,15 +210,16 @@ type Hooks struct { OnFault FaultHook OnGasChange GasChangeHook // Chain events - OnBlockchainInit BlockchainInitHook - OnClose CloseHook - OnBlockStart BlockStartHook - OnBlockEnd BlockEndHook - OnSkippedBlock SkippedBlockHook - OnGenesisBlock GenesisBlockHook - OnReorg ReorgHook - OnSystemCallStart OnSystemCallStartHook - OnSystemCallEnd OnSystemCallEndHook + OnBlockchainInit BlockchainInitHook + OnClose CloseHook + OnBlockStart BlockStartHook + OnBlockEnd BlockEndHook + OnSkippedBlock SkippedBlockHook + OnGenesisBlock GenesisBlockHook + OnReorg ReorgHook + OnSystemCallStart OnSystemCallStartHook + OnSystemCallStartV2 OnSystemCallStartHookV2 + OnSystemCallEnd OnSystemCallEndHook // State events OnBalanceChange BalanceChangeHook OnNonceChange NonceChangeHook diff --git a/eth/tracers/logger/logger_json.go b/eth/tracers/logger/logger_json.go index de021e74be..797f7ac658 100644 --- a/eth/tracers/logger/logger_json.go +++ b/eth/tracers/logger/logger_json.go @@ -127,7 +127,7 @@ func (l *jsonLogger) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracin l.encoder.Encode(log) } -func (l *jsonLogger) onSystemCallStart(_ *tracing.VMContext) { +func (l *jsonLogger) onSystemCallStart() { // Process no events while in system call. hooks := *l.hooks *l.hooks = tracing.Hooks{