Blockchain is a decentralized network where many computers (called nodes) work collaboratively to validate transactions by the use of the software present in the network. They verify the ledger and ensure that the network is stable and secure at all times.
A fork is a change in protocol on how a given blockchain network functions as opposed to the previous version. It is a collective agreement on a software update.
Each fork is unique and results in a different outcome. Forks are mainly like software updates. These updates can be minor or major depending on how they seek to change the way blockchain functions, the way transaction happens and get validated.
Forks can happen for multiple reasons as mentioned below –
- Fixing a security loophole in the current system
- Add new functionality, changing one core rule or modify existing features
- Reverse transactions
The nature of these changes determine whether a fork is a hard fork or a soft fork.
If the code development team implements feature updates that renders the previous version of blockchain incompatible, it is called a hard fork. The older version is rendered invalid as a result.
For example, change in consensus protocol rules can be considered as a hard fork. Also changes in mining algorithm, increase of block size is considered as hard fork.
Let’s consider that a blockchain validates blocks of size maximum 2 MB. Now a hard fork happens which increases the maximum block size to 4 MB. Now if a new block of 1 MB has to be added to the blockchain, both the old version as well as the hard forked new version will be able to add the same to the blockchain. However, if the block size is 3 MB, the older version will not be able to add the block while the newer version will be able to add it to the blockchain.
Hard forks are complex and risky.
Contentious Hard Fork
Whenever a hard fork deployment happens, the users have the choice to either accept or reject it. This can lead to a split in the blockchain network because members who do not agree to the update will have a separate ledger with respect to the ledger with the members who agree to the update.
Whenever a hard fork is not unanimously agreed upon by all the members of the blockchain network, it is called as a contentious hard fork.
An example of occurrence of a contentious hard fork happened during The DAO Attack. The Ethereum community was split between whether to accept the hard fork and return the amount stolen to the DAO owners or to not (as per blockchain philosophy). When the hard fork finally happened, those that did not agree with the fork formed a separate Ethereum blockchain called as the Classic Ethereum.
When the updates to the blockchain is compatible to the existing version of blockchain, it is called a soft fork.
For example, creation of a new class of address is a soft fork. This happened in SegWit (for bitcoin). Other examples of a soft fork will include cosmetic changes or any other change that does not interfere with the structure or consensus protocol followed during block validation and addition.
In our example of hard fork, we had considered a block size increase from 2 MB to 4 MB. Now suppose the block size decreases from 2 MB to 1 MB. Both the older version and the newer version can accommodate a block of 512 KB or 0.5 MB. This fork is compatible with the older version and hence will be considered as a soft fork.