mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 03:10:48 +00:00
eth/tracers: fix evm trace for t8n (#34862)
The mux tracer fanned out every standard hook to its children but never
forwarded OnSystemCall{Start,End}. Tracers that rely on these - like
`logger.jsonLogger`, which uses the start hook to silence its opcode
hook for the duration of a system call - never got the signal when
wrapped behind a mux.
In evm t8n, combining `--trace` with `--opcode-count` (default for geth
with exec specs) produces exactly that wrapping. The first system call
(e.g. `ProcessBeaconBlockRoot`) then fires `OnOpcode` on the json logger
before any `OnTxStart` has run, dereferencing a nil env and crashing
t8n.
Forward both hooks through the mux. The V2 fan-out falls back to V1 for
children that only implement the legacy hook, mirroring the precedence
already used in `core/state_processor.go`.
This commit is contained in:
parent
a15778c52f
commit
b9c5fe6d26
1 changed files with 32 additions and 12 deletions
|
|
@ -79,6 +79,8 @@ func NewMuxTracer(names []string, objects []*tracers.Tracer) (*tracers.Tracer, e
|
||||||
OnCodeChange: t.OnCodeChange,
|
OnCodeChange: t.OnCodeChange,
|
||||||
OnStorageChange: t.OnStorageChange,
|
OnStorageChange: t.OnStorageChange,
|
||||||
OnLog: t.OnLog,
|
OnLog: t.OnLog,
|
||||||
|
OnSystemCallStartV2: t.OnSystemCallStart,
|
||||||
|
OnSystemCallEnd: t.OnSystemCallEnd,
|
||||||
},
|
},
|
||||||
GetResult: t.GetResult,
|
GetResult: t.GetResult,
|
||||||
Stop: t.Stop,
|
Stop: t.Stop,
|
||||||
|
|
@ -189,6 +191,24 @@ func (t *muxTracer) OnLog(log *types.Log) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *muxTracer) OnSystemCallStart(vm *tracing.VMContext) {
|
||||||
|
for _, t := range t.tracers {
|
||||||
|
if t.OnSystemCallStartV2 != nil {
|
||||||
|
t.OnSystemCallStartV2(vm)
|
||||||
|
} else if t.OnSystemCallStart != nil {
|
||||||
|
t.OnSystemCallStart()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *muxTracer) OnSystemCallEnd() {
|
||||||
|
for _, t := range t.tracers {
|
||||||
|
if t.OnSystemCallEnd != nil {
|
||||||
|
t.OnSystemCallEnd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// GetResult returns an empty json object.
|
// GetResult returns an empty json object.
|
||||||
func (t *muxTracer) GetResult() (json.RawMessage, error) {
|
func (t *muxTracer) GetResult() (json.RawMessage, error) {
|
||||||
resObject := make(map[string]json.RawMessage)
|
resObject := make(map[string]json.RawMessage)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue