feat(core): extends tracing.Hooks with OnSystemCallStartV2 #30786 (#2073)

This commit is contained in:
Daniel Liu 2026-02-28 20:55:51 +08:00 committed by GitHub
parent 11471fd4b0
commit 240b318dfb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 11 deletions

View file

@ -703,9 +703,7 @@ func ProcessParentBlockHash(prevHash common.Hash, evm *vm.EVM) {
} }
if tracer := evm.Config.Tracer; tracer != nil { if tracer := evm.Config.Tracer; tracer != nil {
if tracer.OnSystemCallStart != nil { onSystemCallStart(tracer, evm.GetVMContext())
tracer.OnSystemCallStart()
}
if tracer.OnSystemCallEnd != nil { if tracer.OnSystemCallEnd != nil {
defer tracer.OnSystemCallEnd() defer tracer.OnSystemCallEnd()
} }
@ -735,3 +733,11 @@ func historyStorageKey(number uint64) common.Hash {
binary.BigEndian.PutUint64(key[24:], ringIndex) binary.BigEndian.PutUint64(key[24:], ringIndex)
return key return key
} }
func onSystemCallStart(tracer *tracing.Hooks, ctx *tracing.VMContext) {
if tracer.OnSystemCallStartV2 != nil {
tracer.OnSystemCallStartV2(ctx)
} else if tracer.OnSystemCallStart != nil {
tracer.OnSystemCallStart()
}
}

View file

@ -144,6 +144,10 @@ type (
// will not be invoked. // will not be invoked.
OnSystemCallStartHook = func() 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
// beacon block root. // beacon block root.
@ -186,6 +190,7 @@ type Hooks struct {
OnSkippedBlock SkippedBlockHook OnSkippedBlock SkippedBlockHook
OnGenesisBlock GenesisBlockHook OnGenesisBlock GenesisBlockHook
OnSystemCallStart OnSystemCallStartHook OnSystemCallStart OnSystemCallStartHook
OnSystemCallStartV2 OnSystemCallStartHookV2
OnSystemCallEnd OnSystemCallEndHook OnSystemCallEnd OnSystemCallEndHook
// State events // State events
OnBalanceChange BalanceChangeHook OnBalanceChange BalanceChangeHook