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

fix(TracerEip3155): clear Inspector data after transaction. #1230

Merged
merged 6 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 3 additions & 1 deletion crates/revm/src/inspector/eip3155.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ impl<DB: Database> Inspector<DB> for TracerEip3155 {
let value = Summary {
state_root: B256::ZERO.to_string(),
output: outcome.result.output.to_string(),
gas_used: hex_number(inputs.gas_limit - self.gas_inspector.gas_remaining()),
gas_used: hex_number(
context.inner.env().tx.gas_limit - self.gas_inspector.gas_remaining(),
),
pass: outcome.result.is_ok(),

time: None,
Expand Down
10 changes: 9 additions & 1 deletion examples/generate_block_traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::io::BufWriter;
use std::io::Write;
use std::sync::Arc;
use std::sync::Mutex;
use std::time::Instant;

macro_rules! local_fill {
($left:expr, $right:expr, $fun:expr) => {
Expand Down Expand Up @@ -100,7 +101,7 @@ async fn main() -> anyhow::Result<()> {
println!("Found {txs} transactions.");

let console_bar = Arc::new(ProgressBar::new(txs as u64));
let elapsed = std::time::Duration::ZERO;
let start = Instant::now();

// Create the traces directory if it doesn't exist
std::fs::create_dir_all("traces").expect("Failed to create traces directory");
Expand All @@ -109,6 +110,10 @@ async fn main() -> anyhow::Result<()> {
for tx in block.transactions {
evm = evm
.modify()
.reset_handler_with_external_context(TracerEip3155::new(
Box::new(std::io::stdout()),
true,
))
.modify_tx_env(|etx| {
etx.caller = Address::from(tx.from.as_fixed_bytes());
etx.gas_limit = tx.gas.as_u64();
Expand Down Expand Up @@ -148,6 +153,7 @@ async fn main() -> anyhow::Result<()> {
None => TransactTo::create(),
};
})
.append_handler_register(inspector_handle_register)
.build();

// Construct the file writer to write the trace to
Expand Down Expand Up @@ -176,6 +182,8 @@ async fn main() -> anyhow::Result<()> {
}

console_bar.finish_with_message("Finished all transactions.");

let elapsed = start.elapsed();
println!(
"Finished execution. Total CPU time: {:.6}s",
elapsed.as_secs_f64()
Expand Down
Loading