From 427ddcca0c6514ae161ac3a397ae0c3990fa7a1e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 13 Mar 2024 17:16:02 +0100 Subject: [PATCH] perf: use fxhash in maps when the key is small --- Cargo.lock | 121 +++++++++++++++------------- Cargo.toml | 10 +-- crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/src/inspector.rs | 3 +- crates/common/Cargo.toml | 1 + crates/common/src/compile.rs | 3 +- crates/common/src/evm.rs | 4 +- crates/evm/core/Cargo.toml | 3 +- crates/evm/core/src/fork/backend.rs | 3 +- crates/evm/core/src/ic.rs | 11 +-- crates/evm/coverage/Cargo.toml | 1 + crates/evm/coverage/src/analysis.rs | 9 ++- crates/evm/evm/src/executors/mod.rs | 6 +- crates/forge/Cargo.toml | 17 +--- crates/forge/bin/cmd/coverage.rs | 5 +- crates/forge/src/runner.rs | 2 +- 16 files changed, 104 insertions(+), 96 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8d5f0d37be90..5ee659cab83f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -564,7 +564,7 @@ dependencies = [ "futures", "hash-db", "hyper", - "itertools 0.11.0", + "itertools 0.12.1", "k256", "memory-db", "parking_lot", @@ -645,9 +645,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "arbitrary" @@ -1195,9 +1195,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.14.3" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" +checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" [[package]] name = "byteorder" @@ -1326,7 +1326,7 @@ dependencies = [ "foundry-wallets", "futures", "indicatif", - "itertools 0.11.0", + "itertools 0.12.1", "rand 0.8.5", "rayon", "regex", @@ -1701,9 +1701,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.11.2" +version = "1.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b37dae8c8ded08d5ec72caa1b4204a5344047cd4a2c7387e3d150020abfbc1c9" +checksum = "5ba00838774b4ab0233e355d26710fbfc8327a05c017f6dc4873f876d1f79f78" dependencies = [ "cfg-if", "cpufeatures", @@ -2521,7 +2521,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.52", - "toml 0.8.10", + "toml 0.8.11", "walkdir", ] @@ -2878,7 +2878,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.10", + "toml 0.8.11", "uncased", "version_check", ] @@ -2989,7 +2989,7 @@ dependencies = [ "globset", "hyper", "indicatif", - "itertools 0.11.0", + "itertools 0.12.1", "once_cell", "opener", "parking_lot", @@ -3001,6 +3001,7 @@ dependencies = [ "regex", "reqwest", "revm-inspectors", + "rustc-hash", "semver 1.0.22", "serde", "serde_json", @@ -3031,7 +3032,7 @@ dependencies = [ "foundry-common", "foundry-compilers", "foundry-config", - "itertools 0.11.0", + "itertools 0.12.1", "mdbook", "once_cell", "rayon", @@ -3040,7 +3041,7 @@ dependencies = [ "serde_json", "solang-parser", "thiserror", - "toml 0.8.10", + "toml 0.8.11", "tracing", ] @@ -3051,11 +3052,11 @@ dependencies = [ "alloy-primitives", "ariadne", "foundry-config", - "itertools 0.11.0", + "itertools 0.12.1", "pretty_assertions", "solang-parser", "thiserror", - "toml 0.8.10", + "toml 0.8.11", "tracing", "tracing-subscriber", ] @@ -3089,7 +3090,7 @@ dependencies = [ "foundry-wallets", "futures", "indicatif", - "itertools 0.11.0", + "itertools 0.12.1", "parking_lot", "revm-inspectors", "semver 1.0.22", @@ -3169,7 +3170,7 @@ dependencies = [ "alloy-rpc-types", "alloy-signer", "alloy-sol-types", - "base64 0.21.7", + "base64 0.22.0", "const-hex", "eyre", "foundry-cheatcodes-spec", @@ -3178,15 +3179,16 @@ dependencies = [ "foundry-config", "foundry-evm-core", "foundry-wallets", - "itertools 0.11.0", + "itertools 0.12.1", "jsonpath_lib", "k256", "p256", "parking_lot", "revm", + "rustc-hash", "serde_json", "thiserror", - "toml 0.8.10", + "toml 0.8.11", "tracing", "walkdir", ] @@ -3274,6 +3276,7 @@ dependencies = [ "pretty_assertions", "rand 0.8.5", "reqwest", + "rustc-hash", "semver 1.0.22", "serde", "serde_json", @@ -3289,9 +3292,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f5a6dffd81de844c96fea0aaf825cd2a9760c4a768ae3f5786d431ef3c57d69" +checksum = "1cc03b422b28e49d6dd61b8442bcee16c22edd975be1764de5a39c4037ecb478" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3351,7 +3354,7 @@ dependencies = [ "serde_regex", "tempfile", "thiserror", - "toml 0.8.10", + "toml 0.8.11", "toml_edit 0.21.1", "tracing", "walkdir", @@ -3393,7 +3396,7 @@ dependencies = [ "foundry-evm-fuzz", "foundry-evm-traces", "hashbrown 0.14.3", - "itertools 0.11.0", + "itertools 0.12.1", "parking_lot", "proptest", "rand 0.8.5", @@ -3425,11 +3428,12 @@ dependencies = [ "foundry-config", "foundry-macros", "futures", - "itertools 0.11.0", + "itertools 0.12.1", "once_cell", "parking_lot", "revm", "revm-inspectors", + "rustc-hash", "serde", "serde_json", "thiserror", @@ -3448,6 +3452,7 @@ dependencies = [ "foundry-compilers", "foundry-evm-core", "revm", + "rustc-hash", "semver 1.0.22", "tracing", ] @@ -3468,7 +3473,7 @@ dependencies = [ "foundry-evm-coverage", "foundry-evm-traces", "hashbrown 0.14.3", - "itertools 0.11.0", + "itertools 0.12.1", "parking_lot", "proptest", "rand 0.8.5", @@ -3495,7 +3500,7 @@ dependencies = [ "foundry-evm-core", "futures", "hashbrown 0.14.3", - "itertools 0.11.0", + "itertools 0.12.1", "once_cell", "revm-inspectors", "serde", @@ -3562,7 +3567,7 @@ dependencies = [ "eyre", "foundry-common", "foundry-config", - "itertools 0.11.0", + "itertools 0.12.1", "rpassword", "rusoto_core", "rusoto_kms", @@ -5524,7 +5529,7 @@ checksum = "4ccca0f6c17acc81df8e242ed473ec144cbf5c98037e69aa6d144780aad103c8" dependencies = [ "inlinable_string", "pear_codegen", - "yansi 1.0.0", + "yansi 1.0.1", ] [[package]] @@ -5926,9 +5931,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -5943,7 +5948,7 @@ dependencies = [ "quote", "syn 2.0.52", "version_check", - "yansi 1.0.0", + "yansi 1.0.1", ] [[package]] @@ -6255,9 +6260,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.25" +version = "0.11.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eea5a9eb898d3783f17c6407670e3592fd174cb81a10e51d4c37f49450b9946" +checksum = "78bf93c4af7a8bb7d879d51cebe797356ff10ae8516ace542b5182d9dcac10b2" dependencies = [ "base64 0.21.7", "bytes", @@ -6470,9 +6475,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b1d9521f889713d1221270fdd63370feca7e5c71a18745343402fa86e4f04f" +checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62" dependencies = [ "alloy-rlp", "arbitrary", @@ -6598,6 +6603,12 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -6757,9 +6768,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" +checksum = "2ef2175c2907e7c8bc0a9c3f86aeb5ec1f3b275300ad58a44d0c3ae379a5e52e" dependencies = [ "cfg-if", "derive_more", @@ -6769,9 +6780,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" +checksum = "634d9b8eb8fd61c5cdd3390d9b2132300a7e7618955b98b8416f118c1b4e144f" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -7483,20 +7494,20 @@ dependencies = [ [[package]] name = "system-configuration" -version = "0.6.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bc6ee10a9b4fcf576e9b0819d95ec16f4d2c02d39fd83ac1c8789785c4a42" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags 2.4.2", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.6.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" dependencies = [ "core-foundation-sys", "libc", @@ -7567,18 +7578,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", @@ -7793,15 +7804,15 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" +checksum = "af06656561d28735e9c1cd63dfd57132c8155426aa6af24f36a00a351f88c48e" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.6", + "toml_edit 0.22.7", ] [[package]] @@ -7848,9 +7859,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.6" +version = "0.22.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" +checksum = "18769cd1cec395d70860ceb4d932812a0b4d06b1a4bb336745a4d21b9496e992" dependencies = [ "indexmap", "serde", @@ -8751,9 +8762,9 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "yansi" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c2861d76f58ec8fc95708b9b1e417f7b12fd72ad33c01fa6886707092dea0d3" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] name = "zerocopy" diff --git a/Cargo.toml b/Cargo.toml index f56a5cfd7847..1831efc1c453 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -186,26 +186,26 @@ alloy-rlp = "0.3.3" solang-parser = "=0.3.3" ## misc +base64 = "0.22" chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" derive_more = "0.99" +evm-disassembler = "0.4" eyre = "0.6" hex = { package = "const-hex", version = "1.6", features = ["hex"] } -itertools = "0.11" +itertools = "0.12" jsonpath_lib = "0.3" +k256 = "0.13" pretty_assertions = "1.4" -protobuf = "=3.2.0" rand = "0.8" +rustc-hash = "1.1" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } -base64 = "0.21" strum = "0.26" toml = "0.8" tracing = "0.1" tracing-subscriber = "0.3" -evm-disassembler = "0.4" vergen = { version = "8", default-features = false } -k256 = "0.13" axum = "0.6" hyper = "0.14" diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 7524afb635f3..57b39966e034 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -42,3 +42,4 @@ k256.workspace = true walkdir = "2" p256 = "0.13.2" thiserror = "1" +rustc-hash.workspace = true diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 9b26e77547cf..bf39684b4955 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -32,6 +32,7 @@ use revm::{ primitives::{BlockEnv, CreateScheme, TransactTo}, EvmContext, InnerEvmContext, Inspector, }; +use rustc_hash::FxHashMap; use serde_json::Value; use std::{ collections::{BTreeMap, HashMap, VecDeque}, @@ -154,7 +155,7 @@ pub struct Cheatcodes { pub expected_emits: VecDeque, /// Map of context depths to memory offset ranges that may be written to within the call depth. - pub allowed_mem_writes: HashMap>>, + pub allowed_mem_writes: FxHashMap>>, /// Current broadcasting information pub broadcast: Option, diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 49be9df68407..cf6e53040b38 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -57,6 +57,7 @@ tracing.workspace = true url = "2" walkdir = "2" yansi = "0.5" +rustc-hash.workspace = true [dev-dependencies] foundry-macros.workspace = true diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 96574f460f25..3f159f069b0f 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -11,6 +11,7 @@ use foundry_compilers::{ Artifact, ArtifactId, FileFilter, Graph, Project, ProjectCompileOutput, ProjectPathsConfig, Solc, SolcConfig, }; +use rustc_hash::FxHashMap; use std::{ collections::{BTreeMap, HashMap}, convert::Infallible, @@ -278,7 +279,7 @@ pub struct ContractSources { /// Map over artifacts' contract names -> vector of file IDs pub ids_by_name: HashMap>, /// Map over file_id -> (source code, contract) - pub sources_by_id: HashMap, + pub sources_by_id: FxHashMap, } impl ContractSources { diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 4b2a94f4377d..7b915891386b 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -11,11 +11,11 @@ use foundry_config::{ }, Chain, Config, }; +use rustc_hash::FxHashMap; use serde::Serialize; -use std::collections::HashMap; /// Map keyed by breakpoints char to their location (contract address, pc) -pub type Breakpoints = HashMap; +pub type Breakpoints = FxHashMap; /// `EvmArgs` and `EnvArgs` take the highest precedence in the Config/Figment hierarchy. /// All vars are opt-in, their default values are expected to be set by the diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 347d0489cfb7..5e01c91141f5 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -37,14 +37,15 @@ revm = { workspace = true, default-features = false, features = [ ] } revm-inspectors.workspace = true -derive_more.workspace = true auto_impl = "1" +derive_more.workspace = true eyre = "0.6" futures = "0.3" hex.workspace = true itertools.workspace = true once_cell = "1" parking_lot = "0.12" +rustc-hash.workspace = true serde = "1" serde_json = "1" thiserror = "1" diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 6613c0f13497..8e720a2505d2 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -18,6 +18,7 @@ use revm::{ db::DatabaseRef, primitives::{AccountInfo, Bytecode, KECCAK_EMPTY}, }; +use rustc_hash::FxHashMap; use std::{ collections::{hash_map::Entry, HashMap, VecDeque}, pin::Pin, @@ -86,7 +87,7 @@ pub struct BackendHandler

{ /// Listeners that wait for a `get_storage_at` response storage_requests: HashMap<(Address, U256), Vec>, /// Listeners that wait for a `get_block` response - block_requests: HashMap>, + block_requests: FxHashMap>, /// Incoming commands. incoming: Receiver, /// unprocessed queued requests diff --git a/crates/evm/core/src/ic.rs b/crates/evm/core/src/ic.rs index 479a50b0a528..7bb2179c5e9a 100644 --- a/crates/evm/core/src/ic.rs +++ b/crates/evm/core/src/ic.rs @@ -1,20 +1,21 @@ use revm::{ interpreter::{opcode, opcode::spec_opcode_gas}, - primitives::{HashMap, SpecId}, + primitives::SpecId, }; +use rustc_hash::FxHashMap; /// Maps from program counter to instruction counter. /// /// Inverse of [`IcPcMap`]. pub struct PcIcMap { - pub inner: HashMap, + pub inner: FxHashMap, } impl PcIcMap { /// Creates a new `PcIcMap` for the given code. pub fn new(spec: SpecId, code: &[u8]) -> Self { let opcode_infos = spec_opcode_gas(spec); - let mut map = HashMap::new(); + let mut map = FxHashMap::default(); let mut i = 0; let mut cumulative_push_size = 0; @@ -44,14 +45,14 @@ impl PcIcMap { /// /// Inverse of [`PcIcMap`]. pub struct IcPcMap { - pub inner: HashMap, + pub inner: FxHashMap, } impl IcPcMap { /// Creates a new `IcPcMap` for the given code. pub fn new(spec: SpecId, code: &[u8]) -> Self { let opcode_infos = spec_opcode_gas(spec); - let mut map = HashMap::new(); + let mut map = FxHashMap::default(); let mut i = 0; let mut cumulative_push_size = 0; diff --git a/crates/evm/coverage/Cargo.toml b/crates/evm/coverage/Cargo.toml index 4a9a39276abf..6a3dc92ff3b3 100644 --- a/crates/evm/coverage/Cargo.toml +++ b/crates/evm/coverage/Cargo.toml @@ -20,3 +20,4 @@ eyre = "0.6" revm.workspace = true semver = "1" tracing = "0.1" +rustc-hash.workspace = true diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 9af93cb688c4..1926d2b4ed20 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -1,6 +1,7 @@ use super::{ContractId, CoverageItem, CoverageItemKind, SourceLocation}; use foundry_common::TestFunctionExt; use foundry_compilers::artifacts::ast::{self, Ast, Node, NodeType}; +use rustc_hash::FxHashMap; use semver::Version; use std::collections::{HashMap, HashSet}; @@ -443,9 +444,9 @@ pub struct SourceAnalysis { #[derive(Clone, Debug, Default)] pub struct SourceAnalyzer { /// A map of source IDs to their source code - sources: HashMap, + sources: FxHashMap, /// A map of AST node IDs of contracts to their contract IDs. - contract_ids: HashMap, + contract_ids: FxHashMap, /// A map of contract IDs to their AST nodes. contracts: HashMap, /// A collection of coverage items. @@ -463,8 +464,8 @@ impl SourceAnalyzer { /// (defined by `version`). pub fn new( version: Version, - asts: HashMap, - sources: HashMap, + asts: FxHashMap, + sources: FxHashMap, ) -> eyre::Result { let mut analyzer = SourceAnalyzer { sources, ..Default::default() }; diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index a62d070a5ec4..469d6b6e4a01 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -838,11 +838,7 @@ fn convert_call_result( .. } = call_result; - let breakpoints = if let Some(c) = call_result.cheatcodes { - c.breakpoints - } else { - std::collections::HashMap::new() - }; + let breakpoints = call_result.cheatcodes.map(|c| c.breakpoints).unwrap_or_default(); match status { return_ok!() => { diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 0a120f975408..46e9ffd38a44 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -15,11 +15,7 @@ name = "forge" path = "bin/main.rs" [build-dependencies] -vergen = { workspace = true, default-features = false, features = [ - "build", - "git", - "gitcl", -] } +vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } [dependencies] # lib @@ -83,6 +79,7 @@ thiserror = "1" tokio = { version = "1", features = ["time"] } watchexec = "2.3.2" evm-disassembler.workspace = true +rustc-hash.workspace = true # doc server axum = { workspace = true, features = ["ws"] } @@ -99,9 +96,7 @@ globset = "0.4" paste = "1.0" path-slash = "0.2" pretty_assertions.workspace = true -svm = { package = "svm-rs", version = "0.3", default-features = false, features = [ - "rustls", -] } +svm = { package = "svm-rs", version = "0.3", default-features = false, features = ["rustls"] } tempfile = "3" tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } @@ -113,11 +108,7 @@ rustls = [ "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots", ] -openssl = [ - "foundry-cli/openssl", - "reqwest/default-tls", - "foundry-wallets/openssl", -] +openssl = ["foundry-cli/openssl", "reqwest/default-tls", "foundry-wallets/openssl"] asm-keccak = ["alloy-primitives/asm-keccak"] [[bench]] diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 7acfa8fdf346..e140b8436aaf 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -26,6 +26,7 @@ use foundry_compilers::{ Artifact, Project, ProjectCompileOutput, }; use foundry_config::{Config, SolcReq}; +use rustc_hash::FxHashMap; use semver::Version; use std::{collections::HashMap, path::PathBuf, sync::mpsc::channel}; use yansi::Paint; @@ -155,8 +156,8 @@ impl CoverageArgs { let mut report = CoverageReport::default(); // Collect ASTs and sources - let mut versioned_asts: HashMap> = HashMap::new(); - let mut versioned_sources: HashMap> = HashMap::new(); + let mut versioned_asts: HashMap> = HashMap::new(); + let mut versioned_sources: HashMap> = HashMap::new(); for (path, mut source_file, version) in sources.into_sources_with_version() { report.add_source(version.clone(), source_file.id as usize, path.clone()); diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 3b1a1a207178..e8dba45a234c 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -383,7 +383,7 @@ impl<'a> ContractRunner<'a> { err.stipend, None, err.state_changeset, - HashMap::new(), + Default::default(), ) } Err(EvmError::SkipError) => {