reth_node_core/args/storage.rs
1//! clap [Args](clap::Args) for storage configuration
2
3use clap::{ArgAction, Args};
4
5/// Parameters for storage configuration.
6///
7/// This controls whether the node uses v2 storage defaults (with `RocksDB` and static file
8/// optimizations) or v1/legacy storage defaults.
9///
10/// Individual storage settings can be overridden with `--static-files.*` and `--rocksdb.*` flags.
11#[derive(Debug, Args, PartialEq, Eq, Clone, Copy, Default)]
12#[command(next_help_heading = "Storage")]
13pub struct StorageArgs {
14 /// Enable v2 storage defaults (static files + `RocksDB` routing).
15 ///
16 /// When enabled, the node uses optimized storage settings:
17 /// - Receipts and transaction senders in static files
18 /// - History indices in `RocksDB` (accounts, storages, transaction hashes)
19 /// - Account and storage changesets in static files
20 ///
21 /// This is a genesis-initialization-only setting: changing it after genesis requires a
22 /// re-sync.
23 ///
24 /// Individual settings can still be overridden with `--static-files.*` and `--rocksdb.*`
25 /// flags.
26 #[arg(long = "storage.v2", action = ArgAction::SetTrue)]
27 pub v2: bool,
28}
29
30#[cfg(test)]
31mod tests {
32 use super::*;
33 use clap::Parser;
34
35 /// A helper type to parse Args more easily
36 #[derive(Parser)]
37 struct CommandParser<T: Args> {
38 #[command(flatten)]
39 args: T,
40 }
41
42 #[test]
43 fn test_default_storage_args() {
44 let default_args = StorageArgs::default();
45 let args = CommandParser::<StorageArgs>::parse_from(["reth"]).args;
46 assert_eq!(args, default_args);
47 assert!(!args.v2);
48 }
49
50 #[test]
51 fn test_parse_v2_flag() {
52 let args = CommandParser::<StorageArgs>::parse_from(["reth", "--storage.v2"]).args;
53 assert!(args.v2);
54 }
55}