Skip to content

chore: Mmr Checkpoint - #2468

Draft
sergerad wants to merge 6 commits into
sergerad-concurrent-loadfrom
sergerad-mmr-checkpoint
Draft

chore: Mmr Checkpoint#2468
sergerad wants to merge 6 commits into
sergerad-concurrent-loadfrom
sergerad-mmr-checkpoint

Conversation

@sergerad

@sergerad sergerad commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Warning

Blocked until incremental serialization of Mmr enabled by miden-vm (0xMiden/miden-vm#3585). Current impl performs full mmr file write every time.

Summary

Relates to #1697.

Why:

  • The chain MMR had no persisted form: it was rebuilt from every block header commitment in
    SQLite on every startup, the only remaining load-time cost that grows with chain height.
  • Operators get startup time that no longer scales with chain length; no functional or API
    change.

How:

  • Added ChainMmrCheckpoint: an on-disk cache of the derived MMR (<data-dir>/chainmmr.bin,
    version-prefixed serialized Blockchain).
  • load_mmr restores the checkpoint and tops it up with only the block commitments committed
    since it was taken (new select_block_header_commitments_from query), then verifies the
    result against the latest header's chain commitment — the same check the rebuild path uses.
    A missing, corrupt, or divergent checkpoint transparently falls back to a full rebuild.
  • The write worker refreshes the checkpoint on graceful shutdown, so the next startup only
    tops up blocks committed after that point.

Changelog

[[entry]]
scope       = "node"
impact      = "changed"
description = "Store startup now restores the chain MMR from an on-disk checkpoint and tops it up with only the blocks committed since, instead of rebuilding it from the database on every boot."

Comment thread crates/store/src/state/chain_mmr_checkpoint.rs
Comment thread crates/store/src/state/chain_mmr_checkpoint.rs Outdated
Comment thread crates/store/src/state/chain_mmr_checkpoint.rs Outdated
Comment thread crates/store/src/state/writer/worker.rs
@sergerad
sergerad force-pushed the sergerad-mmr-checkpoint branch from 0baedff to d0e19ee Compare August 12, 2026 01:23
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.

2 participants