Skip to content

Commit 8602e1b

Browse files
authored
feat(forge): Add call tracing support (#192)
* first pass * fixes * fmt * better fmting * updates colored prints, better dev ux, verbosity > 2 trace printing * fmt * updates * fmt * fix after master merge * fix tests post master merge * warning fixes * fmt * lots of fixes * fmt * fix * cyan color * fixes * prettier raw logs + parse setup contracts * update diff_score threshold * better printing * remove integration tests * improvements * improvements + fmt + clippy * fixes * more cleanup * cleanup and verbosity > 3 setup print * refactor printing * documentation + cleanup * fix negative number printing * fix tests to match master and fix tracing_enabled * fix unnecessary trace_index set * refactor runner tracing + tracing_enabled * nits + value printing * last nits
1 parent c5f18b6 commit 8602e1b

File tree

15 files changed

+1200
-60
lines changed

15 files changed

+1200
-60
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/src/cmd/test.rs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,14 @@ impl Cmd for TestArgs {
158158
let backend = Arc::new(backend);
159159

160160
let precompiles = PRECOMPILES_MAP.clone();
161-
let evm =
162-
Executor::new_with_cheatcodes(backend, env.gas_limit, &cfg, &precompiles, ffi);
161+
let evm = Executor::new_with_cheatcodes(
162+
backend,
163+
env.gas_limit,
164+
&cfg,
165+
&precompiles,
166+
ffi,
167+
verbosity > 2,
168+
);
163169

164170
test(builder, project, evm, pattern, json, verbosity, allow_failure)
165171
}
@@ -318,6 +324,36 @@ fn test<A: ArtifactOutput + 'static, S: Clone, E: evm_adapters::Evm<S>>(
318324
}
319325

320326
println!();
327+
328+
if verbosity > 2 {
329+
if let (Some(traces), Some(identified_contracts)) =
330+
(&result.traces, &result.identified_contracts)
331+
{
332+
let mut ident = identified_contracts.clone();
333+
if verbosity > 3 {
334+
// print setup calls as well
335+
traces.iter().for_each(|trace| {
336+
trace.pretty_print(
337+
0,
338+
&runner.known_contracts,
339+
&mut ident,
340+
&runner.evm,
341+
"",
342+
);
343+
});
344+
} else if !traces.is_empty() {
345+
traces.last().expect("no last but not empty").pretty_print(
346+
0,
347+
&runner.known_contracts,
348+
&mut ident,
349+
&runner.evm,
350+
"",
351+
);
352+
}
353+
354+
println!();
355+
}
356+
}
321357
}
322358
}
323359
}

evm-adapters/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ futures = "0.3.17"
2727
revm_precompiles = "0.1.0"
2828
serde_json = "1.0.72"
2929
serde = "1.0.130"
30+
ansi_term = "0.12.1"
3031

3132
[dev-dependencies]
3233
evmodin = { git = "https://github.com/vorot93/evmodin", features = ["util"] }

0 commit comments

Comments
 (0)