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.OnSystemCallStart != nil {
tracer.OnSystemCallStart()
}
onSystemCallStart(tracer, evm.GetVMContext())
if tracer.OnSystemCallEnd != nil {
defer tracer.OnSystemCallEnd()
}
@ -735,3 +733,11 @@ func historyStorageKey(number uint64) common.Hash {
binary.BigEndian.PutUint64(key[24:], ringIndex)
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.
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
// beacon block root.
@ -179,14 +183,15 @@ type Hooks struct {
OnFault FaultHook
OnGasChange GasChangeHook
// Chain events
OnBlockchainInit BlockchainInitHook
OnClose CloseHook
OnBlockStart BlockStartHook
OnBlockEnd BlockEndHook
OnSkippedBlock SkippedBlockHook
OnGenesisBlock GenesisBlockHook
OnSystemCallStart OnSystemCallStartHook
OnSystemCallEnd OnSystemCallEndHook
OnBlockchainInit BlockchainInitHook
OnClose CloseHook
OnBlockStart BlockStartHook
OnBlockEnd BlockEndHook
OnSkippedBlock SkippedBlockHook
OnGenesisBlock GenesisBlockHook
OnSystemCallStart OnSystemCallStartHook
OnSystemCallStartV2 OnSystemCallStartHookV2
OnSystemCallEnd OnSystemCallEndHook
// State events
OnBalanceChange BalanceChangeHook
OnNonceChange NonceChangeHook