reth_optimism_node/
args.rs1use op_alloy_consensus::interop::SafetyLevel;
6use reth_optimism_txpool::supervisor::DEFAULT_SUPERVISOR_URL;
7use url::Url;
8
9#[derive(Debug, Clone, PartialEq, Eq, clap::Args)]
11#[command(next_help_heading = "Rollup")]
12pub struct RollupArgs {
13 #[arg(long = "rollup.sequencer", visible_aliases = ["rollup.sequencer-http", "rollup.sequencer-ws"])]
15 pub sequencer: Option<String>,
16
17 #[arg(long = "rollup.disable-tx-pool-gossip")]
19 pub disable_txpool_gossip: bool,
20
21 #[arg(long = "rollup.compute-pending-block")]
30 pub compute_pending_block: bool,
31
32 #[arg(long = "rollup.discovery.v4", default_value = "false")]
34 pub discovery_v4: bool,
35
36 #[arg(long = "rollup.enable-tx-conditional", default_value = "false")]
38 pub enable_tx_conditional: bool,
39
40 #[arg(
42 long = "rollup.supervisor-http",
43 value_name = "SUPERVISOR_HTTP_URL",
44 default_value = DEFAULT_SUPERVISOR_URL
45 )]
46 pub supervisor_http: String,
47
48 #[arg(
50 long = "rollup.supervisor-safety-level",
51 default_value_t = SafetyLevel::CrossUnsafe,
52 )]
53 pub supervisor_safety_level: SafetyLevel,
54
55 #[arg(long = "rollup.sequencer-headers", requires = "sequencer")]
57 pub sequencer_headers: Vec<String>,
58
59 #[arg(
61 long = "rollup.historicalrpc",
62 alias = "rollup.historical-rpc",
63 value_name = "HISTORICAL_HTTP_URL"
64 )]
65 pub historical_rpc: Option<String>,
66
67 #[arg(long, default_value_t = 1_000_000)]
69 pub min_suggested_priority_fee: u64,
70
71 #[arg(long, alias = "websocket-url")]
76 pub flashblocks_url: Option<Url>,
77
78 #[arg(long, default_value_t = false, requires = "flashblocks_url")]
84 pub flashblock_consensus: bool,
85}
86
87impl Default for RollupArgs {
88 fn default() -> Self {
89 Self {
90 sequencer: None,
91 disable_txpool_gossip: false,
92 compute_pending_block: false,
93 discovery_v4: false,
94 enable_tx_conditional: false,
95 supervisor_http: DEFAULT_SUPERVISOR_URL.to_string(),
96 supervisor_safety_level: SafetyLevel::CrossUnsafe,
97 sequencer_headers: Vec::new(),
98 historical_rpc: None,
99 min_suggested_priority_fee: 1_000_000,
100 flashblocks_url: None,
101 flashblock_consensus: false,
102 }
103 }
104}
105
106#[cfg(test)]
107mod tests {
108 use super::*;
109 use clap::{Args, Parser};
110
111 #[derive(Parser)]
113 struct CommandParser<T: Args> {
114 #[command(flatten)]
115 args: T,
116 }
117
118 #[test]
119 fn test_parse_optimism_default_args() {
120 let default_args = RollupArgs::default();
121 let args = CommandParser::<RollupArgs>::parse_from(["reth"]).args;
122 assert_eq!(args, default_args);
123 }
124
125 #[test]
126 fn test_parse_optimism_compute_pending_block_args() {
127 let expected_args = RollupArgs { compute_pending_block: true, ..Default::default() };
128 let args =
129 CommandParser::<RollupArgs>::parse_from(["reth", "--rollup.compute-pending-block"])
130 .args;
131 assert_eq!(args, expected_args);
132 }
133
134 #[test]
135 fn test_parse_optimism_discovery_v4_args() {
136 let expected_args = RollupArgs { discovery_v4: true, ..Default::default() };
137 let args = CommandParser::<RollupArgs>::parse_from(["reth", "--rollup.discovery.v4"]).args;
138 assert_eq!(args, expected_args);
139 }
140
141 #[test]
142 fn test_parse_optimism_sequencer_http_args() {
143 let expected_args =
144 RollupArgs { sequencer: Some("http://host:port".into()), ..Default::default() };
145 let args = CommandParser::<RollupArgs>::parse_from([
146 "reth",
147 "--rollup.sequencer-http",
148 "http://host:port",
149 ])
150 .args;
151 assert_eq!(args, expected_args);
152 }
153
154 #[test]
155 fn test_parse_optimism_disable_txpool_args() {
156 let expected_args = RollupArgs { disable_txpool_gossip: true, ..Default::default() };
157 let args =
158 CommandParser::<RollupArgs>::parse_from(["reth", "--rollup.disable-tx-pool-gossip"])
159 .args;
160 assert_eq!(args, expected_args);
161 }
162
163 #[test]
164 fn test_parse_optimism_enable_tx_conditional() {
165 let expected_args = RollupArgs { enable_tx_conditional: true, ..Default::default() };
166 let args =
167 CommandParser::<RollupArgs>::parse_from(["reth", "--rollup.enable-tx-conditional"])
168 .args;
169 assert_eq!(args, expected_args);
170 }
171
172 #[test]
173 fn test_parse_optimism_many_args() {
174 let expected_args = RollupArgs {
175 disable_txpool_gossip: true,
176 compute_pending_block: true,
177 enable_tx_conditional: true,
178 sequencer: Some("http://host:port".into()),
179 ..Default::default()
180 };
181 let args = CommandParser::<RollupArgs>::parse_from([
182 "reth",
183 "--rollup.disable-tx-pool-gossip",
184 "--rollup.compute-pending-block",
185 "--rollup.enable-tx-conditional",
186 "--rollup.sequencer-http",
187 "http://host:port",
188 ])
189 .args;
190 assert_eq!(args, expected_args);
191 }
192}