In the era when blockchains were very popular, the most term relevant to blockchains was decentralization, and the fork came next.
Then what is a fork? In the simplest words, the forks are software updating for blockchains. Software updating is most common from the days when we owned our first computers to the days of owning smart phones. The Windows has been updated from Win95 to the current Win10, and the Snapchat versions have also been updated for countless times. But do you ever wonder why the concept of fork has never been heard before? Why is the software updating known as the fork in the world of blockchain?
Why is there a fork?
Now, let’s think about what usually happens if the software we are using needs to be updated. For example, if our Snapchat version needs to be updated, we will be reminded by the prompt first, right?
Then we will have two choices, to accept updating or refuse updating. In general, we will choose to accept the updating because the new version of software tends to be better than the previous one, for example, more features will be added or some bugs will be fixed.
What if we refuse updating?
Nothing will be changed, right? We can still use the software and its name is still Snapchat. In fact, all the software we are using, including the Snapchat, are centralized, the so-called client–server model.
Bitcoin belongs to the decentralized + blockchain, which is equivalent to storing a copy of all transaction data for each computer. Those transaction data are stored in the computer in the type of blockchain. So, the special features are listed as follows:
Every computer has stored a copy of blockchain.
All new transactions will be packaged together in a new block and then broadcast it through a certain computer.
A new block can be recorded on the chain only when it’s confirmed by a certain number of computers in the network.
Once the blocks are recorded on the chain, they will stay there forever and cannot be tampered and deleted.
If I was a member of the bitcoin team and I found an obvious security bug in the program, then we decided to upgrade. However, the new blocks generated after the upgrading must be recognized by a certain number of nodes in the entire network before being recorded in the chain, that’s the basis of the bitcoin consensus mechanism.
Therefore, to make new blocks be broadcast and successfully recorded, we must update the block generation and verification protocols and encourage all workers to upgrade their mining program for the new protocol. It’s just like we have improved the game rules and fixed for the bugs so as not to leave chances for the criminals.
However, the new rules must be recognized by most players. A decentralized world is such a democratic mechanism in which the minority must obey the majority. For updating, we usually need to set a starting time, which can be controlled by the block length, for example, if we decided to allow the upgraded blocks to be recorded in the 41578th block. Since the miners in the entire community will not update the software at the same time, we will find that some miners are using a new version of program while others are still using the old one, so sometimes the new version of blocks will be produced while sometimes they are still the old blocks. The first 41,578 blocks are still of the old version and they should be immune to any changes. Then, the new version of blocks will naturally be forked.
There are two cases about the fork.
The first one: the new rule is a subset of the old one, which means we make some improvements based on the old rules to make it stricter. In this case, the new version of blocks will be verified by the old mining software, but the new software will certainly not be able to verify the old blocks. For instance, I opened a vegetarian restaurant and I decided to change it to a full-vegetarian one. All my old customers would certainly accept the new recipes, but it’s not the case if vice versa.
Such a case is called a soft fork. It’s shown as below:
Strictly speaking, soft fork should not be considered as a fork, because even if the program is not upgraded, it can still accept new versions of blocks. The feature of forward compatibility allows the new and old versions to be recorded on the same chain.
There is such a logic in the bitcoin program: if more than 95% of the 1000 blocks (including the latest blocks) are of new versions, the program will regard that the new rule has reached consensus by default, so the old versions of blocks will no longer be recorded on the chain. In this way, it will force the rest 5% of workers to update their programs to realize software upgrading across the entire network.
The new rules proposed by the soft fork are normally beneficial to all workers, so everyone will have the motivation to start upgrading.
The second one: the old and new rules are completely incompatible. In this case, if the mining program is not upgraded, it’s impossible to verify the new version of blocks. So, the old version chain will always exist while the new version of blocks will be forked out separately. Such a case is called a hard fork.
It’s shown as below:
In this case, the mining reward generated by the new version of blocks cannot be called bitcoin any longer. If they were still called bitcoin, the transaction history on both forks can never be synchronized and a lot of history data will be missing, so it needs a new name. For example, the BCH is the hard fork of bitcoin.
It’s interesting that both forks are separated from the same chain. Due to the non-tamper feature of the blocks, the transaction records before the fork are valid by default on both chains. In other words, if you own a certain amount of bitcoin before the fork, you can get the same amount of coins after the fork.
Generally, the hard fork will break the paradigm of the original rules, or the new rules are so controversial that they will never be unanimously approved by the workers of the entire network. Therefore, the original chain will exist forever, which means the coexistence of both cryptocurrencies.
The new and old rules represent the different views of the workers in two mining camps. For the sake of the cryptocurrency they support, they must compete for hash resources.
According to our viewpoint, the hard fork will distract a large amount of hashrate and waste a lot of resources, so it’s best not to conduct “hard fork” if possible.
At the same time, it’s also a major drawback of decentralization, because it’s the workers themselves that will decide whether to conduct software upgrading and the blockchain structure results in poor scalability, therefore the software innovation and updating efficiency are far inferior to that of the centralized software.
This is the reason why there are few heavyweight decentralized applications. It’s impossible to create an application at one stroke because it should be gradually improved based on its prototype to approach perfection eventually.