Understanding the network layer that enables decentralized blockchain communication
By the end of this session, you will be able to:
A peer-to-peer (P2P) network is a distributed network where participants (peers) communicate directly with each other without relying on centralized servers or intermediaries.
Random connections between peers
Organized topology (e.g., DHT)
Combines structured and unstructured
Most blockchain networks (like Bitcoin and Ethereum) use unstructured P2P networks because they prioritize robustness and decentralization over routing efficiency.
How it works: Each node forwards messages to all its neighbors
Advantages:
Disadvantages:
How it works: Message is forwarded to a randomly selected neighbor
Advantages:
Disadvantages:
Bitcoin uses a modified flooding approach:
How does a new node joining the network find other peers to connect to? This is the fundamental bootstrap problem in P2P networks.
Hardcoded list of well-known nodes
Pros: Simple, reliable initial connection
Cons: Centralization risk, maintenance overhead
DNS queries return IP addresses of active nodes
Pros: Dynamic, can return multiple addresses
Cons: Relies on DNS infrastructure
Existing peers share addresses of other peers
Pros: Fully decentralized, self-maintaining
Cons: Requires initial connection
Distributed Hash Table for peer discovery
Pros: Efficient, structured approach
Cons: Complex implementation
Churn refers to the continuous process of nodes joining and leaving the network. In blockchain networks, nodes may go offline due to:
Regular ping/pong messages to detect node failures
Maintain multiple connections to different peers
Store addresses of known peers for future connections
Ethereum handles churn through:
An attacker controls all of a victim's peer connections, effectively isolating them from the honest network. This can lead to:
Time for message propagation
Messages processed per second
Performance with network size
Fault tolerance capability
In the next session, we'll explore Proof of Work, diving into the hash-puzzle mechanism that secures Bitcoin and understanding how mining difficulty adjusts to maintain consistent block times.