reth_node_core/args/
engine.rs1use clap::Args;
4use reth_engine_primitives::TreeConfig;
5
6use crate::node_config::{
7 DEFAULT_CROSS_BLOCK_CACHE_SIZE_MB, DEFAULT_MAX_PROOF_TASK_CONCURRENCY,
8 DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, DEFAULT_PERSISTENCE_THRESHOLD, DEFAULT_RESERVED_CPU_CORES,
9};
10
11#[derive(Debug, Clone, Args, PartialEq, Eq)]
13#[command(next_help_heading = "Engine")]
14pub struct EngineArgs {
15 #[arg(long = "engine.persistence-threshold", default_value_t = DEFAULT_PERSISTENCE_THRESHOLD)]
17 pub persistence_threshold: u64,
18
19 #[arg(long = "engine.memory-block-buffer-target", default_value_t = DEFAULT_MEMORY_BLOCK_BUFFER_TARGET)]
21 pub memory_block_buffer_target: u64,
22
23 #[arg(long = "engine.legacy-state-root", default_value = "false")]
25 pub legacy_state_root_task_enabled: bool,
26
27 #[arg(long = "engine.caching-and-prewarming", default_value = "true", hide = true)]
30 #[deprecated]
31 pub caching_and_prewarming_enabled: bool,
32
33 #[arg(long = "engine.disable-caching-and-prewarming")]
35 pub caching_and_prewarming_disabled: bool,
36
37 #[deprecated]
40 #[arg(long = "engine.parallel-sparse-trie", default_value = "true", hide = true)]
41 pub parallel_sparse_trie_enabled: bool,
42
43 #[arg(long = "engine.disable-parallel-sparse-trie", default_value = "false")]
45 pub parallel_sparse_trie_disabled: bool,
46
47 #[arg(long = "engine.state-provider-metrics", default_value = "false")]
51 pub state_provider_metrics: bool,
52
53 #[arg(long = "engine.cross-block-cache-size", default_value_t = DEFAULT_CROSS_BLOCK_CACHE_SIZE_MB)]
55 pub cross_block_cache_size: u64,
56
57 #[arg(long = "engine.state-root-task-compare-updates")]
60 pub state_root_task_compare_updates: bool,
61
62 #[arg(long = "engine.accept-execution-requests-hash")]
64 pub accept_execution_requests_hash: bool,
65
66 #[arg(long = "engine.max-proof-task-concurrency", default_value_t = DEFAULT_MAX_PROOF_TASK_CONCURRENCY)]
68 pub max_proof_task_concurrency: u64,
69
70 #[arg(long = "engine.reserved-cpu-cores", default_value_t = DEFAULT_RESERVED_CPU_CORES)]
72 pub reserved_cpu_cores: usize,
73
74 #[arg(long = "engine.precompile-cache", default_value = "true", hide = true)]
77 #[deprecated]
78 pub precompile_cache_enabled: bool,
79
80 #[arg(long = "engine.disable-precompile-cache", default_value = "false")]
82 pub precompile_cache_disabled: bool,
83
84 #[arg(long = "engine.state-root-fallback", default_value = "false")]
86 pub state_root_fallback: bool,
87
88 #[arg(
94 long = "engine.always-process-payload-attributes-on-canonical-head",
95 default_value = "false"
96 )]
97 pub always_process_payload_attributes_on_canonical_head: bool,
98}
99
100#[allow(deprecated)]
101impl Default for EngineArgs {
102 fn default() -> Self {
103 Self {
104 persistence_threshold: DEFAULT_PERSISTENCE_THRESHOLD,
105 memory_block_buffer_target: DEFAULT_MEMORY_BLOCK_BUFFER_TARGET,
106 legacy_state_root_task_enabled: false,
107 state_root_task_compare_updates: false,
108 caching_and_prewarming_enabled: true,
109 caching_and_prewarming_disabled: false,
110 parallel_sparse_trie_enabled: true,
111 parallel_sparse_trie_disabled: false,
112 state_provider_metrics: false,
113 cross_block_cache_size: DEFAULT_CROSS_BLOCK_CACHE_SIZE_MB,
114 accept_execution_requests_hash: false,
115 max_proof_task_concurrency: DEFAULT_MAX_PROOF_TASK_CONCURRENCY,
116 reserved_cpu_cores: DEFAULT_RESERVED_CPU_CORES,
117 precompile_cache_enabled: true,
118 precompile_cache_disabled: false,
119 state_root_fallback: false,
120 always_process_payload_attributes_on_canonical_head: false,
121 }
122 }
123}
124
125impl EngineArgs {
126 pub fn tree_config(&self) -> TreeConfig {
128 TreeConfig::default()
129 .with_persistence_threshold(self.persistence_threshold)
130 .with_memory_block_buffer_target(self.memory_block_buffer_target)
131 .with_legacy_state_root(self.legacy_state_root_task_enabled)
132 .without_caching_and_prewarming(self.caching_and_prewarming_disabled)
133 .with_disable_parallel_sparse_trie(self.parallel_sparse_trie_disabled)
134 .with_state_provider_metrics(self.state_provider_metrics)
135 .with_always_compare_trie_updates(self.state_root_task_compare_updates)
136 .with_cross_block_cache_size(self.cross_block_cache_size * 1024 * 1024)
137 .with_max_proof_task_concurrency(self.max_proof_task_concurrency)
138 .with_reserved_cpu_cores(self.reserved_cpu_cores)
139 .without_precompile_cache(self.precompile_cache_disabled)
140 .with_state_root_fallback(self.state_root_fallback)
141 .with_always_process_payload_attributes_on_canonical_head(
142 self.always_process_payload_attributes_on_canonical_head,
143 )
144 }
145}
146
147#[cfg(test)]
148mod tests {
149 use super::*;
150 use clap::Parser;
151
152 #[derive(Parser)]
154 struct CommandParser<T: Args> {
155 #[command(flatten)]
156 args: T,
157 }
158
159 #[test]
160 fn test_parse_engine_args() {
161 let default_args = EngineArgs::default();
162 let args = CommandParser::<EngineArgs>::parse_from(["reth"]).args;
163 assert_eq!(args, default_args);
164 }
165}