Definition: A fork is a split of the blockchain into two (or more) branches. This happens, if there are two blocks with the same height (or block number).
In this post we explain what forks in blockchain context are, how they can happen and what the result is.
Block C and C’ build upon the common block B. They have the same block height.
Miners follow the protocol and this leads to a single chain. But disagreements about the protocol can arise. This happens usually if a group of developers proposes changes/updates to the protocol. In such a situation, not every miner wants to follow the update, since some updates can have huge implications for miners, wallets, and users. If the community cannot agree on a compromise, this can lead to a fork.
Since both branches share the same history from before the fork, coins belonging to one address before the fork belong to this address on both branches after the fork.
There are three main reasons for forks.
- Race conditions
- Network split
- Introduction of new protocol rules (hard forks and soft forks)
The first reason is that there are two miners accidentally finding a block at the same time. In such a situation we have a so-called race condition. Typically, if the blockchain network latency is low enough and the block finding time is high enough such situations resolve quickly without disturbing the network significantly.
If a certain part of the network is disconnected from the rest of the network, blocks and transactions cannot be sent to all nodes. The result is that each network fraction builds on its own chain.
Network splits can occur for various reasons. Technical issues or natural disasters might disconnect large geographic areas from the rest of the internet. Also, political decisions could be the reason for such a disconnection.
If the network reconnects after some time, the longest chain would be chosen as the canonical chain. This makes a network split very dangerous. All transactions which were created after the split and which were processed in the shorter chain would suddenly disappear.
New protocol rules
If new protocol rules are introduced, accepting those rules is voluntary. Each miner can decide whether or not to follow the new rules or sticking to the old ones. The consequence of this is that we might have a few miners sticking to the old rules and a few following the new ones.
There are three basic outcomes:
- Blocks created according to the new rules are invalid according to the old rules. But blocks created according to the old rules are still accepted by the new rules. This means that the protocol got less restricted. An example could be the increase of the maximum block size.
- Blocks created according to the old rules are invalid by the new rules. But blocks created by the new rules are still accepted by the old rules. Here, the rules got stricter. This could happen if the block size is reduced.
- The rules are incompatible. This could happen if a new hashing algorithm is introduced for example.
In the following topics, we explain those implications in-depth and we introduce the concept of hard fork and soft fork.
Explanation: A hard fork (sometimes also spelled hardfork) is a protocol change that is not forward compatible. Blocks created according to the new rules are invalid under the old rules. To prevent a split (fork) of the chain all nodes must update their software.
There are two possibilities. The new rules are incompatible with the old rules (hashing algorithm, difficulty rules, signature algorithm, etc.) or they are less strict (like increasing the maximum block size from 1 MB to 2 MB or accepting certain scripts that were invalid before).
Let us assume that the majority of miners updated their software. The protocol change was introduced after block B.
The first block that is appended to the chain is block C (green). It follows the new rules.
If now a miner that is still following the old rules creates a block C’ (yellow). It cannot be appended to Block C because from the miner’s perspective this is an invalid block. Instead, it has to build upon block B.
Now, the updated miners have the choice. They can either build upon block C or block C’. This is possible if the new rules are stricter than the old ones. If they are incompatible, the updated miners can only build upon block C. But even if the rules are backward compatible, it is likely that the next new miner chooses block C over C’ because he should have heard of it earlier.
Let us assume that the next two miners follow the new rules. This is reasonable because we said that the majority of miners have updated their software.
If we continue with this, we see that this chain has split into two branches. While one is following the old rules, the other one follows the new ones. It is impossible for them to be merged into one chain.
Explanation: A soft fork (or softfork) occurs if the new blockchain protocol rules consider the old rules as invalid. But according to the old rules, new blocks are valid. That way the softfork is backward compatible. It is possible to say that rules get stricter in a soft fork.
Again, we assume that the majority of the miners have updated their software.
Now, a miner following the new rules creates a block C (green) and appends it to block B.
After that, a miner following the old rules finds a block (yellow). He will choose block C as the tip of the chain as we said that the new rules are less strict.
If now a new miner finds another block it has to choose block C as the tip of the chain. Block D is invalid according to the new rules he follows. And since the majority of miners updated their software it is likely that two or more miners find consecutive blocks. Block D orphans.
If another old miner finds a block in this situation, it will add it to block E’, since this is the longest valid chain.
A new miner again has to choose block E’ and again the old block (F) orphans. The longest chain is A-B-C-D’-E’-F’-G’.In the end, new miners always build the longest chain and old miners will be puzzled that their block always orphaned. They don’t earn any mining rewards and thus have an incentive to update their clients.
A detailed explanation of softforks can be found here: https://en.bitcoin.it/wiki/Softfork
It can be a rational design choice of new features to make sure that they are softforks, since this creates some pressure on old nodes to update their software while it prevents a split of the chain.
Sometimes it is desirable to introduce protocol changes which would actually be a hardfork as a softfork. This is possible with new transaction types.
Here, sender, receiver, and miners need to understand the new transaction type.
Softforks can be further divided into miner-activated softforks (MASF) and user-activated softforks (UASF).
If a majority of miners update it is called miner activated softfork. If full nodes enforce the new rules instead of the miners, this is called a user-activated softfork.
Security concerns of soft forks
If only a small majority of miners of a blockchain have updated their software, many orphaned blocks occur. Such orphaned blocks can create a fake confirmation as they are later overtaken by the longer chain. Attackers could take advantage of this with a double-spending attempt. They could create a transaction that is valid under the old rules but violates the new rules. An old miner would take this transaction into its block, which would look like a confirmation.
But after a while this block would be overtaken by blocks following the new rules.
A double-spend transaction is included in the old block D. There might be one old block mined on top of it letting it look like a confirmation.
Valuation after a hard fork
The valuation of the coins in one blockchain branch depends on its future outlook. Usually, one branch will be abandoned after a while. But if there is strong enough community support that ensures maintenance, mining power, and trading, both branches can turn out to live for a long time. This happened for example with Bitcoin Cash and Ethereum Classic.
In the best case, the valuation of the funds doubles after a fork.
This might also have some taxation implications.