From f2279a81c093d3d7b0337ccf6d06ab1415cda8da Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Mon, 22 Jul 2024 09:01:06 -0700 Subject: [PATCH] chore(trie): introduce wrapper struct for hashed cursor related impls (#9707) --- crates/blockchain-tree/src/blockchain_tree.rs | 7 ++- crates/trie/db/src/state.rs | 30 +++++++---- crates/trie/parallel/benches/root.rs | 12 +++-- crates/trie/parallel/src/async_root.rs | 15 ++++-- crates/trie/parallel/src/parallel_root.rs | 16 ++++-- crates/trie/trie/src/hashed_cursor/default.rs | 43 ++++++++++++--- crates/trie/trie/src/hashed_cursor/mod.rs | 2 +- .../trie/trie/src/hashed_cursor/post_state.rs | 52 ++++++++++++------- crates/trie/trie/src/proof.rs | 6 +-- crates/trie/trie/src/state.rs | 6 ++- crates/trie/trie/src/trie.rs | 8 +-- 11 files changed, 137 insertions(+), 60 deletions(-) diff --git a/crates/blockchain-tree/src/blockchain_tree.rs b/crates/blockchain-tree/src/blockchain_tree.rs index 2aa35d750..2fb567463 100644 --- a/crates/blockchain-tree/src/blockchain_tree.rs +++ b/crates/blockchain-tree/src/blockchain_tree.rs @@ -26,7 +26,10 @@ use reth_provider::{ use reth_prune_types::PruneModes; use reth_stages_api::{MetricEvent, MetricEventsSender}; use reth_storage_errors::provider::{ProviderResult, RootMismatch}; -use reth_trie::{hashed_cursor::HashedPostStateCursorFactory, StateRoot}; +use reth_trie::{ + hashed_cursor::{DatabaseHashedCursorFactory, HashedPostStateCursorFactory}, + StateRoot, +}; use reth_trie_db::DatabaseStateRoot; use std::{ collections::{btree_map::Entry, BTreeMap, HashSet}, @@ -1239,7 +1242,7 @@ where .disable_long_read_transaction_safety(); let (state_root, trie_updates) = StateRoot::from_tx(provider.tx_ref()) .with_hashed_cursor_factory(HashedPostStateCursorFactory::new( - provider.tx_ref(), + DatabaseHashedCursorFactory::new(provider.tx_ref()), &hashed_state_sorted, )) .with_prefix_sets(prefix_sets) diff --git a/crates/trie/db/src/state.rs b/crates/trie/db/src/state.rs index 46e60de7d..8c72825e1 100644 --- a/crates/trie/db/src/state.rs +++ b/crates/trie/db/src/state.rs @@ -2,7 +2,9 @@ use reth_db_api::transaction::DbTx; use reth_execution_errors::StateRootError; use reth_primitives::{BlockNumber, B256}; use reth_trie::{ - hashed_cursor::HashedPostStateCursorFactory, prefix_set::PrefixSetLoader, updates::TrieUpdates, + hashed_cursor::{DatabaseHashedCursorFactory, HashedPostStateCursorFactory}, + prefix_set::PrefixSetLoader, + updates::TrieUpdates, HashedPostState, StateRoot, StateRootProgress, }; use std::ops::RangeInclusive; @@ -100,9 +102,11 @@ pub trait DatabaseStateRoot<'a, TX>: Sized { ) -> Result<(B256, TrieUpdates), StateRootError>; } -impl<'a, TX: DbTx> DatabaseStateRoot<'a, TX> for StateRoot<&'a TX, &'a TX> { +impl<'a, TX: DbTx> DatabaseStateRoot<'a, TX> + for StateRoot<&'a TX, DatabaseHashedCursorFactory<'a, TX>> +{ fn from_tx(tx: &'a TX) -> Self { - Self::new(tx, tx) + Self::new(tx, DatabaseHashedCursorFactory::new(tx)) } fn incremental_root_calculator( @@ -140,10 +144,12 @@ impl<'a, TX: DbTx> DatabaseStateRoot<'a, TX> for StateRoot<&'a TX, &'a TX> { fn overlay_root(tx: &'a TX, post_state: HashedPostState) -> Result { let prefix_sets = post_state.construct_prefix_sets().freeze(); let sorted = post_state.into_sorted(); - Self::from_tx(tx) - .with_hashed_cursor_factory(HashedPostStateCursorFactory::new(tx, &sorted)) - .with_prefix_sets(prefix_sets) - .root() + StateRoot::new( + tx, + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(tx), &sorted), + ) + .with_prefix_sets(prefix_sets) + .root() } fn overlay_root_with_updates( @@ -152,10 +158,12 @@ impl<'a, TX: DbTx> DatabaseStateRoot<'a, TX> for StateRoot<&'a TX, &'a TX> { ) -> Result<(B256, TrieUpdates), StateRootError> { let prefix_sets = post_state.construct_prefix_sets().freeze(); let sorted = post_state.into_sorted(); - Self::from_tx(tx) - .with_hashed_cursor_factory(HashedPostStateCursorFactory::new(tx, &sorted)) - .with_prefix_sets(prefix_sets) - .root_with_updates() + StateRoot::new( + tx, + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(tx), &sorted), + ) + .with_prefix_sets(prefix_sets) + .root_with_updates() } } diff --git a/crates/trie/parallel/benches/root.rs b/crates/trie/parallel/benches/root.rs index 7251d230a..3a4632d3c 100644 --- a/crates/trie/parallel/benches/root.rs +++ b/crates/trie/parallel/benches/root.rs @@ -9,7 +9,8 @@ use reth_provider::{ }; use reth_tasks::pool::BlockingTaskPool; use reth_trie::{ - hashed_cursor::HashedPostStateCursorFactory, HashedPostState, HashedStorage, StateRoot, + hashed_cursor::{DatabaseHashedCursorFactory, HashedPostStateCursorFactory}, + HashedPostState, HashedStorage, StateRoot, }; use reth_trie_db::DatabaseStateRoot; use reth_trie_parallel::{async_root::AsyncStateRoot, parallel_root::ParallelStateRoot}; @@ -47,11 +48,12 @@ pub fn calculate_state_root(c: &mut Criterion) { (provider, sorted_state, prefix_sets) }, |(provider, sorted_state, prefix_sets)| async move { + let hashed_cursor_factory = HashedPostStateCursorFactory::new( + DatabaseHashedCursorFactory::new(provider.tx_ref()), + &sorted_state, + ); StateRoot::from_tx(provider.tx_ref()) - .with_hashed_cursor_factory(HashedPostStateCursorFactory::new( - provider.tx_ref(), - &sorted_state, - )) + .with_hashed_cursor_factory(hashed_cursor_factory) .with_prefix_sets(prefix_sets) .root() }, diff --git a/crates/trie/parallel/src/async_root.rs b/crates/trie/parallel/src/async_root.rs index db6152b6a..cf3eabcdc 100644 --- a/crates/trie/parallel/src/async_root.rs +++ b/crates/trie/parallel/src/async_root.rs @@ -7,7 +7,9 @@ use reth_primitives::B256; use reth_provider::{providers::ConsistentDbView, DatabaseProviderFactory, ProviderError}; use reth_tasks::pool::BlockingTaskPool; use reth_trie::{ - hashed_cursor::{HashedCursorFactory, HashedPostStateCursorFactory}, + hashed_cursor::{ + DatabaseHashedCursorFactory, HashedCursorFactory, HashedPostStateCursorFactory, + }, node_iter::{TrieElement, TrieNodeIter}, trie_cursor::TrieCursorFactory, updates::TrieUpdates, @@ -107,9 +109,13 @@ where let handle = self.blocking_pool.spawn_fifo(move || -> Result<_, AsyncStateRootError> { let provider = view.provider_ro()?; + let hashed_state = HashedPostStateCursorFactory::new( + DatabaseHashedCursorFactory::new(provider.tx_ref()), + &hashed_state_sorted, + ); Ok(StorageRoot::new_hashed( provider.tx_ref(), - HashedPostStateCursorFactory::new(provider.tx_ref(), &hashed_state_sorted), + hashed_state, hashed_address, #[cfg(feature = "metrics")] metrics, @@ -125,7 +131,10 @@ where let provider_ro = self.view.provider_ro()?; let tx = provider_ro.tx_ref(); - let hashed_cursor_factory = HashedPostStateCursorFactory::new(tx, &hashed_state_sorted); + let hashed_cursor_factory = HashedPostStateCursorFactory::new( + DatabaseHashedCursorFactory::new(tx), + &hashed_state_sorted, + ); let trie_cursor_factory = tx; let walker = TrieWalker::new( diff --git a/crates/trie/parallel/src/parallel_root.rs b/crates/trie/parallel/src/parallel_root.rs index 0983fd47e..87e6ee8a6 100644 --- a/crates/trie/parallel/src/parallel_root.rs +++ b/crates/trie/parallel/src/parallel_root.rs @@ -6,7 +6,9 @@ use reth_execution_errors::StorageRootError; use reth_primitives::B256; use reth_provider::{providers::ConsistentDbView, DatabaseProviderFactory, ProviderError}; use reth_trie::{ - hashed_cursor::{HashedCursorFactory, HashedPostStateCursorFactory}, + hashed_cursor::{ + DatabaseHashedCursorFactory, HashedCursorFactory, HashedPostStateCursorFactory, + }, node_iter::{TrieElement, TrieNodeIter}, trie_cursor::TrieCursorFactory, updates::TrieUpdates, @@ -91,9 +93,13 @@ where .into_par_iter() .map(|(hashed_address, prefix_set)| { let provider_ro = self.view.provider_ro()?; + let hashed_cursor_factory = HashedPostStateCursorFactory::new( + DatabaseHashedCursorFactory::new(provider_ro.tx_ref()), + &hashed_state_sorted, + ); let storage_root_result = StorageRoot::new_hashed( provider_ro.tx_ref(), - HashedPostStateCursorFactory::new(provider_ro.tx_ref(), &hashed_state_sorted), + hashed_cursor_factory, hashed_address, #[cfg(feature = "metrics")] self.metrics.storage_trie.clone(), @@ -108,8 +114,10 @@ where let mut trie_updates = TrieUpdates::default(); let provider_ro = self.view.provider_ro()?; - let hashed_cursor_factory = - HashedPostStateCursorFactory::new(provider_ro.tx_ref(), &hashed_state_sorted); + let hashed_cursor_factory = HashedPostStateCursorFactory::new( + DatabaseHashedCursorFactory::new(provider_ro.tx_ref()), + &hashed_state_sorted, + ); let trie_cursor_factory = provider_ro.tx_ref(); let walker = TrieWalker::new( diff --git a/crates/trie/trie/src/hashed_cursor/default.rs b/crates/trie/trie/src/hashed_cursor/default.rs index 197fd7ecd..e667f4723 100644 --- a/crates/trie/trie/src/hashed_cursor/default.rs +++ b/crates/trie/trie/src/hashed_cursor/default.rs @@ -6,13 +6,30 @@ use reth_db_api::{ }; use reth_primitives::{Account, B256, U256}; -impl<'a, TX: DbTx> HashedCursorFactory for &'a TX { - type AccountCursor = ::Cursor; +/// A struct wrapping database transaction that implements [`HashedCursorFactory`]. +#[derive(Debug)] +pub struct DatabaseHashedCursorFactory<'a, TX>(&'a TX); + +impl<'a, TX> Clone for DatabaseHashedCursorFactory<'a, TX> { + fn clone(&self) -> Self { + Self(self.0) + } +} + +impl<'a, TX> DatabaseHashedCursorFactory<'a, TX> { + /// Create new database hashed cursor factory. + pub const fn new(tx: &'a TX) -> Self { + Self(tx) + } +} + +impl<'a, TX: DbTx> HashedCursorFactory for DatabaseHashedCursorFactory<'a, TX> { + type AccountCursor = DatabaseHashedAccountCursor<::Cursor>; type StorageCursor = DatabaseHashedStorageCursor<::DupCursor>; fn hashed_account_cursor(&self) -> Result { - self.cursor_read::() + Ok(DatabaseHashedAccountCursor(self.0.cursor_read::()?)) } fn hashed_storage_cursor( @@ -20,24 +37,36 @@ impl<'a, TX: DbTx> HashedCursorFactory for &'a TX { hashed_address: B256, ) -> Result { Ok(DatabaseHashedStorageCursor::new( - self.cursor_dup_read::()?, + self.0.cursor_dup_read::()?, hashed_address, )) } } -impl HashedCursor for C +/// A struct wrapping database cursor over hashed accounts implementing [`HashedCursor`] for +/// iterating over accounts. +#[derive(Debug)] +pub struct DatabaseHashedAccountCursor(C); + +impl DatabaseHashedAccountCursor { + /// Create new database hashed account cursor. + pub const fn new(cursor: C) -> Self { + Self(cursor) + } +} + +impl HashedCursor for DatabaseHashedAccountCursor where C: DbCursorRO, { type Value = Account; fn seek(&mut self, key: B256) -> Result, reth_db::DatabaseError> { - self.seek(key) + self.0.seek(key) } fn next(&mut self) -> Result, reth_db::DatabaseError> { - self.next() + self.0.next() } } diff --git a/crates/trie/trie/src/hashed_cursor/mod.rs b/crates/trie/trie/src/hashed_cursor/mod.rs index 05de76721..053836e82 100644 --- a/crates/trie/trie/src/hashed_cursor/mod.rs +++ b/crates/trie/trie/src/hashed_cursor/mod.rs @@ -2,7 +2,7 @@ use reth_primitives::{Account, B256, U256}; /// Default implementation of the hashed state cursor traits. mod default; -pub use default::DatabaseHashedStorageCursor; +pub use default::*; /// Implementation of hashed state cursor traits for the post state. mod post_state; diff --git a/crates/trie/trie/src/hashed_cursor/post_state.rs b/crates/trie/trie/src/hashed_cursor/post_state.rs index ac262f3d4..fffd66a73 100644 --- a/crates/trie/trie/src/hashed_cursor/post_state.rs +++ b/crates/trie/trie/src/hashed_cursor/post_state.rs @@ -8,7 +8,7 @@ use reth_primitives::{Account, B256, U256}; use std::collections::HashSet; /// The hashed cursor factory for the post state. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct HashedPostStateCursorFactory<'a, CF> { cursor_factory: CF, post_state: &'a HashedPostStateSorted, @@ -328,7 +328,7 @@ where #[cfg(test)] mod tests { use super::*; - use crate::{HashedPostState, HashedStorage}; + use crate::{hashed_cursor::DatabaseHashedCursorFactory, HashedPostState, HashedStorage}; use proptest::prelude::*; use proptest_arbitrary_interop::arb; use reth_db::{tables, test_utils::create_test_rw_db}; @@ -387,7 +387,8 @@ mod tests { let sorted = hashed_post_state.into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); assert_account_cursor_order(&factory, accounts.into_iter()); } @@ -406,7 +407,10 @@ mod tests { let sorted_post_state = HashedPostState::default().into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted_post_state); + let factory = HashedPostStateCursorFactory::new( + DatabaseHashedCursorFactory::new(&tx), + &sorted_post_state, + ); assert_account_cursor_order(&factory, accounts.into_iter()); } @@ -431,7 +435,8 @@ mod tests { let sorted = hashed_post_state.into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); assert_account_cursor_order(&factory, accounts.into_iter()); } @@ -461,7 +466,8 @@ mod tests { let sorted = hashed_post_state.into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); let expected = accounts.into_iter().filter(|x| !removed_keys.contains(&x.0)); assert_account_cursor_order(&factory, expected); } @@ -488,7 +494,8 @@ mod tests { let sorted = hashed_post_state.into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); assert_account_cursor_order(&factory, accounts.into_iter()); } @@ -520,7 +527,7 @@ mod tests { let sorted = hashed_post_state.into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); assert_account_cursor_order(&factory, expected.into_iter()); } ); @@ -535,7 +542,8 @@ mod tests { { let sorted = HashedPostState::default().into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); let mut cursor = factory.hashed_storage_cursor(address).unwrap(); assert!(cursor.is_storage_empty().unwrap()); } @@ -558,7 +566,8 @@ mod tests { { let sorted = HashedPostState::default().into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); let mut cursor = factory.hashed_storage_cursor(address).unwrap(); assert!(!cursor.is_storage_empty().unwrap()); } @@ -573,7 +582,8 @@ mod tests { let sorted = hashed_post_state.into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); let mut cursor = factory.hashed_storage_cursor(address).unwrap(); assert!(cursor.is_storage_empty().unwrap()); } @@ -589,7 +599,8 @@ mod tests { let sorted = hashed_post_state.into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); let mut cursor = factory.hashed_storage_cursor(address).unwrap(); assert!(cursor.is_storage_empty().unwrap()); } @@ -605,7 +616,8 @@ mod tests { let sorted = hashed_post_state.into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); let mut cursor = factory.hashed_storage_cursor(address).unwrap(); assert!(!cursor.is_storage_empty().unwrap()); } @@ -643,7 +655,8 @@ mod tests { let sorted = hashed_post_state.into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); let expected = std::iter::once((address, db_storage.into_iter().chain(post_state_storage).collect())); assert_storage_cursor_order(&factory, expected); @@ -679,7 +692,8 @@ mod tests { let sorted = hashed_post_state.into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); let expected = std::iter::once(( address, post_state_storage.into_iter().filter(|(_, value)| *value > U256::ZERO).collect(), @@ -716,7 +730,8 @@ mod tests { let sorted = hashed_post_state.into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); let expected = std::iter::once((address, post_state_storage)); assert_storage_cursor_order(&factory, expected); } @@ -751,7 +766,8 @@ mod tests { let sorted = hashed_post_state.into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); let expected = std::iter::once((address, storage)); assert_storage_cursor_order(&factory, expected); } @@ -798,7 +814,7 @@ mod tests { let sorted = hashed_post_state.into_sorted(); let tx = db.tx().unwrap(); - let factory = HashedPostStateCursorFactory::new(&tx, &sorted); + let factory = HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(&tx), &sorted); assert_storage_cursor_order(&factory, expected.into_iter()); }); } diff --git a/crates/trie/trie/src/proof.rs b/crates/trie/trie/src/proof.rs index 55b86d355..ea42ff9be 100644 --- a/crates/trie/trie/src/proof.rs +++ b/crates/trie/trie/src/proof.rs @@ -1,5 +1,5 @@ use crate::{ - hashed_cursor::{HashedCursorFactory, HashedStorageCursor}, + hashed_cursor::{DatabaseHashedCursorFactory, HashedCursorFactory, HashedStorageCursor}, node_iter::{TrieElement, TrieNodeIter}, prefix_set::TriePrefixSetsMut, trie_cursor::{DatabaseAccountTrieCursor, DatabaseStorageTrieCursor}, @@ -46,10 +46,10 @@ impl<'a, TX, H> Proof<'a, TX, H> { } } -impl<'a, TX> Proof<'a, TX, &'a TX> { +impl<'a, TX> Proof<'a, TX, DatabaseHashedCursorFactory<'a, TX>> { /// Create a new [Proof] instance from database transaction. pub fn from_tx(tx: &'a TX) -> Self { - Self::new(tx, tx) + Self::new(tx, DatabaseHashedCursorFactory::new(tx)) } } diff --git a/crates/trie/trie/src/state.rs b/crates/trie/trie/src/state.rs index cf31247cc..99c4ddd3c 100644 --- a/crates/trie/trie/src/state.rs +++ b/crates/trie/trie/src/state.rs @@ -1,5 +1,5 @@ use crate::{ - hashed_cursor::HashedPostStateCursorFactory, + hashed_cursor::{DatabaseHashedCursorFactory, HashedPostStateCursorFactory}, prefix_set::{PrefixSetMut, TriePrefixSetsMut}, proof::Proof, Nibbles, @@ -203,8 +203,10 @@ impl HashedPostState { ) -> Result { let sorted = self.clone().into_sorted(); let prefix_sets = self.construct_prefix_sets(); + let hashed_cursor_factory = + HashedPostStateCursorFactory::new(DatabaseHashedCursorFactory::new(tx), &sorted); Proof::from_tx(tx) - .with_hashed_cursor_factory(HashedPostStateCursorFactory::new(tx, &sorted)) + .with_hashed_cursor_factory(hashed_cursor_factory) .with_prefix_sets_mut(prefix_sets) .account_proof(address, slots) } diff --git a/crates/trie/trie/src/trie.rs b/crates/trie/trie/src/trie.rs index ce1d9f7ac..b42bd4e3f 100644 --- a/crates/trie/trie/src/trie.rs +++ b/crates/trie/trie/src/trie.rs @@ -1,5 +1,5 @@ use crate::{ - hashed_cursor::{HashedCursorFactory, HashedStorageCursor}, + hashed_cursor::{DatabaseHashedCursorFactory, HashedCursorFactory, HashedStorageCursor}, node_iter::{TrieElement, TrieNodeIter}, prefix_set::{PrefixSet, TriePrefixSets}, progress::{IntermediateStateRootState, StateRootProgress}, @@ -363,12 +363,12 @@ impl StorageRoot { } } -impl<'a, TX: DbTx> StorageRoot<&'a TX, &'a TX> { +impl<'a, TX: DbTx> StorageRoot<&'a TX, DatabaseHashedCursorFactory<'a, TX>> { /// Create a new storage root calculator from database transaction and raw address. pub fn from_tx(tx: &'a TX, address: Address) -> Self { Self::new( tx, - tx, + DatabaseHashedCursorFactory::new(tx), address, #[cfg(feature = "metrics")] TrieRootMetrics::new(TrieType::Storage), @@ -379,7 +379,7 @@ impl<'a, TX: DbTx> StorageRoot<&'a TX, &'a TX> { pub fn from_tx_hashed(tx: &'a TX, hashed_address: B256) -> Self { Self::new_hashed( tx, - tx, + DatabaseHashedCursorFactory::new(tx), hashed_address, #[cfg(feature = "metrics")] TrieRootMetrics::new(TrieType::Storage),