mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: use shorter map names (#14445)
This commit is contained in:
@ -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 }
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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};
|
||||
@ -1106,7 +1104,7 @@ mod tests {
|
||||
&self,
|
||||
_input: TrieInput,
|
||||
_target: HashedPostState,
|
||||
) -> ProviderResult<B256HashMap<Bytes>> {
|
||||
) -> ProviderResult<B256Map<Bytes>> {
|
||||
Ok(HashMap::default())
|
||||
}
|
||||
}
|
||||
|
||||
@ -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};
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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};
|
||||
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 {
|
||||
|
||||
3
crates/rpc/rpc-eth-types/src/cache/db.rs
vendored
3
crates/rpc/rpc-eth-types/src/cache/db.rs
vendored
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
@ -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));
|
||||
@ -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);
|
||||
|
||||
@ -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},
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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};
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
@ -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::{
|
||||
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
@ -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},
|
||||
@ -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
|
||||
@ -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.
|
||||
|
||||
@ -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;
|
||||
@ -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 {
|
||||
@ -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 {
|
||||
@ -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 }
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
@ -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 {
|
||||
@ -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,
|
||||
}
|
||||
|
||||
@ -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)]
|
||||
@ -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 {
|
||||
@ -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.
|
||||
|
||||
@ -5,7 +5,7 @@ use alloc::vec::Vec;
|
||||
use alloy_consensus::constants::KECCAK_EMPTY;
|
||||
use alloy_primitives::{
|
||||
keccak256,
|
||||
map::{hash_map, B256HashMap, B256HashSet, HashMap},
|
||||
map::{hash_map, B256Map, B256Set, HashMap},
|
||||
Address, Bytes, B256, U256,
|
||||
};
|
||||
use alloy_rlp::{encode_fixed_size, Decodable, EMPTY_STRING_CODE};
|
||||
@ -18,7 +18,7 @@ use itertools::Itertools;
|
||||
use reth_primitives_traits::Account;
|
||||
|
||||
/// Proof targets map.
|
||||
pub type MultiProofTargets = B256HashMap<B256HashSet>;
|
||||
pub type MultiProofTargets = B256Map<B256Set>;
|
||||
|
||||
/// The state multiproof of target accounts and multiproofs of their storage tries.
|
||||
/// Multiproof is effectively a state subtrie that only contains the nodes
|
||||
@ -32,7 +32,7 @@ pub struct MultiProof {
|
||||
/// The tree masks of the branch nodes in the account proof.
|
||||
pub branch_node_tree_masks: HashMap<Nibbles, TrieMask>,
|
||||
/// Storage trie multiproofs.
|
||||
pub storages: B256HashMap<StorageMultiProof>,
|
||||
pub storages: B256Map<StorageMultiProof>,
|
||||
}
|
||||
|
||||
impl MultiProof {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use crate::{BranchNodeCompact, HashBuilder, Nibbles};
|
||||
use alloc::vec::Vec;
|
||||
use alloy_primitives::{
|
||||
map::{B256HashMap, B256HashSet, HashMap, HashSet},
|
||||
map::{B256Map, B256Set, HashMap, HashSet},
|
||||
B256,
|
||||
};
|
||||
|
||||
@ -16,7 +16,7 @@ pub struct TrieUpdates {
|
||||
#[cfg_attr(any(test, feature = "serde"), serde(with = "serde_nibbles_set"))]
|
||||
pub removed_nodes: HashSet<Nibbles>,
|
||||
/// Collection of updated storage tries indexed by the hashed address.
|
||||
pub storage_tries: B256HashMap<StorageTrieUpdates>,
|
||||
pub storage_tries: B256Map<StorageTrieUpdates>,
|
||||
}
|
||||
|
||||
impl TrieUpdates {
|
||||
@ -38,7 +38,7 @@ impl TrieUpdates {
|
||||
}
|
||||
|
||||
/// Returns a reference to updated storage tries.
|
||||
pub const fn storage_tries_ref(&self) -> &B256HashMap<StorageTrieUpdates> {
|
||||
pub const fn storage_tries_ref(&self) -> &B256Map<StorageTrieUpdates> {
|
||||
&self.storage_tries
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ impl TrieUpdates {
|
||||
&mut self,
|
||||
hash_builder: HashBuilder,
|
||||
removed_keys: HashSet<Nibbles>,
|
||||
destroyed_accounts: B256HashSet,
|
||||
destroyed_accounts: B256Set,
|
||||
) {
|
||||
// Retrieve updated nodes from hash builder.
|
||||
let (_, updated_nodes) = hash_builder.split();
|
||||
@ -359,7 +359,7 @@ pub struct TrieUpdatesSorted {
|
||||
pub removed_nodes: HashSet<Nibbles>,
|
||||
/// Storage tries storage stored by hashed address of the account
|
||||
/// the trie belongs to.
|
||||
pub storage_tries: B256HashMap<StorageTrieUpdatesSorted>,
|
||||
pub storage_tries: B256Map<StorageTrieUpdatesSorted>,
|
||||
}
|
||||
|
||||
impl TrieUpdatesSorted {
|
||||
@ -374,7 +374,7 @@ impl TrieUpdatesSorted {
|
||||
}
|
||||
|
||||
/// Returns reference to updated storage tries.
|
||||
pub const fn storage_tries_ref(&self) -> &B256HashMap<StorageTrieUpdatesSorted> {
|
||||
pub const fn storage_tries_ref(&self) -> &B256Map<StorageTrieUpdatesSorted> {
|
||||
&self.storage_tries
|
||||
}
|
||||
}
|
||||
@ -424,7 +424,7 @@ fn exclude_empty_from_pair<V>(
|
||||
pub mod serde_bincode_compat {
|
||||
use crate::{BranchNodeCompact, Nibbles};
|
||||
use alloc::borrow::Cow;
|
||||
use alloy_primitives::map::{B256HashMap, HashMap, HashSet};
|
||||
use alloy_primitives::map::{B256Map, HashMap, HashSet};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use serde_with::{DeserializeAs, SerializeAs};
|
||||
|
||||
@ -447,7 +447,7 @@ pub mod serde_bincode_compat {
|
||||
pub struct TrieUpdates<'a> {
|
||||
account_nodes: Cow<'a, HashMap<Nibbles, BranchNodeCompact>>,
|
||||
removed_nodes: Cow<'a, HashSet<Nibbles>>,
|
||||
storage_tries: B256HashMap<StorageTrieUpdates<'a>>,
|
||||
storage_tries: B256Map<StorageTrieUpdates<'a>>,
|
||||
}
|
||||
|
||||
impl<'a> From<&'a super::TrieUpdates> for TrieUpdates<'a> {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory, PrefixSetLoader};
|
||||
use alloy_primitives::{
|
||||
map::{AddressHashMap, B256HashMap},
|
||||
map::{AddressMap, B256Map},
|
||||
Address, BlockNumber, B256, U256,
|
||||
};
|
||||
use reth_db::tables;
|
||||
@ -230,7 +230,7 @@ impl<TX: DbTx> DatabaseHashedPostState<TX> for HashedPostState {
|
||||
}
|
||||
|
||||
// Iterate over storage changesets and record value before first occurring storage change.
|
||||
let mut storages = AddressHashMap::<B256HashMap<U256>>::default();
|
||||
let mut storages = AddressMap::<B256Map<U256>>::default();
|
||||
let mut storage_changesets_cursor = tx.cursor_read::<tables::StorageChangeSets>()?;
|
||||
for entry in
|
||||
storage_changesets_cursor.walk_range(BlockNumberAddress((from, Address::ZERO))..)?
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory};
|
||||
use alloy_primitives::{map::B256HashMap, Bytes};
|
||||
use alloy_primitives::{map::B256Map, Bytes};
|
||||
use reth_db_api::transaction::DbTx;
|
||||
use reth_execution_errors::TrieWitnessError;
|
||||
use reth_trie::{
|
||||
@ -17,7 +17,7 @@ pub trait DatabaseTrieWitness<'a, TX> {
|
||||
tx: &'a TX,
|
||||
input: TrieInput,
|
||||
target: HashedPostState,
|
||||
) -> Result<B256HashMap<Bytes>, TrieWitnessError>;
|
||||
) -> Result<B256Map<Bytes>, TrieWitnessError>;
|
||||
}
|
||||
|
||||
impl<'a, TX: DbTx> DatabaseTrieWitness<'a, TX>
|
||||
@ -31,7 +31,7 @@ impl<'a, TX: DbTx> DatabaseTrieWitness<'a, TX>
|
||||
tx: &'a TX,
|
||||
input: TrieInput,
|
||||
target: HashedPostState,
|
||||
) -> Result<B256HashMap<Bytes>, TrieWitnessError> {
|
||||
) -> Result<B256Map<Bytes>, TrieWitnessError> {
|
||||
let nodes_sorted = input.nodes.into_sorted();
|
||||
let state_sorted = input.state.into_sorted();
|
||||
Self::from_tx(tx)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::{root::ParallelStateRootError, stats::ParallelTrieTracker, StorageRootTargets};
|
||||
use alloy_primitives::{
|
||||
map::{B256HashMap, HashMap},
|
||||
map::{B256Map, HashMap},
|
||||
B256,
|
||||
};
|
||||
use alloy_rlp::{BufMut, Encodable};
|
||||
@ -119,7 +119,7 @@ where
|
||||
tracker.set_precomputed_storage_roots(storage_root_targets_len as u64);
|
||||
|
||||
let mut storage_proofs =
|
||||
B256HashMap::with_capacity_and_hasher(storage_root_targets.len(), Default::default());
|
||||
B256Map::with_capacity_and_hasher(storage_root_targets.len(), Default::default());
|
||||
|
||||
for (hashed_address, prefix_set) in
|
||||
storage_root_targets.into_iter().sorted_unstable_by_key(|(address, _)| *address)
|
||||
@ -231,7 +231,7 @@ where
|
||||
|
||||
// Initialize all storage multiproofs as empty.
|
||||
// Storage multiproofs for non empty tries will be overwritten if necessary.
|
||||
let mut storages: B256HashMap<_> =
|
||||
let mut storages: B256Map<_> =
|
||||
targets.keys().map(|key| (*key, StorageMultiProof::empty())).collect();
|
||||
let mut account_rlp = Vec::with_capacity(TRIE_ACCOUNT_RLP_MAX_SIZE);
|
||||
let mut account_node_iter = TrieNodeIter::new(
|
||||
@ -317,7 +317,7 @@ mod tests {
|
||||
use super::*;
|
||||
use alloy_primitives::{
|
||||
keccak256,
|
||||
map::{B256HashSet, DefaultHashBuilder},
|
||||
map::{B256Set, DefaultHashBuilder},
|
||||
Address, U256,
|
||||
};
|
||||
use rand::Rng;
|
||||
@ -373,7 +373,7 @@ mod tests {
|
||||
let mut targets = MultiProofTargets::default();
|
||||
for (address, (_, storage)) in state.iter().take(10) {
|
||||
let hashed_address = keccak256(*address);
|
||||
let mut target_slots = B256HashSet::default();
|
||||
let mut target_slots = B256Set::default();
|
||||
|
||||
for (slot, _) in storage.iter().take(5) {
|
||||
target_slots.insert(*slot);
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
use alloy_primitives::{map::B256HashMap, B256};
|
||||
use alloy_primitives::{map::B256Map, B256};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use reth_trie::prefix_set::PrefixSet;
|
||||
|
||||
/// Target accounts with corresponding prefix sets for storage root calculation.
|
||||
#[derive(Deref, DerefMut, Debug)]
|
||||
pub struct StorageRootTargets(B256HashMap<PrefixSet>);
|
||||
pub struct StorageRootTargets(B256Map<PrefixSet>);
|
||||
|
||||
impl StorageRootTargets {
|
||||
/// Create new storage root targets from updated post state accounts
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use alloy_primitives::{map::B256HashMap, B256, U256};
|
||||
use alloy_primitives::{map::B256Map, B256, U256};
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use itertools::Itertools;
|
||||
use proptest::{prelude::*, strategy::ValueTree, test_runner::TestRunner};
|
||||
@ -215,7 +215,7 @@ fn calculate_root_from_leaves_repeated(c: &mut Criterion) {
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_test_data(size: usize) -> B256HashMap<U256> {
|
||||
fn generate_test_data(size: usize) -> B256Map<U256> {
|
||||
let mut runner = TestRunner::deterministic();
|
||||
proptest::collection::hash_map(any::<B256>(), any::<U256>(), size)
|
||||
.new_tree(&mut runner)
|
||||
|
||||
@ -4,7 +4,7 @@ use crate::{
|
||||
};
|
||||
use alloy_primitives::{
|
||||
hex,
|
||||
map::{B256HashMap, HashSet},
|
||||
map::{B256Map, HashSet},
|
||||
Bytes, B256,
|
||||
};
|
||||
use alloy_rlp::{Decodable, Encodable};
|
||||
@ -25,11 +25,11 @@ pub struct SparseStateTrie<F: BlindedProviderFactory = DefaultBlindedProviderFac
|
||||
/// Sparse account trie.
|
||||
state: SparseTrie<F::AccountNodeProvider>,
|
||||
/// Sparse storage tries.
|
||||
storages: B256HashMap<SparseTrie<F::StorageNodeProvider>>,
|
||||
storages: B256Map<SparseTrie<F::StorageNodeProvider>>,
|
||||
/// Collection of revealed account trie paths.
|
||||
revealed_account_paths: HashSet<Nibbles>,
|
||||
/// Collection of revealed storage trie paths, per account.
|
||||
revealed_storage_paths: B256HashMap<HashSet<Nibbles>>,
|
||||
revealed_storage_paths: B256Map<HashSet<Nibbles>>,
|
||||
/// Flag indicating whether trie updates should be retained.
|
||||
retain_updates: bool,
|
||||
/// Reusable buffer for RLP encoding of trie accounts.
|
||||
@ -331,7 +331,7 @@ impl<F: BlindedProviderFactory> SparseStateTrie<F> {
|
||||
pub fn reveal_witness(
|
||||
&mut self,
|
||||
state_root: B256,
|
||||
witness: &B256HashMap<Bytes>,
|
||||
witness: &B256Map<Bytes>,
|
||||
) -> SparseStateTrieResult<()> {
|
||||
// Create a `(hash, path, maybe_account)` queue for traversing witness trie nodes
|
||||
// starting from the root node.
|
||||
@ -498,7 +498,7 @@ impl<F: BlindedProviderFactory> SparseStateTrie<F> {
|
||||
/// Returns storage trie updates for tries that have been revealed.
|
||||
///
|
||||
/// Panics if any of the storage tries are not revealed.
|
||||
pub fn storage_trie_updates(&mut self) -> B256HashMap<StorageTrieUpdates> {
|
||||
pub fn storage_trie_updates(&mut self) -> B256Map<StorageTrieUpdates> {
|
||||
self.storages
|
||||
.iter_mut()
|
||||
.map(|(address, trie)| {
|
||||
|
||||
@ -1507,7 +1507,7 @@ impl SparseTrieUpdates {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use alloy_primitives::{map::B256HashSet, U256};
|
||||
use alloy_primitives::{map::B256Set, U256};
|
||||
use alloy_rlp::Encodable;
|
||||
use assert_matches::assert_matches;
|
||||
use itertools::Itertools;
|
||||
@ -1553,7 +1553,7 @@ mod tests {
|
||||
fn run_hash_builder(
|
||||
state: impl IntoIterator<Item = (Nibbles, Account)> + Clone,
|
||||
trie_cursor: impl TrieCursor,
|
||||
destroyed_accounts: B256HashSet,
|
||||
destroyed_accounts: B256Set,
|
||||
proof_targets: impl IntoIterator<Item = Nibbles>,
|
||||
) -> (B256, TrieUpdates, ProofNodes, HashMap<Nibbles, TrieMask>, HashMap<Nibbles, TrieMask>)
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use super::{HashedCursor, HashedCursorFactory, HashedStorageCursor};
|
||||
use crate::forward_cursor::ForwardInMemoryCursor;
|
||||
use alloy_primitives::{map::B256HashSet, B256, U256};
|
||||
use alloy_primitives::{map::B256Set, B256, U256};
|
||||
use reth_primitives_traits::Account;
|
||||
use reth_storage_errors::db::DatabaseError;
|
||||
use reth_trie_common::{HashedAccountsSorted, HashedPostStateSorted, HashedStorageSorted};
|
||||
@ -46,7 +46,7 @@ pub struct HashedPostStateAccountCursor<'a, C> {
|
||||
/// Forward-only in-memory cursor over accounts.
|
||||
post_state_cursor: ForwardInMemoryCursor<'a, B256, Account>,
|
||||
/// Reference to the collection of account keys that were destroyed.
|
||||
destroyed_accounts: &'a B256HashSet,
|
||||
destroyed_accounts: &'a B256Set,
|
||||
/// The last hashed account that was returned by the cursor.
|
||||
/// De facto, this is a current cursor position.
|
||||
last_account: Option<B256>,
|
||||
@ -180,7 +180,7 @@ pub struct HashedPostStateStorageCursor<'a, C> {
|
||||
/// Forward-only in-memory cursor over non zero-valued account storage slots.
|
||||
post_state_cursor: Option<ForwardInMemoryCursor<'a, B256, U256>>,
|
||||
/// Reference to the collection of storage slot keys that were cleared.
|
||||
cleared_slots: Option<&'a B256HashSet>,
|
||||
cleared_slots: Option<&'a B256Set>,
|
||||
/// Flag indicating whether database storage was wiped.
|
||||
storage_wiped: bool,
|
||||
/// The last slot that has been returned by the cursor.
|
||||
|
||||
@ -8,7 +8,7 @@ use crate::{
|
||||
};
|
||||
use alloy_primitives::{
|
||||
keccak256,
|
||||
map::{B256HashMap, B256HashSet, HashMap, HashSet},
|
||||
map::{B256Map, B256Set, HashMap, HashSet},
|
||||
Address, B256,
|
||||
};
|
||||
use alloy_rlp::{BufMut, Encodable};
|
||||
@ -121,7 +121,7 @@ where
|
||||
|
||||
// Initialize all storage multiproofs as empty.
|
||||
// Storage multiproofs for non empty tries will be overwritten if necessary.
|
||||
let mut storages: B256HashMap<_> =
|
||||
let mut storages: B256Map<_> =
|
||||
targets.keys().map(|key| (*key, StorageMultiProof::empty())).collect();
|
||||
let mut account_rlp = Vec::with_capacity(TRIE_ACCOUNT_RLP_MAX_SIZE);
|
||||
let mut account_node_iter = TrieNodeIter::new(walker, hashed_account_cursor);
|
||||
@ -268,7 +268,7 @@ where
|
||||
/// Generate storage proof.
|
||||
pub fn storage_multiproof(
|
||||
mut self,
|
||||
targets: B256HashSet,
|
||||
targets: B256Set,
|
||||
) -> Result<StorageMultiProof, StateProofError> {
|
||||
let mut hashed_storage_cursor =
|
||||
self.hashed_cursor_factory.hashed_storage_cursor(self.hashed_address)?;
|
||||
|
||||
@ -8,7 +8,7 @@ use reth_trie_common::HashedPostState;
|
||||
|
||||
use alloy_primitives::{
|
||||
keccak256,
|
||||
map::{B256HashMap, B256HashSet, Entry, HashMap},
|
||||
map::{B256Map, B256Set, Entry, HashMap},
|
||||
Bytes, B256,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
@ -33,7 +33,7 @@ pub struct TrieWitness<T, H> {
|
||||
/// A set of prefix sets that have changes.
|
||||
prefix_sets: TriePrefixSetsMut,
|
||||
/// Recorded witness.
|
||||
witness: B256HashMap<Bytes>,
|
||||
witness: B256Map<Bytes>,
|
||||
}
|
||||
|
||||
impl<T, H> TrieWitness<T, H> {
|
||||
@ -85,10 +85,7 @@ where
|
||||
/// # Arguments
|
||||
///
|
||||
/// `state` - state transition containing both modified and touched accounts and storage slots.
|
||||
pub fn compute(
|
||||
mut self,
|
||||
state: HashedPostState,
|
||||
) -> Result<B256HashMap<Bytes>, TrieWitnessError> {
|
||||
pub fn compute(mut self, state: HashedPostState) -> Result<B256Map<Bytes>, TrieWitnessError> {
|
||||
if state.is_empty() {
|
||||
return Ok(self.witness)
|
||||
}
|
||||
@ -178,10 +175,10 @@ where
|
||||
) -> Result<MultiProofTargets, StateProofError> {
|
||||
let mut proof_targets = MultiProofTargets::default();
|
||||
for hashed_address in state.accounts.keys() {
|
||||
proof_targets.insert(*hashed_address, B256HashSet::default());
|
||||
proof_targets.insert(*hashed_address, B256Set::default());
|
||||
}
|
||||
for (hashed_address, storage) in &state.storages {
|
||||
let mut storage_keys = storage.storage.keys().copied().collect::<B256HashSet>();
|
||||
let mut storage_keys = storage.storage.keys().copied().collect::<B256Set>();
|
||||
if storage.wiped {
|
||||
// storage for this account was destroyed, gather all slots from the current state
|
||||
let mut storage_cursor =
|
||||
|
||||
Reference in New Issue
Block a user