paint-brush
Learn the Blockchain Basics - Part 5: Why Blockchains Fork?by@mickeymaler
1,147 reads
1,147 reads

Learn the Blockchain Basics - Part 5: Why Blockchains Fork?

by Mickey MalerAugust 10th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Forking is only one way of updating a blockchain, but it's an important one in the tricky context of decentralized networks. So, fork and reach further!

People Mentioned

Mention Thumbnail

Company Mentioned

Mention Thumbnail

Coins Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Learn the Blockchain Basics - Part 5: Why Blockchains Fork?
Mickey Maler HackerNoon profile picture

The ideas behind forking a blockchain

Forking is only one way of updating a blockchain, but it's an important one in the tricky context of decentralized networks. Another interesting use of forking is to have your own copy of a particular blockchain and be able to do whatever you want with it.

A fork is a word commonly used in the world of open-source software development to describe a project splitting into two (or more) versions of itself, usually following a disagreement on the path to take. In a blockchain context, forking can lead to a “chain split”, a condition where the state of the blockchain diverges into different chains, where each chain starts following separate consensus rules. It is also a method that is applied when everyone is willing to switch to a new version of the software together at the same time. The forking mentioned in this article are forks that are applied to change the consensus rules or to apply them on the same chain, or on the chain that is created as a fork from the original chain. Meaning: forking for blockchains, mentioned in this article, is only relevant in the context of the consensus component.

Consensus forks are a way of allowing a community to change certain rules while maintaining the security that comes with the longest chain rule. The longest chain rule ensures that the network will recognize the “valid chain with most work” as the main chain. A chain's work is equal to the expected number of hashes it would take for someone to replicate a chain of the same number of blocks and the exact same difficulty steps. 

Now, please, allow me to do a little detour. This detour should answer the question: “Why can we sometimes encounter the term “heaviest” instead of the “longest” chain rule in the Proof-of-Work-based (PoW) blockchains?

In the Bitcoin White Paper, Satoshi didn't initially realize that choosing the correct chain by just counting blocks allows for some extremely easy attacks. Bitcoin Version 0.1 only counted the number of blocks to ascertain the main chain. That's why the White Paper just says "longest" chain. The idea of "chain work" was added a little later and that's how the term “heaviest” chain got into use.

Bitcoin's historical “longest chain rule” labeling:

Bitcoin Version 0.1:

  • longest chain rule

Mentions that started to occur by the end of 0.1 to 2018:

  • longest chain rule mixed with the heaviest chain rule

Currently used terms, which refer to a “valid chain with the most cumulative proof of work”, measured using the difficulty target algorithm:

  • "heaviest valid chain"
  • "difficulty-wise longest well-formed chain"

Additional details:

  • The longest chain is the one that carries the most work. The proof of work security arises from a blockchain's heaviness. The heavier a chain is, (which means the more blocks with some heavy PoW a blockchain has) the more secure it becomes since these blocks are harder to “undo”.

Now, back to forking...

Forking is also a way to apply software updates or upgrades, add new features, enhance current capabilities, and improve the reliability of security protocols in a decentralized world. That's right since we are in the decentralized world of blockchains now, we can't do a simple update as we are used to doing on our home computers or our company servers. What we need to do is to apply a new set of consensus rules and wait for their activation. When the consensus rules are changed, and when triggered, the blockchain splits into two forks.  These rules change at a specific block height and the new (forked/updated consensus rules) chain history begins to diverge from the old (previous consensus rules) chain history at that block height.

