feat(storage): return --storage.v2 flag (#23120)

Co-authored-by: Alexey Shekhirin <5773434+shekhirin@users.noreply.github.com>
Co-authored-by: Alexey Shekhirin <github@shekhirin.com>
This commit is contained in:
Derek Cofausper
2026-03-19 08:18:51 -07:00
committed by GitHub
parent 20cce0a6df
commit 2a94eedd61
17 changed files with 185 additions and 20 deletions

View File

@@ -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;

View File

@@ -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<DefaultStorageValues> = 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::<StorageArgs>::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::<StorageArgs>::parse_from(["reth", "--storage.v2"]).args;
fn test_storage_v2_explicit_true() {
let args = CommandParser::<StorageArgs>::parse_from(["reth", "--storage.v2=true"]).args;
assert!(args.v2);
}
#[test]
fn test_storage_v2_explicit_false() {
let args = CommandParser::<StorageArgs>::parse_from(["reth", "--storage.v2=false"]).args;
assert!(!args.v2);
}
}

View File

@@ -373,14 +373,15 @@ impl<ChainSpec> NodeConfig<ChainSpec> {
/// 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

View File

@@ -131,6 +131,15 @@ Static Files:
--static-files.blocks-per-file.storage-change-sets <BLOCKS_PER_FILE_STORAGE_CHANGE_SETS>
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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 <FORMAT>
The format to use for logs written to stdout

View File

@@ -112,6 +112,14 @@ Static Files:
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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 <URL>
Specify a snapshot URL or let the command propose a default one.

View File

@@ -112,6 +112,14 @@ Static Files:
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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 <first-block-number>
Optional first block number to export from the db.
It is by default 0.

View File

@@ -112,6 +112,14 @@ Static Files:
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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 <IMPORT_ERA_PATH>
The path to a directory for import.

View File

@@ -112,6 +112,14 @@ Static Files:
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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.

View File

@@ -112,6 +112,14 @@ Static Files:
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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.

View File

@@ -111,6 +111,15 @@ Static Files:
--static-files.blocks-per-file.storage-change-sets <BLOCKS_PER_FILE_STORAGE_CHANGE_SETS>
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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 <FORMAT>
The format to use for logs written to stdout

View File

@@ -1057,6 +1057,15 @@ Static Files:
--static-files.blocks-per-file.storage-change-sets <BLOCKS_PER_FILE_STORAGE_CHANGE_SETS>
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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 <FORMAT>
The format to use for logs written to stdout

View File

@@ -111,6 +111,15 @@ Static Files:
--static-files.blocks-per-file.storage-change-sets <BLOCKS_PER_FILE_STORAGE_CHANGE_SETS>
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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 <PROMETHEUS>
Enable Prometheus metrics.

View File

@@ -112,6 +112,14 @@ Static Files:
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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 <FROM>
The height to start at

View File

@@ -112,6 +112,14 @@ Static Files:
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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]
<STAGE>
Possible values:
- headers: The headers stage within the pipeline

View File

@@ -118,6 +118,15 @@ Static Files:
--static-files.blocks-per-file.storage-change-sets <BLOCKS_PER_FILE_STORAGE_CHANGE_SETS>
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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 <FORMAT>
The format to use for logs written to stdout

View File

@@ -112,6 +112,14 @@ Static Files:
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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 <SOCKET>
Enable Prometheus metrics.

View File

@@ -117,6 +117,14 @@ Static Files:
Number of blocks per file for the storage changesets segment
Storage:
--storage.v2 <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