From 5a410ac973b0426d6fb4ef037edf3b533dda9596 Mon Sep 17 00:00:00 2001 From: Brechtpd Date: Mon, 13 May 2024 04:13:26 +0200 Subject: [PATCH] misc small improvements to tracer support --- Cargo.lock | 109 ++++--------------------------------- README.md | 2 +- lib/Cargo.toml | 1 - lib/src/builder/execute.rs | 12 ++-- 4 files changed, 16 insertions(+), 108 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3be99b0b..5dec16eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2255,24 +2255,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "enr" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a3d8dc56e02f954cac8eb489772c552c473346fc34f67412bb6244fd647f7e4" -dependencies = [ - "base64 0.21.7", - "bytes", - "hex", - "k256", - "log", - "rand", - "rlp", - "serde", - "sha3", - "zeroize", -] - [[package]] name = "enum-as-inner" version = "0.6.0" @@ -2400,8 +2382,8 @@ dependencies = [ "const-hex", "ethers-contract-abigen", "ethers-contract-derive", - "ethers-core 2.0.10", - "ethers-providers 2.0.10", + "ethers-core", + "ethers-providers", "futures-util", "once_cell", "pin-project", @@ -2418,7 +2400,7 @@ dependencies = [ "Inflector", "const-hex", "dunce", - "ethers-core 2.0.10", + "ethers-core", "eyre", "prettyplease", "proc-macro2", @@ -2439,7 +2421,7 @@ dependencies = [ "Inflector", "const-hex", "ethers-contract-abigen", - "ethers-core 2.0.10", + "ethers-core", "proc-macro2", "quote", "serde_json", @@ -2475,33 +2457,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "ethers-core" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d80cc6ad30b14a48ab786523af33b37f28a8623fc06afd55324816ef18fb1f" -dependencies = [ - "arrayvec", - "bytes", - "chrono", - "const-hex", - "elliptic-curve", - "ethabi", - "generic-array 0.14.7", - "k256", - "num_enum 0.7.2", - "open-fastrlp", - "rand", - "rlp", - "serde", - "serde_json", - "strum 0.26.2", - "tempfile", - "thiserror", - "tiny-keccak", - "unicode-xid", -] - [[package]] name = "ethers-providers" version = "2.0.10" @@ -2512,46 +2467,8 @@ dependencies = [ "base64 0.21.7", "bytes", "const-hex", - "enr 0.9.1", - "ethers-core 2.0.10", - "futures-channel", - "futures-core", - "futures-timer", - "futures-util", - "hashers", - "http 0.2.12", - "instant", - "jsonwebtoken", - "once_cell", - "pin-project", - "reqwest 0.11.27", - "serde", - "serde_json", - "thiserror", - "tokio", - "tokio-tungstenite", - "tracing", - "tracing-futures", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "ws_stream_wasm", -] - -[[package]] -name = "ethers-providers" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6434c9a33891f1effc9c75472e12666db2fa5a0fec4b29af6221680a6fe83ab2" -dependencies = [ - "async-trait", - "auto_impl", - "base64 0.21.7", - "bytes", - "const-hex", - "enr 0.10.0", - "ethers-core 2.0.14", + "enr", + "ethers-core", "futures-channel", "futures-core", "futures-timer", @@ -5046,7 +4963,7 @@ dependencies = [ "cfg-if", "clap 4.5.4", "env_logger", - "ethers-core 2.0.10", + "ethers-core", "flate2", "hyper 0.14.28", "lazy_static", @@ -5177,7 +5094,7 @@ dependencies = [ "clap 4.5.4", "dirs", "env_logger", - "ethers-core 2.0.10", + "ethers-core", "flate2", "hyper 0.14.28", "lazy_static", @@ -5474,13 +5391,10 @@ dependencies = [ "auto_impl", "cfg-if", "dyn-clone", - "ethers-core 2.0.14", - "ethers-providers 2.0.14", "revm-interpreter", "revm-precompile", "serde", "serde_json", - "tokio", ] [[package]] @@ -5696,8 +5610,8 @@ dependencies = [ "bytemuck", "cfg-if", "ethers-contract", - "ethers-core 2.0.10", - "ethers-providers 2.0.10", + "ethers-core", + "ethers-providers", "hex", "log", "once_cell", @@ -6995,9 +6909,6 @@ name = "strum" version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" -dependencies = [ - "strum_macros 0.26.2", -] [[package]] name = "strum_macros" diff --git a/README.md b/README.md index 920da765..62d78ecd 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file +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. \ No newline at end of file diff --git a/lib/Cargo.toml b/lib/Cargo.toml index ba43e96f..d89ef232 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -60,5 +60,4 @@ sp1 = [] risc0 = [] tracer = [ "revm/serde-json", - "revm/ethersdb", ] \ No newline at end of file diff --git a/lib/src/builder/execute.rs b/lib/src/builder/execute.rs index 260f2498..8eb298fc 100644 --- a/lib/src/builder/execute.rs +++ b/lib/src/builder/execute.rs @@ -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, @@ -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()); @@ -495,12 +495,10 @@ fn set_trace_writer( } impl Write for FlushWriter { fn write(&mut self, buf: &[u8]) -> std::io::Result { - //println!("writing"); self.writer.lock().unwrap().write(buf) } fn flush(&mut self) -> std::io::Result<()> { - //println!("flushing"); self.writer.lock().unwrap().flush() } } @@ -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 }