From 146e86d136d4e576f888a5989cc2cac3387e839a Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin Date: Wed, 11 Dec 2024 12:00:13 +0000 Subject: [PATCH] fix test --- crates/engine/tree/src/tree/root.rs | 33 +++++++++++++++++++++++------ crates/trie/sparse/src/blinded.rs | 4 ++-- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/crates/engine/tree/src/tree/root.rs b/crates/engine/tree/src/tree/root.rs index 2995434cfd066..318edccea2305 100644 --- a/crates/engine/tree/src/tree/root.rs +++ b/crates/engine/tree/src/tree/root.rs @@ -62,7 +62,7 @@ impl StateRootHandle { pub struct StateRootConfig { /// View over the state in the database. pub consistent_view: ConsistentDbView, - /// Latest trie input + /// Latest trie input. pub input: Arc, } @@ -250,9 +250,12 @@ where + Send + Sync + 'static, - ABP: BlindedProvider, - SBP: BlindedProvider, - BPF: BlindedProviderFactory, + ABP: BlindedProvider + Send + Sync + 'static, + SBP: BlindedProvider + Send + Sync + 'static, + BPF: BlindedProviderFactory + + Send + + Sync + + 'static, { /// Creates a new state root task with the unified message channel pub fn new(config: StateRootConfig, blinded_provider: BPF) -> Self { @@ -635,7 +638,11 @@ mod tests { providers::ConsistentDbView, test_utils::create_test_provider_factory, HashingWriter, }; use reth_testing_utils::generators::{self, Rng}; - use reth_trie::{test_utils::state_root, TrieInput}; + use reth_trie::{ + hashed_cursor::HashedPostStateCursorFactory, proof::ProofBlindedProviderFactory, + test_utils::state_root, trie_cursor::InMemoryTrieCursorFactory, TrieInput, + }; + use reth_trie_db::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory}; use revm_primitives::{ Account as RevmAccount, AccountInfo, AccountStatus, Address, EvmState, EvmStorageSlot, HashMap, B256, KECCAK_EMPTY, U256, @@ -752,7 +759,21 @@ mod tests { consistent_view: ConsistentDbView::new(factory, None), input: Arc::new(TrieInput::from_state(hashed_state)), }; - let task = StateRootTask::new(config); + let provider = config.consistent_view.provider_ro().unwrap(); + let nodes_sorted = config.input.nodes.clone().into_sorted(); + let state_sorted = config.input.state.clone().into_sorted(); + let blinded_provider_factory = ProofBlindedProviderFactory::new( + InMemoryTrieCursorFactory::new( + DatabaseTrieCursorFactory::new(provider.tx_ref()), + &nodes_sorted, + ), + HashedPostStateCursorFactory::new( + DatabaseHashedCursorFactory::new(provider.tx_ref()), + &state_sorted, + ), + Arc::new(config.input.prefix_sets.clone()), + ); + let task = StateRootTask::new(config, blinded_provider_factory); let mut state_hook = task.state_hook(); let handle = task.spawn(); diff --git a/crates/trie/sparse/src/blinded.rs b/crates/trie/sparse/src/blinded.rs index 54f93b35be8fc..22471cf99ffd0 100644 --- a/crates/trie/sparse/src/blinded.rs +++ b/crates/trie/sparse/src/blinded.rs @@ -5,7 +5,7 @@ use reth_execution_errors::SparseTrieError; use reth_trie_common::Nibbles; /// Factory for instantiating blinded node providers. -pub trait BlindedProviderFactory: Send + Sync { +pub trait BlindedProviderFactory { /// Type capable of fetching blinded account nodes. type AccountNodeProvider: BlindedProvider; /// Type capable of fetching blinded storage nodes. @@ -19,7 +19,7 @@ pub trait BlindedProviderFactory: Send + Sync { } /// Trie node provider for retrieving blinded nodes. -pub trait BlindedProvider: Send + Sync { +pub trait BlindedProvider { /// The error type for the provider. type Error: Into;