Skip to main content

Module commitment_state

Module commitment_state 

Source
Expand description

Responder-side commitment builder + rotation state.

Phase 2b of the v12 storage-bound audit design. Builds, signs, and caches a StorageCommitment over the responder’s currently-stored key set; serves audit lookups by expected_commitment_hash; retains recently-gossiped commitments for a bounded TTL window (with a slot backstop) so an audit pinned to a still-answerable commitment does not false-fail across rotations.

Rotation strategy:

  • rotate(new_built) atomically replaces current with new_built and demotes the prior current to previous. The prior previous is dropped.
  • lookup(hash) reads the in-memory map and returns an Arc to the matching BuiltCommitment, keeping it alive for the audit response regardless of subsequent rotation (mirrors the ArcSwap semantics specified in v6 §2: an in-flight reader holding its Arc is unaffected by a concurrent rotate).

Retention is persisted across restart (ADR-0004 A1): ResponderCommitmentState::snapshot captures the signed commitments + their key sets + gossip stamps, and ResponderCommitmentState::restore reloads them and rebuilds each tree from its persisted key set — so an honest restarted node can answer every pin that is still inside its answerability window, and an unanswerable pin is provable misbehaviour rather than an honest crash-restart. Trees are otherwise rebuilt from ChunkStore at the next rotation tick. Memory cost is bounded by 2 × (key_count × ~64 bytes + signature_size) — for 10k keys, ~1.3 MB.

Structs§

BuiltCommitment
A fully-built commitment: signed wire blob, cached hash, Merkle tree for inclusion proofs, and a sorted leaf-index lookup for the auditor’s leaf_index field.
PeerCommitmentRecord
Auditor-side per-peer commitment state.
PersistedRetention
The persisted responder retention. Slots are newest-first; has_current says whether slots[0] was the live advertised commitment.
ResponderCommitmentState
Responder retention state (ADR-0002).