-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat(anvil
): add support for trace logging in Anvil
#9895
base: master
Are you sure you want to change the base?
Conversation
…local artifacts in Anvil yet
…performed in Anvil
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 looks good,
what we need some feedback on is when to actually print them, always or in the non success case, especially estimate could be a bit noisy because this call multiple times
fn print_traces(tracer: TracingInspector) { | ||
let arena = tokio::task::block_in_place(move || { | ||
tokio::runtime::Handle::current().block_on(async move { | ||
let mut arena = tracer.into_traces(); | ||
let decoder = CallTraceDecoder::new(); | ||
decoder.populate_traces(arena.nodes_mut()).await; | ||
arena | ||
}) | ||
}); |
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.
We could potentially enhance this to decode the traces by using the local Foundry cache if Anvil is aware of the context it is running in. We already do something similar for Cast.
Current output looks as follows:
Traces:
[96345] → new <unknown>@0x5FbDB2315678afecb367f032d93F642f64180aa3
└─ ← [Return] 481 bytes of code
Transaction: 0xfe54630a47e967d67c729e38f22942235228fc01521f4db04597c9177be18e1c
Contract created: 0x5FbDB2315678afecb367f032d93F642f64180aa3
Gas used: 156813
Block Number: 1
Block Hash: 0x25012fdbcb7c25948454ec6b8cfad6ac788b309e1637e30504f29220b12997b4
Block Time: "Tue, 25 Mar 2025 16:28:30 +0000"
Traces:
[22418] 0x5FbDB2315678afecb367f032d93F642f64180aa3::d09de08a()
├─ storage changes:
│ @ 0: 0 → 1
└─ ← [Stop]
Traces:
eth_getTransactionReceipt
[5392] 0x5FbDB2315678afecb367f032d93F642f64180aa3::3fb5c1cb(000000000000000000000000000000000000000000000000000000000000002a)
├─ storage changes:
│ @ 0: 1 → 42
└─ ← [Stop]
Motivation
Closes: #9887
Solution
Work in progress
Current output looks as follows:
It is likely possible to decode the traces to some extend using cached selectors but there is some complexity involved as all of these functions are not async.
PR Checklist