Skip to content

feat: add LtHash snapshot integrity verification#242

Open
G0G0S wants to merge 1 commit into
Overclock-Validator:devfrom
G0G0S:g0g0s/feat-lthash-snapshot-verification
Open

feat: add LtHash snapshot integrity verification#242
G0G0S wants to merge 1 commit into
Overclock-Validator:devfrom
G0G0S:g0g0s/feat-lthash-snapshot-verification

Conversation

@G0G0S
Copy link
Copy Markdown

@G0G0S G0G0S commented May 25, 2026

Closes #149

Adds an integrity check that runs after AccountsDB is built from a snapshot:
we recompute the lattice hash from the loaded accounts and compare it against
the LtHash field in the incremental manifest. On a mismatch the snapshot
is treated as tampered and the build aborts with an error, rather than
silently carrying on.

The motivation is that today there's no way to catch a corrupted or tampered
snapshot at load time. A misbehaving or malicious RPC node can serve altered
account state and we don't notice until block replay produces a divergent
bank hash hours later, by which point you've paid for a full bootstrap plus
a partial replay and have to start over. Failing fast at load is a far
cheaper signal.

Changes

  • New pkg/snapshot/verify_lthash.go — parallel verification across 32 workers
  • pkg/snapshot/build_db_with_incr.go — invokes the check right after accountsDb.OpenDb()

The 32-worker count is a heuristic that worked on my hardware; happy to make
it tunable or tie it to runtime.NumCPU() if that fits better with how the
rest of the codebase scales.

Re-compute the lattice hash from all accounts after building AccountsDB
and compare against the incremental manifest's LtHash. If they don't match,
the snapshot is considered tampered and the build fails with an error.

This prevents a DoS vector where a malicious RPC node serves a snapshot
with altered account data that would only be detected much later during
replay as a bankhash mismatch.

- New file: verify_lthash.go (parallelized verification with 32 workers)
- Modified: build_db_with_incr.go (call verification after OpenDb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[A43] Lattice hash of a snapshot is never validated by re-computing the hash

1 participant