diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 2127ddc4de90..4231c55b4122 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -11,7 +11,7 @@ use foundry_evm::{ traces::{CallTraceArena, TraceKind}, }; use revm::interpreter::{return_ok, InstructionResult}; -use std::collections::BTreeMap; +use std::collections::HashMap; /// The function selector of the REPL contract's entrypoint, the `run()` function. static RUN_SELECTOR: [u8; 4] = [0xc0, 0x40, 0x62, 0x26]; @@ -44,7 +44,7 @@ pub struct ChiselResult { /// Amount of gas used in the transaction pub gas_used: u64, /// Map of addresses to their labels - pub labeled_addresses: BTreeMap, + pub labeled_addresses: HashMap, /// Return data pub returned: Bytes, /// Called address diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 971a2a21f530..bb660317861e 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -33,7 +33,7 @@ use revm::{ BlockEnv, Bytecode, Env, ExecutionResult, Output, ResultAndState, SpecId, TransactTo, TxEnv, }, }; -use std::collections::BTreeMap; +use std::collections::HashMap; mod builder; pub use builder::ExecutorBuilder; @@ -593,7 +593,7 @@ pub struct ExecutionErr { pub logs: Vec, pub traces: Option, pub debug: Option, - pub labels: BTreeMap, + pub labels: HashMap, pub transactions: Option, pub state_changeset: Option, pub script_wallets: Vec, @@ -653,7 +653,7 @@ pub struct CallResult { /// The logs emitted during the call pub logs: Vec, /// The labels assigned to addresses during the call - pub labels: BTreeMap, + pub labels: HashMap, /// The traces of the call pub traces: Option, /// The coverage info collected during the call @@ -698,7 +698,7 @@ pub struct RawCallResult { /// The logs emitted during the call pub logs: Vec, /// The labels assigned to addresses during the call - pub labels: BTreeMap, + pub labels: HashMap, /// The traces of the call pub traces: Option, /// The coverage info collected during the call @@ -735,7 +735,7 @@ impl Default for RawCallResult { gas_refunded: 0, stipend: 0, logs: Vec::new(), - labels: BTreeMap::new(), + labels: HashMap::new(), traces: None, coverage: None, debug: None, diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 87cc29b51865..35044677f86c 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -15,7 +15,7 @@ use revm::{ primitives::{BlockEnv, Env}, EVMData, Inspector, }; -use std::{collections::BTreeMap, sync::Arc}; +use std::{collections::HashMap, sync::Arc}; #[derive(Clone, Debug, Default)] #[must_use = "builders do nothing unless you call `build` on them"] @@ -185,7 +185,7 @@ macro_rules! call_inspectors { /// The collected results of [`InspectorStack`]. pub struct InspectorData { pub logs: Vec, - pub labels: BTreeMap, + pub labels: HashMap, pub traces: Option, pub debug: Option, pub coverage: Option, diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index 72fded966fb5..66e59ebcb783 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -15,7 +15,7 @@ use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use itertools::Itertools; use serde::{Deserialize, Serialize}; -use std::{collections::BTreeMap, fmt}; +use std::{collections::HashMap, fmt}; pub use proptest::test_runner::{Config as FuzzConfig, Reason}; @@ -143,7 +143,7 @@ pub struct FuzzTestResult { pub decoded_logs: Vec, /// Labeled addresses - pub labeled_addresses: BTreeMap, + pub labeled_addresses: HashMap, /// Exemplary traces for a fuzz run of the test function /// diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 426b4885c24f..ad2941aa83ff 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -590,7 +590,7 @@ pub struct ScriptResult { pub traces: Traces, pub debug: Option>, pub gas_used: u64, - pub labeled_addresses: BTreeMap, + pub labeled_addresses: HashMap, pub transactions: Option, pub returned: Bytes, pub address: Option
, diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 28faf48be9ed..1dc91041cf33 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -165,10 +165,7 @@ impl ScriptRunner { returned: Bytes::new(), success, gas_used, - labeled_addresses: labeled_addresses - .into_iter() - .map(|l| (l.0, l.1)) - .collect::>(), + labeled_addresses, transactions, logs, traces, diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 94551e876327..26646a38d4d0 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -12,7 +12,7 @@ use foundry_evm::{ }; use serde::{Deserialize, Serialize}; use std::{ - collections::BTreeMap, + collections::{BTreeMap, HashMap}, fmt::{self, Write}, time::Duration, }; @@ -127,7 +127,7 @@ pub struct TestResult { pub coverage: Option, /// Labeled addresses - pub labeled_addresses: BTreeMap, + pub labeled_addresses: HashMap, /// The debug nodes of the call pub debug: Option, @@ -266,7 +266,7 @@ pub struct TestSetup { /// Call traces of the setup pub traces: Traces, /// Addresses labeled during setup - pub labeled_addresses: BTreeMap, + pub labeled_addresses: HashMap, /// The reason the setup failed, if it did pub reason: Option, /// Coverage info during setup @@ -278,7 +278,7 @@ impl TestSetup { error: EvmError, mut logs: Vec, mut traces: Traces, - mut labeled_addresses: BTreeMap, + mut labeled_addresses: HashMap, ) -> Self { match error { EvmError::Execution(err) => { @@ -301,7 +301,7 @@ impl TestSetup { address: Address, logs: Vec, traces: Traces, - labeled_addresses: BTreeMap, + labeled_addresses: HashMap, coverage: Option, ) -> Self { Self { address, logs, traces, labeled_addresses, reason: None, coverage } @@ -310,7 +310,7 @@ impl TestSetup { pub fn failed_with( logs: Vec, traces: Traces, - labeled_addresses: BTreeMap, + labeled_addresses: HashMap, reason: String, ) -> Self { Self { diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 14783d47b9c7..686df8f44c33 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -157,7 +157,7 @@ impl<'a> ContractRunner<'a> { } Err(err) => { error!(reason=%err, contract=%address, "setUp failed"); - (Vec::new(), None, BTreeMap::new(), Some(format!("setup failed: {err}")), None) + (Vec::new(), None, HashMap::new(), Some(format!("setup failed: {err}")), None) } }; traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); @@ -563,7 +563,7 @@ impl<'a> ContractRunner<'a> { let fuzzed_executor = FuzzedExecutor::new(self.executor.clone(), runner.clone(), self.sender, fuzz_config); let state = fuzzed_executor.build_fuzz_state(); - let mut result = fuzzed_executor.fuzz(func, address, should_fail, self.errors); + let result = fuzzed_executor.fuzz(func, address, should_fail, self.errors); let mut debug = Default::default(); let mut breakpoints = Default::default(); @@ -631,8 +631,8 @@ impl<'a> ContractRunner<'a> { }; // Record logs, labels and traces - logs.append(&mut result.logs); - labeled_addresses.append(&mut result.labeled_addresses); + logs.extend(result.logs); + labeled_addresses.extend(result.labeled_addresses); traces.extend(result.traces.map(|traces| (TraceKind::Execution, traces))); coverage = merge_coverages(coverage, result.coverage);