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    /// Path to a JWT secret to use for the authenticated engine-API RPC server.
19    ///
20    /// This will perform JWT authentication for all requests to the given engine RPC url.
21    ///
22    /// If no path is provided, a secret will be generated and stored in the datadir under
23    /// `<DIR>/<CHAIN_ID>/jwt.hex`. For mainnet this would be `~/.reth/mainnet/jwt.hex` by default.
24    #[arg(long = "jwtsecret", value_name = "PATH", global = true, required = false)]
25    pub auth_jwtsecret: Option<PathBuf>,
26
27    /// The RPC url to use for sending engine requests.
28    #[arg(
29        long,
30        value_name = "ENGINE_RPC_URL",
31        verbatim_doc_comment,
32        default_value = "http://localhost:8551"
33    )]
34    pub engine_rpc_url: String,
35
36    /// The path to the output directory for granular benchmark results.
37    #[arg(long, short, value_name = "BENCHMARK_OUTPUT", verbatim_doc_comment)]
38    pub output: Option<PathBuf>,
39}
40
41#[cfg(test)]
42mod tests {
43    use super::*;
44    use clap::Parser;
45
46    /// A helper type to parse Args more easily
47    #[derive(Parser)]
48    struct CommandParser<T: Args> {
49        #[command(flatten)]
50        args: T,
51    }
52
53    #[test]
54    fn test_parse_benchmark_args() {
55        let default_args = BenchmarkArgs {
56            engine_rpc_url: "http://localhost:8551".to_string(),
57            ..Default::default()
58        };
59        let args = CommandParser::<BenchmarkArgs>::parse_from(["reth-bench"]).args;
60        assert_eq!(args, default_args);
61    }
62}