reth_node_core/args/benchmark_args.rs
1//! clap [Args](clap::Args) for benchmark configuration
2
3use clap::Args;
4use std::path::PathBuf;
5
6/// Parameters for benchmark configuration
7#[derive(Debug, Args, PartialEq, Eq, Default, Clone)]
8#[command(next_help_heading = "Benchmark")]
9pub struct BenchmarkArgs {
10 /// Run the benchmark from a specific block.
11 #[arg(long, verbatim_doc_comment)]
12 pub from: Option<u64>,
13
14 /// Run the benchmark to a specific block.
15 #[arg(long, verbatim_doc_comment)]
16 pub to: Option<u64>,
17
18 /// Number of blocks to advance from the current head block.
19 /// When specified, automatically sets --from to current head + 1 and --to to current head +
20 /// advance. Cannot be used together with explicit --from and --to arguments.
21 #[arg(long, conflicts_with_all = &["from", "to"], verbatim_doc_comment)]
22 pub advance: Option<u64>,
23
24 /// Path to a JWT secret to use for the authenticated engine-API RPC server.
25 ///
26 /// This will perform JWT authentication for all requests to the given engine RPC url.
27 ///
28 /// If no path is provided, a secret will be generated and stored in the datadir under
29 /// `<DIR>/<CHAIN_ID>/jwt.hex`. For mainnet this would be `~/.reth/mainnet/jwt.hex` by default.
30 #[arg(
31 long = "jwt-secret",
32 alias = "jwtsecret",
33 value_name = "PATH",
34 global = true,
35 required = false
36 )]
37 pub auth_jwtsecret: Option<PathBuf>,
38
39 /// The RPC url to use for sending engine requests.
40 #[arg(
41 long,
42 value_name = "ENGINE_RPC_URL",
43 verbatim_doc_comment,
44 default_value = "http://localhost:8551"
45 )]
46 pub engine_rpc_url: String,
47
48 /// The `WebSocket` RPC URL to use for persistence subscriptions.
49 ///
50 /// If not provided, will attempt to derive from engine-rpc-url by:
51 /// - Converting http/https to ws/wss
52 /// - Using port 8546 (standard RPC `WebSocket` port)
53 ///
54 /// Example: `ws://localhost:8546`
55 #[arg(long, value_name = "WS_RPC_URL", verbatim_doc_comment)]
56 pub ws_rpc_url: Option<String>,
57
58 /// The path to the output directory for granular benchmark results.
59 #[arg(long, short, value_name = "BENCHMARK_OUTPUT", verbatim_doc_comment)]
60 pub output: Option<PathBuf>,
61}
62
63#[cfg(test)]
64mod tests {
65 use super::*;
66 use clap::Parser;
67
68 /// A helper type to parse Args more easily
69 #[derive(Parser)]
70 struct CommandParser<T: Args> {
71 #[command(flatten)]
72 args: T,
73 }
74
75 #[test]
76 fn test_parse_benchmark_args() {
77 let default_args = BenchmarkArgs {
78 engine_rpc_url: "http://localhost:8551".to_string(),
79 ..Default::default()
80 };
81 let args = CommandParser::<BenchmarkArgs>::parse_from(["reth-bench"]).args;
82 assert_eq!(args, default_args);
83 }
84}