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)]
76 pub flashblocks_url: Option<Url>,
77}
78
79impl Default for RollupArgs {
80 fn default() -> Self {
81 Self {
82 sequencer: None,
83 disable_txpool_gossip: false,
84 compute_pending_block: false,
85 discovery_v4: false,
86 enable_tx_conditional: false,
87 supervisor_http: DEFAULT_SUPERVISOR_URL.to_string(),
88 supervisor_safety_level: SafetyLevel::CrossUnsafe,
89 sequencer_headers: Vec::new(),
90 historical_rpc: None,
91 min_suggested_priority_fee: 1_000_000,
92 flashblocks_url: None,
93 }
94 }
95}
96
97#[cfg(test)]
98mod tests {
99 use super::*;
100 use clap::{Args, Parser};
101
102 #[derive(Parser)]
104 struct CommandParser<T: Args> {
105 #[command(flatten)]
106 args: T,
107 }
108
109 #[test]
110 fn test_parse_optimism_default_args() {
111 let default_args = RollupArgs::default();
112 let args = CommandParser::<RollupArgs>::parse_from(["reth"]).args;
113 assert_eq!(args, default_args);
114 }
115
116 #[test]
117 fn test_parse_optimism_compute_pending_block_args() {
118 let expected_args = RollupArgs { compute_pending_block: true, ..Default::default() };
119 let args =
120 CommandParser::<RollupArgs>::parse_from(["reth", "--rollup.compute-pending-block"])
121 .args;
122 assert_eq!(args, expected_args);
123 }
124
125 #[test]
126 fn test_parse_optimism_discovery_v4_args() {
127 let expected_args = RollupArgs { discovery_v4: true, ..Default::default() };
128 let args = CommandParser::<RollupArgs>::parse_from(["reth", "--rollup.discovery.v4"]).args;
129 assert_eq!(args, expected_args);
130 }
131
132 #[test]
133 fn test_parse_optimism_sequencer_http_args() {
134 let expected_args =
135 RollupArgs { sequencer: Some("http://host:port".into()), ..Default::default() };
136 let args = CommandParser::<RollupArgs>::parse_from([
137 "reth",
138 "--rollup.sequencer-http",
139 "http://host:port",
140 ])
141 .args;
142 assert_eq!(args, expected_args);
143 }
144
145 #[test]
146 fn test_parse_optimism_disable_txpool_args() {
147 let expected_args = RollupArgs { disable_txpool_gossip: true, ..Default::default() };
148 let args =
149 CommandParser::<RollupArgs>::parse_from(["reth", "--rollup.disable-tx-pool-gossip"])
150 .args;
151 assert_eq!(args, expected_args);
152 }
153
154 #[test]
155 fn test_parse_optimism_enable_tx_conditional() {
156 let expected_args = RollupArgs { enable_tx_conditional: true, ..Default::default() };
157 let args =
158 CommandParser::<RollupArgs>::parse_from(["reth", "--rollup.enable-tx-conditional"])
159 .args;
160 assert_eq!(args, expected_args);
161 }
162
163 #[test]
164 fn test_parse_optimism_many_args() {
165 let expected_args = RollupArgs {
166 disable_txpool_gossip: true,
167 compute_pending_block: true,
168 enable_tx_conditional: true,
169 sequencer: Some("http://host:port".into()),
170 ..Default::default()
171 };
172 let args = CommandParser::<RollupArgs>::parse_from([
173 "reth",
174 "--rollup.disable-tx-pool-gossip",
175 "--rollup.compute-pending-block",
176 "--rollup.enable-tx-conditional",
177 "--rollup.sequencer-http",
178 "http://host:port",
179 ])
180 .args;
181 assert_eq!(args, expected_args);
182 }
183}