Understanding consensus can be hard for beginners. This guide aims to make blockchain consensus easy to grasp for beginners

Consensus and The blockchain

The blockchain is constantly being built upon to make the “chain” of blocks. In order for a block to be added to the “chain”, the nodes in a network must come to an agreement or consensus.

The aim of consensus is to provide objectivity among the many participants of a network in arriving at an agreement and enable the continuous building of new blocks.

Consensus has been in evolution since the inception of the blockchain. We have had proof-of-work (POW) proof of stake (POS) and hybrid consensus (which is used by Polkadot and Kusama).

Let’s have an idea of how they work.

PROOF OF WORK (POW).

POW is a type of consensus that is simple and effective in reaching an agreement on the next block produced and holds within it a chain selection algorithm where all nodes attempt to solve a cryptographic puzzle, the first one to come up with a solution gets to create the block that is added to the chain, in the process collects the miner reward.

Miners with a higher ”hash rate” stand high chances of creating the next block and with mining pools where miners bring together their resources in order to further increase their chances of making the next block the network then tilts towards centralization at some point.

Also, enormous amounts of power are needed for these operations, there is no “provable finality”(I’ll be explaining this in a while). An example of blockchains using the POW model is the Bitcoin blockchain.

How proof of work works

PROOF OF STAKE (POS):

Unlike POW, POS consensus selects miners/validators, based on the amount of stakes they have on the network

Here they are said to “mint” or “forge” the next blocks instead of mining. In order to be a validator, a node has to deposit a certain amount of coins or tokens into the network known as a “Stake”, this stake serves as a security deposit. The bigger the size of the stake, the higher the chances of a validator being chosen to mint the next block.

It’s a simple linear correlation. Let’s take two validators for example Adam deposits 50 tokens as stake and Olamide deposits 500 tokens as stake. Olamide stands ten times more chances than Adam to be selected to forge the next block.

When a node is selected to validate the next block, its job is to check if all transactions within it are valid and if everything checks out the node signs off on the transaction which is then added to the blockchain and as a reward the node collects the transaction fees associated with it.

Stakes put into the network by validators as mentioned earlier serve as a trust for which if validators approve fraudulent transactions they lose a part of their stake, so validators can be trusted to do their job as long as the stake is higher than the transaction fees as they will lose far more than they will gain if they approve fraudulent transactions.

Proof-of-stake tends to tilt toward centralization, where a few validators in the network could be so wealthy and have a lot of stakes that they could have a significant influence on the network.

How proof of stake works

HYBRID CONSENSUS

Before going into this, there are some terms that should first be understood:

  • probabilistic finality and
  • provable finality

Probabilistic finality is a type of finality, in which the probability that a transaction will not be reverted increases as the block which contains that transaction sinks deeper into the chain

Provable finality assures the irreversibility of a consensus.

There are gadgets that can achieve this type of consensus which is usually irreversible. An example is GRANDPA (Ghost-based recursive Ancestor derived prefix) which is the finality gadget being used in Polkadot and Kusama. It should be noted however that the GRANDPA doesn’t produce new blocks. In essence, the hybrid consensus is a combination of the positive qualities of both provable finality and probabilistic finality which is harnessed to achieve an efficient consensus mechanism.

In Polkadot’s Hybrid consensus, the ability to produce new blocks as seen with probabilistic finality is essential and is achieved using the Blind assignment for Blockchain extension protocol (BABE).

Its function is the determination or assignment of block production slots to validators according to stake and through its verifiable random function (VRF).

The combination of these two forms the Hybrid consensus which allows for rapid production and finalization of blocks

So how do validators get selected in Polkadot using the hybrid consensus model?

Polkadot uses a mechanism known as Nominated proof of stake (NPOS). This type of selection is done in order to get the most out of the system.

Validators are the ones that have the responsibility of minting new blocks. The slots for the blocks are assigned to the validators by BABE, as explained earlier. Validators are also tasked with validating the parachain blocks and guaranteeing finality.

Nominators on the other hand have the task of selecting validators that they trust. This is done by delegating(staking) their DOT tokens to validators. The DOTs staked are to enable validators to get into the active set and start producing blocks. In order for a nominator to stake his tokens to a validator node, The nominator’s tokens have to be locked.

In turn, nominators receive a portion of validator node rewards. However, nominators can also be punished by automatically losing some of their DOT, should the validator node they selected behaves badly.

Click here to learn more about Polkadot’s consensus

Share.

Comments are closed.