diff --git a/bins/revme/src/cmd/statetest/runner.rs b/bins/revme/src/cmd/statetest/runner.rs index 12b5b7c186..3c75f38e04 100644 --- a/bins/revme/src/cmd/statetest/runner.rs +++ b/bins/revme/src/cmd/statetest/runner.rs @@ -358,7 +358,6 @@ pub fn execute_test_suite( .reset_handler_with_external_context(TracerEip3155::new( Box::new(stderr()), false, - true, )) .append_handler_register(inspector_handle_register) .build(); @@ -422,7 +421,7 @@ pub fn execute_test_suite( let mut evm = Evm::builder() .with_spec_id(spec_id) .with_db(state) - .with_external_context(TracerEip3155::new(Box::new(stdout()), false, false)) + .with_external_context(TracerEip3155::new(Box::new(stdout()), false)) .append_handler_register(inspector_handle_register) .build(); let _ = evm.transact_commit(); diff --git a/bins/revme/src/main.rs b/bins/revme/src/main.rs index 2555de53e1..5e21714f2f 100644 --- a/bins/revme/src/main.rs +++ b/bins/revme/src/main.rs @@ -1,7 +1,9 @@ -use revme::cmd::{Error, MainCmd}; +use revme::cmd::MainCmd; use structopt::StructOpt; -pub fn main() -> Result<(), Error> { +pub fn main() { let cmd = MainCmd::from_args(); - cmd.run() + if let Err(e) = cmd.run() { + println!("{}", e) + } } diff --git a/crates/revm/src/inspector/eip3155.rs b/crates/revm/src/inspector/eip3155.rs index 1da606af9d..3df0c90173 100644 --- a/crates/revm/src/inspector/eip3155.rs +++ b/crates/revm/src/inspector/eip3155.rs @@ -12,15 +12,14 @@ pub struct TracerEip3155 { output: Box, gas_inspector: GasInspector, - #[allow(dead_code)] - trace_mem: bool, - #[allow(dead_code)] - trace_return_data: bool, + /// Print summary of the execution. + print_summary: bool, stack: Vec, pc: usize, opcode: u8, gas: u64, + refunded: i64, mem_size: usize, skip: bool, } @@ -99,16 +98,16 @@ impl TracerEip3155 { } impl TracerEip3155 { - pub fn new(output: Box, trace_mem: bool, trace_return_data: bool) -> Self { + pub fn new(output: Box, print_summary: bool) -> Self { Self { output, gas_inspector: GasInspector::default(), - trace_mem, - trace_return_data, + print_summary, stack: Default::default(), pc: 0, opcode: 0, gas: 0, + refunded: 0, mem_size: 0, skip: false, } @@ -133,6 +132,7 @@ impl Inspector for TracerEip3155 { self.opcode = interp.current_opcode(); self.mem_size = interp.shared_memory.len(); self.gas = interp.gas.remaining(); + self.refunded = interp.gas.refunded(); } fn step_end(&mut self, interp: &mut Interpreter, context: &mut EvmContext) { @@ -150,7 +150,7 @@ impl Inspector for TracerEip3155 { stack: self.stack.iter().map(hex_number_u256).collect(), depth: context.journaled_state.depth(), return_data: "0x".to_string(), - refund: "0x0".to_string(), + refund: hex_number(self.refunded as u64), mem_size: self.mem_size.to_string(), op_name: opcode::OPCODE_JUMPMAP[self.opcode as usize], @@ -173,7 +173,7 @@ impl Inspector for TracerEip3155 { outcome: CallOutcome, ) -> CallOutcome { let outcome = self.gas_inspector.call_end(context, inputs, outcome); - if context.journaled_state.depth() == 0 { + if self.print_summary && context.journaled_state.depth() == 0 { let value = Summary { state_root: B256::ZERO.to_string(), output: outcome.result.output.to_string(), diff --git a/examples/db_by_ref.rs b/examples/db_by_ref.rs index 01f51faec3..8d0e1db7de 100644 --- a/examples/db_by_ref.rs +++ b/examples/db_by_ref.rs @@ -72,7 +72,7 @@ fn run_transaction_and_commit(db: &mut CacheDB) -> anyhow::Result<()> { fn main() -> anyhow::Result<()> { let mut cache_db = CacheDB::new(EmptyDB::default()); - let mut tracer = TracerEip3155::new(Box::new(std::io::stdout()), true, true); + let mut tracer = TracerEip3155::new(Box::new(std::io::stdout()), true); run_transaction_and_commit_with_ext(&mut cache_db, &mut tracer, inspector_handle_register)?; run_transaction_and_commit(&mut cache_db)?; diff --git a/examples/generate_block_traces.rs b/examples/generate_block_traces.rs index 10951c8359..37a1550778 100644 --- a/examples/generate_block_traces.rs +++ b/examples/generate_block_traces.rs @@ -76,7 +76,7 @@ async fn main() -> anyhow::Result<()> { let mut state = StateBuilder::new_with_database(cache_db).build(); let mut evm = Evm::builder() .with_db(&mut state) - .with_external_context(TracerEip3155::new(Box::new(std::io::stdout()), true, true)) + .with_external_context(TracerEip3155::new(Box::new(std::io::stdout()), true)) .modify_block_env(|b| { if let Some(number) = block.number { let nn = number.0[0];