Consensus Mechanisms

All you need to know about Consensus Mechanism!

A blockchain network is celebrated for its most common attribute, called decentralization. But, how do we ensure that a decentralized peer-to-peer network with no centralized authoritative entity makes decisions? In the blockchain, we do it through consensus mechanisms.

When it comes to data transfer or transactions between nodes on a blockchain network. The nodes need to come in agreement with a set of network protocols. Protocols or laws are enacted to ensure the validity of the transactions in the blockchain network. These protocols are enforced and agreed upon by concerned nodes on the blockchain network through consensus mechanisms. In simple words, the consensus mechanism is a tool to ensure the transactions done on a distributed network like blockchain are valid.

Before we dig deeper into the topic, let’s break down the concept. To get a better understanding of what’s coming ahead. 

What Is a Consensus?

A consensus means an agreement reached by the majority members that are affected by the agreement. For example, the elections in a country are conducted to determine whether majority members in the state agree to select a particular person as the head of their state. The same goes for blockchain networks, in which a consensus is achieved when the majority of nodes agree upon the validity of a transaction. 

The goal of a blockchain network is to ensure that the trustless nodes in the blockchain network reach an agreement upon a single alter-proof record of transactions, called consensus. A transaction mainly involves sending or receiving tokens or coins, or it can be any other transfer of data on the blockchain. 

What Is a Consensus Mechanism?

There are different ways to achieve a consensus on a blockchain network, but the goal is the same, to ensure the validity of the transactions. A consensus mechanism is how the validity of a transaction is testified. But why do nodes spend their energy to validate a transaction? What is the incentive here? The consensus nodes or miners get rewarded after a successful transaction is achieved; the reward depends upon the type of consensus mechanism being incorporated.

Types of Consensus Mechanisms

Now we will explore the three most common types of consensus mechanisms.

Proof of Work (PoW)

In the Proof of Work consensus mechanism, each block of transactions has a specific hash. The hash is assigned to the block through an algorithm, for Ethereum 1.0. the mining algorithm is termed Ethash, and for Bitcoin, it is SHA-256.  

In order to validate the block, the consensus nodes or miners have to solve an arbitrary mathematical puzzle through mining devices. The purpose of the puzzle is to ensure that a certain computation effort called mining is done by the miners that qualify them to add new transactions to the blockchain. Whoever solves the puzzle first wins the reward. 

In technical terms, the miners have to repeatedly run a dataset through a mathematical function that generates a target hash that’s less than or equal to that of the block. This continuous process is performed by all the miners to determine the cryptographic nonce for a block. 

Through the PoW consensus mechanism, the miners compete with each other to add a new block to the blockchain and get rewarded. For example, in Ethereum, the winning miner is rewarded with two freshly minted ETH and all the transaction fees within the block. PoW is like a race with multiple runners who spend their energy and put in the effort, but one runner wins the race.

Proof of Stake (PoS)

The Proof of Stake (PoS) consensus mechanism is one of the alternatives to Proof of Work (PoW) but requires less energy. 

Before discussing the details, it is important to understand the different nomenclature used in the PoS consensus mechanism. In PoS, there are no miners but validators that are chosen amongst the different consensus validators in the blockchain network. The validators do not mine the new blocks; instead, they get to mint or forge new blocks in the blockchain network. 

The PoS consensus mechanism uses a pseudo-random deterministic algorithm to choose a validator to validate the transactions in the block. To become a validator, the consensus node has to put some coins at stake in the network; this stake acts as a security deposit. The higher the number of coins at stake, the higher the chances of the node becoming a validator. 

Image: Saher Aamir

The amount placed at stake has to be higher than the reward received by the validator to ensure that the validator performs the job correctly. The reason why this pseudo-random method selects the node with the highest bidding is that the validator only receives the transaction fee for each transaction in the block. The validator has the risk of losing a share of its stake if it validates a fraudulent transaction. 

The chances of 51% attack that is a threat in the PoW blockchain network still exists but highly unlikely in PoS. However, the PoS mechanism favors the rich as they have the tendency to put more coins at stake than other nodes. 

PoS also increases the chances of a rich validator to become a validator more often because they keep on getting the transaction fee and hence have more coins for bidding. The PoS consensus mechanism is used by many blockchain networks such as Polkadot, EOSIO, and Cardano etc. 

Proof of Stake vs Proof of Work

