Longest Chain Rule. Examples of Blockchain Forks.
Why would miners always switch to the longest chain of a blockchain and abandon a shorter chain that appears as a result of a fork? The answer is simple: because of the self-interest. Miners on the Bitcoin blockchain are getting rewards in Bitcoins for creating blocks of the bitcoin blockchain. This is exactly how the Bitcoin blockchain adds coins to circulation. Satoshi Nakamoto has designed the network in such a way that there can only be 21 million bitcoins in circulation total. From the blocks 1 to 210,000, the Bitcoin network has been adding 50 bitcoins per block into circulation. Then, the reward split in half and became 25 bitcoins. The reward splits every 210,000 blocks and when the network reaches 21 million bitcoins in circulation, the reward will go to zero. You can see the current number of Bitcoins in circulation, the date of the next split of the reward, the total number of Bitcoins left to mine and other interesting stats about the Bitcoin network by visiting http://www.bitcoinblockhalf.com/ . The idea of Nakamoto was that miners on the network will keep mining new blocks of the blockchain after they mine all 21 million bitcoins because they will be getting paid by the users of the network in the form of transaction fees.
All of this means that miners are inherently interested in mining new blocks on a blockchain that is growing. If a miner keeps mining blocks on a blockchain that is no longer longest, it means that the miner will be getting less profit compared to the profit for mining on the longest blockchain. All transactions that are happening on the shorter chain do not become a part of the longest chain, which means that if miners stay on a shorter chain, they will not get any rewards from the longest chain, be it in the form of transaction fees or network rewards for creating the blocks of the blockchain.
The combination of proof-of-work and of the longest chain rule makes the Bitcoin and Bitcoin Cash blockchains extremely secure.
Planned and contentious forks
Forks can be planned or contentious. A planned fork is when the community agrees that the network needs an upgrade and then software developers create the upgrade. Parties on the network then discuss when the upgrade will go in effect and upgrade their software. A contentious fork is when a number of members of the community disagree with a direction that the community is going and decide to issue an upgrade without getting support from the entire community.
Because blockchain technology is so new and unregulated, blockchain networks, including Bitcoin, have had both contentious and planned forks.
From the software standpoint, a fork can be soft or hard. The difference between soft and hard forks is about backwards compatibility. Soft forks are backwards compatible with the previous version of the software. Hard forks are not.
Examples of hard and soft forks
Here is an example that illustrates the difference between a soft fork and a hard fork. Let’s say a blockchain network has five nodes.
a node on a blockchain network is a computer that has a full copy of the blockchain. While you typically don’t have to download the entire blockchain to participate in transactions and can only download a wallet, it is the nodes that provide blockchain networks with integrity and security because as long as there is even one copy of the blockchain, the chain will be able to restore itself and keep functioning. You can see a list of all Bitcoin nodes that are online as you are reading this article by checking this website https://bitnodes.earn.com/ and the map of the Bitcoin Cash nodes is here: https://bchnodes.online/
***end of explanation note***
Three nodes, N1 through N3, have not upgraded their software, and nodes N4 and N5 did upgrade their software. If the node N5 creates a new block of the blockchain, all the nodes will accept the block because the software is backwards-compatible. If one of the nodes N1 through N3 is also a miner and creates a block of the blockchain, nodes N4 and N5 will not accept it as a valid block because the new software will not accept blocks from the old software.
A hard fork is a modification of software that is not backwards-compatible. In the same example as above, if nodes N1 through N3 do not upgrade their software and N4 and N5 do successfully go through an upgrade, then no matter what blocks N1, N2, and N3 create, N4 and N5 will reject them and the opposite will also be true. In essence, this means that once nodes choose the network after a hard fork, they stay on the network and do not participate in what happens on the other network. The fork of Bitcoin Cash was a hard fork from the Bitcoin network.
In practical terms, this means that up to August 1, 2017, or up to the block #487559 Bitcoin Cash and Bitcoin have the same blockchain, but they are not compatible after the block #487559. This also means that those who had Bitcoins on August 1, 2017, automatically got the same amount of Bitcoin Cash coins in addition to their Bitcoins. However, this does not means that when a blockchain network gets a new fork, the amount of money automatically doubles because a fork typically decreases the value of the original coin.