refactor systemcall tracing invocations

This commit is contained in:
Sina Mahmoodi 2024-08-22 20:56:38 +02:00
parent 1bf5bd80a3
commit 28b4f5a293

View file

@ -189,11 +189,13 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
// ProcessBeaconBlockRoot applies the EIP-4788 system call to the beacon block root // ProcessBeaconBlockRoot applies the EIP-4788 system call to the beacon block root
// contract. This method is exported to be used in tests. // contract. This method is exported to be used in tests.
func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *state.StateDB) { func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *state.StateDB) {
if vmenv.Config.Tracer != nil && vmenv.Config.Tracer.OnSystemCallStart != nil { if tracer := vmenv.Config.Tracer; tracer != nil {
vmenv.Config.Tracer.OnSystemCallStart() if tracer.OnSystemCallStart != nil {
} tracer.OnSystemCallStart()
if vmenv.Config.Tracer != nil && vmenv.Config.Tracer.OnSystemCallEnd != nil { }
defer vmenv.Config.Tracer.OnSystemCallEnd() if tracer.OnSystemCallEnd != nil {
defer tracer.OnSystemCallEnd()
}
} }
// If EIP-4788 is enabled, we need to invoke the beaconroot storage contract with // If EIP-4788 is enabled, we need to invoke the beaconroot storage contract with
@ -216,12 +218,12 @@ func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *stat
// ProcessParentBlockHash stores the parent block hash in the history storage contract // ProcessParentBlockHash stores the parent block hash in the history storage contract
// as per EIP-2935. // as per EIP-2935.
func ProcessParentBlockHash(prevHash common.Hash, vmenv *vm.EVM, statedb *state.StateDB) { func ProcessParentBlockHash(prevHash common.Hash, vmenv *vm.EVM, statedb *state.StateDB) {
if vmenv.Config.Tracer != nil { if tracer := vmenv.Config.Tracer; tracer != nil {
if Config.Tracer.OnSystemCallStart != nil { if tracer.OnSystemCallStart != nil {
vmenv.Config.Tracer.OnSystemCallStart() tracer.OnSystemCallStart()
} }
if vmenv.Config.Tracer.OnSystemCallEnd != nil { if tracer.OnSystemCallEnd != nil {
defer vmenv.Config.Tracer.OnSystemCallEnd() defer tracer.OnSystemCallEnd()
} }
} }