@@ -13,8 +13,7 @@ use alloy_rlp::{BufMut, Encodable};
1313use itertools:: Itertools ;
1414use reth_execution_errors:: StorageRootError ;
1515use reth_provider:: {
16- providers:: ConsistentDbView , BlockReader , DBProvider , DatabaseProviderFactory , FactoryTx ,
17- ProviderError ,
16+ providers:: ConsistentDbView , BlockReader , DBProvider , DatabaseProviderFactory , ProviderError ,
1817} ;
1918use reth_storage_errors:: db:: DatabaseError ;
2019use reth_trie:: {
@@ -33,7 +32,7 @@ use reth_trie_common::{
3332 proof:: { DecodedProofNodes , ProofRetainer } ,
3433} ;
3534use reth_trie_db:: { DatabaseHashedCursorFactory , DatabaseTrieCursorFactory } ;
36- use std:: sync:: { mpsc :: Receiver , Arc } ;
35+ use std:: sync:: Arc ;
3736use tracing:: trace;
3837
3938/// Parallel proof calculator.
@@ -58,7 +57,7 @@ pub struct ParallelProof<Factory: DatabaseProviderFactory> {
5857 /// Provided by the user to give the necessary context to retain extra proofs.
5958 multi_added_removed_keys : Option < Arc < MultiAddedRemovedKeys > > ,
6059 /// Handle to the storage proof task.
61- storage_proof_task_handle : ProofTaskManagerHandle < FactoryTx < Factory > > ,
60+ storage_proof_task_handle : ProofTaskManagerHandle < <Factory :: Provider as DBProvider > :: Tx > ,
6261 #[ cfg( feature = "metrics" ) ]
6362 metrics : ParallelTrieMetrics ,
6463}
@@ -70,7 +69,7 @@ impl<Factory: DatabaseProviderFactory> ParallelProof<Factory> {
7069 nodes_sorted : Arc < TrieUpdatesSorted > ,
7170 state_sorted : Arc < HashedPostStateSorted > ,
7271 prefix_sets : Arc < TriePrefixSetsMut > ,
73- storage_proof_task_handle : ProofTaskManagerHandle < FactoryTx < Factory > > ,
72+ storage_proof_task_handle : ProofTaskManagerHandle < <Factory :: Provider as DBProvider > :: Tx > ,
7473 ) -> Self {
7574 Self {
7675 view,
@@ -112,18 +111,17 @@ where
112111 hashed_address : B256 ,
113112 prefix_set : PrefixSet ,
114113 target_slots : B256Set ,
115- ) -> Receiver < Result < DecodedStorageMultiProof , ParallelStateRootError > > {
114+ ) -> crossbeam_channel :: Receiver < Result < DecodedStorageMultiProof , ParallelStateRootError > > {
116115 let input = StorageProofInput :: new (
117116 hashed_address,
118117 prefix_set,
119- Arc :: new ( target_slots) ,
118+ target_slots,
120119 self . collect_branch_node_masks ,
121120 self . multi_added_removed_keys . clone ( ) ,
122121 ) ;
123122
124- let ( sender, receiver) = std:: sync:: mpsc:: channel ( ) ;
125- let _ =
126- self . storage_proof_task_handle . queue_task ( ProofTaskKind :: StorageProof ( input, sender) ) ;
123+ let ( sender, receiver) = crossbeam_channel:: unbounded ( ) ;
124+ self . storage_proof_task_handle . queue_task ( ProofTaskKind :: StorageProof ( input, sender) ) ;
127125 receiver
128126 }
129127
@@ -356,7 +354,7 @@ where
356354#[ cfg( test) ]
357355mod tests {
358356 use super :: * ;
359- use crate :: proof_task:: { ProofTaskCtx , ProofTaskManager } ;
357+ use crate :: proof_task:: { new_proof_task_handle , ProofTaskCtx } ;
360358 use alloy_primitives:: {
361359 keccak256,
362360 map:: { B256Set , DefaultHashBuilder } ,
@@ -435,19 +433,13 @@ mod tests {
435433
436434 let task_ctx =
437435 ProofTaskCtx :: new ( Default :: default ( ) , Default :: default ( ) , Default :: default ( ) ) ;
438- let proof_task = ProofTaskManager :: new (
436+ let proof_task_handle = new_proof_task_handle (
439437 rt. handle ( ) . clone ( ) ,
440438 consistent_view. clone ( ) ,
441439 task_ctx,
442- 1 ,
443- 1 , // storage_worker_count for test
440+ 1 , // max_concurrency for test
444441 )
445442 . expect ( "Failed to create proof task" ) ;
446- let proof_task_handle = proof_task. handle ( ) ;
447-
448- // keep the join handle around to make sure it does not return any errors
449- // after we compute the state root
450- let join_handle = rt. spawn_blocking ( move || proof_task. run ( ) ) ;
451443
452444 let parallel_result = ParallelProof :: new (
453445 consistent_view,
@@ -482,9 +474,8 @@ mod tests {
482474 // then compare the entire thing for any mask differences
483475 assert_eq ! ( parallel_result, sequential_result_decoded) ;
484476
485- // drop the handle to terminate the task and then block on the proof task handle to make
486- // sure it does not return any errors
477+ // Drop the handle to release transaction pool resources
478+ // Note: No manager loop to join in the new design - handle manages lifecycle via Drop
487479 drop ( proof_task_handle) ;
488- rt. block_on ( join_handle) . unwrap ( ) . expect ( "The proof task should not return an error" ) ;
489480 }
490481}
0 commit comments