Introduction to Blockchain | In-depth understanding of Orphan Block: Orphan Block is actually a stale block

Source: First position

Editor's Note: The original title was "In-depth understanding of orphan blocks"

Although I am fond of Ethereum and Turing's complete blockchain (bitcoin is not), Ethereum is also based on many concepts of bitcoin, so the two are very similar.

In this article, let's talk about Bitcoin's "solitary block". In most cases, all PoW chains are consistent with the description below.

Bitcoin has a "longest chain win" rule, that is, the chain with the highest computing power will be recognized or accepted by the network as the "main chain". This is to prevent individuals or a group from controlling the collective network (unless the group controls more than 50% of the computing power of the network). Because the PoW algorithm requires a lot of computing power to support it, it is not only difficult and costly for the perpetrator to maintain the longest chain.

The most common case is that the longest chain is the chain with the most blocks. If the number of blocks is the same, the total PoW is compared (add up the difficulty). However, "the longest chain wins" is easy to misunderstand that there may be multiple competing chains in the network (except the test chain, which does not participate in the competition). The correct understanding is that there are multiple paths in a chain, and nodes need to follow the path with the most PoW.

What does that path mean? That is, we often encounter unintentional differences or "forks" on the Internet.

In a blockchain using the PoW algorithm, when two miners in the network calculate the PoW problem at almost the same time, an unexpected fork will occur. The two miners each broadcast to the remaining network that they are the "winning" block owner, which is caused by network delays (no instant block generation).

It will take some time for all nodes to know that there is a newly mined block.

Assuming that the two miners worked out the answers almost simultaneously, we will call their blocks B and B '. Both miners broadcast their "success" blocks to surrounding nodes, and the nodes broadcast to peer nodes until the entire network knows about this new block. If it takes 10 seconds (not the real time) for a block to reach the entire network, the two miners are separated at both ends of the network, and after 5 seconds of propagation, there will be a network split (assuming the same delay time for the entire network).

Half of the people think that the chain of block B is the main chain, while the other half think that the chain of block B 'is the main chain.

The problem arises

Until the entire network knows the B and B 'blocks, the first to see the B block will put B at the front, but at the same time will connect the parent block (B and B' block before the block) to the B 'area Block as a reference.

The node puts the B block at the forefront of its main chain, but at the same time maintains a reference to the B 'block.

After that, the miners immediately started the next round of block mining competition. Depending on the miner, the next block is either added to the B chain or added to the B 'chain.

Suppose that in this example, the miner adds the next block C after block B (making B chain the longest chain), and broadcasts block C to the remaining network. Unless there is a fork again, once the C block is received, the B 'chain will automatically accept the B block path (the head is the C block), because the B chain is the longest chain at this time.

Regardless of whether the node has B or B 'as the head, once block C is added after block B, block B' will be discarded.

The transactions of block B 'will be put back into mempool, B' will be discarded and become an isolated block, the miners of B 'will fail and they will lose their mining rewards.

Therefore, the block time of Bitcoin is set to 10 minutes. Satoshi Nakamoto believes that 10 minutes is a "middle ground" between rapid confirmation time and low probability of bifurcation, so the number of isolated blocks will also decrease, which is a good thing.

Update section:

I recently noticed that there is a lot of confusion between orphan blocks and obsolete blocks. This section is used to clarify the difference between the two.

1. The obsolete block is a block dug on an isolated block.

Miners in orphan and obsolete blocks will not be rewarded for mining even if they contribute effective computing power.

This will not happen with Bitcoin, because once the D block is dug and broadcast, the entire network will choose to follow the D block.

2. The lone block is actually a stale block.

Some people would think that the term "solitary block" I used in this article should be cited as a stale block.

3. The obsolete block is a block that is still working after finding a valid PoW block.

A website called "BitCoin Source" has well summarized this (I think it no longer exists now), and I apply their definitions here. "In any second, a block" answer "may be calculated. This means that everyone in the world who is mining this block must stop and start mining again. Areas where mining continues after The block is called a "stale block" because it contains old data and old transactions. "

4. An orphan block refers to a block without a "parent" block.

This is recognized as the second largest reason. Some people think that an orphan block should only refer to a block that has no parent block.

Because Bitcoin is a widely distributed network, some nodes know blocks that others do not. If a node receives a block without knowing its parent block, the node cannot verify, so the node must request the parent block information from the peer node in the network. Before receiving this information, the block will be regarded as an isolated block.

However, after Bitcoin v0.10 version, because the way nodes download blocks has changed, there is no longer any type of solitary block in Bitcoin.