Hi all,
With NU7 moving Zcash to 25-second blocks on 5 November (ZIP 218), how fast a block crosses the network becomes a much bigger share of each block interval, and with it the orphan rate. I’ve been looking at one part of block relay nobody seems to have discussed yet: the order in which a node uploads a new block to the peers that ask for it. I’ve written it up as a discussion paper with a testbed and a live simulation, and submitted it to ZECATHON. I’d really value feedback, especially from the Zebra team.
The idea in one paragraph
Today a Zebra node uploads a new block to every peer that asks for it in parallel, as the requests arrive. Concurrent uploads share its bandwidth evenly through TCP, so every copy finishes late, at about the same moment, and nobody can pass the block on until then. Priority fill serves the peers most likely to relay the block onward first, ranked by the throughput the node has measured from them, at full speed, and fills any spare upload with the next peer in line. Peers that stall are demoted. It’s local to each node: no new messages, no consensus change, no hard or soft fork, no extra bytes.
What I measured
- 100-node testbed built on Zebra’s own
zebra-networkcode (real handshake, codec, peer set, inventory routing and gossip loop), emulated home and datacenter links, 2 MB blocks every 25 s: the estimated stale rate fell from 10.0% to 3.6%, and blocks reached other miners in a median 0.82 s instead of 2.67 s. - 1,000-node model with Poisson block arrivals, which counts orphans directly: 16.2% of blocks orphaned under today’s relay vs 6.0% with priority fill. Most orphans come from blocks found within seconds of each other: 64% of those were orphaned today vs 26% with priority fill.
- Mining centralisation: a pool never orphans its own blocks, so orphans favour big pools. In the model, a 46% pool’s revenue edge over a 1% pool falls from 7.3% to 2.7%.
What it costs
- It needs learned rankings: freshly started nodes recovered only about a quarter of the gain.
- The slowest 10% of nodes don’t gain; home nodes rank low and wait in upload queues.
- Rankings can be gamed. Ten slow-reading attackers delayed the slowest nodes by 0.8 s. A demotion rule (a stalled upload gives up its slot and its rank) cut that to 0.4 s: blunted, not removed.
- It adds state and tuning to a security-critical path.
Things I want to be upfront about
- The testbed’s priority-fill runs also announced relayed blocks to every peer rather than Zebra’s random third. For freshly started nodes this made no measurable difference, and the 1,000-node model keeps one-third announcements and still shows most of the gain. But steady state with one-third fanout hasn’t been tested on Zebra’s code.
- Poisson block arrivals haven’t been run on Zebra’s code yet: my single-machine testbed ran out of memory when blocks overlapped. The Poisson results come from the model, which matches the testbed when run at 100 nodes.
- The models assume full 2 MB blocks, equal-hashrate miners and no compact blocks, so absolute numbers run high (the model orphans 5.2% at 75 s, where mainnet sees about 0.4%). Read them as direction and rough size.
A separate, simpler finding
zebrad’s gossip loop waits PEER_GOSSIP_DELAY (7 s) between tip announcements, and the code comment says it was sized for 75-second blocks (as of commit 1e03ee75). With Poisson arrivals at a 25 s mean, about a quarter of blocks reach a relay while it’s still waiting. Removing the wait in the model cut orphans from 16.2% to 13.4% under today’s relay, and from 6.0% to 3.9% with priority fill. It may already be addressed in newer code, but it seems worth checking before NU7.
What it isn’t
This is not a proposal to merge anything. The Zebra changes sit behind an off-by-default testbed feature and the relay binary refuses to run off loopback. The aim is to ask whether upload order deserves a place in the relay discussion alongside compact blocks (PR #11938).
Questions I’d love input on
- Is there data on Zcash nodes’ real bandwidth and connectivity, or would a measurement study or testnet trial be the right next step?
- Is trading fairness for speed acceptable, or should home nodes get a guaranteed share of upload?
- Which mitigations against ranking attacks are worth their complexity (prefix caps, a random reserve slot, outbound preference)?
- Would this fit in Zebra as an opt-in setting, somewhere else, or not at all?
- Once NU7 is live, how should the measured stale rate feed into decisions like this?
Links
- Live 1,000-node simulation: https://web-production-b8358a.up.railway.app
- 2-minute explainer video: Priority-Fill Relay Explainer
- Paper (PDF): zcash-priority-fill-relay/paper/paper.pdf at main · onemanbillion/zcash-priority-fill-relay · GitHub
- Code, Zebra patches, testbed, model and every node log: GitHub - onemanbillion/zcash-priority-fill-relay: Discussion paper and testbed: priority-fill block upload scheduling for Zcash (Zebra). Experimental, not for deployment. · GitHub
The analysis, code and drafting were done with help from Claude. I’m responsible for the content and happy to dig into any of it. This is based on an idea I had many years ago for Bitcoin and decided to look into it again for zcash.