-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(anvil): add PreStateTracer support for debug_traceTransaction #11709
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@w1tcher thank you! please rebase and add a test, here are some samples
foundry/crates/anvil/tests/it/traces.rs
Line 161 in 86d5c5b
async fn test_call_tracer_debug_trace_call() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while this works, this is mega extra overhead on top of the overhead of recorded traces that we already have
imo we should instead cleanup the existing replay functionality that we use for the js tracer and make this general purpose replay
@grandizzy I have added test cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is pretty neat
tysm for this.
while the actually replay+trace impl isnt super nice to read, it's fine imo
still something we can take another look at, but out of scope for this pr.
pending @grandizzy
where | ||
for<'a> I: Inspector<EthEvmContext<WrapDatabaseRef<&'a CacheDB<Box<&'a StateDb>>>>> | ||
+ Inspector<OpContext<WrapDatabaseRef<&'a CacheDB<Box<&'a StateDb>>>>> | ||
+ 'a, | ||
for<'a> F: | ||
FnOnce(ResultAndState<OpHaltReason>, CacheDB<Box<&'a StateDb>>, I, TxEnv, Env) -> T, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are a bit horrific, but not much we can do here :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, lgtm!
Motivation
This commit introduces support for the PreStateTracer in anvil's
debug_traceTransaction RPC method. With this change, users can now
obtain detailed pre-state information (accounts, storage, and balances)
when tracing transactions, enabling more advanced debugging and state
analysis workflows.
Solution
By storing the state changes generated during transaction execution in the exec_state variable, the PreStateTracer can later retrieve this data and return the relevant information.
PR Checklist