#35558 p2p: Prefill compact blocks
https://github.com/bitcoin/bitcoin/pull/35558 · · +717/-143 in 16 files, 16 commits · labels: P2P
Goal
- Predictively prefill likely missing transactions when sending compact blocks
- Avoids high-latency GETBLOCKTXN round-trips to speed block propagation and reduce stale block risk
Improves BIP152 compact block relay by predictively prefilling transactions that were missing from the local mempool during reconstruction (such as those retrieved via GETBLOCKTXN, extrapool transactions, or announcer prefills). To avoid adding network latency, prefill payload sizes are dynamically bounded by the peer's TCP congestion and receive window.
Problem: Presently, compact blocks only prefill the coinbase transaction, causing roughly 43% of block reconstructions to require an additional high-latency GETBLOCKTXN round-trip to fetch missing transactions, which slows network-wide block propagation and increases stale block risk.
Category: P2P (#4 of 65)
P2 · speedup
- P2 because it significantly improves compact block relay without requiring protocol changes
- Increases instant block reconstruction rates from roughly 57% to 90%
- Directly reduces network-wide block propagation delays and stale block risk
P2 because it yields a significant improvement to compact block relay performance, increasing instant block reconstruction rates from 56.9% to 89.7% without protocol changes, directly reducing block propagation delays and network orphan/stale risks.
Membership: Directly alters P2P compact block creation and transmission heuristics in net_processing and blockencodings.
Factors: security/stability 1, bug 0, performance 3, user value 2, leverage 1
Reviewability: Ready: Review #35724 first
The branch is clean and passing CI, but the author rebased on top of #35724 to pull out the logging changes first.
Author status: active, last pushed 2026-08-04 rebasing on top of PR 35724
Resolved concerns:
- Seeding prefill candidates with coinbase caused unnecessary TCP info syscalls even when no extra tx was prefilled; resolved by requiring candidate count > 1 (andrewtoth).
- Use-after-free and incorrect transaction size counting in debug logging during block reconstruction; resolved in later push and isolated into PR 35724 (andrewtoth, m4ycon).
Agreement: Strong
- Broad concept consensus with multiple tested approvals
- Support for a backwards-compatible approach to speed block relay (josibake, 0xB10C)
- Verified with node telemetry and test suites across transports (m4ycon, s00ly, johnnyasantoss)
- Resolved objections regarding unnecessary syscalls and a use-after-free (andrewtoth, m4ycon)
- Concept approval without stated reasons (w0xlt, murchandamus, edilmedeiros, ismaelsadeeq)
Strong concept consensus with tested ACKs; technical objections on socket checks and logging were addressed and split into #35724.
Widespread concept approval across maintainers and active contributors, multiple substantive tested ACKs, and all inline review criticisms raised by andrewtoth and m4ycon have been fixed.
- Concept ACKs from 0xB10C, josibake, murchandamus, w0xlt, ismaelsadeeq, and edilmedeiros
- Tested ACKs from m4ycon and s00ly with empirical propagation observations
- Andrewtoth's inline bugs were resolved by code updates
Objections:
| Reviewer | Kind | Harm | Status | Blocking | Author replied | Quote |
|---|---|---|---|---|---|---|
| andrewtoth | approach | Seeding prefill candidates with coinbase forced unnecessary socket queries and prefill code paths even when no non-coinbase transactions were prefilled | resolved | yes | yes | 2026-07-03: 'In that case, the check in net_processing for prefill_candidates.size() > 0 is always true, so we will always go through the prefill path and do all the syscalls' Settled: 2026-07-14: 'Great catch, thank you, I took this by changing the check to be prefill_candidates.size() > 1' |
| m4ycon | correctness | prefilled_size was never incremented, reporting 0 in reconstruction log statistics | resolved | no | yes | 2026-07-27: 'the value is always zero. Which could not be true in any scenario as coinbase is always prefilled.' Settled: 2026-08-04: 'Good catch, this got messed up while rebasing, pushed a fix... Rebased on top of #35724, where I\'ve pulled out the logging changes' |
Support:
- josibake: the simplicity and backwards compatibility of the approach make this a very strong proposal
- 0xB10C: thanks for picking this idea up and moving it closer to the finish line
- s00ly: tested all compact block test suites under v1 and v2 transports and rebased cleanly onto master
- m4ycon: collected research telemetry confirming prefill efficacy on live node setups
- johnnyasantoss: utACK based on group code review of compact block relay BIP logic
- w0xlt: Concept ACK [not substantive]
- murchandamus: Concept ACK [not substantive]
- edilmedeiros: Concept ACK [not substantive]
- ismaelsadeeq: Concept ACK [not substantive]
Participants: w0xlt (support), ismaelsadeeq (support), josibake (support), edilmedeiros (support), murchandamus (support), 0xB10C (support), johnnyasantoss (support), andrewtoth (objection), m4ycon (support), s00ly (support)
State derived from the lists: substantive support, no open objection (josibake, 0xB10C, s00ly, m4ycon, johnnyasantoss)
Review verdicts (DrahtBot): 0 (+2)
- Stale ACK: m4ycon, s00ly
- Concept ACK: w0xlt, ismaelsadeeq, josibake, edilmedeiros, murchandamus, 0xB10C, johnnyasantoss
Dependencies
Depends on: #35724
Files
139 lines under test/bench/ci.
- src/net_processing.cpp +165/-50
- src/blockencodings.cpp +120/-35
- src/util/sock.h +130/-0
- src/net.cpp +94/-0
- src/test/fuzz/cmpctblock.cpp +19/-40
- src/test/sock_tests.cpp +49/-4
- src/util/sock.cpp +46/-1
- src/net.h +29/-0
- src/compat/compat.h +27/-1
- src/blockencodings.h +21/-1
- src/test/blockencodings_tests.cpp +11/-8
- src/bench/blockencodings.cpp +2/-1
- src/test/fuzz/p2p_headers_presync.cpp +1/-1
- src/test/fuzz/partially_downloaded_block.cpp +1/-1
- CMakeLists.txt +1/-0
- src/test/util/net.cpp +1/-0
Card
Prefills compact blocks with transactions that peers are expected to lack, bounding prefill payload size to the connection's TCP window to avoid introducing additional round-trips. In node telemetry, this increased compact block reconstruction without extra requests from 56.9% to 89.7%, substantially improving block propagation times and lowering network stale rates without requiring protocol breaks. The change has strong concept agreement and tested ACKs, with earlier review objections resolved. Reviewers should note it is stacked on open PR 35724 which isolates the reconstruction logging changes.