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 `~/.local/share/reth/mainnet/jwt.hex`
30 /// by default.
31 #[arg(
32 long = "jwt-secret",
33 alias = "jwtsecret",
34 value_name = "PATH",
35 global = true,
36 required = false
37 )]
38 pub auth_jwtsecret: Option<PathBuf>,
39
40 /// The RPC url to use for sending engine requests.
41 #[arg(
42 long,
43 value_name = "ENGINE_RPC_URL",
44 verbatim_doc_comment,
45 default_value = "http://localhost:8551"
46 )]
47 pub engine_rpc_url: String,
48
49 /// The `WebSocket` RPC URL to use for persistence subscriptions.
50 ///
51 /// If not provided, will attempt to derive from engine-rpc-url by:
52 /// - Converting http/https to ws/wss
53 /// - Using port 8546 (standard RPC `WebSocket` port)
54 ///
55 /// Example: `ws://localhost:8546`
56 #[arg(long, value_name = "WS_RPC_URL", verbatim_doc_comment)]
57 pub ws_rpc_url: Option<String>,
58
59 /// The path to the output directory for granular benchmark results.
60 #[arg(long, short, value_name = "BENCHMARK_OUTPUT", verbatim_doc_comment)]
61 pub output: Option<PathBuf>,
62
63 /// Optional Prometheus metrics endpoint to scrape after each block.
64 ///
65 /// When provided, reth-bench will fetch metrics from this URL after each
66 /// `newPayload` / `forkchoiceUpdated` call, recording per-block execution
67 /// and state root durations. Results are written to `metrics.csv` in the
68 /// output directory.
69 ///
70 /// Example: `http://127.0.0.1:9001/metrics`
71 #[arg(long = "metrics-url", value_name = "URL", verbatim_doc_comment)]
72 pub metrics_url: Option<String>,
73
74 /// Use `reth_newPayload` endpoint instead of `engine_newPayload*`.
75 ///
76 /// The `reth_newPayload` endpoint is a reth-specific extension that takes `ExecutionData`
77 /// directly, waits for persistence and cache updates to complete before processing,
78 /// and returns server-side timing breakdowns (latency, persistence wait, cache wait).
79 #[arg(long, default_value = "false", verbatim_doc_comment)]
80 pub reth_new_payload: bool,
81
82 /// Fetch and replay RLP-encoded blocks. Implies `reth_new_payload`.
83 #[arg(long, default_value = "false", verbatim_doc_comment)]
84 pub rlp_blocks: bool,
85}
86
87#[cfg(test)]
88mod tests {
89 use super::*;
90 use clap::Parser;
91
92 /// A helper type to parse Args more easily
93 #[derive(Parser)]
94 struct CommandParser<T: Args> {
95 #[command(flatten)]
96 args: T,
97 }
98
99 #[test]
100 fn test_parse_benchmark_args() {
101 let default_args = BenchmarkArgs {
102 engine_rpc_url: "http://localhost:8551".to_string(),
103 ..Default::default()
104 };
105 let args = CommandParser::<BenchmarkArgs>::parse_from(["reth-bench"]).args;
106 assert_eq!(args, default_args);
107 }
108}