@@ -25,12 +25,12 @@ use reth_evm::{
2525 ConfigureEvm , EvmEnvFor , OnStateHook , SpecFor , TxEnvFor ,
2626} ;
2727use reth_primitives_traits:: NodePrimitives ;
28- use reth_provider:: {
29- providers:: ConsistentDbView , BlockReader , DatabaseProviderFactory , StateProviderFactory ,
30- StateReader ,
31- } ;
28+ use reth_provider:: { BlockReader , DatabaseProviderROFactory , StateProviderFactory , StateReader } ;
3229use reth_revm:: { db:: BundleState , state:: EvmState } ;
33- use reth_trie:: TrieInput ;
30+ use reth_trie:: {
31+ hashed_cursor:: HashedCursorFactory , prefix_set:: TriePrefixSetsMut ,
32+ trie_cursor:: TrieCursorFactory ,
33+ } ;
3434use reth_trie_parallel:: {
3535 proof_task:: { ProofTaskCtx , ProofWorkerHandle } ,
3636 root:: ParallelStateRootError ,
9494 > ,
9595 /// Whether to disable the parallel sparse trie.
9696 disable_parallel_sparse_trie : bool ,
97- /// A cleared trie input, kept around to be reused so allocations can be minimized.
98- trie_input : Option < TrieInput > ,
9997 /// Maximum concurrency for prewarm task.
10098 prewarm_max_concurrency : usize ,
10199}
@@ -122,7 +120,6 @@ where
122120 precompile_cache_disabled : config. precompile_cache_disabled ( ) ,
123121 precompile_cache_map,
124122 sparse_state_trie : Arc :: default ( ) ,
125- trie_input : None ,
126123 disable_parallel_sparse_trie : config. disable_parallel_sparse_trie ( ) ,
127124 prewarm_max_concurrency : config. prewarm_max_concurrency ( ) ,
128125 }
@@ -167,43 +164,39 @@ where
167164 /// This returns a handle to await the final state root and to interact with the tasks (e.g.
168165 /// canceling)
169166 #[ allow( clippy:: type_complexity) ]
170- pub fn spawn < P , I : ExecutableTxIterator < Evm > > (
167+ pub fn spawn < P , F , I : ExecutableTxIterator < Evm > > (
171168 & mut self ,
172169 env : ExecutionEnv < Evm > ,
173170 transactions : I ,
174171 provider_builder : StateProviderBuilder < N , P > ,
175- consistent_view : ConsistentDbView < P > ,
176- trie_input : TrieInput ,
172+ multiproof_provider_factory : F ,
177173 config : & TreeConfig ,
178174 ) -> Result <
179175 PayloadHandle < WithTxEnv < TxEnvFor < Evm > , I :: Tx > , I :: Error > ,
180176 ( ParallelStateRootError , I , ExecutionEnv < Evm > , StateProviderBuilder < N , P > ) ,
181177 >
182178 where
183- P : DatabaseProviderFactory < Provider : BlockReader >
184- + BlockReader
185- + StateProviderFactory
186- + StateReader
179+ P : BlockReader + StateProviderFactory + StateReader + Clone + ' static ,
180+ F : DatabaseProviderROFactory < Provider : TrieCursorFactory + HashedCursorFactory >
187181 + Clone
182+ + Send
188183 + ' static ,
189184 {
190185 let ( to_sparse_trie, sparse_trie_rx) = channel ( ) ;
191- // spawn multiproof task, save the trie input
192- let ( trie_input, state_root_config) = MultiProofConfig :: from_input ( trie_input) ;
193- self . trie_input = Some ( trie_input) ;
186+
187+ // We rely on the cursor factory to provide whatever DB overlay is necessary to see a
188+ // consistent view of the database, including the trie tables. Because of this there is no
189+ // need for an overarching prefix set to invalidate any section of the trie tables, and so
190+ // we use an empty prefix set.
191+ let prefix_sets = Arc :: new ( TriePrefixSetsMut :: default ( ) ) ;
194192
195193 // Create and spawn the storage proof task
196- let task_ctx = ProofTaskCtx :: new (
197- state_root_config. nodes_sorted . clone ( ) ,
198- state_root_config. state_sorted . clone ( ) ,
199- state_root_config. prefix_sets . clone ( ) ,
200- ) ;
194+ let task_ctx = ProofTaskCtx :: new ( multiproof_provider_factory, prefix_sets) ;
201195 let storage_worker_count = config. storage_worker_count ( ) ;
202196 let account_worker_count = config. account_worker_count ( ) ;
203197 let max_proof_task_concurrency = config. max_proof_task_concurrency ( ) as usize ;
204198 let proof_handle = ProofWorkerHandle :: new (
205199 self . executor . handle ( ) . clone ( ) ,
206- consistent_view,
207200 task_ctx,
208201 storage_worker_count,
209202 account_worker_count,
@@ -213,7 +206,6 @@ where
213206 // spawn one Tokio task for the account proof, and one Tokio task for the storage proof.
214207 let max_multi_proof_task_concurrency = max_proof_task_concurrency / 2 ;
215208 let multi_proof_task = MultiProofTask :: new (
216- state_root_config,
217209 self . executor . clone ( ) ,
218210 proof_handle. clone ( ) ,
219211 to_sparse_trie,
@@ -361,11 +353,6 @@ where
361353 CacheTaskHandle { cache, to_prewarm_task : Some ( to_prewarm_task) , cache_metrics }
362354 }
363355
364- /// Takes the trie input from the inner payload processor, if it exists.
365- pub const fn take_trie_input ( & mut self ) -> Option < TrieInput > {
366- self . trie_input . take ( )
367- }
368-
369356 /// Returns the cache for the given parent hash.
370357 ///
371358 /// If the given hash is different then what is recently cached, then this will create a new
@@ -663,12 +650,12 @@ mod tests {
663650 use reth_evm_ethereum:: EthEvmConfig ;
664651 use reth_primitives_traits:: { Account , Recovered , StorageEntry } ;
665652 use reth_provider:: {
666- providers:: { BlockchainProvider , ConsistentDbView } ,
653+ providers:: { BlockchainProvider , OverlayStateProviderFactory } ,
667654 test_utils:: create_test_provider_factory_with_chain_spec,
668655 ChainSpecProvider , HashingWriter ,
669656 } ;
670657 use reth_testing_utils:: generators;
671- use reth_trie:: { test_utils:: state_root, HashedPostState , TrieInput } ;
658+ use reth_trie:: { test_utils:: state_root, HashedPostState } ;
672659 use revm_primitives:: { Address , HashMap , B256 , KECCAK_EMPTY , U256 } ;
673660 use revm_state:: { AccountInfo , AccountStatus , EvmState , EvmStorageSlot } ;
674661 use std:: sync:: Arc ;
@@ -850,17 +837,18 @@ mod tests {
850837 & TreeConfig :: default ( ) ,
851838 PrecompileCacheMap :: default ( ) ,
852839 ) ;
853- let provider = BlockchainProvider :: new ( factory) . unwrap ( ) ;
840+
841+ let provider_factory = BlockchainProvider :: new ( factory) . unwrap ( ) ;
842+
854843 let mut handle =
855844 payload_processor
856845 . spawn (
857846 Default :: default ( ) ,
858847 core:: iter:: empty :: <
859848 Result < Recovered < TransactionSigned > , core:: convert:: Infallible > ,
860849 > ( ) ,
861- StateProviderBuilder :: new ( provider. clone ( ) , genesis_hash, None ) ,
862- ConsistentDbView :: new_with_latest_tip ( provider) . unwrap ( ) ,
863- TrieInput :: from_state ( hashed_state) ,
850+ StateProviderBuilder :: new ( provider_factory. clone ( ) , genesis_hash, None ) ,
851+ OverlayStateProviderFactory :: new ( provider_factory) ,
864852 & TreeConfig :: default ( ) ,
865853 )
866854 . map_err ( |( err, ..) | err)
0 commit comments