Forking in Blockchains: Understanding soft and hard forks for successful upgrades

Forking in Blockchains: Understanding soft and hard forks for successful upgrades

Introduction

The decentralized nature of blockchains allows different participants(nodes) to validate and verify transactions on the network securely and transparently. This setting can however cause disagreements among participants on which rules to follow to reach a consensus on the state of the network.

Some participants can choose to create a new version of the blockchain that uses the rules they agree upon. This is what is known as forking.

In this article, you will understand what forking is, the different types, and its significance on the state of the network.

What is a node?

A node is a computer or device that is connected to the blockchain network and is responsible for verifying, validating transactions, and broadcasting them to other nodes. A node has special software that contains the rules which it uses to verify the transactions on the blockchain network. The most common type of node is the full node. This type contains the full copy of the blockchain ledger which is used to track how the transactions have been happening right away from the first transaction in 2009.

How are blocks created?

All nodes on the network are always in a race to find the next valid block to be added to the chain. When a node finds a valid block, it broadcasts it to the entire network to be verified by other nodes. When other nodes that were in the race receive this valid block, they confirm that it is indeed valid, stop what they have been doing, and immediately embark on finding the next valid block using the received block as a reference on the chain.

So the whole process is like this: node receives the latest block and tests it against the rules. if the block is valid, the node starts the process of creating a new block while referencing the latest block.

All nodes across the network have the same set of rules that they use to reach a consensus on which block is valid or not. Situations arise when the current set of rules known across the network needs to be improved to address some bugs or even introduce new features on the network.

The nodes now have to update the set of rules that they use to reach a consensus. This process is not automatic. Every node that agrees to the new rules has to manually download and install this update. The node which does not agree to the new rules won't download and update its software.

This whole situation of some nodes updating their software and others choosing not to update their software leads to disagreements on which set of rules to use to reach a consensus. A node running the old software can create a valid block only for it to be rejected by the node running the updated

Some nodes running the old software can confirm a valid block only to be invalidated by the nodes running the updated software if the new software contains rules to invalidate it. This leads to a fork in a network.

Types of forking.

Soft fork: This is a type of forking that is meant to add a new feature or improve the security of the network, and it is backward compatible. Nodes can choose to either upgrade to the new rules or not. Nodes that don't upgrade to the new rules can still communicate with the nodes that have upgraded and vice versa. However, as time goes on, all the nodes have to upgrade to the new rules as the blocks created with the old rules will be rejected.

Hard fork: This type of forking is intended to introduce new rules to the network and is non-backward compatible. The nodes that upgrade to the new rules have no way to communicate with the nodes having the old rules. Two blockchains are created as a result of this, with one network consisting of the nodes that agreed to keep with the old rules, and the other network having the nodes that have upgraded to the new rules.

A typical example of a hard fork is the 2017 Bitcoin SegWit hard fork that led to the creation of a new blockchain called Bitcoin Cash. Read more about it here.

Which type of fork to utilize?

Depending on the situation, one type of fork is preferred over the other. In 2015, bitcoin implemented the BIP66, a proposal that would introduce stricter rules for validating transactions, a soft fork was preferred over a hard fork since there were no significant changes to be made in the bitcoin core program.

Also, the Ethereum network implemented a hard fork in 2016 to help reverse the attack on a Decentralized Autonomous Organization(DAO) where millions of dollars had been compromised by the attacker. With this fork, millions of dollars were saved from being stolen.

Conclusion

Forking is a significant part of blockchain and network technology that allows for innovation, improvement to the protocol, and evolution of the network protocol to facilitate the ever-changing needs of the users. When executed properly, it can lead to significant improvements in network performance. However, on the other side, it can also lead to division and fragmentation of the community if there is no mutual agreement.