Skip to content

Commit

Permalink
misc small improvements to tracer support
Browse files Browse the repository at this point in the history
  • Loading branch information
Brechtpd committed May 13, 2024
1 parent 6f86106 commit 5a410ac
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 108 deletions.
109 changes: 10 additions & 99 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ You can generate an execution trace for the block that is being proven by enabli
$ cargo run --features tracer
```

A folder called `traces` will be generated inside the root directory. This folder will contain json files with the trace of each valid transaction in the block.
A `traces` folder will be created inside the root directory. This folder will contain json files with the trace of each valid transaction in the block.
1 change: 0 additions & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,4 @@ sp1 = []
risc0 = []
tracer = [
"revm/serde-json",
"revm/ethersdb",
]
12 changes: 5 additions & 7 deletions lib/src/builder/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl TxExecStrategy for TkoTxExecStrategy {
inplace_print(&format!("\rprocessing tx {tx_no}/{num_transactions}..."));

#[cfg(feature = "tracer")]
let inner = set_trace_writer(
let trace = set_trace_writer(
&mut evm.context.external,
chain_id,
block_builder.input.block_number,
Expand Down Expand Up @@ -286,7 +286,7 @@ impl TxExecStrategy for TkoTxExecStrategy {

#[cfg(feature = "tracer")]
// Flush the trace file writer
inner.lock().unwrap().flush().expect("Error flushing trace");
trace.lock().unwrap().flush().expect("Error flushing trace");

tx_transact_duration.add_assign(start.elapsed());

Expand Down Expand Up @@ -495,12 +495,10 @@ fn set_trace_writer(
}
impl Write for FlushWriter {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
//println!("writing");
self.writer.lock().unwrap().write(buf)
}

fn flush(&mut self) -> std::io::Result<()> {
//println!("flushing");
self.writer.lock().unwrap().flush()
}
}
Expand All @@ -515,11 +513,11 @@ fn set_trace_writer(
.create(true)
.truncate(true)
.open(file_name);
let inner = Arc::new(Mutex::new(BufWriter::new(
let trace = Arc::new(Mutex::new(BufWriter::new(
write.expect("Failed to open file"),
)));
let writer = FlushWriter::new(Arc::clone(&inner));
let writer = FlushWriter::new(Arc::clone(&trace));
tracer.set_writer(Box::new(writer));

inner
trace
}

0 comments on commit 5a410ac

Please sign in to comment.