Bitcoin P2P network design — node discovery, message relay, and block propagation

Figures: Satoshi Nakamoto

Introduction

This page is L1 #1 — P2P network design in the design-document series. It covers the network layer end-to-end: how nodes discover each other, how they exchange messages, and how transactions and blocks propagate across the peer-to-peer gossip network.

The network layer sits beneath the consensus, transaction, and block layers. It provides the transport over which everything else operates — without reliable peer-to-peer communication, the deterministic validation rules described in the consensus design, transaction design, and block and chain design pages would have no data to act on.

Where behavior differs between the Satoshi-era implementation (v0.1, January 2009) and modern Bitcoin Core (v27+ baseline), both are noted.

1. Network topology

Bitcoin uses an unstructured gossip network. Nodes form a random mesh of TCP connections and relay data to their peers, who relay it to theirs. There is no central server, no routing table, no distributed hash table (DHT), and no hierarchy among nodes. Every full node is equally authoritative.

Node A

Node B

Node C

Node D

Node E

Node F

Node G

Node H

PropertyDesign choice
StructureUnstructured random graph — no DHT, no supernode hierarchy
Connections per nodeEach node maintains a small set of peers (default: 11 outbound + up to 125 inbound in v27+)
Relay modelStore-and-forward gossip — each node independently validates before relaying
RedundancyMessages propagate across multiple paths; no single link is critical
Partition resistanceRandom peer selection makes targeted network splits difficult

Why gossip and not structured routing. A DHT or hierarchical topology would reduce message redundancy but would also introduce single points of failure and make the network easier to partition. Bitcoin’s flat gossip model ensures that an attacker must compromise a large fraction of a node’s peers to control what it sees — the foundation of Eclipse attack resistance.

2. Node discovery

A new node joining the network faces a bootstrap problem: it needs to find at least one existing peer, but it has no prior knowledge of the network’s membership.

Discovery mechanisms