Before applying the planned changes that modify existing characteristics or add new features, you have to find out if your supporters, miners, and node providers are in favor of these changes or not. This could be done by a public referendum open to anyone or a vote between members of the community. However, when it comes to actually activating a fork there is only one way: miners and economic nodes must run the software in sync to support and enforce the change. Historically, there have been various signaling methods used including miners` and social signaling, see these examples for SegWit:

Forking is particularly useful in situations where people cannot find common ground about a planned blockchain update or change in direction that might go against the blockchain’s original principles or ideas. One of the main benefits behind blockchain forking is that it allows developers to start from a single blockchain, where everyone agrees on the blockchain’s current state, and use that agreement as to the starting point for the future blockchain state. They can separate from the original blockchain, taking the last validated state on that blockchain with them, and continue from there. People simply diverge and start agreeing on another path for the blocks in the new chain.

This leaves us with one big question: What will happen to the original chain after the fork? Well, this depends on whether we are discussing a hard or a soft fork. There can be "soft" forks and "hard" forks, but don't let these terms mislead you. The term “soft” doesn't mean that it will be easy and “hard” will be more demanding. They don't describe the difficulty of the task, but how different the end state of the chain will be after the forking process. However, in some ways, yes that actually is what the terms are referring to:

Soft forks are considered easier because not all miners and nodes have to update for the fork to be safe to activate with no risk of a chain split. Whereas with a hard fork, you generally need all miners and nodes to update to avoid a chain split.

Soft fork

With a soft fork, the rules get more strict. This means nodes running an older version of the software can still participate on the network, but they can't mine new blocks. 

Example: With the old rules, there is a maximum fee of 10 tokens. Under the new rules, the maximum fee is 5 tokens. The old node will not reject blocks that others mined taking 5 tokens, since 5 is less than 10. But if the old node tries to mine a block taking 10 tokens, the other (upgraded) nodes will reject it.

The acceptance of a soft fork is a continuation of the original (still the same blockchain), but enhanced with new code, features, and fixes introduced by the fork.

Applying a soft fork does not create new tokens if the fork does not result in a chain split.

A new chain will not be created if:

A majority (or all) nodes and miners agree to update and support the changes proposed by a soft fork. Then, there will be no chain split because the chain with the new rules will outweigh any version of the chain built by miners who haven't updated (and nodes running the old rules will consider the chain with the new rules to be valid since it's a soft fork). In this case, the soft fork acts as a software update in a decentralized manner.

A new chain (even though not fully supported) will be created if:

A majority of miners stay on the old rules, but a minority are mining on the new rules. Then, there will be a chain split (because those mining on the old rules will be extending a chain that updated nodes do not consider valid).

When a soft fork occurs:

If the majority of miners have updated, there won’t be a chain split since updated nodes and non-updated nodes will both consider the chain built by the majority of miners to be the longest valid chain.

If only a minority of miners have updated, the updated nodes will cause a chain split, as they don't consider the chain built by the non-updated majority of miners to be valid.

Additional reading:

The differences between a hard fork, a soft fork, and a chain split, and what they mean for the future of bitcoin

Hard fork

A hard fork creates two blockchains where the forked one is, essentially, a clone with changed consensus rules of the original one prior to the moment of forking. At the block height of the fork, one path follows the forked blockchain and its new consensus rules, and the other path continues along with the old consensus rules.

With a hard fork, the rules get less strict. This means nodes running an older version of the software aren't able to participate in the new forked network once there is a transaction that relies on the new hard fork rules to be considered valid

Example: With the old rules there is a maximum fee of 5 tokens. Under the new rules, the maximum fee is 10 tokens. The old node will reject blocks from other (updated) nodes as they mine blocks taking 10 tokens, which is more than the allowed 5. The old node could participate in mining, it will just be mining on a different chain than the forked nodes.

A hard fork is a permanent divergence from the previous version of the blockchain, and transactions between these two blockchains are no longer possible. Switching to a hard fork requires all nodes to upgrade and agree on the latest version.

In addition to the previous paragraph:

To make the above statement exactly true, we need to take another two points into consideration, depending on what we mean by "transactions between these two blockchains".

1. There is the issue of replay transactions, where sending tokens on the old chain results in the same transaction being sent on the new chain, and vice versa. Rise of Replay Attacks Intensifies Ethereum Divide

  2. There are blockchain interoperability protocols like IBC that enable users to create transactions on one chain that affect transactions on another chain.

THE INDUSTRY STANDARD PROTOCOL FOR INTER‑BLOCKCHAIN COMMUNICATION

The result of a hard fork is two distinct blockchains instead of one. This is only true if there are miners on either the new hard fork chain or the old pre-hard fork chain who build blocks to extend that chain. If all miners update to the new consensus rules (or if all miners fail to update) then there will only be one chain.

When a hard fork occurs:

If there are miners on both the old rules and the new rules, there will be a chain split, regardless of whether it's a minority or a majority on either side. In case a majority is upgraded, the old nodes will create an active fork as they don't recognize the longest chain as valid.

In contrast to a soft fork, a hard fork creates new tokens and a new blockchain. Users with a stake in the original blockchain automatically obtain a similar stake in the new fork (at a 1:1 ratio).

What do forks mean for cryptocurrencies?

When a hard fork occurs, sometimes, the cryptocurrency tokens are copied, resulting in two versions, identical in every respect except in name. But this is not always the case. Some hard forks result in non-identical versions since a hard fork can introduce any arbitrary rule changes, there could certainly be changes to the tokens. For example, some people in the BSV community want to hard fork the blockchain and give the coins that they think are Satoshi's unmoved coins to CSW. (Even though, if CSW were Satoshi, he should have the private keys and be able to move them himself anyways, right? 🙃)

In addition, the owners of the original tokens obtain the same amount of new tokens. However, the value of the tokens is initially zero, but often rises quickly through speculation. Furthermore, in anticipation of a hard fork, the value of the original tokens can rise as well, since obtaining them prior to the fork means getting more forked tokens “for free”, and the increased demand drives the value up. 

Hard forks usually split the community of the currency into two camps, the “old-chain supporters” and the “new-chain supporters”, each of whom supports the fork they deem more viable. 

Hard forks can be controversial and create volatility, but are necessary from time to time. For example, if an enhancement intended as a soft fork is not accepted by the stakeholders, the owner of the enhancement can choose to diverge their version to a hard fork.

When a soft fork is applied, on the other hand, there are no free cryptocurrency tokens for the taking, but there may be free upgrades (but only if there's no chain split, which isn't guaranteed to be the case.). For instance, if a code change introduced to the blockchain via a soft fork improves the efficiency of the mining, everyone on the blockchain benefits from this. 

For example, in 2017, Bitcoin introduced a soft fork known as Segwit, which increased the available data stream volume through a block. This method increased the capacity of the blockchain by removing signature data from transactions. Therefore, the approval process for each soft fork can be crucial for the future of the entire blockchain.

Conclusion

Forks are a risky event in the life of a blockchain. In a decentralized world, applying a software update is not as easy as updating an app on your phone. A blockchain’s developers may want to use a fork in order to add additional features or fix bugs in the software (or even occasionally, reverse “problematic” transactions as in the case of The DAO hack, which resulted in Ethereum forking into a new chain, with the original chain now called “Ethereum Classic”. Ethereum Classic has hard forked a few times since then too, is the current Ethereum Classic chain the same as the "original chain"? This is mostly a philosophical question, I would argue no though :D). However, developers are only part of the puzzle –  many different groups must be aligned to support an update without a chain split. Miners, node operators, devs, and users must all agree on the future of a chain, and if the majority disagrees, a plan B in the shape of the hard fork may occur. That being said, when a blockchain with its cryptocurrency token forks, it often results in holders of that coin getting some additional assets, so it's not all bad!

Sovryn explorer: If you are hungry for additional knowledge and want to get your understanding of the blockchain forking to another level, continue with the comprehensive article made by Sovryn community blockchain guru, John Light.

Congratulations. You made the fifth step in becoming a blockchain expert.

Have you enjoyed reading this episode? Head over to the Sovryn database full of technological episodes about blockchain technology, written in plain English with the aim to foster basic knowledge in blockchain newcomers.

See You in the next episodes about the Blockchain transaction.