“A blockchain is a “chain” of blocks, where each block stores a pointer to its previous block.”

As the blockchain continues to grow by adding more and more blocks, some scenarios may lead to the split of blockchain into one more potential path. For example, if one or more blocks point to a different block, this causes a split, producing a second blockchain that shares its history with the original but moves forward in a new direction. These splits are known as forks in blockchain.

We have already seen forks in our previous article briefing double-spending. In this article, we will discuss some situations that cause forks.

Bitcoin uses proof of work (PoW) consensus where the miners compete to solve a cryptographic puzzle. The network nodes will accept the block produced by whoever solves the puzzle first. What if more than one miner solves the puzzle simultaneously? What happens then??

Assuming the transactions within the blocks are valid, both blocks stand valid. Both blocks get circulated in the network. When a node receives the blocks, it may have to consider both the blocks for the time being.

The blockchain will have a branch at this point since there are two blocks pointing to the same previous block (parent block). Now we have a “fork” in the network. Which branch should be considered while mining the next block?

The decentralized nature of blockchain allows each node to independently decide which block should be added to the main chain. Some nodes may proceed with the blue block, and others with the green block. A broader picture of the blockchain network may look like below.

This depicts a disagreement among the network participants regarding the current state of the blockchain. However, the whole network should adhere to a single chain for the proper functioning of the blockchain system. Let’s see how??

Well, like any situation where multiple opinions exist, can we go for voting ?. Let the majority of the network decide the next block in the chain !! Though the idea is simple, its implementation in an extensive network like bitcoin will increase the complexity of network functionality. Forks can be expected anytime. For every fork, we will require an additional processing step to get the network’s majority opinion. To avoid this extra overhead, Bitcoin suggests an alternative solution for forks.

PoW is a computationally complex process. The selection of a single chain is made based on the “longest chain rule”. The block that required more work, spending maximum hashing power, will be added to the chain. This block will be used as the parent block of the following block to be mined, and the other branch will be stored for future reference.

Due to varying network delays, some nodes may first receive the blue block rather than green and start building the next block. There may be a chain after the blue block, which was initially discarded.

The chain’s length is measured by the amount of work done rather than the number of blocks in it. The total amount of PoW spent to create a chain is calculated by adding the difficulty recorded in each block in that chain. The heavier the work, the longer will be the chain. The blocks in the shorter chain will be considered stale blocks. There will be no reward for those who mine these blocks. So the longest chain rule is applied again.

Nodes may also receive orphan blocks, that do not have a valid parent block. Orphan blocks are saved in a memory area until their parents are welcomed.

In this scenario, fork resolution is based on the difficulty of the consensus algorithm. By selecting the greatest-difficulty chain, all nodes eventually converge to a single chain. Bitcoin has chosen 10 minutes between block productions to reduce the chances of forking. The transactions included in the discarded blocks will not be considered as happened. The Bitcoin network suggests users wait until six blocks are added on top of a block to confirm a transaction.

Based on the split and the blockchain functioning effect, the split can be categorized. Forks may occur for a variety of other reasons. We will see them in detail in the following article.

Stay tuned…..