Skip to content

Commit

Permalink
fix(revme): revme error output and remove double summary (#1169)
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita authored Mar 8, 2024
1 parent bfcc058 commit b60f796
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
3 changes: 1 addition & 2 deletions bins/revme/src/cmd/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 5 additions & 3 deletions bins/revme/src/main.rs
Original file line number Diff line number Diff line change
@@ -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)
}
}
18 changes: 9 additions & 9 deletions crates/revm/src/inspector/eip3155.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ pub struct TracerEip3155 {
output: Box<dyn Write>,
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<U256>,
pc: usize,
opcode: u8,
gas: u64,
refunded: i64,
mem_size: usize,
skip: bool,
}
Expand Down Expand Up @@ -99,16 +98,16 @@ impl TracerEip3155 {
}

impl TracerEip3155 {
pub fn new(output: Box<dyn Write>, trace_mem: bool, trace_return_data: bool) -> Self {
pub fn new(output: Box<dyn Write>, 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,
}
Expand All @@ -133,6 +132,7 @@ impl<DB: Database> Inspector<DB> 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<DB>) {
Expand All @@ -150,7 +150,7 @@ impl<DB: Database> Inspector<DB> 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],
Expand All @@ -173,7 +173,7 @@ impl<DB: Database> Inspector<DB> 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(),
Expand Down
2 changes: 1 addition & 1 deletion examples/db_by_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn run_transaction_and_commit(db: &mut CacheDB<EmptyDB>) -> 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)?;
Expand Down
2 changes: 1 addition & 1 deletion examples/generate_block_traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit b60f796

Please sign in to comment.