Skip to content

feat(cli): add reth db checksum rocksdb command#21217

Merged
joshieDo merged 6 commits intomainfrom
feat/rocksdb-checksum
Jan 20, 2026
Merged

feat(cli): add reth db checksum rocksdb command#21217
joshieDo merged 6 commits intomainfrom
feat/rocksdb-checksum

Conversation

@gakonst
Copy link
Member

@gakonst gakonst commented Jan 20, 2026

Summary

Extends the reth db checksum command to support RocksDB tables, following the same pattern as the existing mdbx and static-file subcommands from #21211.

Note: This PR depends on #21211 and should be merged after it.

Usage

reth db checksum rocksdb transaction-hash-numbers
reth db checksum rocksdb accounts-history --limit 100000
reth db checksum rocksdb storages-history

Supported RocksDB tables

  • transaction-hash-numbers - Transaction hash to transaction number mapping
  • accounts-history - Account history indices
  • storages-history - Storage history indices

Motivation

When data is stored in RocksDB (e.g., TransactionHashNumbers, AccountsHistory, StoragesHistory based on storage settings), there was no way to verify the RocksDB contents match between different nodes. This enables direct comparison using the same hashing approach as the existing mdbx/static-file checksums.

Implementation

  • Adds RocksDbTable enum for the three supported tables
  • Adds Rocksdb subcommand (cfg-gated on unix + rocksdb feature)
  • Uses the same foldhash hasher with RETHRETH seed for consistency
  • Iterates through RocksDB entries using RocksDBProvider::iter()
  • Adds rocksdb feature to reth-cli-commands that enables reth-provider/rocksdb

@gakonst gakonst requested a review from mattsse as a code owner January 20, 2026 16:59
@gakonst gakonst added C-enhancement New feature or request A-cli Related to the reth CLI labels Jan 20, 2026
@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Jan 20, 2026
Extends the `reth db checksum` command to support RocksDB tables, following
the same pattern as the existing `mdbx` and `static-file` subcommands.

Usage:
  reth db checksum rocksdb transaction-hash-numbers
  reth db checksum rocksdb accounts-history --limit 100000
  reth db checksum rocksdb storages-history

Supported tables:
- transaction-hash-numbers: Transaction hash to number mapping
- accounts-history: Account state change history indices
- storages-history: Storage slot change history indices

This enables verification that RocksDB data matches between different nodes,
similar to how checksums work for MDBX tables and static files.
@gakonst gakonst force-pushed the feat/rocksdb-checksum branch from b178e75 to f43ec04 Compare January 20, 2026 17:14
Address review feedback: edge should enable rocksdb in downstream crates
instead of having rocksdb as a separate feature.
Move all RocksDB checksum code into a separate rocksdb_checksum submodule
that's only compiled when the edge feature is enabled. This reduces the
number of cfg attributes from 10 to just 3.
@gakonst gakonst force-pushed the feat/rocksdb-checksum branch from 747dc52 to dfac5ae Compare January 20, 2026 17:42
Add RocksDBRawIter that yields raw (key_bytes, value_bytes) pairs
directly without decoding/encoding. This avoids unnecessary work
when computing checksums since we only need the raw bytes.
Copy link
Member

@yongkangc yongkangc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Jan 20, 2026
@joshieDo joshieDo enabled auto-merge January 20, 2026 19:08
@joshieDo joshieDo added this pull request to the merge queue Jan 20, 2026
Merged via the queue into main with commit ff8f434 Jan 20, 2026
45 checks passed
@joshieDo joshieDo deleted the feat/rocksdb-checksum branch January 20, 2026 19:19
@github-project-automation github-project-automation bot moved this from In Progress to Done in Reth Tracker Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Related to the reth CLI C-enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants