1
1
//! Engine tree configuration.
2
2
3
- use crate :: tree:: payload_processor:: executor:: has_enough_parallelism;
4
- use alloy_eips:: merge:: EPOCH_SLOTS ;
5
-
6
- /// The largest gap for which the tree will be used for sync. See docs for `pipeline_run_threshold`
7
- /// for more information.
8
- ///
9
- /// This is the default threshold, the distance to the head that the tree will be used for sync.
10
- /// If the distance exceeds this threshold, the pipeline will be used for sync.
11
- pub ( crate ) const MIN_BLOCKS_FOR_PIPELINE_RUN : u64 = EPOCH_SLOTS ;
12
-
13
3
/// Triggers persistence when the number of canonical blocks in memory exceeds this threshold.
14
4
pub const DEFAULT_PERSISTENCE_THRESHOLD : u64 = 2 ;
15
5
@@ -18,11 +8,26 @@ pub const DEFAULT_MEMORY_BLOCK_BUFFER_TARGET: u64 = 2;
18
8
19
9
const DEFAULT_BLOCK_BUFFER_LIMIT : u32 = 256 ;
20
10
const DEFAULT_MAX_INVALID_HEADER_CACHE_LENGTH : u32 = 256 ;
21
-
22
11
const DEFAULT_MAX_EXECUTE_BLOCK_BATCH_SIZE : usize = 4 ;
23
-
24
12
const DEFAULT_CROSS_BLOCK_CACHE_SIZE : u64 = 4 * 1024 * 1024 * 1024 ;
25
13
14
+ /// Determines if the host has enough parallelism to run the payload processor.
15
+ ///
16
+ /// It requires at least 5 parallel threads:
17
+ /// - Engine in main thread that spawns the state root task.
18
+ /// - Multiproof task in payload processor
19
+ /// - Sparse Trie task in payload processor
20
+ /// - Multiproof computation spawned in payload processor
21
+ /// - Storage root computation spawned in trie parallel proof
22
+ pub fn has_enough_parallelism ( ) -> bool {
23
+ #[ cfg( feature = "std" ) ]
24
+ {
25
+ std:: thread:: available_parallelism ( ) . is_ok_and ( |num| num. get ( ) >= 5 )
26
+ }
27
+ #[ cfg( not( feature = "std" ) ) ]
28
+ false
29
+ }
30
+
26
31
/// The configuration of the engine tree.
27
32
#[ derive( Debug ) ]
28
33
pub struct TreeConfig {
@@ -77,7 +82,7 @@ impl Default for TreeConfig {
77
82
78
83
impl TreeConfig {
79
84
/// Create engine tree configuration.
80
- #[ allow ( clippy:: too_many_arguments) ]
85
+ #[ expect ( clippy:: too_many_arguments) ]
81
86
pub const fn new (
82
87
persistence_threshold : u64 ,
83
88
memory_block_buffer_target : u64 ,
@@ -225,7 +230,7 @@ impl TreeConfig {
225
230
}
226
231
227
232
/// Whether or not to use state root task
228
- pub ( crate ) fn use_state_root_task ( & self ) -> bool {
233
+ pub fn use_state_root_task ( & self ) -> bool {
229
234
self . has_enough_parallelism && !self . legacy_state_root
230
235
}
231
236
}
0 commit comments