A Blockchain Primer › Module 3 › Lesson 3.1
Lesson 3.1: How the Ledger Spreads Between Nodes — Gossip Forwarding and Deduplication
- #1. The Core Question
- #2. An Everyday Analogy
- #3. Core Concepts Explained
- #4. Diagrams
- #5. Key Takeaways
- #6. Quiz
Module 2 made the ledger on a single node hard to tamper with. But a blockchain isn't one computer's ledger. Many nodes each keep their own copy. This lesson answers the next question: with no central server, how do new transactions and new blocks reach every node?
1. The Core Question
In a pure distributed peer-to-peer system, there's no "master server" pushing messages out to everyone. Messages can get lost, show up twice, or arrive out of order, and nodes can drop offline or come back online at any moment.
This lesson answers one question: How do nodes find each other, stay connected, pass along new information, and make sure they all end up with the complete ledger?
The short version: Nodes spread news the way people spread gossip. When you hear something new, you pass it on to the nodes you know. Hashes weed out duplicates, timestamps help with order, and nodes catch up by filling in whatever they missed.
2. An Everyday Analogy
Office Gossip
Say your company has no all-staff mailing list, and you want everyone to hear some news. The most effective approach isn't telling people one at a time. It's telling a few well-connected people who know lots of others and letting them pass it on to the people they know.
The news travels along people's connections, and eventually most people hear it. This process has a few features:
- You don't need to know everyone.
- Each person only needs to know some people.
- The same news may reach someone several times.
- Some people may not hear it until a while later.
The way blockchain nodes spread transactions and blocks is almost exactly this kind of "digital gossip."
Small Talk, News, and Newcomers
Human communication falls roughly into three kinds:
- Small talk: keeping relationships going, without passing along anything important.
- News: trading information that's actually useful.
- Introducing new people: bringing newcomers into the circle and letting them learn the history and the rules.
Nodes have three matching kinds of communication:
- Keeping existing connections alive.
- Making new connections.
- Spreading new transactions and new blocks.
3. Core Concepts Explained
3.1 The Conditions for Node Communication
Nodes talk to each other over the internet, and each node has a unique address. They can disconnect and reconnect at any time, and each one keeps its own list of the nodes it knows.
That list usually covers only a small fraction of the network, not every node. No node needs to know the whole network. It just needs to pass messages along through its neighbors.
3.2 Network Messages Are Unreliable
When you send messages over the internet, you can't assume they'll get through. Messages can:
- Get lost and never arrive.
- Arrive as duplicates, so the same message shows up more than once.
- Arrive out of order, so a later message shows up first.
If nodes didn't handle these three cases, they'd process transactions more than once, scramble the order, or never receive some information at all.
3.3 Spreading with Gossip
The fix is gossip forwarding:
- When a node receives new information, it forwards it to the nodes it knows.
- Those neighbors receive it and forward it to their own neighbors.
- It spreads outward layer by layer until most nodes have it.
Any single message may get lost, but gossip doesn't depend on any one message getting through. As long as there are other paths, the information still makes its way around. The goal is "eventually delivered," not "every message guaranteed to arrive."
3.4 Deduplicating with Hashes
Messages may arrive more than once. How does a node know it has already received a particular transaction?
Every transaction and every block has a hash value. Nodes can remember the hashes they've already seen and just ignore repeat content when it shows up.
Here the hash isn't doing tamper resistance. Its job is to tell quickly whether two things are the same.
3.5 Ordering with Timestamps
Messages may arrive out of order. Transaction data and block headers carry timestamps, so nodes can use them to judge what came first. At the very least, timestamps give nodes an objective basis for ordering.
Timestamps can't solve every ordering problem, and they can't prove a transaction is legitimate on their own. They're just one piece of information that helps nodes deal with messages that arrive out of order.
3.6 The Three Purposes of Communication
Communication between nodes mainly serves three purposes.
First, keeping existing connections alive. Nodes regularly send a small message to their neighbors (usually called a ping) and expect a pong back. A node that keeps failing to respond gets dropped from the neighbor list. It's like coworkers saying hi to each other to confirm the relationship is still alive.
Second, making new connections. A new node can send a join request to an existing node. Once that's confirmed, the existing node adds the newcomer to its neighbor list, and the newcomer adds the existing node to its own list. So it doesn't lose its connection by relying on one node, a new node usually connects to several existing nodes at once.
Third, spreading new information. New transactions and new blocks get forwarded to neighbors gossip-style, and the neighbors keep forwarding them.
3.7 Three Catch-Up Scenarios
New information doesn't spread only through real-time forwarding. There are three scenarios.
Continuous spreading. As soon as new transactions and new blocks appear, they spread across the network.
Reconnection updates. A node that's been offline for a while reconnects and has to fill in the transactions and blocks it missed.
New node enrollment. A brand-new node has no history at all. It has to get a complete copy of the ledger from existing nodes before it can actually take part in maintaining it.
Together, these three scenarios make sure nodes get both what's happening now and what they missed.
3.8 Spreading Isn't Accepting
This lesson only covers how messages reach nodes. Once nodes receive transactions and blocks, they still have to check whether those are legitimate: signatures, balances, block structure, hash puzzles, and so on.
Spreading brings the message over. Validation decides whether to accept it. The next lesson covers validation and acceptance.
4. Diagrams
Figure 3-1-1: Gossip Spreading
Figure 3-1-2: The Three Catch-Up Scenarios
5. Key Takeaways
- A peer-to-peer network has no central server. Nodes forward information gossip-style through their neighbors.
- Each node keeps only a subset of neighbors. It doesn't need to know the whole network.
- Messages can get lost, show up twice, or arrive out of order, so the spreading mechanism has to tolerate these problems.
- Gossip aims to reach the whole network eventually. It doesn't guarantee that every message gets delivered.
- Hash values catch duplicate messages, and timestamps help with ordering.
- Node communication has three purposes: keeping connections alive, making new connections, and spreading new information.
- New information spreads in three scenarios: continuous spreading, reconnection updates, and new nodes getting the complete history.
- Spreading isn't accepting. Messages still have to be validated after they arrive.
6. Quiz
Part 1: Single Choice (1–4)
Question 1
What's the core idea behind gossip spreading?
A. A central server sends the message to everyone
B. A node forwards new information to its neighbors, and the neighbors keep forwarding it
C. Each node stores only its own transactions
D. Every node has to connect directly to every other node
Show answer
Answer: B
Explanation: Gossip relies on nodes forwarding to their neighbors so the information spreads layer by layer. It doesn't depend on a central server, and it doesn't need every node connected to every other node.
Question 2
How does a node tell whether it has already received a transaction?
A. By the length of the transaction text
B. By comparing the transaction's hash value
C. By the sender's name
D. By when the message arrived
Show answer
Answer: B
Explanation: Transactions have hash values, so nodes can spot duplicates by their hashes. Text length, sender names, and arrival times can't reliably catch duplicates.
Question 3
What are ping/pong messages mainly used for?
A. Spreading new transactions
B. Confirming whether neighbor nodes are still online
C. Computing block hashes
D. Generating private keys
Show answer
Answer: B
Explanation: Ping/pong confirms whether neighbors are still online. Nodes that keep failing to respond get dropped from the neighbor list.
Question 4
When a new node joins the system, what does it usually need to do?
A. Connect to just one node and never switch
B. Connect to several existing nodes and get the complete history
C. Make up its own ledger from scratch
D. Delete all old blocks
Show answer
Answer: B
Explanation: A new node usually connects to several existing nodes and gets the complete history, so it doesn't depend on any single node.
Part 2: Multiple Choice (5–7)
Question 5
What can happen to messages in a peer-to-peer network?
A. They get lost
B. They arrive as duplicates
C. They arrive out of order
D. They always arrive in the order they were sent
Show answer
Answer: A, B, C
Explanation: Messages can get lost, show up twice, or arrive out of order. D is an absolute claim that doesn't match how real networks behave.
Question 6
What are the main purposes of communication between nodes?
A. Keeping existing connections alive
B. Making new connections
C. Spreading new transactions and new blocks
D. Turning every node into a central server
Show answer
Answer: A, B, C
Explanation: Communication is for keeping connections alive, making connections, and spreading information. D contradicts the whole idea of a peer-to-peer system.
Question 7
Which statements about spreading new information are correct?
A. New transactions and new blocks keep getting forwarded
B. A node that was disconnected has to fill in what it missed after reconnecting
C. A new node needs to get the complete ledger history
D. A node accepts any message it receives without validating it
Show answer
Answer: A, B, C
Explanation: New information keeps spreading, disconnected nodes catch up, and new nodes get the complete history. D is wrong because spreading isn't accepting, and nodes still have to validate what they receive.
Part 3: True or False (8–9)
Question 8
True or false: gossip guarantees that every message gets delivered to every node.
Show answer
Answer: False
Explanation: Gossip aims to reach the whole network eventually, but it doesn't guarantee that every message gets delivered.
Question 9
True or false: spreading and validation are two different things. First you receive the message, then you decide whether to accept it.
Show answer
Answer: True
Explanation: Spreading takes care of getting the message there. Validation decides whether to accept it.
Part 4: Scenario Analysis (10)
Question 10
A new node joins a peer-to-peer network for the first time. It knows only node A, but A could go offline at any moment.
Answer the following:
- Why shouldn't the new node connect only to A?
- What does it need to get after joining before it can help maintain the ledger?
- If it receives a duplicate transaction, what should it do?
Show answer
Answer:
- Because A could go offline, disconnect, or crash, and if the new node were connected only to A, it would be cut off from the network. Connecting to several nodes keeps it better connected.
- It needs to get the complete ledger history, filling in every transaction and block from before it joined, before it can become a full node that helps maintain the ledger.
- It should use the transaction's hash value to check whether it has seen it before. If it's a duplicate, it should ignore it and not process it again.