go-ethereum/eth/tracers
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
..
internal/tracetest [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
js [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
logger [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
native fix: pre-state tracer logging storage after call from precompile (#64) 2024-10-29 17:26:29 +11:00
api.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
api_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
tracers.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
tracers_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
tracker.go eth/traces: add state limit (#25812) 2022-10-06 10:48:04 +02:00
tracker_test.go eth/traces: add state limit (#25812) 2022-10-06 10:48:04 +02:00