Skip to content

Conversation

@ARR4N
Copy link
Collaborator

@ARR4N ARR4N commented Oct 28, 2024

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 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.

@ARR4N ARR4N marked this pull request as ready for review October 29, 2024 06:26
@ARR4N ARR4N merged commit 12b8aa5 into main Oct 29, 2024
3 checks passed
@ARR4N ARR4N deleted the arr4n/prestate-capture-precompile-call branch October 29, 2024 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants