perf(trie): use sequential hashing in BlockchainProvider::hashed_post_state (#22660)

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com>
This commit is contained in:
Derek Cofausper
2026-02-28 04:23:48 -08:00
committed by GitHub
parent a6d6a21524
commit c45ccc3e38

View File

@@ -46,33 +46,6 @@ impl HashedPostState {
/// Hashes all changed accounts and storage entries that are currently stored in the bundle
/// state.
#[inline]
#[cfg(feature = "rayon")]
pub fn from_bundle_state<'a, KH: KeyHasher>(
state: impl IntoParallelIterator<Item = (&'a Address, &'a BundleAccount)>,
) -> Self {
state
.into_par_iter()
.map(|(address, account)| {
let hashed_address = KH::hash_key(address);
let hashed_account = account.info.as_ref().map(Into::into);
let hashed_storage = HashedStorage::from_plain_storage(
account.status,
account.storage.iter().map(|(slot, value)| (slot, &value.present_value)),
);
(
hashed_address,
hashed_account,
(!hashed_storage.is_empty()).then_some(hashed_storage),
)
})
.collect()
}
/// Initialize [`HashedPostState`] from bundle state.
/// Hashes all changed accounts and storage entries that are currently stored in the bundle
/// state.
#[cfg(not(feature = "rayon"))]
pub fn from_bundle_state<'a, KH: KeyHasher>(
state: impl IntoIterator<Item = (&'a Address, &'a BundleAccount)>,
) -> Self {