Bitcoin BIP152 Compact Block Relay Explained: Short IDs and Missing Transactions
A Bitcoin block contains a header and a list of transactions. Sending every transaction again to every peer wastes bandwidth when the receiving node already has most of those transactions in its mempool. BIP152 defines compact block relay to take advantage of that overlap. It is a deployed P2P relay mechanism, not a change to Bitcoin consensus.
What is transmitted in a compact block?
A cmpctblock message includes the block header, a nonce used to derive short-ID keys, short transaction identifiers for many transactions, and some full transactions that the sender chooses to prefill. The coinbase transaction is normally prefilled because it is specific to that block and was not previously in the mempool.
Short IDs are 6-byte values derived using SipHash and keys associated with the block header and nonce. They are efficient references, not cryptographic proofs that a transaction belongs in a block. A node must reconstruct the actual transactions and validate the resulting block.
Reconstructing the block
The receiver tries to match short IDs against transactions already available locally. If it cannot reconstruct all positions, it can send getblocktxn to request the missing transaction indexes. The sender replies with blocktxn, containing the full requested transactions.
The receiving node verifies the assembled block against the header's Merkle commitment and all applicable consensus rules. Short-ID collisions or differing mempools can require additional data or a fallback to full-block download. Compact relay improves transport efficiency; it never relaxes validation.
Low-bandwidth and high-bandwidth relay
Peers negotiate support using sendcmpct. In low-bandwidth mode, compact blocks are typically requested after learning about a block. In high-bandwidth mode, peers can announce new blocks proactively with compact blocks, reducing latency. A node should not treat a compact block as trustworthy merely because it arrived early.
When does compact relay work best?
It works especially well when peers have already received nearly all the block's transactions. Divergent mempools, unusual transaction packages, and rapid block arrival can increase the number of missing transactions. BIP152 does not guarantee a fixed bandwidth saving for every block.
Primary references
BIP152 — Compact Block Relay: https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki
Bitcoin Core P2P documentation: https://github.com/bitcoin/bitcoin/tree/master/doc
