The Story of those that DIDN’T make it — Stales, Uncles and …Orphans?

Sarvagya Bansal
tech@iiit-gwalior
Published in
10 min readMay 23, 2020
blockchain

Nowadays, blockchains are rising at an unprecedented rate. It would be fair to say that in a few years, blockchain will become an integral part of our lives. So I’ve written this blog to clear one of the common source of confusion for newcomers to blockchain. We all know about the blocks that get added to the chain, they make blockchain what it is. But what about the blocks that didn’t get added to the chain — what happens to them? This is the question we’re answering in this blog, with respect to the two most famous blockchains — Bitcoin and Ethereum.

This article assumes you have basic knowledge of how blockchains work, but for those who want a refresher or don’t know the basics and still want to read this, I’ve included a very high-level explanation of how blockchains work so they can understand the article. Others can just jump to the next heading.

The Basics

Blockchains can be thought of like linked-lists. Each new block has some data and points to the previous block in the chain (except the first or genesis block). Blockchains are decentralized which means that there is no central server. Every person participating in a blockchain has full copy of the blockchain i.e. all the blocks in it (again this is a very high-level explanation and therefore not entirely accurate) and has all the data in it.

Adding new Blocks —

Since every person has the full copy of it, and everyone has to have the same blockchain, therefore rules have to be set for adding new blocks to the blockchain. If everyone could add new blocks (i.e. new data) to the blockchain as per their wish, there would be no consistency among the copies of blockchains everyone has, making it useless.

Adding a new block to the chain requires a particular problem/puzzle to be solved. The people who solve this problem/puzzle are called miners. Anyone can try to solve this problem/puzzle, but it is not feasible for everyone to try to solve it since it requires a lot of computing power. Once a miner solves the puzzle, the newly found solution is propagated to everyone having a copy of the chain. Everyone verifies the solution of the puzzle and the data in the block. Once verified, this new block is added to everyone’s blockchain.

It is important to note that there can be multiple solutions and hence multiple blocks which qualify for being added next in the chain. Once a block becomes a part of the chain, miners immediately stop working on trying to find solution to the previous puzzle, and start trying to solve the new puzzle. Miners are incentivized to use their time and resources to solve the puzzle by providing them a reward for every block they add to the chain.

Problem arises when multiple miners solve the puzzle at approximately the same time. What happens then?

Which Block gets Added??

A block takes some time to propagate, so everyone will not receive it at the same time. The problem is what if by the time one miner’s solution reaches everyone in the blockchain, another miner solves the problem too and starts propagating his/her solution.

Let’s consider a case where Miner A and Miner B both solve the problem at the same time and start propagating it. Half the people receive Miner A’s solution first and the other half receive Miner B’s solution first. Now the problem is clear - how do we decide which block to discard and which to keep. We can’t choose randomly since it would make the blockchain inconsistent across the network. For consistency, everyone needs to have the same blockchain everywhere.

Different blockchains employ different methods to deal with such a situation. We’re going to discuss how the two most popular blockchains - Bitcoin and Ethereum, deal with this.

Stale Blocks

In Bitcoin, when two blocks reach a person, a fork in the blockchain is created. So no one can be sure which block is a part of the main chain and which is going to be discarded.

Bitcoin follows the rule of the longest chain. This means that the chain with the most blocks will be considered the main chain and the ultimate truth, discarding other forks. This means, which block gets to be a part of the main chain, depends on the next block. Whichever chain receives the next block will become the longer one, and hence will be the main chain discarding the other chain. The blocks that are part of the discarded chain, i.e. not part of the main chain, are said to be stale blocks.

Longest chain is the Main chain

Now you must be thinking if two blocks can arrive at the same time once, why can’t they arrive together a second time, a third time, a fourth time. Actually, they can. This is the reason that once the block with your data becomes a part of the main chain, you should not rejoice at that very moment. It is generally advised that you should wait up to 6 confirmations (or 6 blocks to be added to the chain) to be sure that your block has in fact become a part of the main chain and will not be discarded at a later stage. Although it is theoretically possible that your block might become discarded at any point of time, it is practically almost impossible after 6 confirmations. The probability of a chain getting discarded after 6 confirmations is extremely low. The probability of even two chains receiving blocks at the same time more than once is very low, this eliminates multiple chains increasing at the same time and by waiting up to six confirmations, the chances of even two chains increasing at the same time becomes very low.

Nothing is better than a practical example (although some things are just better left to theory) so here it is -

Bitcoin blockchain receives two blocks A1 and B1 at the same time. So it has two branches now. Let’s say another block comes and points to A1. So A1’s branch becomes the longer chain and hence becomes the main chain and B1 becomes a stale block. In another case- if A2 comes at A1 and B2 comes at B1 at the same time, then the third block would decide if A1, A2 or B1, B2 are going to become stale blocks.

