Expand description
Compact sync for compact-storage qmdbs.
Compact sync does not transfer or reconstruct the full historical operation log. Instead, the source serves the minimum authenticated state needed to recreate the latest committed compact db state:
- the total committed leaf count,
- the compact frontier’s pinned nodes for that leaf count,
- the final commit operation, and
- a proof authenticating that final commit against the requested root.
§What compact dbs store
A compact db persists two pieces of state that must always describe the same committed tip:
- the compact Merkle frontier (persisted by
crate::merkle::compact), and - a db-level witness for the last commit (persisted by
qmdb::compact::witness).
The witness exists because only the db layer knows how to encode and decode the typed commit operation. Without it, a compact db could recover its root and continue appending, but it could not serve compact sync to another node.
§When compact state changes
The servable compact state advances only on durable persistence:
syncverifies the final commit proof and compact frontier before database construction.Database::from_validated_statereconstructs the already-validated state in memory only.- Compact db-local commits persist the frontier and witness together during
sync/commit. rewindrestores both the frontier and the witness from the previous slot together.
Unsynced in-memory mutations are therefore intentionally not servable: current_target() and
compact-state responses lag behind apply_batch() until the next durable sync.
§Safety and invariants
The compact path relies on these invariants:
- the served commit proof must authenticate the final commit at
leaf_count - 1, - the frontier pins and witness must move together in the same ping-pong slot,
- reopen and rewind must re-verify the persisted witness against the root restored from that slot, and
- reconstructed state must not be persisted until the db recomputes the requested root locally.
If those invariants are violated by missing or corrupted persisted data, compact db reopen fails
with DataCorrupted rather than silently serving or restoring mismatched state.
Structs§
- Config
- Configuration for compact synchronization into a compact-storage database.
- Fetch
Result - Result from a compact-state fetch.
- State
- Authenticated state for initializing a compact-storage database at a target root.
- Target
- Compact-sync target for a compact-storage database.
- Validated
State - Compact state that has been validated against a target root.
Enums§
- Serve
Error - Resolver-side errors for compact state serving.
Traits§
- Compact
DbResolver - Marker trait for resolvers whose associated types match a specific compact-sync database.
- Database
- Database types that can be initialized directly from compact state.
- Resolver
- Trait for compact sync fetches from a source database.
Functions§
- sync
- Create/open a compact-storage database and initialize it from compact authenticated state.