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

Add support for trace logging in anvil #9887

Open
mattsse opened this issue Feb 14, 2025 · 0 comments · May be fixed by #9895
Open

Add support for trace logging in anvil #9887

mattsse opened this issue Feb 14, 2025 · 0 comments · May be fixed by #9895
Assignees
Labels
C-anvil Command: anvil first issue A good way to start contributing T-blocked Type: blocked T-feature Type: feature

Comments

@mattsse
Copy link
Member

mattsse commented Feb 14, 2025

Component

Anvil

Describe the feature you would like

in forge t -vvvv we log nice traces:

Traces:
  [34410] CounterTest::test_Increment()
    ├─ [22337] Counter::increment()
    │   └─ ← [Stop]
    ├─ [281] Counter::number() [staticcall]
    │   └─ ← [Return] 1
    ├─ [0] VM::assertEq(1, 1) [staticcall]
    │   └─ ← [Return]
    ├─ [0] console::log("%e", 99999999999999999999999999999999999999999 [9.999e40]) [staticcall]
    │   └─ ← [Stop]
    └─ ← [Stop]

it would be nice to have this as an option in anvil as well, we already have inspector support:

/// The [`revm::Inspector`] used when transacting in the evm
#[derive(Clone, Debug, Default)]
pub struct Inspector {

that logs logs:

inspector.print_logs();

we can install another tracer that emits traces via TracingInspector

ref:

let traces = tracer.map(|tracer| tracer.into_traces()).map(|arena| {
let ignored = cheatcodes
.as_mut()
.map(|cheatcodes| {
let mut ignored = std::mem::take(&mut cheatcodes.ignored_traces.ignored);
// If the last pause call was not resumed, ignore the rest of the trace
if let Some(last_pause_call) = cheatcodes.ignored_traces.last_pause_call {
ignored.insert(last_pause_call, (arena.nodes().len(), 0));
}
ignored
})
.unwrap_or_default();
SparsedTraceArena { arena, ignored }

and

/// Render a collection of call traces to a string.
pub fn render_trace_arena(arena: &SparsedTraceArena) -> String {
render_trace_arena_inner(arena, false, false)
}

this should be configured via a new avil cli arg for --print-traces

Additional context

No response

@mattsse mattsse added T-feature Type: feature T-needs-triage Type: this issue needs to be labelled labels Feb 14, 2025
@github-project-automation github-project-automation bot moved this to Todo in Foundry Feb 14, 2025
@mattsse mattsse added first issue A good way to start contributing C-anvil Command: anvil and removed T-needs-triage Type: this issue needs to be labelled labels Feb 14, 2025
@zerosnacks zerosnacks self-assigned this Feb 14, 2025
@zerosnacks zerosnacks linked a pull request Feb 14, 2025 that will close this issue
3 tasks
@zerosnacks zerosnacks added the T-blocked Type: blocked label Feb 17, 2025
@zerosnacks zerosnacks moved this from Todo to In Progress in Foundry Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-anvil Command: anvil first issue A good way to start contributing T-blocked Type: blocked T-feature Type: feature
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

2 participants