Skip to content

Commit

Permalink
feat(forge): Add call tracing support (foundry-rs#192)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
brockelmore authored and clifton committed Dec 27, 2021
1 parent e4d7d61 commit 4cf28ed
Show file tree
Hide file tree
Showing 15 changed files with 1,200 additions and 60 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 38 additions & 2 deletions cli/src/cmd/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,14 @@ impl Cmd for TestArgs {
let backend = Arc::new(backend);

let precompiles = PRECOMPILES_MAP.clone();
let evm =
Executor::new_with_cheatcodes(backend, env.gas_limit, &cfg, &precompiles, ffi);
let evm = Executor::new_with_cheatcodes(
backend,
env.gas_limit,
&cfg,
&precompiles,
ffi,
verbosity > 2,
);

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

println!();

if verbosity > 2 {
if let (Some(traces), Some(identified_contracts)) =
(&result.traces, &result.identified_contracts)
{
let mut ident = identified_contracts.clone();
if verbosity > 3 {
// print setup calls as well
traces.iter().for_each(|trace| {
trace.pretty_print(
0,
&runner.known_contracts,
&mut ident,
&runner.evm,
"",
);
});
} else if !traces.is_empty() {
traces.last().expect("no last but not empty").pretty_print(
0,
&runner.known_contracts,
&mut ident,
&runner.evm,
"",
);
}

println!();
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions evm-adapters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ futures = "0.3.17"
revm_precompiles = "0.1.0"
serde_json = "1.0.72"
serde = "1.0.130"
ansi_term = "0.12.1"

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

0 comments on commit 4cf28ed

Please sign in to comment.