go-ethereum/eth/tracers/native
Arran Schlosberg 12b8aa5c2e
fix: pre-state tracer logging storage after call from precompile (#64)
## Why this should be merged

Fixes tracing when a stateful precompile calls another contract that
itself accesses storage.

## How this works

The pre-state tracer from `eth/tracers/native` doesn't implement
`CaptureEnter()` (entry of a new context), instead relying on
`CaptureState()` (per-opcode tracing) to detect that a new contract has
been entered. In doing so, it [maintains an
invariant](cb7eb89341/eth/tracers/native/prestate.go (L160))
that is expected when `CaptureState(vm.SLOAD, ...)` is called—breaking
the invariant results in a panic due to a nil map.

The fix involves (a) maintaining the invariant as part of
`CaptureEnter()` (previously a no-op); and (b) calling said method
inside `vm.PrecompileEnvironment.Call()`. The latter has the added
benefit of properly handling all tracing involving an outbound call from
precompiles.

## How this was tested

New integration test demonstrates that the tracer can log the retrieved
storage value.

---------

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
2024-10-29 17:26:29 +11:00
..
4byte.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
call.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
call_flat.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
gen_account_json.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
gen_callframe_json.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
gen_flatcallaction_json.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
gen_flatcallresult_json.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
mux.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
noop.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
prestate.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
prestate_libevm.go fix: pre-state tracer logging storage after call from precompile (#64) 2024-10-29 17:26:29 +11:00