diff --git a/crates/node/core/src/args/mod.rs b/crates/node/core/src/args/mod.rs index 656fee26cd..7e27a51a7b 100644 --- a/crates/node/core/src/args/mod.rs +++ b/crates/node/core/src/args/mod.rs @@ -78,7 +78,7 @@ pub use static_files::{StaticFilesArgs, MINIMAL_BLOCKS_PER_FILE}; /// `StorageArgs` for configuring storage settings. mod storage; -pub use storage::StorageArgs; +pub use storage::{DefaultStorageValues, StorageArgs}; mod error; pub mod types; diff --git a/crates/node/core/src/args/storage.rs b/crates/node/core/src/args/storage.rs index b054e90e02..910d03578c 100644 --- a/crates/node/core/src/args/storage.rs +++ b/crates/node/core/src/args/storage.rs @@ -1,26 +1,68 @@ //! clap [Args](clap::Args) for storage configuration -use clap::{ArgAction, Args}; +use clap::Args; +use std::sync::OnceLock; + +/// Global static storage defaults +static STORAGE_DEFAULTS: OnceLock = OnceLock::new(); + +/// Default values for storage that can be customized +/// +/// Global defaults can be set via [`DefaultStorageValues::try_init`]. +#[derive(Debug, Clone)] +pub struct DefaultStorageValues { + v2: bool, +} + +impl DefaultStorageValues { + /// Initialize the global storage defaults with this configuration + pub fn try_init(self) -> Result<(), Self> { + STORAGE_DEFAULTS.set(self) + } + + /// Get a reference to the global storage defaults + pub fn get_global() -> &'static Self { + STORAGE_DEFAULTS.get_or_init(Self::default) + } + + /// Set the default V2 storage layout flag + pub const fn with_v2(mut self, v: bool) -> Self { + self.v2 = v; + self + } +} + +impl Default for DefaultStorageValues { + fn default() -> Self { + Self { v2: true } + } +} /// Parameters for storage configuration. /// -/// V2 storage is now the default for all new databases. The `--storage.v2` flag is -/// accepted for backwards compatibility but has no effect — v2 is always used. +/// `--storage.v2` controls whether new databases use the hot/cold V2 storage layout. +/// Defaults to `true`. /// /// Existing databases always use the settings persisted in their metadata. -/// -/// Individual storage settings can be overridden with `--static-files.*` and `--rocksdb.*` flags. -#[derive(Debug, Args, PartialEq, Eq, Clone, Copy, Default)] +#[derive(Debug, Args, PartialEq, Eq, Clone, Copy)] #[command(next_help_heading = "Storage")] pub struct StorageArgs { - /// Deprecated no-op: v2 storage is now always enabled for new databases. + /// Enable V2 (hot/cold) storage layout for new databases. /// - /// Kept for backwards compatibility with existing scripts and configurations. - /// Existing databases always use the settings persisted in their metadata. - #[arg(long = "storage.v2", action = ArgAction::SetTrue, hide = true)] + /// When set, new databases will be initialized with the V2 storage layout that + /// separates hot and cold data. Existing databases always use the settings + /// persisted in their metadata regardless of this flag. + #[arg(long = "storage.v2", default_value_t = DefaultStorageValues::get_global().v2, action = clap::ArgAction::Set)] pub v2: bool, } +impl Default for StorageArgs { + fn default() -> Self { + let defaults = DefaultStorageValues::get_global(); + Self { v2: defaults.v2 } + } +} + #[cfg(test)] mod tests { use super::*; @@ -36,13 +78,18 @@ mod tests { #[test] fn test_default_storage_args() { let args = CommandParser::::parse_from(["reth"]).args; - assert_eq!(args, StorageArgs::default()); + assert!(args.v2); } #[test] - fn test_parse_v2_flag_accepted() { - // Flag is accepted for backwards compatibility but is a no-op - let args = CommandParser::::parse_from(["reth", "--storage.v2"]).args; + fn test_storage_v2_explicit_true() { + let args = CommandParser::::parse_from(["reth", "--storage.v2=true"]).args; assert!(args.v2); } + + #[test] + fn test_storage_v2_explicit_false() { + let args = CommandParser::::parse_from(["reth", "--storage.v2=false"]).args; + assert!(!args.v2); + } } diff --git a/crates/node/core/src/node_config.rs b/crates/node/core/src/node_config.rs index 1eb367b55a..9f7ed00507 100644 --- a/crates/node/core/src/node_config.rs +++ b/crates/node/core/src/node_config.rs @@ -373,14 +373,15 @@ impl NodeConfig { /// Returns the effective storage settings for this node. /// - /// Always returns [`StorageSettings::v2()`] — v2 storage is the default for - /// new nodes. Existing nodes retain whatever settings are persisted in their - /// database metadata (checked during genesis init). - /// + /// Determined by the `--storage.v2` flag (defaults to `true`). /// Existing databases retain whatever settings are persisted in their /// metadata (checked during genesis init). pub const fn storage_settings(&self) -> StorageSettings { - StorageSettings::v2() + if self.storage.v2 { + StorageSettings::v2() + } else { + StorageSettings::v1() + } } /// Returns the max block that the node should run to, looking it up from the network if diff --git a/docs/vocs/docs/pages/cli/reth/db.mdx b/docs/vocs/docs/pages/cli/reth/db.mdx index 89de29ac57..b518c199be 100644 --- a/docs/vocs/docs/pages/cli/reth/db.mdx +++ b/docs/vocs/docs/pages/cli/reth/db.mdx @@ -131,6 +131,15 @@ Static Files: --static-files.blocks-per-file.storage-change-sets Number of blocks per file for the storage changesets segment +Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + Logging: --log.stdout.format The format to use for logs written to stdout diff --git a/docs/vocs/docs/pages/cli/reth/download.mdx b/docs/vocs/docs/pages/cli/reth/download.mdx index 28b58aa700..c4c96a489c 100644 --- a/docs/vocs/docs/pages/cli/reth/download.mdx +++ b/docs/vocs/docs/pages/cli/reth/download.mdx @@ -112,6 +112,14 @@ Static Files: Number of blocks per file for the storage changesets segment Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + -u, --url Specify a snapshot URL or let the command propose a default one. diff --git a/docs/vocs/docs/pages/cli/reth/export-era.mdx b/docs/vocs/docs/pages/cli/reth/export-era.mdx index 58cbeff41e..72bbba12aa 100644 --- a/docs/vocs/docs/pages/cli/reth/export-era.mdx +++ b/docs/vocs/docs/pages/cli/reth/export-era.mdx @@ -112,6 +112,14 @@ Static Files: Number of blocks per file for the storage changesets segment Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + --first-block-number Optional first block number to export from the db. It is by default 0. diff --git a/docs/vocs/docs/pages/cli/reth/import-era.mdx b/docs/vocs/docs/pages/cli/reth/import-era.mdx index 6dc604e0ee..fe3cfdfe6c 100644 --- a/docs/vocs/docs/pages/cli/reth/import-era.mdx +++ b/docs/vocs/docs/pages/cli/reth/import-era.mdx @@ -112,6 +112,14 @@ Static Files: Number of blocks per file for the storage changesets segment Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + --path The path to a directory for import. diff --git a/docs/vocs/docs/pages/cli/reth/import.mdx b/docs/vocs/docs/pages/cli/reth/import.mdx index c4636008f0..d9969e8d2b 100644 --- a/docs/vocs/docs/pages/cli/reth/import.mdx +++ b/docs/vocs/docs/pages/cli/reth/import.mdx @@ -112,6 +112,14 @@ Static Files: Number of blocks per file for the storage changesets segment Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + --no-state Disables stages that require state. diff --git a/docs/vocs/docs/pages/cli/reth/init-state.mdx b/docs/vocs/docs/pages/cli/reth/init-state.mdx index 7f78b1478c..cf1fe65066 100644 --- a/docs/vocs/docs/pages/cli/reth/init-state.mdx +++ b/docs/vocs/docs/pages/cli/reth/init-state.mdx @@ -112,6 +112,14 @@ Static Files: Number of blocks per file for the storage changesets segment Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + --without-evm Specifies whether to initialize the state without relying on EVM historical data. diff --git a/docs/vocs/docs/pages/cli/reth/init.mdx b/docs/vocs/docs/pages/cli/reth/init.mdx index d0eddd2de1..bbf3a175da 100644 --- a/docs/vocs/docs/pages/cli/reth/init.mdx +++ b/docs/vocs/docs/pages/cli/reth/init.mdx @@ -111,6 +111,15 @@ Static Files: --static-files.blocks-per-file.storage-change-sets Number of blocks per file for the storage changesets segment +Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + Logging: --log.stdout.format The format to use for logs written to stdout diff --git a/docs/vocs/docs/pages/cli/reth/node.mdx b/docs/vocs/docs/pages/cli/reth/node.mdx index 6b929f138f..38474f22ff 100644 --- a/docs/vocs/docs/pages/cli/reth/node.mdx +++ b/docs/vocs/docs/pages/cli/reth/node.mdx @@ -1057,6 +1057,15 @@ Static Files: --static-files.blocks-per-file.storage-change-sets Number of blocks per file for the storage changesets segment +Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + Logging: --log.stdout.format The format to use for logs written to stdout diff --git a/docs/vocs/docs/pages/cli/reth/prune.mdx b/docs/vocs/docs/pages/cli/reth/prune.mdx index 86c176dbe8..8675092c5a 100644 --- a/docs/vocs/docs/pages/cli/reth/prune.mdx +++ b/docs/vocs/docs/pages/cli/reth/prune.mdx @@ -111,6 +111,15 @@ Static Files: --static-files.blocks-per-file.storage-change-sets Number of blocks per file for the storage changesets segment +Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + Metrics: --metrics Enable Prometheus metrics. diff --git a/docs/vocs/docs/pages/cli/reth/re-execute.mdx b/docs/vocs/docs/pages/cli/reth/re-execute.mdx index c9901f6ef6..9da1b8860c 100644 --- a/docs/vocs/docs/pages/cli/reth/re-execute.mdx +++ b/docs/vocs/docs/pages/cli/reth/re-execute.mdx @@ -112,6 +112,14 @@ Static Files: Number of blocks per file for the storage changesets segment Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + --from The height to start at diff --git a/docs/vocs/docs/pages/cli/reth/stage/drop.mdx b/docs/vocs/docs/pages/cli/reth/stage/drop.mdx index b038dc6cf6..d0daa4cc5b 100644 --- a/docs/vocs/docs/pages/cli/reth/stage/drop.mdx +++ b/docs/vocs/docs/pages/cli/reth/stage/drop.mdx @@ -112,6 +112,14 @@ Static Files: Number of blocks per file for the storage changesets segment Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + Possible values: - headers: The headers stage within the pipeline diff --git a/docs/vocs/docs/pages/cli/reth/stage/dump.mdx b/docs/vocs/docs/pages/cli/reth/stage/dump.mdx index 2366fc9826..4d99a4ab32 100644 --- a/docs/vocs/docs/pages/cli/reth/stage/dump.mdx +++ b/docs/vocs/docs/pages/cli/reth/stage/dump.mdx @@ -118,6 +118,15 @@ Static Files: --static-files.blocks-per-file.storage-change-sets Number of blocks per file for the storage changesets segment +Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + Logging: --log.stdout.format The format to use for logs written to stdout diff --git a/docs/vocs/docs/pages/cli/reth/stage/run.mdx b/docs/vocs/docs/pages/cli/reth/stage/run.mdx index 7ea51f6741..26064a9e9b 100644 --- a/docs/vocs/docs/pages/cli/reth/stage/run.mdx +++ b/docs/vocs/docs/pages/cli/reth/stage/run.mdx @@ -112,6 +112,14 @@ Static Files: Number of blocks per file for the storage changesets segment Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + --metrics Enable Prometheus metrics. diff --git a/docs/vocs/docs/pages/cli/reth/stage/unwind.mdx b/docs/vocs/docs/pages/cli/reth/stage/unwind.mdx index efe541ddbb..1f1758008a 100644 --- a/docs/vocs/docs/pages/cli/reth/stage/unwind.mdx +++ b/docs/vocs/docs/pages/cli/reth/stage/unwind.mdx @@ -117,6 +117,14 @@ Static Files: Number of blocks per file for the storage changesets segment Storage: + --storage.v2 + Enable V2 (hot/cold) storage layout for new databases. + + When set, new databases will be initialized with the V2 storage layout that separates hot and cold data. Existing databases always use the settings persisted in their metadata regardless of this flag. + + [default: true] + [possible values: true, false] + --offline If this is enabled, then all stages except headers, bodies, and sender recovery will be unwound