Third Block deciding which chain is the main chain

Bitcoin follows the policy- for one to be winner, others have to lose. Miner whose block becomes a part of the main chain, receives the full reward for block creation while those who produced stales, are not rewarded for their efforts.

Ommer/Uncle Blocks

Ethereum handles this situation in a different way. Stale blocks in Bitcoin are called uncle or ommer (gender neutral term) blocks in Ethereum. Ethereum follows its own version of a protocol called Greedy Heaviest Observed Subtree or GHOST protocol. Instead of following the longest chain rule, it follows the heaviest chain rule.

Heaviest chain means that chain which has the most amount of effort put into creating it. So the chain that took the most amount of effort in forming is considered to be the main chain.

Now let’s say two blocks have come at the same time. So we don’t know which chain should be considered the main chain. In Ethereum, a block not only points to its previous block, but can also point to the block adjacent to it in the chain. The blocks pointed to by a block not as its parent are called its uncles.

For e.g.-

A1 and B1 arrives the same time. The next block A2 arrives and it points to A1 as its parent block. Now in Ethereum, A2 can also hold the pointer to B1 as its uncle. Now say two blocks A2 and B2 arrive at the same time. A2 points to A1 and B2 points to B1. But A2 also points to B1 as its uncle. This means that A2 has had more effort put into creating it because it also includes block B1. Therefore A1←A2 will become the main chain and B1 will become an uncle block to A2. B2 will be discarded.

Why would a miner go an extra mile and put more effort into including B1 block in his/her block?

Ethereum follows the policy- why have one winner when all of us can be winners. Ethereum not only rewards miners of the blocks of the main chain, but also the miners of the uncle blocks. So the miner who includes the uncle block gets a little extra reward and the miner who created the uncle block also gets a significant percent of the block reward granted for the main block. This ensures that people stay motivated and keep mining.

Since the block time (the time it takes for a new block to get added to the chain) of Ethereum is very low (around 15 seconds) compared to Bitcoin (10 minutes), a lot more stale blocks are created in Ethereum compared to Bitcoin. If most of the times the miner’s work is going to go unrewarded, they would lose motivation and stop mining which would make the chain vulnerable to attacks. As Ethereum adds uncles to the main chain, even if the chain is only 5% efficient, an attacker will have to do work of the entire chain (main blocks plus uncles) to become the main chain, which is not possible unless the attacker has more than 50% of the total mining power in the blockchain.

Some more points about uncles —

  • Uncles can get included but relatives with a divergence of two or higher cannot i.e. children of uncles cannot be added to the main chain. Continuing the above example — block B2 cannot be included by A2 which is at the same level as B2 and also no child of A2 can further include block B2 as uncle because it has a divergence of two, or it is child of an uncle.
  • An uncle can get included in the main chain up to the length of 7th generation ancestor. Ancestor limit (k) → 2≤k≤7. In the above example, with A1 and B1, suppose there was also a C1. This C1 was not included by A2 or B2. This does not mean that C1 cannot be added to the main chain anymore. Ethereum allows blocks up to 7th generation of ancestors. Say another block A3 comes and points to A2 as its parent. A3 can also include C1 in it as its uncle(3rd generation).
  • One uncle can be included in the chain only once.
  • An uncle must be a valid block header, but does not need to be a previously verified or even valid block.
  • When a miner includes an uncle block, the miner of the current block receives extra rewards based on the number and generation of uncles included .The miners of the uncle blocks receive rewards based on the generation in which the uncle block was included. The sooner an uncle is included, the more is the reward for its miner. It is entirely possible that blocks don’t include any uncles, it is completely the miner’s choice (although there is a good chance someone else will and outweigh this miner’s chain).

Orphan Blocks

Orphan blocks in Bitcoin are often a point of confusion for many people. Orphan blocks are simply blocks for which a particular node doesn’t have the parent yet. This does not mean the block is invalid or it is not included in the main chain, it simply means that the node cannot verify the block at the moment, and has to ask its peers for its parents first.

Orphan blocks are not a network-wide condition but node specific meaning if one node doesn’t have the parents of the block it has received, it is that particular node’s problem and not a problem of the network that affects everyone.

Since Bitcoin Core 0.10, the concept of orphan blocks does not exist anymore because of changes in the block fetching logic. It is not possible anymore, for a block to be received before its parent has arrived.

These days a lot of people use orphan blocks for stale blocks which creates a lot of confusion. So next time someone mentions orphan blocks, they’re most probably talking about stale blocks.

Conclusion

Hope you enjoyed it and more than that, learnt something new from it. If you find any mistakes, I’d appreciate it if you leave a comment, so that this post can become beneficial for the community.

--

--