Cryptocurrencies that use PoW consensus mechanisms consume a lot of energy because mining requires a lot of power due to the PoW algorithm. Bitcoin miners consumed 91TWh of electricity last year because of their substantial mining farms. PoW is expensive because it rewards miners with sophisticated mining devices that can generate cryptographic nonce at a relatively higher rate.

The high amount of energy consumption encourages the miners to form mining pools. In a mining pool, the reward is evenly distributed among all the miners after a successful transaction. The mining pool compromises the decentralized network, which is an essential determinant of the blockchain network. 

The mechanism of PoS is more fair than PoW because, in PoW, whales can enjoy the cost advantage and higher production through economies of scale. However, in PoS, the validator receives the transaction fee for each transaction in the validated block. If the validator validates a faulty transaction, a share of its stake is lost. The financial motivation of losing more money than gaining acts as the key mechanism to ensure the accuracy of the transactions. 

The evident distinction between PoS and PoW is that in PoW, every consensus node is a miner, while PoS only selects a few validators and hence consumes less energy. PoS is more decentralized and less expensive than PoW and encourages more people to chip in. 

Proof of History (PoH)

One of the most common issues in a network of distributed systems is agreement on time, and Proof of History  solves that problem. Proof of History can be understood as a modified version of PoS. PoH is specifically designed to enable consensus nodes to perform faster by encoding time into the blockchain. 

PoH uses Verifiable Delay Function (VDH) to add a time delay on the hashes being generated. This function takes delay (t) as a parameter so the validators know the order in which the transaction occurred. The output of the VDF is then proved by the validator nodes through sequential computing. 

Image: Saher Aamir

Solana popularized PoH, the mechanism is somewhat similar to PoS with a few additions. In Solana, there is no requirement to become a validator. The nodes in Solana can easily become validators by paying a validation fee along with some amount that is put on stake. 

Image: Saher Aamir

When the time-stamped blocks are validated, their order can be easily determined. And, the blocks are then added to the blockchain. In the PoH consensus mechanism, the node contains the record that a particular transaction took place at one specific moment in time. A major advantage of Proof of History is that the nodes do not have to communicate continuously to agree on the time of validation done. 

What is Blocktime?

By now you must be wondering why some blockchains are faster than others. And if consensus mechanism makes it so easier then why not every blockchain does that? Well the answer lies in how the nodes validate the blocks and the time required to validate a block. 

In order to put the blocks in the blockchain, it is important that the blocks are in the right order. The blocks are hashed and timestamped by the masternode, then sent to the validator nodes for validation. The validator nodes then add the blocks to the blockchain according to their respective order. The total time required to validate the blocks and then add that blockchain is blocktime. 

Why Do We Need Blocktime?

We have discussed before that validating a block requires the node to solve a mathematical puzzle. That puzzle has a difficulty level. The difficulty level is set in a way that it can be solved within the range of average blocktime. 

In the case of the Bitcoin blockchain network, the expected blocktime is ten minutes. To make sure that all the validators do not add the block to the blockchain simultaneously.  

However, you can alter the bitcoin timestamping undectably (Pawel Szalachowski, 2018). So whenever a node synchronizes the blockchain it cannot be certain about the correct order of transactions. 

Ethereum uses wallclock timestamping, which is only valid for two hours. The average blocktime for Ethereum blockchain network is 10 to 12 seconds.

Solana has modified the term block to entries, a complete revolution to the blocktime concept. Now validator nodes get streams of transactions and they vote on the cryptographic proof. The average blocktime of Solana is 400 milliseconds because validators don’t have to confirm the order of transactions. Basically, the smaller the blocktime is, the faster the blockchain network will be.

Is PoH the Best Consensus Mechanism?

The consensus mechanisms are mainly used to ensure security and decentralization in the blockchain network. PoW is a decentralized method of verifying transactions that ensures a high level of security but the transactions are slower. The drawback of PoW is that all the consensus nodes use expensive mining devices to perform mining. But, only the fastest miner gets the reward in the form of a block. 

PoW is one of the earliest consensus mechanisms in the blockchain network; currently, there are other less energy-intensive consensus mechanisms available such as PoS and PoH. 
The Proof of History consensus mechanism is a hybrid as the validators in the Solana network are chosen by the Proof of Stake protocols. By far, PoH is the fastest and most secure way to achieve a consensus on a blockchain network. There exist further extensions of these consensus mechanisms i.e. DPoS, PoA, PoL, PoI, PoET, PoB, PoC, and PoST etc.


- Advertisement -

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Follow us for latest news!

- Advertisement -

Latest News

- Advertisement -
- Advertisement -