What is forking in blockchain?

Forking in blockchain

A blockchain is a data storage system that stores information and data in chunks of memory called blocks. Each block is recognized on the chain with its unique address. We generate the address of the next block in the previous one, a new block also contains a hash of the previous block and keeps the chain going.

Forking

To fork in Blockchain means to divide any given task into subtasks. We can use forking to achieve our desired goals. This results in faster computation because it breaks down the problem into smaller parts.

We encrypt each block after storage, and then add a new block

Hash functions and storage

A blockchain contains a hash function that allows it to generate the address of every block. This storage mechanism enables the blockchain to store data in a decentralized manner, that is, in different and multiple locations. Since a blockchain stores data on a decentralized principle, it makes every user a stakeholder of data and transactions. We develop a consensus mechanism before we add any new block of data.

A fork divides program or instruction into multiple smaller parts for smoother flow and execution

Advantages of forking

Once we divide a program or instruction into multiple sub-instructions, we reduce the processor’s load. Also, we can evenly divide resources among the smaller parts with ease. The resource allocation ensures that the program has all the required tools and utilities at its disposal for quick execution. The smaller parts then achieve their respective purposes and the whole program moves closer to completion.

Forking in blockchain

Forking is a very commonly used method in operating systems, but it also occurs in the blockchain.

Forking in blockchain occurs when a single chain diverges into two other chains. The process works when a single block generates two other blocks. This does not affect data storage, but both blocks have different addresses and, therefore, store different information. Problems may occur when we link information from the previous block, as both new blocks emerge from the same predecessor.

Two blocks emerge from a single one due to forking

Forking in blockchain occurs due to several reasons, such as:

  • Change in protocols
  • Multiple miners simultaneously mining the same block
  • A lack of consensus between stakeholders (users)

Types of forking

Just like there are many reasons for forking in blockchain, there are multiple types of forks. The two major types of forks are as follows:

Accidental forks

Such forks occur when multiple miners mine a block at the same time. As their name suggests, accidental forks occur by accident. No change in protocols or instructions causes these forks.

Intentional forks

As their name suggests, intentional forks occur by intention. We are aware of and approve of the actions that result in these forks. These changes alter the operations and result in forks. The users are aware of this action and approve it, that is why it is called an intentional fork.

We can further categorize intentional forks into soft forks and hard forks. The table below lists their major differences:

Soft Forks vs. Hard Forks

Soft Forks

Hard Forks

One blockchain continues

Two blockchains emerge

One of the blocks is discarded

Both resulting blocks remain active

No new upgrade in the system is required

The system must adopt the new protocols