Terminology§
The key words “MUST”, “MUST NOT”, “SHOULD”, “SHOULD NOT”, and “MAY” in this document are to be interpreted as described in BCP 14 1 when, and only when, they appear in all capitals.
- best tip
- The tip of a node’s best block chain.
- limited peer
- A peer that advertises
NODE_NETWORK_LIMITEDand notNODE_NETWORK.
Abstract§
This ZIP defines the service flag NODE_NETWORK_LIMITED for the Zcash
peer-to-peer protocol specified in ZIP 204 2. A node that sets it
serves at least the most recent 2,304 blocks of its best chain, but not
necessarily older blocks. It is the Zcash counterpart of BIP 159
3.
Motivation§
A node that deletes old block bodies, such as a Zebra node with pruning
enabled, cannot set NODE_NETWORK, and ZIP 204 defines no other flag for
serving blocks. Peers cannot tell that such a node serves recent blocks: some
ignore it, and others request historical blocks it does not have.
The Version 2 P2P protocol draft 4 defines the same flag. This ZIP specifies it for the current protocol, so that it can be deployed without the rest of that draft.
Specification§
Service Flag§
The service flag NODE_NETWORK_LIMITED is defined as bit 10
(0x0000000000000400) of the services field.
A node that sets NODE_NETWORK_LIMITED MUST be able to serve every block of
its best chain at a height greater than its best tip height minus 2,304, in
response to getdata requests with MSG_BLOCK. A node that does not hold all
of these blocks, for example because it retains fewer than 2,304 blocks or
started from a recent state snapshot, MUST NOT set it until it does.
A node that cannot serve the complete block chain MUST NOT set NODE_NETWORK,
and SHOULD set NODE_NETWORK_LIMITED if it meets the requirement above. A
node that sets NODE_NETWORK MAY also set it.
Serving§
A limited peer SHOULD NOT serve blocks more than 2,304 blocks below its best
tip, and SHOULD answer requests for them with notfound. It MAY disconnect a
peer that requests a block more than 2,306 blocks below its best tip; the
2-block margin allows for the best tip advancing while a request is in
flight.
Requesting§
A node MUST NOT request a block from a limited peer unless it knows the
block’s height from its own validated chain, and that height is within 2,304
blocks of its own best tip. A block whose parent is in the node’s best chain
has a known height. A block known only by its hash, for example from an inv
message, does not, and the node MUST request it from another peer or learn its
height first.
A node SHOULD rely on limited peers for blocks only while its best tip is
within 1,152 blocks of the network’s best tip, leaving half of the window for
chain reorganizations and for differences between the two nodes' best tips.
It SHOULD send getblocks to a limited peer only when the first hash in the
request’s block locator is its own best tip.
Address Relay§
Nodes SHOULD relay addresses advertising NODE_NETWORK_LIMITED as they relay
other addresses.
Deployment§
This ZIP requires no network upgrade. Nodes ignore service flags they do not
recognize, so a node can set NODE_NETWORK_LIMITED as soon as it implements
this ZIP.
Rationale§
Bit 10 and the 2,304-block window match the Version 2 P2P protocol draft 4, so a node can advertise the same capability in both protocols. Bit 10 is also the bit that BIP 159 assigns to the same capability in Bitcoin.
The window is defined in blocks rather than time, so that a peer can check a request against it without knowing the block target spacing. At 75, 25 and 10 seconds per block it covers about 48, 16 and 6.4 hours.
The 1,152-block margin for requesters, and the rule against serving older blocks, follow BIP 159’s 144-block reorganization buffer and its fingerprinting countermeasure. BIP 159 does not specify disconnection; the 2-block margin follows Bitcoin Core’s implementation 5.
A peer can announce the hash of any block, including one far below the window, so a requester checks the window against a height it has validated itself. An announcement that carries the block header, such as a compact block, names the parent, so a block a limited peer has just mined can still be requested from that peer.
Security and Privacy Considerations§
A limited peer that served every block it retains would reveal its retention depth, which helps distinguish it from other nodes. Serving only the window avoids this.