Skip to content

Commit 15f4dec

Browse files
arya2claude
andcommitted
Add draft ZIP: Block Chain Synchronization
Recommends how nodes synchronize over the version 2 P2P protocol, which defines the primitives (get-headers/get-blocks/get-hashes) and the normative synchronization rules. This ZIP recommends two concrete strategies satisfying those rules: - Headers-first synchronization (the baseline full-validation method). - Checkpointed synchronization: verify checkpoint-spaced get-hashes responses against a local trusted commitment (e.g. compiled-in hash chunk hashes), fetch stride-1 hashes as download handles, and hash-chain each downloaded range to its verified checkpoints. Plus strategy selection and peer-diversity recommendations, with graceful degradation to headers-first when get-hashes is unavailable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C36xn69yRXtupScMCYarca
1 parent 95de382 commit 15f4dec

1 file changed

Lines changed: 219 additions & 0 deletions

File tree

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
ZIP: XXX
2+
Title: Block Chain Synchronization
3+
Owners: Arya <arya@zfnd.org>
4+
Status: Draft
5+
Category: Network
6+
Created: 2026-08-06
7+
License: MIT
8+
Discussions-To: <https://github.com/zcash/zips/issues/352>
9+
10+
11+
# Terminology
12+
13+
The key words "MUST", "MUST NOT", "SHOULD", "SHOULD NOT", "MAY", and
14+
"RECOMMENDED" in this document are to be interpreted as described in BCP 14
15+
[^BCP14] when, and only when, they appear in all capitals.
16+
17+
The terms "Mainnet" and "Testnet" are to be interpreted as described in
18+
section 3.12 of the Zcash Protocol Specification. [^protocol-networks]
19+
20+
The term "block chain" in this document is to be interpreted as described in
21+
section 3.3 of the Zcash Protocol Specification. [^protocol-blockchain]
22+
23+
The term "v2 protocol" in this document refers to the version 2 Zcash P2P
24+
network protocol [^draft-p2p-v2]. The terms "peer" and "request stream", the
25+
`get-headers`, `get-blocks`, `get-tx`, and `get-hashes` request stream
26+
types, and the synchronization rules of that protocol, are to be interpreted
27+
as defined there.
28+
29+
best chain
30+
: The consensus block chain that a node considers current, as determined by
31+
the consensus rules; its *tip* is its highest block.
32+
33+
validated tip
34+
: The highest block that a node has accepted into its best chain under the
35+
v2 protocol's synchronization rules.
36+
37+
synchronization strategy
38+
: A procedure by which a node advances its validated tip toward the network
39+
chain tip, using the request streams of the v2 protocol.
40+
41+
checkpoint
42+
: A (height, block hash) pair that a synchronizing node treats as
43+
authoritative for the block at that height.
44+
45+
checkpoint spacing
46+
: The height interval between a node's consecutive checkpoints.
47+
48+
hash chunk
49+
: A list of checkpointed block hashes covering a contiguous span of block
50+
heights, used as the unit of commitment and verification.
51+
52+
trusted commitment
53+
: Data, obtained by a node through a channel it already trusts (for
54+
example, compiled into its binary or supplied by local configuration),
55+
that binds the block hashes of its checkpoints — for example, a list of
56+
hash chunk hashes.
57+
58+
59+
# Abstract
60+
61+
This ZIP recommends how a node synchronizes the block chain over the version
62+
2 Zcash P2P network protocol. The v2 protocol defines the synchronization
63+
primitives — `get-headers`, `get-blocks`, `get-hashes` — and the rules that
64+
any use of them must satisfy; this ZIP recommends concrete *synchronization
65+
strategies* satisfying those rules — headers-first synchronization and
66+
*checkpointed synchronization* — and how a node selects between them.
67+
68+
69+
# Motivation
70+
71+
The recommended checkpointed strategy exists because headers-first
72+
synchronization is expensive for deep history. A serialized Zcash block
73+
header is 1487 bytes on Mainnet and Testnet (including the Equihash
74+
solution), and `get-headers` responses are limited to 160 headers, so
75+
synchronizing the header chain from genesis at a Mainnet height of roughly
76+
3.4 million blocks transfers about 5 GB of headers in more than 21,000
77+
sequential round trips — and every one of those headers is transferred again
78+
inside its full block. Nodes that ship with checkpoints do not need the
79+
standalone header pass for the checkpointed span: the authenticity of a
80+
downloaded block there is established by its hash chain to a checkpoint.
81+
What they need from the network is block *hashes* — 32 bytes each, up to
82+
50,000 per `get-hashes` response — as checkpoint data to verify and as
83+
download handles for `get-blocks`.
84+
85+
Checkpoints themselves also motivate this design. The Zebra implementation
86+
compiles in checkpoint lists that record a block hash at least every 400
87+
blocks — several hundred kilobytes of hashes that grow with the chain and
88+
must be regenerated for each release. Under the checkpointed strategy, a
89+
node can instead compile in only a short list of hash chunk hashes (its
90+
trusted commitment), obtain the chunks themselves from untrusted peers via
91+
`get-hashes`, and verify them; the compiled-in data shrinks from hundreds of
92+
kilobytes to a few kilobytes without weakening the trust model, since both
93+
are trusted only because they are part of the binary.
94+
95+
96+
# Specification
97+
98+
The synchronization rules of the v2 protocol [^draft-p2p-v2] apply to every
99+
strategy below and are not restated here.
100+
101+
In addition to those rules, this ZIP recommends that a node SHOULD spread
102+
block downloads across multiple peers rather than depending on one — this
103+
turns the v2 protocol's stalling timeout into a recovery mechanism — and
104+
SHOULD compare the chains offered by several peers (for example, by their
105+
advertised `start_height` and by probing with `get-headers`) before
106+
committing its download budget to one.
107+
108+
## Recommended Strategies
109+
110+
A node implements headers-first synchronization (the v2 protocol's fallback
111+
rule requires it) and MAY implement checkpointed synchronization.
112+
113+
### Headers-First Synchronization
114+
115+
Headers-first synchronization is specified in the v2 protocol
116+
[^draft-p2p-v2]. It is the full-validation strategy: it assumes no trusted
117+
commitments, and every accepted block is validated under the consensus
118+
rules.
119+
120+
### Checkpointed Synchronization
121+
122+
A node MAY synchronize the portion of the block chain covered by a trusted
123+
commitment as follows. Per the v2 protocol, the commitment scheme — the
124+
checkpoint spacing, the chunk boundaries, and the hash function used to
125+
commit to each chunk — is local to the synchronizing node.
126+
127+
1. **Obtain checkpoint hashes.** The node requests the hashes of its
128+
checkpoint heights with `get-hashes` requests whose `stride` is its
129+
checkpoint spacing.
130+
131+
2. **Verify them against the trusted commitment.** The node reassembles the
132+
returned hashes into hash chunks and verifies each chunk against the
133+
trusted commitment. A response that does not match is discarded without
134+
a misbehavior penalty and the request MAY be retried with a different
135+
peer. Hashes are checkpoints only once verified.
136+
137+
3. **Obtain per-height hashes.** For each inter-checkpoint range being
138+
synchronized, the node requests the hashes of every block in the range
139+
with `get-hashes` requests with `stride = 1`. These hashes cannot be
140+
verified in isolation and serve only as download handles; a mismatch
141+
with the checkpoints is detected in step 5.
142+
143+
4. **Download blocks.** The node downloads the corresponding blocks with
144+
`get-blocks` requests, observing the v2 protocol's download parameters.
145+
146+
5. **Validate against the checkpoints.** For each inter-checkpoint range,
147+
the node verifies that the downloaded blocks form a hash chain: each
148+
block's header hashes to the hash by which the block was requested, each
149+
block's `hashPrevBlock` is the hash of its predecessor, the first
150+
block's `hashPrevBlock` is the checkpoint (or previously validated
151+
block) below the range, and the last block's hash is the verified
152+
checkpoint hash at the top of the range. A range that fails this check
153+
is discarded and MAY be re-fetched from different peers, without a
154+
misbehavior penalty; provably invalid blocks are scored as specified by
155+
the v2 protocol. The node then accepts the range's blocks, applying
156+
whatever abbreviated validation its local policy permits for
157+
checkpoint-authenticated blocks under the v2 protocol's validated
158+
advancement rule.
159+
160+
Steps 1–5 pipeline naturally: distinct ranges MAY be fetched and validated
161+
concurrently from different peers, subject to the download parameters, and
162+
contiguous validated ranges extend the node's validated tip in height
163+
order.
164+
165+
## Strategy Selection
166+
167+
A synchronizing node SHOULD proceed as follows:
168+
169+
1. If it has a trusted commitment covering heights above its current
170+
validated tip, it SHOULD use checkpointed synchronization for the
171+
covered span, up to the reorganization margin of the synchronization
172+
rules: checkpointed synchronization strictly dominates headers-first
173+
synchronization over that span in bandwidth, round trips, and validation
174+
cost.
175+
176+
2. For heights above the span covered by its trusted commitment — including
177+
the entire chain, if it has no trusted commitment — it uses
178+
headers-first synchronization.
179+
180+
3. If a peer refuses `get-hashes` (with `REFUSED` or
181+
`UNSUPPORTED_STREAM_TYPE`), the node MAY retry with other peers, and
182+
SHOULD fall back to headers-first synchronization if too few of its
183+
peers serve `get-hashes` to sustain checkpointed synchronization.
184+
185+
186+
# Security and Privacy Considerations
187+
188+
The security properties of the strategies are analyzed in the v2 protocol's
189+
security considerations [^draft-p2p-v2]. Both recommended strategies satisfy
190+
its synchronization rules, so the choice between them — including falling
191+
back from checkpointed to headers-first synchronization — affects
192+
performance, not the integrity of the resulting chain.
193+
194+
**Fingerprinting.** The heights and strides a node requests reveal its
195+
checkpoint spacing and synchronization progress, which may identify its
196+
implementation and version. This is comparable to the fingerprinting
197+
surface of headers-first synchronization and of the `user_agent` field, and
198+
carries the same mitigation: nodes concerned about it can align their
199+
request patterns with common implementations.
200+
201+
202+
# Deployment
203+
204+
This ZIP depends on the v2 protocol [^draft-p2p-v2], which specifies the
205+
`get-hashes` request stream and the synchronization rules. No version gating
206+
is required beyond the v2 protocol's own deployment: refusal of `get-hashes`
207+
degrades gracefully to headers-first synchronization (see
208+
[Strategy Selection](#strategyselection)).
209+
210+
211+
# References
212+
213+
[^BCP14]: [Information on BCP 14 — "RFC 2119: Key words for use in RFCs to Indicate Requirement Levels" and "RFC 8174: Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words"](https://www.rfc-editor.org/info/bcp14)
214+
215+
[^protocol-networks]: [Zcash Protocol Specification, Version 2026.8.0 [NU6.3]. Section 3.12: Mainnet and Testnet](protocol/protocol.pdf#networks)
216+
217+
[^protocol-blockchain]: [Zcash Protocol Specification, Version 2026.8.0 [NU6.3]. Section 3.3: The Block Chain](protocol/protocol.pdf#blockchain)
218+
219+
[^draft-p2p-v2]: [Draft ZIP: Version 2 Zcash P2P Network Protocol](draft-arya-jvff-p2p-quic-transport.md)

0 commit comments

Comments
 (0)