add OnSystemCallStartV2

This commit is contained in:
Sina Mahmoodi 2024-10-14 06:47:39 +02:00
parent a2ca5f81ff
commit 85a85d09c7
3 changed files with 24 additions and 15 deletions

View File

@ -208,8 +208,10 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
// 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 tracer := vmenv.Config.Tracer; tracer != nil { if tracer := vmenv.Config.Tracer; tracer != nil {
if tracer.OnSystemCallStart != nil { if tracer.OnSystemCallStartV2 != nil {
tracer.OnSystemCallStart(vmenv.GetVMContext()) tracer.OnSystemCallStartV2(vmenv.GetVMContext())
} else if tracer.OnSystemCallStart != nil {
tracer.OnSystemCallStart()
} }
if tracer.OnSystemCallEnd != nil { if tracer.OnSystemCallEnd != nil {
defer tracer.OnSystemCallEnd() defer tracer.OnSystemCallEnd()
@ -237,8 +239,10 @@ func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *stat
// 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 tracer := vmenv.Config.Tracer; tracer != nil { if tracer := vmenv.Config.Tracer; tracer != nil {
if tracer.OnSystemCallStart != nil { if tracer.OnSystemCallStartV2 != nil {
tracer.OnSystemCallStart(vmenv.GetVMContext()) tracer.OnSystemCallStartV2(vmenv.GetVMContext())
} else if tracer.OnSystemCallStart != nil {
tracer.OnSystemCallStart()
} }
if tracer.OnSystemCallEnd != nil { if tracer.OnSystemCallEnd != nil {
defer tracer.OnSystemCallEnd() defer tracer.OnSystemCallEnd()

View File

@ -148,7 +148,11 @@ type (
// //
// Note that system call happens outside normal transaction execution, so the `OnTxStart/OnTxEnd` hooks // Note that system call happens outside normal transaction execution, so the `OnTxStart/OnTxEnd` hooks
// will not be invoked. // 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, // 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 // 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 OnFault FaultHook
OnGasChange GasChangeHook OnGasChange GasChangeHook
// Chain events // Chain events
OnBlockchainInit BlockchainInitHook OnBlockchainInit BlockchainInitHook
OnClose CloseHook OnClose CloseHook
OnBlockStart BlockStartHook OnBlockStart BlockStartHook
OnBlockEnd BlockEndHook OnBlockEnd BlockEndHook
OnSkippedBlock SkippedBlockHook OnSkippedBlock SkippedBlockHook
OnGenesisBlock GenesisBlockHook OnGenesisBlock GenesisBlockHook
OnReorg ReorgHook OnReorg ReorgHook
OnSystemCallStart OnSystemCallStartHook OnSystemCallStart OnSystemCallStartHook
OnSystemCallEnd OnSystemCallEndHook OnSystemCallStartV2 OnSystemCallStartHookV2
OnSystemCallEnd OnSystemCallEndHook
// State events // State events
OnBalanceChange BalanceChangeHook OnBalanceChange BalanceChangeHook
OnNonceChange NonceChangeHook OnNonceChange NonceChangeHook

View File

@ -127,7 +127,7 @@ func (l *jsonLogger) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracin
l.encoder.Encode(log) l.encoder.Encode(log)
} }
func (l *jsonLogger) onSystemCallStart(_ *tracing.VMContext) { func (l *jsonLogger) onSystemCallStart() {
// Process no events while in system call. // Process no events while in system call.
hooks := *l.hooks hooks := *l.hooks
*l.hooks = tracing.Hooks{ *l.hooks = tracing.Hooks{