Reading — step 1 of 5
Read
P2P Gossip Propagation
Bitcoin and most blockchains use a gossip protocol to spread blocks and transactions across the network. Each node maintains ~8 outbound peers + up to ~125 inbound. When a node learns of a new tx or block, it:
- Sends a tiny INV message to each peer (just an item id).
- Peer responds GETDATA if they don't have it yet.
- Original node sends the full item.
This INV-GETDATA dance saves bandwidth: peers don't re-request what they already have.
Propagation time
For Bitcoin's real network, a typical block reaches >50% of nodes within ~5 seconds and >99% within ~10 seconds (Bitnodes measurements). The variance matters: miners on the well-connected backbone get blocks first and have a head start on the next block — a small selfish-mining advantage.
Eclipse attacks
If an attacker controls all of your peer connections, they control your view of the chain. Mitigations: random peer selection, address gossip diversity, prefer high-uptime peers, manual peer pinning for important nodes.
Compact block relay (BIP-152)
To reduce block propagation latency:
- Instead of sending the full block, send a compact block sketch: 6-byte short txid per tx.
- Receiver reconstructs the block from its mempool.
- Missing txs requested separately.
This reduced block propagation from ~5s to ~1s on average.
Erlay (proposed)
An even smarter relay using set reconciliation instead of full INV gossip. Saves bandwidth at the cost of CPU.
This exercise simulates basic gossip on a peer graph: announce an item, tick the clock, watch it spread one hop per tick.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…