From 6d323ed07b55de32f056977365c5cf06cb834780 Mon Sep 17 00:00:00 2001 From: GarmashAlex Date: Fri, 4 Jul 2025 22:10:45 +0300 Subject: [PATCH 1/2] Clarify comments in ChiselRunner: fix incomplete and misleading docstrings --- crates/chisel/src/runner.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 49a5f06a73983..0c01e9220061b 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -3,13 +3,13 @@ //! This module contains the `ChiselRunner` struct, which assists with deploying //! and calling the REPL contract on a in-memory REVM instance. -use alloy_primitives::{Address, Bytes, Log, U256, map::AddressHashMap}; +use alloy_primitives::{map::AddressHashMap, Address, Bytes, Log, U256}; use eyre::Result; use foundry_evm::{ executors::{DeployResult, Executor, RawCallResult}, traces::{TraceKind, Traces}, }; -use revm::interpreter::{InstructionResult, return_ok}; +use revm::interpreter::{return_ok, InstructionResult}; /// The function selector of the REPL contract's entrypoint, the `run()` function. static RUN_SELECTOR: [u8; 4] = [0xc0, 0x40, 0x62, 0x26]; @@ -79,7 +79,7 @@ impl ChiselRunner { /// /// ### Returns /// - /// Optionally, a tuple containing the deployed address of the bytecode as well as a + /// A tuple containing the deployed address of the bytecode as well as a /// [ChiselResult] containing information about the result of the call to the deployed REPL /// contract. pub fn run(&mut self, bytecode: Bytes) -> Result<(Address, ChiselResult)> { @@ -151,9 +151,9 @@ impl ChiselRunner { self.executor.env_mut().tx.gas_limit = mid_gas_limit; let res = self.executor.call_raw(from, to, calldata.clone(), value)?; match res.exit_reason { - InstructionResult::Revert - | InstructionResult::OutOfGas - | InstructionResult::OutOfFunds => { + InstructionResult::Revert | + InstructionResult::OutOfGas | + InstructionResult::OutOfFunds => { lowest_gas_limit = mid_gas_limit; } _ => { @@ -161,9 +161,9 @@ impl ChiselRunner { // if last two successful estimations only vary by 10%, we consider this to // sufficiently accurate const ACCURACY: u64 = 10; - if (last_highest_gas_limit - highest_gas_limit) * ACCURACY - / last_highest_gas_limit - < 1 + if (last_highest_gas_limit - highest_gas_limit) * ACCURACY / + last_highest_gas_limit < + 1 { // update the gas gas_used = highest_gas_limit; @@ -173,7 +173,7 @@ impl ChiselRunner { } } } - // reset gas limit in the + // reset gas limit in the executor environment to its original value self.executor.env_mut().tx.gas_limit = init_gas_limit; } From 29f6450b7fcfcd19a89b8b69d205783e570321dc Mon Sep 17 00:00:00 2001 From: GarmashAlex Date: Fri, 4 Jul 2025 22:32:33 +0300 Subject: [PATCH 2/2] Update runner.rs --- crates/chisel/src/runner.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 0c01e9220061b..5339f3df45232 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -3,13 +3,13 @@ //! This module contains the `ChiselRunner` struct, which assists with deploying //! and calling the REPL contract on a in-memory REVM instance. -use alloy_primitives::{map::AddressHashMap, Address, Bytes, Log, U256}; +use alloy_primitives::{Address, Bytes, Log, U256, map::AddressHashMap}; use eyre::Result; use foundry_evm::{ executors::{DeployResult, Executor, RawCallResult}, traces::{TraceKind, Traces}, }; -use revm::interpreter::{return_ok, InstructionResult}; +use revm::interpreter::{InstructionResult, return_ok}; /// The function selector of the REPL contract's entrypoint, the `run()` function. static RUN_SELECTOR: [u8; 4] = [0xc0, 0x40, 0x62, 0x26]; @@ -151,9 +151,9 @@ impl ChiselRunner { self.executor.env_mut().tx.gas_limit = mid_gas_limit; let res = self.executor.call_raw(from, to, calldata.clone(), value)?; match res.exit_reason { - InstructionResult::Revert | - InstructionResult::OutOfGas | - InstructionResult::OutOfFunds => { + InstructionResult::Revert + | InstructionResult::OutOfGas + | InstructionResult::OutOfFunds => { lowest_gas_limit = mid_gas_limit; } _ => { @@ -161,9 +161,9 @@ impl ChiselRunner { // if last two successful estimations only vary by 10%, we consider this to // sufficiently accurate const ACCURACY: u64 = 10; - if (last_highest_gas_limit - highest_gas_limit) * ACCURACY / - last_highest_gas_limit < - 1 + if (last_highest_gas_limit - highest_gas_limit) * ACCURACY + / last_highest_gas_limit + < 1 { // update the gas gas_used = highest_gas_limit;