Skip to content

Conversation

@yongkangc
Copy link
Member

@yongkangc yongkangc commented Dec 23, 2025

closes #20595

RocksDB consistency checks only cover TransactionHashNumbers and StoragesHistory, but AccountsHistory was missing.

Add check_accounts_history() invariant check following the same pattern as
StoragesHistory.

Related

Add consistency checking for the AccountsHistory table in RocksDB,
following the same pattern as StoragesHistory.

Changes:
- Add check_accounts_history() call in check_consistency()
- Add check_accounts_history() and prune_accounts_history_above() functions
- Add comprehensive tests for all edge cases
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a missing RocksDB consistency check for the AccountsHistory table, completing the consistency check coverage alongside the existing TransactionHashNumbers and StoragesHistory checks.

  • Implements check_accounts_history() method following the established pattern for history table invariant checking
  • Adds prune_accounts_history_above() helper for healing inconsistencies when RocksDB is ahead of checkpoints
  • Integrates the new check into the main check_consistency() flow with proper conditional execution

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +423 to +425
/// TODO(<https://github.com/paradigmxyz/reth/issues/20417>): this iterates the whole table,
/// which is inefficient. Use changeset-based pruning instead.
fn prune_accounts_history_above(&self, max_block: BlockNumber) -> ProviderResult<()> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, so rn this requires scanning the entire table?

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, will have to do some refactoring with prune_accounts_history_above and prune_storages_history_above once #20417 is in @mattsse

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah we need changesets in SF to redo this, kinda as a placeholder here + testing asap other components ig

… consistency check

StoragesHistory was missing the case where RocksDB data is behind the
checkpoint, which should trigger an unwind. This aligns with the
AccountsHistory implementation.
Copy link
Collaborator

@joshieDo joshieDo left a comment

Choose a reason for hiding this comment

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

feel like we could dedup storage/account history here, but we can do it another time

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Dec 23, 2025

// Find the max highest_block_number (excluding u64::MAX sentinel) across all
// entries
let mut max_highest_block = 0u64;
Copy link
Collaborator

Choose a reason for hiding this comment

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

i feel like there was already some kind of rocksdb checkpoint block somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Add invariance check for account history

4 participants