Skip to content

Commit

Permalink
chore: remove uneeded uses of std HashMap
Browse files Browse the repository at this point in the history
  • Loading branch information
elfedy committed Oct 31, 2024
1 parent a0d3fb0 commit bbbeee8
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 19 deletions.
4 changes: 2 additions & 2 deletions crates/cheatcodes/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ use revm::{
};
use serde_json::Value;
use std::{
collections::{BTreeMap, HashMap as sHashMap, HashSet, VecDeque},
collections::{BTreeMap, HashSet, VecDeque},
fs::File,
io::BufReader,
ops::Range,
Expand Down Expand Up @@ -571,7 +571,7 @@ pub struct Cheatcodes {
/// would be a significant refactor, we maintain the factory_dep part in the [Cheatcodes].
/// This can be done as each test runs with its own [Cheatcodes] instance, thereby
/// providing the necessary level of isolation.
pub persisted_factory_deps: sHashMap<H256, Vec<u8>>,
pub persisted_factory_deps: HashMap<H256, Vec<u8>>,
}

// This is not derived because calling this in `fn new` with `..Default::default()` creates a second
Expand Down
7 changes: 2 additions & 5 deletions crates/evm/core/src/backend/cow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
InspectorExt,
};
use alloy_genesis::GenesisAccount;
use alloy_primitives::{Address, B256, U256};
use alloy_primitives::{map::HashMap, Address, B256, U256};
use alloy_rpc_types::TransactionRequest;
use eyre::WrapErr;
use foundry_fork_db::DatabaseError;
Expand All @@ -21,10 +21,7 @@ use revm::{
},
Database, DatabaseCommit, JournaledState,
};
use std::{
borrow::Cow,
collections::{BTreeMap, HashMap},
};
use std::{borrow::Cow, collections::BTreeMap};

/// A wrapper around `Backend` that ensures only `revm::DatabaseRef` functions are called.
///
Expand Down
4 changes: 2 additions & 2 deletions crates/evm/core/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
InspectorExt,
};
use alloy_genesis::GenesisAccount;
use alloy_primitives::{keccak256, uint, Address, B256, U256};
use alloy_primitives::{keccak256, map::HashMap, uint, Address, B256, U256};
use alloy_rpc_types::{Block, BlockNumberOrTag, Transaction, TransactionRequest};
use alloy_serde::WithOtherFields;
use eyre::Context;
Expand All @@ -29,7 +29,7 @@ use revm::{
Database, DatabaseCommit, JournaledState,
};
use std::{
collections::{BTreeMap, HashMap, HashSet},
collections::{BTreeMap, HashSet},
time::Instant,
};

Expand Down
4 changes: 2 additions & 2 deletions crates/evm/evm/src/executors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use revm::{
},
Database,
};
use std::{borrow::Cow, collections::HashMap as sHashMap};
use std::borrow::Cow;

mod builder;
pub use builder::ExecutorBuilder;
Expand Down Expand Up @@ -94,7 +94,7 @@ pub struct Executor {
/// Sets up the next transaction to be executed as a ZK transaction.
zk_tx: Option<ZkTransactionMetadata>,
// simulate persisted factory deps
zk_persisted_factory_deps: sHashMap<foundry_zksync_core::H256, Vec<u8>>,
zk_persisted_factory_deps: HashMap<foundry_zksync_core::H256, Vec<u8>>,

pub use_zk: bool,
}
Expand Down
6 changes: 3 additions & 3 deletions crates/zksync/core/src/vm/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
/// in the Database object.
/// This code doesn't do any mutatios to Database: after each transaction run, the Revm
/// is usually collecing all the diffs - and applies them to database itself.
use std::{collections::HashMap, fmt::Debug};
use std::{collections::HashMap as sHashMap, fmt::Debug};

use alloy_primitives::{Address, U256 as rU256};
use alloy_primitives::{map::HashMap, Address, U256 as rU256};
use foundry_cheatcodes_common::record::RecordAccess;
use revm::{primitives::Account, Database, EvmContext, InnerEvmContext};
use zksync_basic_types::{L2ChainId, H160, H256, U256};
Expand All @@ -29,7 +29,7 @@ pub struct ZKVMData<'a, DB: Database> {
// pub journaled_state: &'a mut JournaledState,
ecx: &'a mut InnerEvmContext<DB>,
pub factory_deps: HashMap<H256, Vec<u8>>,
pub override_keys: HashMap<StorageKey, StorageValue>,
pub override_keys: sHashMap<StorageKey, StorageValue>,
pub accesses: Option<&'a mut RecordAccess>,
}

Expand Down
4 changes: 2 additions & 2 deletions crates/zksync/core/src/vm/runner.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alloy_primitives::hex;
use alloy_primitives::{hex, map::HashMap};
use itertools::Itertools;
use revm::{
interpreter::{CallInputs, CallScheme, CallValue},
Expand All @@ -12,7 +12,7 @@ use zksync_types::{
U256,
};

use std::{cmp::min, collections::HashMap, fmt::Debug};
use std::{cmp::min, fmt::Debug};

use crate::{
convert::{ConvertAddress, ConvertH160, ConvertRU256, ConvertU256},
Expand Down
6 changes: 3 additions & 3 deletions crates/zksync/core/src/vm/tracers/cheatcode.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
cell::OnceCell,
collections::{BTreeMap, HashMap as sHashMap, VecDeque},
collections::{BTreeMap, VecDeque},
sync::Arc,
};

Expand Down Expand Up @@ -80,7 +80,7 @@ pub struct CheatcodeTracerContext<'a> {
/// Recorded storage accesses
pub accesses: Option<&'a mut RecordAccess>,
/// Factory deps that were persisted across calls
pub persisted_factory_deps: Option<&'a mut sHashMap<H256, Vec<u8>>>,
pub persisted_factory_deps: Option<&'a mut HashMap<H256, Vec<u8>>>,
/// Paymaster data
pub paymaster_data: Option<ZkPaymasterData>,
}
Expand Down Expand Up @@ -115,7 +115,7 @@ pub struct CallContext {
pub is_static: bool,
/// L1 block hashes to return when `BLOCKHASH` opcode is encountered. This ensures consistency
/// when returning environment data in L2.
pub block_hashes: sHashMap<alloy_primitives::U256, alloy_primitives::FixedBytes<32>>,
pub block_hashes: HashMap<alloy_primitives::U256, alloy_primitives::FixedBytes<32>>,
}

/// A tracer to allow for foundry-specific functionality.
Expand Down

0 comments on commit bbbeee8

Please sign in to comment.