MechanismEraHow it works
IRC bootstrapv0.1 (2009)Nodes joined a specific IRC channel (#bitcoin on irc.lfnet.org) and announced their IP addresses. Other nodes read the channel to find peers. Removed in v0.8.2 (2013).
Hardcoded seed nodesv0.1 → presentA list of known-reliable IP addresses compiled into the binary. Used as a last resort when DNS seeds and cached peers are unavailable.
DNS seedsv0.6+ (2012)Hostnames (e.g., seed.bitcoin.sipa.be) that resolve to IP addresses of currently active nodes. The primary bootstrap method in modern Bitcoin Core.
addr / addrv2 relayv0.1 → presentConnected peers exchange addr messages containing IP addresses of other known nodes. addrv2 (BIP 155, v22.0+) extends this to support Tor v3, I2P, and CJDNS addresses.
Local peer databasev0.1 → presentThe node persists known peer addresses to peers.dat and attempts reconnection on restart. Over time, a healthy node accumulates thousands of addresses.

Bootstrap sequence (v27+ baseline)

Yes

No

Yes

No

Node starts

peers.dat

has addresses?

Try cached peers

Query DNS seeds

Connected to

≥1 peer?

Request addr messages

from connected peers

Connect to

returned addresses

Stable peer set

established

Hardcoded seeds

(last resort)

Satoshi era vs v27+ baseline. The original v0.1 client relied on IRC as the primary discovery mechanism — a simple but centralized approach vulnerable to IRC server downtime and channel bans. Modern Bitcoin Core replaces IRC with DNS seeds operated by independent community members. The DNS seed operators run crawler software that continually probes the network, and their DNS records reflect only nodes that are currently reachable and running compatible protocol versions.

3. Connection management

Each node maintains two classes of TCP connections: outbound connections the node initiates, and inbound connections other nodes initiate to it.

Connection typeDirectionDefault limit (v27+)Purpose
Full-relay outboundOutgoing8Primary peers for relaying transactions and blocks
Block-relay-only outboundOutgoing2Relay blocks only (no transaction/addr relay); increases block connectivity without leaking mempool information
FeelerOutgoing (short-lived)1 at a timeTests whether a candidate address is reachable; disconnects immediately after a successful handshake
InboundIncomingUp to 125Connections from other nodes; the node does not control who connects
AnchorOutgoing (persistent)2 (from block-relay-only set)Saved across restarts to maintain at least two trusted outbound peers; resists Eclipse attacks on restart

Outbound vs inbound: an asymmetry by design. A node trusts its own outbound connections more than inbound connections because it chose the outbound peers itself. An attacker who wants to isolate a node (Eclipse attack) must either control all outbound peers — which requires predicting or manipulating the node’s address selection — or flood the node with attacker-controlled inbound connections. The low outbound count (10 total) and the independent address-selection algorithm make the former difficult; inbound eviction logic makes the latter expensive to sustain.

Eviction

When a node’s inbound slots are full and a new inbound connection arrives, the node runs an eviction algorithm to decide whether to drop an existing peer. The algorithm protects peers with desirable properties:

  • Low latency (recently sent useful data)
  • Long connection duration
  • Diverse network groups (different /16 subnets, different autonomous systems)
  • Recently relayed a valid block or transaction

This diversity-preserving eviction makes it costly for an attacker to monopolize a node’s inbound slots, because the attacker’s connections are unlikely to outcompete honest peers on all protected dimensions simultaneously.

4. Message protocol

All communication between peers uses a binary message protocol. Every message carries a 24-byte header (4-byte network magic + 12-byte command name + 4-byte payload length + 4-byte checksum) followed by the payload.

Version handshake and block relay

Node B (responder)Node A (initiator)Node B (responder)Node A (initiator)Connection established (TCP)Handshake complete — peers are liveLater — new block foundversion (protocol version, services, best height)version (protocol version, services, best height)verackveracksendcmpct (signal compact block support)sendcmpctcmpctblock (header + short tx IDs)Reconstruct block from mempoolgetblocktxn (request missing txs)blocktxn (missing transactions)Validate complete block

Key message types

MessagePayloadRole
versionProtocol version, services bitmask, best block height, node timestampInitiates handshake; peers exchange capabilities
verackEmptyAcknowledges the version message; completes the handshake
invList of inventory vectors (type + hash)Announces known transactions or blocks without sending the data
getdataList of inventory vectorsRequests the full data for announced items
txSerialized transactionDelivers a transaction in response to getdata
blockSerialized full blockDelivers a full block (legacy relay mode)
headersUp to 2,000 block headersDelivers block headers for headers-first synchronization
getheadersLocator hashes + stop hashRequests a range of block headers
cmpctblockHeader + short transaction IDs (BIP 152)Compact block announcement; receiver reconstructs from mempool
getblocktxnBlock hash + indices of missing transactionsRequests transactions not found in the receiver’s mempool
blocktxnBlock hash + missing transactionsDelivers the transactions requested by getblocktxn
addr / addrv2List of peer addresses with timestampsPropagates known peer addresses across the network
ping / pongNonceLatency measurement and liveness check
feefilterMinimum fee rate (satoshis per kB)Tells the peer not to relay transactions below this fee rate
sendheadersEmptyRequests that the peer announce new blocks via headers messages instead of inv

Satoshi era vs v27+ baseline. The v0.1 protocol defined approximately 7 message types and relayed full blocks to every peer. Modern Bitcoin Core (v27+ baseline) supports 27+ message types and uses compact blocks (BIP 152) as the default relay method, reducing block relay bandwidth by roughly 90% for well-connected nodes with overlapping mempools.

5. Transaction relay

When a node accepts a transaction into its mempool, it announces the transaction to its peers via the gossip network.

inv (txid)

inv (txid)

getdata

tx (full transaction)

validate → mempool

inv (txid)

getdata

tx

Wallet submits

transaction

Node A:

validate → accept

into mempool

Node B

Node C

Node D

The relay process follows an announce-then-request pattern:

  1. Announce. The node sends an inv message containing the transaction’s hash to each peer.
  2. Request. A peer that has not seen this hash responds with getdata.
  3. Deliver. The announcing node sends the full tx message.
  4. Validate and propagate. The receiving peer validates the transaction independently. If valid, it accepts the transaction into its own mempool and repeats the announce cycle to its peers.

Privacy-preserving relay. To prevent network observers from tracing a transaction back to the originating node, Bitcoin Core adds a random delay before announcing each transaction to each peer (Poisson-distributed timer). Each peer receives the announcement at a slightly different time and from a potentially different set of earlier relayers, making origin inference difficult.

Fee filter. The feefilter message (BIP 133) allows a node to tell its peers its minimum acceptable fee rate. Peers then skip announcing transactions below that threshold, reducing bandwidth waste for transactions the receiving node would reject anyway.

Orphan transactions. A transaction that references an input whose parent transaction is unknown is called an orphan. The node holds orphans in a limited cache. If the parent transaction arrives later, the orphan is re-evaluated. If the cache fills, the oldest orphan is evicted. This mechanism handles transactions that arrive out of order but prevents memory exhaustion from invalid orphan floods.

6. Block propagation

Block propagation is the most latency-sensitive operation in the network. Slow propagation increases the stale-block rate and gives better-connected miners an advantage, undermining the fairness of the mining competition.

Propagation modes

Compact blocks (BIP 152, v0.13+)

Yes

No

Miner finds block

cmpctblock

(header + short tx IDs)

~20 kB

Peer reconstructs block

from mempool

All txs

found?

Validate block

getblocktxn

(request missing)

blocktxn

(missing txs only)

Headers-first sync (v0.10+)

Node starts IBD

getheaders

(request header chain)

headers

(up to 2,000 headers)

Build header chain,

verify PoW

getdata (parallel block requests

from multiple peers)

Validate full blocks

in chain order

Legacy: full block relay (v0.1)

Miner finds block

inv (block hash)

to all peers

Peer: getdata

block (full serialized block)

~1-2 MB

Peer validates

and relays

ModeBandwidth per blockLatencyWhen used
Legacy full-block relay~1–2 MB (entire block)High — full serialization + transferSatoshi era (v0.1); still available as fallback
Headers-first syncHeaders: 80 bytes each; blocks: full size, but requested in parallelModerate — parallelism compensates for full-block sizeInitial block download (IBD) — syncing from genesis to chain tip
Compact blocks (BIP 152)~20 kB typical (header + short IDs); missing txs on demandLow — most transactions already in mempoolSteady-state block relay between synced nodes (v27+ default)

How compact blocks achieve ~90% savings. When two peers have similar mempools (the common case for well-connected nodes), the receiver already has most of the block’s transactions. The cmpctblock message sends only the block header and a 6-byte short ID for each transaction. The receiver matches these IDs against its mempool, reconstructs the block locally, and requests only the handful of transactions it is missing. For a 2,000-transaction block, the cmpctblock message is roughly 20 kB instead of 1–2 MB.

High-bandwidth vs low-bandwidth mode (BIP 152). Compact blocks operate in two modes. In high-bandwidth mode, the sending peer pushes the cmpctblock immediately upon validation — without waiting for the receiver to request it via inv/getdata. A node typically designates three peers for high-bandwidth mode to minimize relay latency for new blocks. In low-bandwidth mode, the standard announce-then-request pattern is used with inv first, trading latency for bandwidth savings with the remaining peers.

7. Transport layer: plaintext vs encrypted

In the Satoshi-era design, all peer-to-peer communication was transmitted in plaintext. Any network observer — an ISP, a state-level adversary, or a man-in-the-middle on a local network — could read every message, identify which transactions a node was relaying, map the network topology, and selectively drop or delay messages.

BIP 324 v2 transport (supported since v26.0, enabled by default in v27+) introduces an opportunistic encrypted transport layer between peers that both support it.

AspectSatoshi era (v0.1)v27+ baseline (BIP 324)
TransportPlaintext TCPOpportunistic encrypted transport (v2 protocol)
ConfidentialityNone — all messages readable by any network observerMessages encrypted with ChaCha20-Poly1305; content opaque to observers
AuthenticationNoneOptional session-ID comparison allows manual peer authentication; counters man-in-the-middle attacks
Packet structureFixed 24-byte header with plaintext command nameVariable-length encrypted packets; command IDs are single-byte (not readable externally)
DetectabilityEasily identifiable as Bitcoin traffic by network magic bytesDesigned to look like random bytes; resists traffic-analysis classification
Backward compatibilityN/ANodes negotiate v2 at connection start; fall back to v1 (plaintext) if the peer does not support it

Why encrypted transport matters. Plaintext communication gives network-level adversaries three capabilities Bitcoin’s design does not intend them to have: (1) surveillance — an ISP can log which transactions a node relays, correlating with IP addresses; (2) targeted censorship — a state actor can identify and block Bitcoin traffic by pattern-matching the protocol’s distinctive header; (3) man-in-the-middle manipulation — an intermediary can selectively delay blocks or transactions to advantage specific miners or partition specific nodes. Encrypted transport does not eliminate all of these threats (a persistent adversary can still observe connection patterns), but it raises the cost substantially.

8. Two-era comparison

FeatureSatoshi era (v0.1, Jan 2009)Modern Bitcoin Core, v27+ baseline
Peer discoveryIRC channel bootstrap + addr messagesDNS seeds + addr/addrv2 relay + peers.dat cache
Supported address typesIPv4 onlyIPv4, IPv6, Tor v3 (onion), I2P, CJDNS (via addrv2, BIP 155)
Outbound connections8 full-relay8 full-relay + 2 block-relay-only + feeler + anchor connections
Inbound connectionsUp to ~125Up to 125, with diversity-preserving eviction algorithm
Message types~7 (version, verack, addr, inv, getdata, block, tx)27+ message types
Transaction relayDirect tx push after invAnnounce-then-request with Poisson-timed delays, wtxid relay, feefilter
Block relayFull block broadcast to every peerCompact blocks (BIP 152); high-bandwidth and low-bandwidth modes
Initial syncSequential: download and validate one block at a timeHeaders-first: download all headers, then request blocks in parallel
TransportPlaintext TCPOpportunistic encrypted transport (BIP 324, ChaCha20-Poly1305)
Eclipse resistanceMinimal — small peer set, no eviction diversityOutbound peer rotation, diverse eviction, anchor connections, block-relay-only peers
Protocol versioningVersion 1Incremental protocol versions negotiated during handshake; service bits advertise capabilities

9. Limits of this page

This page covers the network layer in isolation. The following topics are out of scope and addressed in their respective domain pages within the design-document series:

  • Transaction validation and UTXO model — what makes a transaction valid before it enters the mempool. Covered in the transaction design page.
  • Block validation and consensus rules — the deterministic checks a node applies to every block received from the network. Covered in the consensus design page.
  • Block structure and Merkle trees — how transactions are committed inside a block header. Covered in the block and chain design page.
  • Mining and proof-of-work — block template construction, the hash puzzle, and pool protocols.
  • Eclipse and Sybil attack economics — the full threat model for network-level attacks. Deferred to the L2 security-model deep dive.
  • Mempool policy details — package relay, Replace-by-Fee mechanics, and fee-rate bucket estimation.