What is a hard fork?
Bitcoin developers can propose a permanent upgrade (change) in the Blockchain, as the software is open source and everyone is allowed to do so. As this change is announced before the hard fork, Bitcoin nodes are thereafter requested to vote on the change, by updating their software to the new version, which contains the upgrade. If the vast majority (around 95%) of the network agrees upon the changes, then the nodes with the old version will be either forced to update to the new one or the chain will split up, creating a new cryptocurrency. In the case of a hard fork, all the previously valid blocks become invalid afterward. An indicative example of a hard fork is the Bitcoin community’s failure to achieve consensus over the adoption of SegWit2x protocol, which lead to the fork that created Bitcoin Cash in August 2017.
If the majority does not agree on the upgrade, then the Blockchain will continue with the existing rules, while the blocks that will be generated by the updated nodes will be rejected and the participants will be split to a new cryptocurrency.
What is a soft fork?
As soft fork happens when new changes are applied in the Blockchain, but they are backward-compatible, meaning that the old nodes will still be compatible with the new changes. A soft fork requires the minimum majority’s consensus (51%) to get in-effect. An example of a soft fork is the implementation of the Segregated Witness protocol. With SegWit, Bitcoin blocks become four times larger virtually, increasing the number of transactions that can fit in a block.
UASF – User Activated Soft Fork
A UASF is a change in the consensus rules that is enforced by single users and businesses, rather than relying on the miners’ consensus. This can be succeeded by applying the upgrade on their Bitcoin clients and ignoring the new blocks found by the miners. In such case, miners would follow the new rules, with the fear of losing their rewards from the orphaned blocks.
Accidental fork – The longest chain
Soft and hard forks occur, in the case of a consensus rules change. However, accidental forks may also happen under the same rules. As miners “work” to find the next valid block, it could be possible that two miners find a block of the same height with a small-time difference. These blocks will then start to be propagated in the Blockchain to achieve consensus from different parts of the network. These two blocks will remain on hold, and it is the following block that will determine which of the two will prevail and get permanently recorded in the ledger. The part of the network that will find the following block will also adopt the previous one that belongs to the longer half of the split chain. The orphaned block will be rejected and marked as “orphaned” and its contents will be placed in a pool of unconfirmed transactions, in order to be included in a subsequent block by the miners.
It is the time intervals between blocks, that determines the possibilities of an accidental fork. Generally, Blockchains with faster block times (e.g., Litecoin and Bitcoin Cash) are more vulnerable to orphaned blocks and double-spending attacks.