feat(state): add the 28.1.0 sync metadata and known-hash chunk format - #11275
feat(state): add the 28.1.0 sync metadata and known-hash chunk format#11275arya2 wants to merge 1 commit into
Conversation
And one more auto-invalidated finding. Analyzed two files, diff |
Merge Protections🔴 1 of 1 protections blocking · waiting on ⛓️ dependency
🔴 ⛓️ Depends-On RequirementsWaiting for
This rule is failing.Requirement based on the presence of
|
8cf4212 to
bcd06a4
Compare
Indexes per-block sync metadata (sizes, tx and note counts, ZIP 221/244 commitments) with a cumulative transparent-output count, adds the known-hash chunk column family, and serves sync metadata to v2 peers. The upgrade backfills existing databases and chases the live tip, and commit-time writes skip ahead-of-backfill heights to keep the column family contiguous from genesis.
bcd06a4 to
8350f30
Compare
Motivation
Third PR of the six-PR stack implementing the draft version 2 Zcash P2P
network protocol (zcash/zips#1344).
The protocol's synchronization requests need per-block data the state does
not index today:
get-hashesserves best-chain hashes with aggregated spanmetadata, and
get-tree-rootsserves per-block note commitment tree rootsand counts. The known-hash sync engine additionally needs a store for
verified known-hash chunks, and SwiftSync spentness hints
(zcash/zips#1346) need a global
ordinal for every transparent output.
Per the design decision in
docs/design-swiftsync-hints.md(one combinedformat), this PR lands all three needs as a single 28.1.0 database
format: the sync-metadata column family with a per-height cumulative
transparent-output count, and the known-hash chunk column family. The QUIC
transport and peer connection that consume this metadata follow in the next
PR.
Solution
sync_meta_by_height: per-block synchronization metadata — serializedsize, transaction and note counts, per-pool transaction counts, the
ZIP 244 authorizing data commitment, and the chain's cumulative
transparent-output count at that block, which assigns every transparent
output its spentness-hint ordinal. Records are written at block commit;
a format upgrade backfills existing databases and chases the live tip,
and commit-time writes skip ahead-of-backfill heights so the column
family stays contiguous from genesis.
known_hash_chunk: verified known-hash chunk bytes by chunk index,stored opaquely after verification against the pinned SHA-256 constants
(the pins stay in
zebra-chainas the trust root). Not backfilled;written on demand.
ReadRequest::SyncHashes/TreeRootsanswer the v2requests from the index — entries stop at
MAX_BLOCK_REORG_HEIGHTbelowthe tip and at the backfill frontier, and tree-roots is refused unless
the anchor is in the best chain. The internal
Request::SyncHashes/TreeRootsvariants are local-only (never routed to a peer), and theinbound service answers them from state.
Tests
cumulative count, upgrade backfill on an existing database, and column
family snapshot updates.
zebra-networkandzebra-statesuites pass;cargo clippy --all-targetswarning-free;zebradbuilds.Specifications & References
docs/design-swiftsync-hints.md(decision 5),docs/port-plan-sync-engine.md(W1)Follow-up Work
p2p-v2-4-peer-connection→p2p-v2-5-peer-set-integration→p2p-v2-6-known-hash-formats(feat(network): serve the v2 synchronization protocol's content-addressed artifacts #11349).AI Disclosure
serving changes, run the test/lint verification, and draft the commit
messages and this description; the changes were reviewed by the author.
PR Checklist
type(scope): descriptionguidelines.