Skip to content

feat(storage): add startup validation for RocksDB CLI flags#21192

Closed
yongkangc wants to merge 14 commits intomainfrom
feat/rocksdb-cli-validation-v2
Closed

feat(storage): add startup validation for RocksDB CLI flags#21192
yongkangc wants to merge 14 commits intomainfrom
feat/rocksdb-cli-validation-v2

Conversation

@yongkangc
Copy link
Copy Markdown
Member

Summary

Adds startup validation to ensure --rocksdb.* flags match the persisted storage layout.

Behavior

  • If CLI override differs from initialized layout → startup error with actionable message
  • If CLI override matches or is not provided → startup proceeds

Changes

  • Added validate_against_persisted() method to RocksDbArgs
  • Added RocksDbSettingsMismatchError for clear error messages
  • Comprehensive tests for validation logic

Example Error

`--rocksdb.tx-hash` differs from initialized layout (expected false, got true). 
This setting is genesis-only; re-sync required (remove datadir or use a new datadir).

PR Stack

  1. feat(cli): add --rocksdb.* flags for RocksDB table routing #21191 - CLI flags ← base
  2. This PR - Validation logic
  3. docs: add documentation for RocksDB table routing CLI flags #21190 - Docs (independent)

Introduces RocksDbArgs struct with --rocksdb.tx-hash, --rocksdb.storages-history,
and --rocksdb.account-history flags for controlling which tables route to RocksDB.

These flags are genesis-initialization-only (changing later requires re-sync).
- Add test for bare flag without value (should require a value)
- Add test for space-separated value syntax
- Add rocksdb field to NodeConfig
- Update init_genesis to apply RocksDB settings on top of static files settings
- All struct initializers and Clone impl updated
@yongkangc yongkangc force-pushed the feat/rocksdb-cli-validation-v2 branch from 31acba8 to 6b6eb83 Compare January 19, 2026 15:18
Wire RocksDbArgs through NodeCommand to enable CLI flags to be passed
through to NodeConfig. Also fix clippy warnings for doc_markdown
(backticks around RocksDB) and missing_const_for_fn.
@yongkangc yongkangc force-pushed the feat/rocksdb-cli-validation-v2 branch from eadabff to 5169575 Compare January 19, 2026 17:56
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jan 19, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing feat/rocksdb-cli-validation-v2 (3bcb9bc) with feat/rocksdb-cli-v2 (09cc552)

Summary

✅ 118 untouched benchmarks
⏩ 7 skipped benchmarks1

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Consolidate 12 tests down to 3 essential ones covering defaults,
parsing, and settings application.
- If any --rocksdb.* flag is set to true, all RocksDB tables are enabled
- Explicit --rocksdb.<table>=false overrides can disable specific tables
- Logs startup message when grouped behavior triggers
- DRY'd doc comments (genesis-only note moved to struct level)
- Added comprehensive tests for grouped enable behavior
- Add test for all-explicit-false edge case
- Add test verifying non-rocksdb fields preserved
- Rename parameter defaults -> settings for clarity
- Extract storage_settings_with_logging() helper to DRY up with_genesis/init_genesis
- Fix clippy doc warnings (backticks around RocksDB)
Validates that --rocksdb.* flags match persisted storage layout.
Errors on mismatch since these are genesis-initialization-only settings.
- Add backticks around RocksDB in doc comments (clippy::doc_markdown)
- Make apply_to_settings() and validate_against_persisted() const fn
- Collapse nested if statements using let-chains
- Add test for matching false overrides against persisted false
- Add test verifying first mismatch is reported when multiple exist
- Add test for partial override matching
@yongkangc yongkangc force-pushed the feat/rocksdb-cli-validation-v2 branch from 5169575 to 405bb65 Compare January 20, 2026 09:26
Integrate the validate_against_persisted() method into init_genesis() so
CLI overrides are validated against persisted storage settings at startup.

- Add RocksDbSettingsMismatch variant to InitStorageError
- Call validation after genesis initialization
- Fail early if CLI flags don't match persisted settings
@yongkangc yongkangc force-pushed the feat/rocksdb-cli-v2 branch from 8ebf7fc to 3972cd0 Compare January 20, 2026 17:48
Base automatically changed from feat/rocksdb-cli-v2 to main January 20, 2026 19:40
@yongkangc yongkangc closed this Jan 22, 2026
@github-project-automation github-project-automation bot moved this from Backlog to Done in Reth Tracker Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant