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 path to the output directory for granular benchmark results.
49    #[arg(long, short, value_name = "BENCHMARK_OUTPUT", verbatim_doc_comment)]
50    pub output: Option<PathBuf>,
51}
52
53#[cfg(test)]
54mod tests {
55    use super::*;
56    use clap::Parser;
57
58    /// A helper type to parse Args more easily
59    #[derive(Parser)]
60    struct CommandParser<T: Args> {
61        #[command(flatten)]
62        args: T,
63    }
64
65    #[test]
66    fn test_parse_benchmark_args() {
67        let default_args = BenchmarkArgs {
68            engine_rpc_url: "http://localhost:8551".to_string(),
69            ..Default::default()
70        };
71        let args = CommandParser::<BenchmarkArgs>::parse_from(["reth-bench"]).args;
72        assert_eq!(args, default_args);
73    }
74}