Unless you’ve been living in a cave for the past 9 years, then you’ve probably heard about cryptocurrency forks.
Bitcoin Cash was probably the most hyped, feared, loved, talked about and scrutinized fork of all – and it happened during the greatest crypto bull market in history.
This attracted much attention to the concept of a fork and had investors wondering what this would do to their Bitcoin stashes.
All About Forks
In this article we take a look at the basics of why a fork happens and cite some examples to show you that even unplanned forks can be dealt with.
We’ve discussed consensus mechanisms and how the blockchain works, so today we’ll talk a little more about what happens when the consensus mechanism is either forced to decide one way or decides one way because of brute force.
The Blockchain Data Structure
The blockchain is a sequential data structure. It does not have branches in it, each block follows exactly one block that was mined before it.
The above illustration, courtesy of Wikipedia, shows a data structure called a linked list. A blockchain in normal operation follows this structure, except for the fact that the previous block does not point to the next block like it does in a linked list, but instead each subsequent block points to the previous one instead.
In the Bitcoin blockchain, each block header contains a field called hashPrevBlock which consists of 32 bytes that point to the previous block in the blockchain.
(Fun fact: The very first block is called the Genesis Block and points to nowhere!)
There is no other pointer in the Bitcoin blockchain header, which means each block cannot point to more than one previous block, it must point to exactly one previous block.
So what happens if about 50% of the Bitcoin network mines a block that points to the previous one and the other 50% mine a block that also point to the previous block? We get a fork.
Because for the next block after this one different block, each of these now split chains will point to the previous (wrong) block which will be different for each end of the chain.
50% of miners will happily continue on mining one chain and the other 50% will continue on mining the other chain.
This kind of fork is (very) undesirable. It is uncontrollable and happens because the consensus mechanism did not reach a true majority, solutions tied at approximately 50% “votes” and, as a result, accepted two different (but valid) block solutions.
A similar situation to the one just described happened during Bitcoin block number 225430.
Nobody noticed at first, but a part of the network (which later was found to have upgraded to version 0.8 of the client) went one way and the other half went a different way.
It took approximately 6 hours for the problem to be noticed and corrected.
Vitalik Buterin, then (year 2013) a writer at Bitcoin Magazine, explained how this fork was fixed:
Buterin also remarked:
This incident will go down in history as one of the closest moments that we have come to the underlying Bitcoin protocol actually failing.
The above situation is an unplanned, accidental fork which was caused by a bug in the 0.8 version of the Bitcoin Core client.
Vitalik’s excellent explanation of the technical background of the bug has all the details about it.
For us, it suffices to know that something caused a part of the network to reach a consensus about one path and the other part of the network to reach a consensus around a different chain. This, of course, indicates a lack of consensus and, as Vitalik remarked, could lead to a catastrophic failure.
In fact, something like this is the sum of all fears in the Bitcoin technical community.
The reason why, for so many years, Bitcoin did not gain a lot of value is because to many people something like this would eventually be exploited and Bitcoin would be taken down. This, of course, did not happen and Bitcoin has survived all the worst attacks that could be devised against it.
Hard forks, as implied by the name, are forced upon users by a mandatory software upgrade. A hard fork happens when there’s a change to the format of transactions, or something on the protocol was changed, so that a new format of blocks, transactions or other data will only be accepted by newer clients.
When a hard fork happens, old software clients will stop working and might show error messages, lock up, stop showing future transactions and so on. Bitcoin has never hard forked. All changes to Bitcoin have been backwards compatible.
In a soft fork, old software continues to recognize new blocks as valid. Those who do not upgrade are not booted off the network.
In a soft fork, a change happens to Bitcoin which makes new software reject something in previous blocks, causing it to fork into a new “correct” chain. The SegWit upgrade to Bitcoin protocol was a soft fork during block 477120 (August 2017).
Forks can also be maliciously induced. For example, if someone found a bug on the cryptocurrency’s reference implementation used by the majority of full nodes, they would be able to try to direct the blockchain in a different direction using an exploit. We saw how the 2013 Bitcoin fork was due to an accident – a bug which appeared during the upgrade from Bitcoin 0.7 to 0.8. What what if such a software issue were used on purpose to induce a fork? This is what happened to Zcash cryptocurrency in February of 2017. Someone used a bug on the Zcash reference implementation to induce a fork which lasted for approximately 24 hours. It was quickly detected and fixed by the Zcash developers.
As you can imagine, reversing a malicious fork is no easy task. Clients must be patched and everyone must upgrade to the patched client in order to join the correct blockchain path. And a lot of controversy usually surrounds this kind of decision.
The ideology of cryptocurrency is that of complete financial freedom with no interference or interventions from any centralized authority. But that’s not what happens during a fork reversal. Were the system to be left to its own after a fork happened, it’d be impossible to rejoin the two chains. People would have already sent or received money on the new chain and reversing the fork would mean telling these people that their transactions never happened and that the game would restart a few blocks behind.
This is similar (though in the opposite direction of forcing a fork, not reversing one) to what happened when The DAO was hacked and the Ethereum developers, led by Vitalik Buterin, decided to hard fork Ethereum and undo the multimillion dollar DAO heist by force.
There was disagreement about this, as the libertarians and idealists of the Ethereum project thought this was State-like intervention in the system and would violate the decentralization rule (it did, in fact, violate all the main ideals of cryptocurrencies) and thus a second fork happened : Charles Hoskinson and others disagreed with the Ethereum fork and left the project, forking Ethereum into two: Ethereum Classic (ETC) and “new” Ethereum (ETH).
The latter was forked and its blockchain did not include the DAO hack, but ETC did. In practice ETC is the “original” Ethereum blockchain.
We hope this quick intro to blockchain forks has helped clear up the concept!
Bitcoin Hard Fork Illustration: Egidio.casati by CC via Wikipedia