What is a fork?
Fork, in programming terms, is an open source modification. Usually, the branching code is similar to the original code, but there are important modifications and two comfortable “branches” that coexist. Sometimes a fork is used to test a process, but with cryptocurrencies, it is often used to make a fundamental change or to create a new asset with the same (but not equal) characteristics as originally.
Not all forks are intentional. With a widely distributed open source base, a fork can happen accidentally when not all nodes copy the same information.
One thing to keep in mind with forks is that they have a “common history”. The trading profile on each chain (old and new) is identical before splitting.
What is hard fork?
A hard fork is an event where a blockchain is “divided” into two separate blockchains that run parallel to each other, each with different parameters from a previous common chain. If older versions continue to run, they will end up with a different protocol and with data different from the newer version. This can lead to significant confusion and possible errors.
With bitcoin, a hard fork will be needed to change defined parameters such as block size, difficulty mining algorithms, additional information limits that can be added, etc. Changing any of these rules would cause blocks to be accepted by the new protocol but rejected by older versions and could lead to serious problems – possibly even losing money.
For example, if the block size limit is increased from 1MB to 4MB, a 2MB block will be accepted by nodes running the new version, but rejected by nodes running the older version.
Let’s say you have two blockchains, one blockchains has both older and newer version blocks, and another blockchains only have older version blocks. Which chain grows faster will depend on which nodes are authenticated the next blocks and may eventually have additional split sections. It is feasible that two (or more) chains can grow in parallel indefinitely.
A hard fork is likely to be very messy. It also carries risks, as it is possible that bitcoin is spent in a new block which can then be spent back into an old block (since sellers, wallets, and users running the previous code will not discover spending on the new code that they consider invalid).
The only solution is for one branch to be abandoned in favor of the other, which involves some lost miners (the transactions themselves will not be lost, they will only be reallocated). Or, all nodes will need to switch to newer versions at the same time, which is difficult to achieve in a decentralized, widely spread system.
What is soft fork?
A soft fork is basically the opposite of a hard fork, whereby the new changes made remain backwards compatible with older versions.
Example: If a protocol is changed in a way that tightens the rules, makes an aesthetic change, or adds a function that does not affect the structure of the blockchain in any way, then the new version blocks will be accepted by the older version nodes. However, it is not the opposite: the newer, “tighter” version will reject the old version blocks.
In bitcoin, older miners will realize their blocks are being rejected and will be forced to upgrade. As more miners upgrade to the latest version, chains with mostly new blocks become the longest, thus increasing the number of old version blocks created and causing more miners to upgrade. This process ensures that the system adjusts itself.
For example, let’s say the community has decided to reduce the block size to 0.5MB from the current theoretical limit of 4MB (with SegWit blocks.) The new version nodes will reject the blocks with the old limit and will build on the previous block (if it is exploited with an updated version of the code), which will cause a temporary forking.
Soft Fork doesn’t carry the double spending risk that makes it difficult for the Hard Fork, as sellers and users running older nodes will read both new and old versions.
The difference between hard fork and soft fork
Basically, both types of forks serve different purposes. Continuous hard forks can divide a community, but pre-planned hard forks have the potential to allow for software modifications with everyone’s consent. But hard fork isn’t the only way to upgrade the software behind a cryptocurrency.
In contrast, soft fork is considered a more secure alternative with backward compatibility, meaning nodes that don’t upgrade to newer versions will still view the chain as valid. A soft fork can be used to add new features and functions that do not change the rules that a blockchain must follow. Soft fork is often used to deploy new features at the programming level.