initial types

This commit is contained in:
Yong Kang
2025-10-22 02:57:23 +00:00
parent 4548209e7b
commit a9e308c002
4 changed files with 34 additions and 14 deletions

View File

@@ -65,6 +65,7 @@ rayon.workspace = true
tracing.workspace = true
derive_more.workspace = true
parking_lot.workspace = true
crossbeam-channel.workspace = true
# optional deps for test-utils
reth-prune-types = { workspace = true, optional = true }

View File

@@ -40,15 +40,13 @@ use reth_trie_sparse::{
ClearedSparseStateTrie, SparseStateTrie, SparseTrie,
};
use reth_trie_sparse_parallel::{ParallelSparseTrie, ParallelismThresholds};
use std::{
sync::{
atomic::AtomicBool,
mpsc::{self, channel, Sender},
Arc,
},
time::Instant,
use std::sync::{
atomic::AtomicBool,
mpsc::{self, channel},
Arc,
};
use tracing::{debug, debug_span, instrument, warn};
use crossbeam_channel::Sender as CrossbeamSender;
use tracing::{debug, instrument, warn};
mod configured_sparse_trie;
pub mod executor;
@@ -322,7 +320,7 @@ where
mut transactions: mpsc::Receiver<impl ExecutableTxFor<Evm> + Clone + Send + 'static>,
transaction_count_hint: usize,
provider_builder: StateProviderBuilder<N, P>,
to_multi_proof: Option<Sender<MultiProofMessage>>,
to_multi_proof: Option<CrossbeamSender<MultiProofMessage>>,
) -> CacheTaskHandle
where
P: BlockReader + StateProviderFactory + StateReader + Clone + 'static,
@@ -452,7 +450,7 @@ where
#[derive(Debug)]
pub struct PayloadHandle<Tx, Err> {
/// Channel for evm state updates
to_multi_proof: Option<Sender<MultiProofMessage>>,
to_multi_proof: Option<CrossbeamSender<MultiProofMessage>>,
// must include the receiver of the state root wired to the sparse trie
prewarm_handle: CacheTaskHandle,
/// Receiver for the state root
@@ -530,7 +528,7 @@ pub(crate) struct CacheTaskHandle {
/// Metrics for the caches
cache_metrics: CachedStateMetrics,
/// Channel to the spawned prewarm task if any
to_prewarm_task: Option<Sender<PrewarmTaskEvent>>,
to_prewarm_task: Option<std::sync::mpsc::Sender<PrewarmTaskEvent>>,
}
impl CacheTaskHandle {

View File

@@ -39,7 +39,8 @@ use std::{
},
time::Instant,
};
use tracing::{debug, debug_span, instrument, trace, warn};
use crossbeam_channel::Sender as CrossbeamSender;
use tracing::{debug, trace, warn};
/// A wrapper for transactions that includes their index in the block.
#[derive(Clone)]
@@ -83,7 +84,7 @@ where
/// The number of transactions to be processed
transaction_count_hint: usize,
/// Sender to emit evm state outcome messages, if any.
to_multi_proof: Option<Sender<MultiProofMessage>>,
to_multi_proof: Option<CrossbeamSender<MultiProofMessage>>,
/// Receiver for events produced by tx execution
actions_rx: Receiver<PrewarmTaskEvent>,
}
@@ -99,7 +100,7 @@ where
executor: WorkloadExecutor,
execution_cache: PayloadExecutionCache,
ctx: PrewarmContext<N, P, Evm>,
to_multi_proof: Option<Sender<MultiProofMessage>>,
to_multi_proof: Option<CrossbeamSender<MultiProofMessage>>,
transaction_count_hint: usize,
max_concurrency: usize,
) -> (Self, Sender<PrewarmTaskEvent>) {

View File

@@ -68,6 +68,26 @@ type TrieNodeProviderResult = Result<Option<RevealedNode>, SparseTrieError>;
type AccountMultiproofResult =
Result<(DecodedMultiProof, ParallelTrieStats), ParallelStateRootError>;
/// Message containing a completed proof result with metadata for direct delivery to `MultiProofTask`.
///
/// This type enables workers to send proof results directly to the `MultiProofTask` event loop.
#[derive(Debug)]
pub struct ProofResultMessage {
/// Sequence number for ordering proofs
pub sequence_number: u64,
/// The proof calculation result
pub result: AccountMultiproofResult,
/// Time taken for the entire proof calculation (from dispatch to completion)
pub elapsed: Duration,
/// Original state update that triggered this proof
pub state: HashedPostState,
}
/// Type alias for the proof result sender channel.
///
/// Workers use this sender to deliver proof results directly to `MultiProofTask`.
pub type ProofResultSender = CrossbeamSender<ProofResultMessage>;
/// Internal message for storage workers.
#[derive(Debug)]
enum StorageWorkerJob {