Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pre-state tracer logging storage after call from precompile #64

Merged
merged 3 commits into from
Oct 29, 2024

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