Skip to content

feat: add checksum computation to AccountsDb snapshots #957

@bmuddha

Description

@bmuddha

Problem:
Need a way to verify that standby nodes have replicated the exact same state as the primary. Currently AccountsDb has no mechanism to compute a hash of its entire state.

Solution:
checksum() method on AccountsDb that iterates all accounts in key-sorted order (via LMDB) and hashes both pubkey and serialized account data using xxHash3. Returns a 64-bit hash suitable for verifying state consistency across nodes.

Implementation details:

  • AccountsDb::checksum() acquires write lock for consistency
  • Uses xxHash3 (fast, non-cryptographic hash with good distribution)
  • Hashes: pubkey (32 bytes) + serialized account data
  • Iteration order is deterministic (LMDB key-sorted)

Acceptance criteria:

  • New method on AccountsDb to compute state checksum
  • Scans all active accounts and hashes them cumulatively
  • Returns single hash value (u64)
  • Integrates with existing snapshot flow (deferred)
  • Unit tests for correctness and determinism

Reference: MIMD-0019 SuperBlock validation

Parent epic: #935

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions