Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use shorter map names #14445

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,11 @@ revm-inspectors = "0.15.0"

# eth
alloy-chains = { version = "0.1.32", default-features = false }
alloy-dyn-abi = "0.8.15"
alloy-dyn-abi = "0.8.20"
alloy-eip2124 = { version = "0.1.0", default-features = false }
alloy-primitives = { version = "0.8.15", default-features = false, features = ["map-foldhash"] }
alloy-primitives = { version = "0.8.20", default-features = false, features = ["map-foldhash"] }
alloy-rlp = { version = "0.3.10", default-features = false }
alloy-sol-types = "0.8.15"
alloy-sol-types = "0.8.20"
alloy-trie = { version = "0.7", default-features = false }

alloy-consensus = { version = "0.11.1", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion book/sources/exex/tracking-state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ reth-tracing = { git = "https://github.com/paradigmxyz/reth.git" }

eyre = "0.6" # Easy error handling
futures-util = "0.3" # Stream utilities for consuming notifications
alloy-primitives = "0.8.7"
alloy-primitives = "0.8.20"
6 changes: 2 additions & 4 deletions crates/chain-state/src/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,9 +944,7 @@ mod tests {
use super::*;
use crate::test_utils::TestBlockBuilder;
use alloy_eips::eip7685::Requests;
use alloy_primitives::{
map::B256HashMap, Address, BlockNumber, Bytes, StorageKey, StorageValue,
};
use alloy_primitives::{map::B256Map, Address, BlockNumber, Bytes, StorageKey, StorageValue};
use rand::Rng;
use reth_errors::ProviderResult;
use reth_primitives::{Account, Bytecode, EthPrimitives, Receipt};
Expand Down Expand Up @@ -1106,7 +1104,7 @@ mod tests {
&self,
_input: TrieInput,
_target: HashedPostState,
) -> ProviderResult<B256HashMap<Bytes>> {
) -> ProviderResult<B256Map<Bytes>> {
Ok(HashMap::default())
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/chain-state/src/memory_overlay.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::ExecutedBlockWithTrieUpdates;
use alloy_consensus::BlockHeader;
use alloy_primitives::{
keccak256, map::B256HashMap, Address, BlockNumber, Bytes, StorageKey, StorageValue, B256,
keccak256, map::B256Map, Address, BlockNumber, Bytes, StorageKey, StorageValue, B256,
};
use reth_errors::ProviderResult;
use reth_primitives::{Account, Bytecode, NodePrimitives};
Expand Down Expand Up @@ -203,7 +203,7 @@ impl<N: NodePrimitives> StateProofProvider for MemoryOverlayStateProviderRef<'_,
&self,
mut input: TrieInput,
target: HashedPostState,
) -> ProviderResult<B256HashMap<Bytes>> {
) -> ProviderResult<B256Map<Bytes>> {
let MemoryOverlayTrieState { nodes, state } = self.trie_state().clone();
input.prepend_cached(nodes, state);
self.historical.witness(input, target)
Expand Down
4 changes: 2 additions & 2 deletions crates/engine/tree/src/tree/cached_state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Implements a state provider that has a shared cache in front of it.
use alloy_primitives::{map::B256HashMap, Address, StorageKey, StorageValue, B256};
use alloy_primitives::{map::B256Map, Address, StorageKey, StorageValue, B256};
use metrics::Gauge;
use mini_moka::sync::CacheBuilder;
use reth_errors::ProviderResult;
Expand Down Expand Up @@ -273,7 +273,7 @@ impl<S: StateProofProvider> StateProofProvider for CachedStateProvider<S> {
&self,
input: TrieInput,
target: HashedPostState,
) -> ProviderResult<B256HashMap<alloy_primitives::Bytes>> {
) -> ProviderResult<B256Map<alloy_primitives::Bytes>> {
self.state_provider.witness(input, target)
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/revm/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloc::vec::Vec;
use alloy_primitives::{
keccak256,
map::{B256HashMap, HashMap},
map::{B256Map, HashMap},
Address, BlockNumber, Bytes, StorageKey, B256, U256,
};
use reth_primitives_traits::{Account, Bytecode};
Expand Down Expand Up @@ -145,7 +145,7 @@ impl StateProofProvider for StateProviderTest {
&self,
_input: TrieInput,
_target: HashedPostState,
) -> ProviderResult<B256HashMap<Bytes>> {
) -> ProviderResult<B256Map<Bytes>> {
unimplemented!("witness generation is not supported")
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/revm/src/witness.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alloy_primitives::{keccak256, map::B256HashMap, Bytes, B256};
use alloy_primitives::{keccak256, map::B256Map, Bytes, B256};
use reth_trie::{HashedPostState, HashedStorage};
use revm::State;

Expand All @@ -11,13 +11,13 @@ pub struct ExecutionWitnessRecord {
/// the execution of the block, including during state root recomputation.
///
/// `keccak(bytecodes) => bytecodes`
pub codes: B256HashMap<Bytes>,
pub codes: B256Map<Bytes>,
/// Map of all hashed account and storage keys (addresses and slots) to their preimages
/// (unhashed account addresses and storage slots, respectively) that were required during
/// the execution of the block. during the execution of the block.
///
/// `keccak(address|slot) => address|slot`
pub keys: B256HashMap<Bytes>,
pub keys: B256Map<Bytes>,
}

impl ExecutionWitnessRecord {
Expand Down
3 changes: 1 addition & 2 deletions crates/rpc/rpc-eth-types/src/cache/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ impl reth_storage_api::StateProofProvider for StateProviderTraitObjWrapper<'_> {
&self,
input: reth_trie::TrieInput,
target: reth_trie::HashedPostState,
) -> reth_errors::ProviderResult<alloy_primitives::map::B256HashMap<alloy_primitives::Bytes>>
{
) -> reth_errors::ProviderResult<alloy_primitives::map::B256Map<alloy_primitives::Bytes>> {
self.0.witness(input, target)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
AccountReader, BlockHashReader, ExecutionDataProvider, StateProvider, StateRootProvider,
};
use alloy_primitives::{map::B256HashMap, Address, BlockNumber, Bytes, B256};
use alloy_primitives::{map::B256Map, Address, BlockNumber, Bytes, B256};
use reth_primitives::{Account, Bytecode};
use reth_storage_api::{HashedPostStateProvider, StateProofProvider, StorageRootProvider};
use reth_storage_errors::provider::ProviderResult;
Expand Down Expand Up @@ -177,7 +177,7 @@ impl<SP: StateProvider, EDP: ExecutionDataProvider> StateProofProvider
&self,
mut input: TrieInput,
target: HashedPostState,
) -> ProviderResult<B256HashMap<Bytes>> {
) -> ProviderResult<B256Map<Bytes>> {
let bundle_state = self.block_execution_data_provider.execution_outcome().state();
input.prepend(self.hashed_post_state(bundle_state));
self.state_provider.witness(input, target)
Expand Down
6 changes: 3 additions & 3 deletions crates/storage/provider/src/providers/database/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use alloy_consensus::{transaction::TransactionMeta, BlockHeader, Header, TxRecei
use alloy_eips::{eip2718::Encodable2718, eip4895::Withdrawals, BlockHashOrNumber};
use alloy_primitives::{
keccak256,
map::{hash_map, B256HashMap, HashMap, HashSet},
map::{hash_map, B256Map, HashMap, HashSet},
Address, BlockHash, BlockNumber, TxHash, TxNumber, B256, U256,
};
use itertools::Itertools;
Expand Down Expand Up @@ -291,7 +291,7 @@ impl<TX: DbTx + DbTxMut + 'static, N: NodeTypesForProvider> DatabaseProvider<TX,

// Unwind storage hashes. Add changed account and storage keys to corresponding prefix
// sets.
let mut storage_prefix_sets = B256HashMap::<PrefixSet>::default();
let mut storage_prefix_sets = B256Map::<PrefixSet>::default();
let storage_entries = self.unwind_storage_hashing(changed_storages.iter().copied())?;
for (hashed_address, hashed_slots) in storage_entries {
account_prefix_set.insert(Nibbles::unpack(hashed_address));
Expand Down Expand Up @@ -2351,7 +2351,7 @@ impl<TX: DbTxMut + DbTx + 'static, N: NodeTypes> StorageTrieWriter for DatabaseP
/// updates by the hashed address, writing in sorted order.
fn write_storage_trie_updates(
&self,
storage_tries: &B256HashMap<StorageTrieUpdates>,
storage_tries: &B256Map<StorageTrieUpdates>,
) -> ProviderResult<usize> {
let mut num_entries = 0;
let mut storage_tries = Vec::from_iter(storage_tries);
Expand Down
6 changes: 2 additions & 4 deletions crates/storage/provider/src/providers/state/historical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use crate::{
HashedPostStateProvider, ProviderError, StateProvider, StateRootProvider,
};
use alloy_eips::merge::EPOCH_SLOTS;
use alloy_primitives::{
map::B256HashMap, Address, BlockNumber, Bytes, StorageKey, StorageValue, B256,
};
use alloy_primitives::{map::B256Map, Address, BlockNumber, Bytes, StorageKey, StorageValue, B256};
use reth_db::{tables, BlockNumberList};
use reth_db_api::{
cursor::{DbCursorRO, DbDupCursorRO},
Expand Down Expand Up @@ -388,7 +386,7 @@ impl<Provider: DBProvider + BlockNumReader + StateCommitmentProvider> StateProof
&self,
mut input: TrieInput,
target: HashedPostState,
) -> ProviderResult<B256HashMap<Bytes>> {
) -> ProviderResult<B256Map<Bytes>> {
input.prepend(self.revert_state()?);
TrieWitness::overlay_witness(self.tx(), input, target).map_err(ProviderError::from)
}
Expand Down
10 changes: 2 additions & 8 deletions crates/storage/provider/src/providers/state/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use crate::{
providers::state::macros::delegate_provider_impls, AccountReader, BlockHashReader,
HashedPostStateProvider, StateProvider, StateRootProvider,
};
use alloy_primitives::{
map::B256HashMap, Address, BlockNumber, Bytes, StorageKey, StorageValue, B256,
};
use alloy_primitives::{map::B256Map, Address, BlockNumber, Bytes, StorageKey, StorageValue, B256};
use reth_db::tables;
use reth_db_api::{cursor::DbDupCursorRO, transaction::DbTx};
use reth_primitives::{Account, Bytecode};
Expand Down Expand Up @@ -146,11 +144,7 @@ impl<Provider: DBProvider + StateCommitmentProvider> StateProofProvider
Proof::overlay_multiproof(self.tx(), input, targets).map_err(ProviderError::from)
}

fn witness(
&self,
input: TrieInput,
target: HashedPostState,
) -> ProviderResult<B256HashMap<Bytes>> {
fn witness(&self, input: TrieInput, target: HashedPostState) -> ProviderResult<B256Map<Bytes>> {
TrieWitness::overlay_witness(self.tx(), input, target).map_err(ProviderError::from)
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/provider/src/providers/state/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ macro_rules! delegate_provider_impls {
StateProofProvider $(where [$($generics)*])? {
fn proof(&self, input: reth_trie::TrieInput, address: alloy_primitives::Address, slots: &[alloy_primitives::B256]) -> reth_storage_errors::provider::ProviderResult<reth_trie::AccountProof>;
fn multiproof(&self, input: reth_trie::TrieInput, targets: reth_trie::MultiProofTargets) -> reth_storage_errors::provider::ProviderResult<reth_trie::MultiProof>;
fn witness(&self, input: reth_trie::TrieInput, target: reth_trie::HashedPostState) -> reth_storage_errors::provider::ProviderResult<alloy_primitives::map::B256HashMap<alloy_primitives::Bytes>>;
fn witness(&self, input: reth_trie::TrieInput, target: reth_trie::HashedPostState) -> reth_storage_errors::provider::ProviderResult<alloy_primitives::map::B256Map<alloy_primitives::Bytes>>;
}
HashedPostStateProvider $(where [$($generics)*])? {
fn hashed_post_state(&self, bundle_state: &revm::db::BundleState) -> reth_trie::HashedPostState;
Expand Down
4 changes: 2 additions & 2 deletions crates/storage/provider/src/test_utils/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use alloy_consensus::{
use alloy_eips::{eip4895::Withdrawals, BlockHashOrNumber, BlockId, BlockNumberOrTag};
use alloy_primitives::{
keccak256,
map::{B256HashMap, HashMap},
map::{B256Map, HashMap},
Address, BlockHash, BlockNumber, Bytes, StorageKey, StorageValue, TxHash, TxNumber, B256, U256,
};
use parking_lot::Mutex;
Expand Down Expand Up @@ -724,7 +724,7 @@ impl<T: Transaction, ChainSpec: EthChainSpec> StateProofProvider for MockEthProv
&self,
_input: TrieInput,
_target: HashedPostState,
) -> ProviderResult<B256HashMap<Bytes>> {
) -> ProviderResult<B256Map<Bytes>> {
Ok(HashMap::default())
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/storage/storage-api/src/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use alloc::{boxed::Box, string::String, sync::Arc, vec::Vec};
use alloy_consensus::transaction::TransactionMeta;
use alloy_eips::{eip4895::Withdrawals, BlockHashOrNumber, BlockId, BlockNumberOrTag};
use alloy_primitives::{
map::{B256HashMap, HashMap},
map::{B256Map, HashMap},
Address, BlockHash, BlockNumber, Bytes, StorageKey, StorageValue, TxHash, TxNumber, B256, U256,
};
use core::{
Expand Down Expand Up @@ -439,7 +439,7 @@ impl<C: Send + Sync, N: NodePrimitives> StateProofProvider for NoopProvider<C, N
&self,
_input: TrieInput,
_target: HashedPostState,
) -> ProviderResult<B256HashMap<Bytes>> {
) -> ProviderResult<B256Map<Bytes>> {
Ok(HashMap::default())
}
}
Expand Down
10 changes: 3 additions & 7 deletions crates/storage/storage-api/src/trie.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alloy_primitives::{map::B256HashMap, Address, Bytes, B256};
use alloy_primitives::{map::B256Map, Address, Bytes, B256};
use reth_storage_errors::provider::ProviderResult;
use reth_trie::{
updates::{StorageTrieUpdates, TrieUpdates},
Expand Down Expand Up @@ -85,11 +85,7 @@ pub trait StateProofProvider: Send + Sync {
) -> ProviderResult<MultiProof>;

/// Get trie witness for provided state.
fn witness(
&self,
input: TrieInput,
target: HashedPostState,
) -> ProviderResult<B256HashMap<Bytes>>;
fn witness(&self, input: TrieInput, target: HashedPostState) -> ProviderResult<B256Map<Bytes>>;
}

/// Trie Writer
Expand All @@ -111,7 +107,7 @@ pub trait StorageTrieWriter: Send + Sync {
/// Returns the number of entries modified.
fn write_storage_trie_updates(
&self,
storage_tries: &B256HashMap<StorageTrieUpdates>,
storage_tries: &B256Map<StorageTrieUpdates>,
) -> ProviderResult<usize>;

/// Writes storage trie updates for the given hashed address.
Expand Down
18 changes: 9 additions & 9 deletions crates/trie/common/src/hashedstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
use alloc::{borrow::Cow, vec::Vec};
use alloy_primitives::{
keccak256,
map::{hash_map, B256HashMap, B256HashSet, HashMap, HashSet},
map::{hash_map, B256Map, B256Set, HashMap, HashSet},
Address, B256, U256,
};
use itertools::Itertools;
Expand All @@ -22,9 +22,9 @@ use rayon::prelude::{IntoParallelIterator, ParallelIterator};
#[derive(PartialEq, Eq, Clone, Default, Debug)]
pub struct HashedPostState {
/// Mapping of hashed address to account info, `None` if destroyed.
pub accounts: B256HashMap<Option<Account>>,
pub accounts: B256Map<Option<Account>>,
/// Mapping of hashed address to hashed storage.
pub storages: B256HashMap<HashedStorage>,
pub storages: B256Map<HashedStorage>,
}

impl HashedPostState {
Expand Down Expand Up @@ -222,7 +222,7 @@ pub struct HashedStorage {
/// Flag indicating whether the storage was wiped or not.
pub wiped: bool,
/// Mapping of hashed storage slot to storage value.
pub storage: B256HashMap<U256>,
pub storage: B256Map<U256>,
}

impl HashedStorage {
Expand Down Expand Up @@ -298,14 +298,14 @@ pub struct HashedPostStateSorted {
/// Updated state of accounts.
pub accounts: HashedAccountsSorted,
/// Map of hashed addresses to hashed storage.
pub storages: B256HashMap<HashedStorageSorted>,
pub storages: B256Map<HashedStorageSorted>,
}

impl HashedPostStateSorted {
/// Create new instance of [`HashedPostStateSorted`]
pub const fn new(
accounts: HashedAccountsSorted,
storages: B256HashMap<HashedStorageSorted>,
storages: B256Map<HashedStorageSorted>,
) -> Self {
Self { accounts, storages }
}
Expand All @@ -316,7 +316,7 @@ impl HashedPostStateSorted {
}

/// Returns reference to hashed account storages.
pub const fn account_storages(&self) -> &B256HashMap<HashedStorageSorted> {
pub const fn account_storages(&self) -> &B256Map<HashedStorageSorted> {
&self.storages
}
}
Expand All @@ -327,7 +327,7 @@ pub struct HashedAccountsSorted {
/// Sorted collection of hashed addresses and their account info.
pub accounts: Vec<(B256, Account)>,
/// Set of destroyed account keys.
pub destroyed_accounts: B256HashSet,
pub destroyed_accounts: B256Set,
}

impl HashedAccountsSorted {
Expand All @@ -347,7 +347,7 @@ pub struct HashedStorageSorted {
/// Sorted hashed storage slots with non-zero value.
pub non_zero_valued_slots: Vec<(B256, U256)>,
/// Slots that have been zero valued.
pub zero_valued_slots: B256HashSet,
pub zero_valued_slots: B256Set,
/// Flag indicating whether the storage was wiped or not.
pub wiped: bool,
}
Expand Down
10 changes: 5 additions & 5 deletions crates/trie/common/src/prefix_set.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::Nibbles;
use alloc::{sync::Arc, vec::Vec};
use alloy_primitives::map::{B256HashMap, B256HashSet};
use alloy_primitives::map::{B256Map, B256Set};

/// Collection of mutable prefix sets.
#[derive(Clone, Default, Debug)]
Expand All @@ -9,9 +9,9 @@ pub struct TriePrefixSetsMut {
pub account_prefix_set: PrefixSetMut,
/// A map containing storage changes with the hashed address as key and a set of storage key
/// prefixes as the value.
pub storage_prefix_sets: B256HashMap<PrefixSetMut>,
pub storage_prefix_sets: B256Map<PrefixSetMut>,
/// A set of hashed addresses of destroyed accounts.
pub destroyed_accounts: B256HashSet,
pub destroyed_accounts: B256Set,
}

impl TriePrefixSetsMut {
Expand Down Expand Up @@ -47,9 +47,9 @@ pub struct TriePrefixSets {
pub account_prefix_set: PrefixSet,
/// A map containing storage changes with the hashed address as key and a set of storage key
/// prefixes as the value.
pub storage_prefix_sets: B256HashMap<PrefixSet>,
pub storage_prefix_sets: B256Map<PrefixSet>,
/// A set of hashed addresses of destroyed accounts.
pub destroyed_accounts: B256HashSet,
pub destroyed_accounts: B256Set,
}

/// A container for efficiently storing and checking for the presence of key prefixes.
Expand Down
Loading
Loading