Skip to content

Commit a21636c

Browse files
committed
chore: use --flashblocks.addr for listening socket
1 parent 0d5fae5 commit a21636c

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

src/args.rs

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ pub struct BuilderArgs {
5858
#[derive(Debug, Clone, PartialEq, Eq, clap::Args)]
5959
#[command(next_help_heading = "Flashblocks")]
6060
pub struct FlashblocksArgs {
61+
/// Whether to enable Flashblocks
62+
#[arg(
63+
long = "flashblocks.enabled",
64+
default_value = "false",
65+
env = "ENABLE_FLASHBLOCKS"
66+
)]
67+
pub flashblocks_enabled: bool,
68+
6169
/// Flashblocks block-time target
6270
#[arg(
6371
long = "flashblocks.interval",
@@ -82,7 +90,7 @@ pub struct FlashblocksArgs {
8290
/// Enables flashblocks publishing on the specified WebSocket address.
8391
/// If no address is specified defaults to 0.0.0.0:10111.
8492
#[arg(
85-
long = "flashblocks",
93+
long = "flashblocks.addr",
8694
name = "WS_ADDRESS",
8795
env = "FLASHBLOCKS_WS_ADDRESS",
8896
num_args = 0..=1,
@@ -197,6 +205,7 @@ impl FlashblocksArgs {
197205
Self {
198206
interval: Duration::from_millis(250),
199207
leeway_time: Duration::from_millis(75),
208+
flashblocks_enabled: true,
200209
ws_address: SocketAddrV4::new(
201210
Ipv4Addr::UNSPECIFIED,
202211
Self::get_available_port(),
@@ -216,6 +225,7 @@ impl FlashblocksArgs {
216225
Self {
217226
interval,
218227
leeway_time,
228+
flashblocks_enabled: true,
219229
ws_address: SocketAddrV4::new(
220230
Ipv4Addr::UNSPECIFIED,
221231
Self::get_available_port(),
@@ -239,3 +249,43 @@ impl FlashblocksArgs {
239249
.port()
240250
}
241251
}
252+
#[cfg(test)]
253+
mod tests {
254+
use {super::*, clap::Parser};
255+
256+
#[test]
257+
fn test_args_cli_parsing() {
258+
let cli = Cli::parse_from([
259+
"flashblocks",
260+
"node",
261+
"--builder.playground=/tmp/playground",
262+
"--flashblocks.enabled",
263+
"--flashblocks.interval=500ms",
264+
"--flashblocks.leeway-time=100ms",
265+
"--flashblocks.addr=127.0.0.1:9999",
266+
"--flashblocks.calculate-state-root",
267+
]);
268+
269+
let Commands::Node(node) = cli.command else {
270+
panic!("Expected node command");
271+
};
272+
273+
let args = node.ext;
274+
275+
assert!(args.revert_protection);
276+
277+
assert_eq!(args.playground.unwrap(), PathBuf::from("/tmp/playground"));
278+
279+
assert!(args.flashblocks_args.flashblocks_enabled);
280+
assert_eq!(args.flashblocks_args.interval, Duration::from_millis(500));
281+
assert_eq!(
282+
args.flashblocks_args.leeway_time,
283+
Duration::from_millis(100)
284+
);
285+
assert_eq!(
286+
args.flashblocks_args.ws_address,
287+
"127.0.0.1:9999".parse().unwrap()
288+
);
289+
assert!(args.flashblocks_args.calculate_state_root);
290+
}
291+
}

0 commit comments

Comments
 (0)