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

feat: add trace option in revme evm #1376

Merged
merged 6 commits into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions bins/revme/src/cmd/evmrunner.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use revm::{
db::BenchmarkDB,
inspector_handle_register,
inspectors::TracerEip3155,
primitives::{Address, Bytecode, TransactTo},
Evm,
};
Expand Down Expand Up @@ -51,6 +53,9 @@ pub struct Cmd {
/// Print the state.
#[structopt(long)]
state: bool,
/// Print the trace.
#[structopt(long)]
trace: bool,
}

impl Cmd {
Expand Down Expand Up @@ -93,13 +98,30 @@ impl Cmd {
microbench::bench(&bench_options, "Run bytecode", || {
let _ = evm.transact().unwrap();
});

return Ok(());
}

let out = if self.trace {
let mut evm = evm
.modify()
.reset_handler_with_external_context(TracerEip3155::new(
Box::new(std::io::stdout()),
))
.append_handler_register(inspector_handle_register)
.build();

evm.transact().map_err(|_| Errors::EVMError)?
} else {
let out = evm.transact().map_err(|_| Errors::EVMError)?;
println!("Result: {:#?}", out.result);
if self.state {
println!("State: {:#?}", out.state);
}
out
};

if self.state {
println!("State: {:#?}", out.state);
}

Ok(())
}
}
Loading