@@ -14,8 +14,7 @@ use dashmap::DashMap;
1414use  itertools:: Itertools ; 
1515use  reth_execution_errors:: StorageRootError ; 
1616use  reth_provider:: { 
17-     providers:: ConsistentDbView ,  BlockReader ,  DBProvider ,  DatabaseProviderFactory ,  FactoryTx , 
18-     ProviderError , 
17+     providers:: ConsistentDbView ,  BlockReader ,  DBProvider ,  DatabaseProviderFactory ,  ProviderError , 
1918} ; 
2019use  reth_storage_errors:: db:: DatabaseError ; 
2120use  reth_trie:: { 
@@ -34,7 +33,7 @@ use reth_trie_common::{
3433    proof:: { DecodedProofNodes ,  ProofRetainer } , 
3534} ; 
3635use  reth_trie_db:: { DatabaseHashedCursorFactory ,  DatabaseTrieCursorFactory } ; 
37- use  std:: sync:: { mpsc :: Receiver ,   Arc } ; 
36+ use  std:: sync:: Arc ; 
3837use  tracing:: trace; 
3938
4039/// Parallel proof calculator. 
@@ -59,7 +58,7 @@ pub struct ParallelProof<Factory: DatabaseProviderFactory> {
5958    /// Provided by the user to give the necessary context to retain extra proofs. 
6059multi_added_removed_keys :  Option < Arc < MultiAddedRemovedKeys > > , 
6160    /// Handle to the storage proof task. 
62- storage_proof_task_handle :  ProofTaskManagerHandle < FactoryTx < Factory > > , 
61+ storage_proof_task_handle :  ProofTaskManagerHandle < <Factory :: Provider   as   DBProvider > :: Tx > , 
6362    /// Cached storage proof roots for missed leaves; this maps 
6463/// hashed (missed) addresses to their storage proof roots. 
6564missed_leaves_storage_roots :  Arc < DashMap < B256 ,  B256 > > , 
@@ -75,7 +74,7 @@ impl<Factory: DatabaseProviderFactory> ParallelProof<Factory> {
7574        state_sorted :  Arc < HashedPostStateSorted > , 
7675        prefix_sets :  Arc < TriePrefixSetsMut > , 
7776        missed_leaves_storage_roots :  Arc < DashMap < B256 ,  B256 > > , 
78-         storage_proof_task_handle :  ProofTaskManagerHandle < FactoryTx < Factory > > , 
77+         storage_proof_task_handle :  ProofTaskManagerHandle < <Factory :: Provider   as   DBProvider > :: Tx > , 
7978    )  -> Self  { 
8079        Self  { 
8180            view, 
@@ -118,18 +117,17 @@ where
118117        hashed_address :  B256 , 
119118        prefix_set :  PrefixSet , 
120119        target_slots :  B256Set , 
121-     )  -> Receiver < Result < DecodedStorageMultiProof ,  ParallelStateRootError > >  { 
120+     )  -> crossbeam_channel :: Receiver < Result < DecodedStorageMultiProof ,  ParallelStateRootError > >  { 
122121        let  input = StorageProofInput :: new ( 
123122            hashed_address, 
124123            prefix_set, 
125-             Arc :: new ( target_slots) , 
124+             target_slots, 
126125            self . collect_branch_node_masks , 
127126            self . multi_added_removed_keys . clone ( ) , 
128127        ) ; 
129128
130-         let  ( sender,  receiver)  = std:: sync:: mpsc:: channel ( ) ; 
131-         let  _ =
132-             self . storage_proof_task_handle . queue_task ( ProofTaskKind :: StorageProof ( input,  sender) ) ; 
129+         let  ( sender,  receiver)  = crossbeam_channel:: unbounded ( ) ; 
130+         self . storage_proof_task_handle . queue_task ( ProofTaskKind :: StorageProof ( input,  sender) ) ; 
133131        receiver
134132    } 
135133
@@ -368,7 +366,7 @@ where
368366#[ cfg( test) ]  
369367mod  tests { 
370368    use  super :: * ; 
371-     use  crate :: proof_task:: { ProofTaskCtx ,   ProofTaskManager } ; 
369+     use  crate :: proof_task:: { new_proof_task_handle ,   ProofTaskCtx } ; 
372370    use  alloy_primitives:: { 
373371        keccak256, 
374372        map:: { B256Set ,  DefaultHashBuilder } , 
@@ -447,19 +445,13 @@ mod tests {
447445
448446        let  task_ctx =
449447            ProofTaskCtx :: new ( Default :: default ( ) ,  Default :: default ( ) ,  Default :: default ( ) ) ; 
450-         let  proof_task  = ProofTaskManager :: new ( 
448+         let  proof_task_handle  = new_proof_task_handle ( 
451449            rt. handle ( ) . clone ( ) , 
452450            consistent_view. clone ( ) , 
453451            task_ctx, 
454-             1 , 
455-             1 ,  // storage_worker_count for test 
452+             1 ,  // max_concurrency for test 
456453        ) 
457454        . expect ( "Failed to create proof task" ) ; 
458-         let  proof_task_handle = proof_task. handle ( ) ; 
459- 
460-         // keep the join handle around to make sure it does not return any errors 
461-         // after we compute the state root 
462-         let  join_handle = rt. spawn_blocking ( move  || proof_task. run ( ) ) ; 
463455
464456        let  parallel_result = ParallelProof :: new ( 
465457            consistent_view, 
@@ -495,9 +487,8 @@ mod tests {
495487        // then compare the entire thing for any mask differences 
496488        assert_eq ! ( parallel_result,  sequential_result_decoded) ; 
497489
498-         // drop  the handle to terminate the task and then block on the proof task handle to make  
499-         // sure it does not return any errors  
490+         // Drop  the handle to release transaction pool resources  
491+         // Note: No manager loop to join in the new design - handle manages lifecycle via Drop  
500492        drop ( proof_task_handle) ; 
501-         rt. block_on ( join_handle) . unwrap ( ) . expect ( "The proof task should not return an error" ) ; 
502493    } 
503494} 
0 commit comments