What is Blockchain consensus algorithm?

Blockchain consensus algorithms are a crucial and indispensable part of blockchain technology. Not only do they play a vital role in maintaining network security, but these algorithms also help blockchains ensure decentralization in their operations.

What is a Blockchain Consensus Algorithm? Why does blockchain need a consensus mechanism? What types of blockchain algorithms are there? How do the mechanisms of these consensus algorithms differ?

What is a Blockchain Consensus Algorithm?

A blockchain consensus algorithm is a rule or mechanism that nodes follow to ensure that transactions performed on the blockchain are accurate, transparent, and consistent across all nodes* in the network.

*Nodes are devices (computers, phones, etc.) that are responsible for sending, receiving, verifying, and recording transactions on the blockchain. All nodes on a blockchain are connected to each other through a peer-to-peer network, constantly exchanging the latest data to keep all nodes updated.

Blockchain
How Consensus Mechanisms Work on a Blockchain

Essentially, a blockchain consists of multiple nodes combined to create a network. For a transaction to be recorded on the blockchain, it must be simultaneously validated by all nodes on the network based on a consensus mechanism.

First, it’s important to understand that the structure of a blockchain comprises multiple blocks linked together, forming a chain. Each block contains information about the hash of the previous block. This hash is generated based on predefined input information from a block, including transaction information that has been validated by nodes.

When a user performs a transaction, the nodes rely on the blockchain’s consensus algorithm (such as PoS, PoW, PoA, etc.) to validate and record the transaction into a new block on the blockchain. Then, all nodes must download the information about the newly validated transaction block to ensure data consistency and integrity across the network.

Consensus algorithms also make it impossible to alter data on the blockchain:

  • When data within a block is changed, the hash of that block also changes.
  • This hash will be compared with the data in other blocks to ensure accuracy and consistency between the hashes of the blocks before and after it.
  • If any discrepancies are found, that data will not be allowed to be written to the blockchain.

Example: Suppose a hacker attacks and alters the information on block number n. At that time:

  • The hash of block n is changed.
  • The system compares the hash of block n with the hash of the previous block to detect the discrepancy.
  • The hacker must then change the hash of the block before n. The system again detects a discrepancy in block n-1. The hacker must continue to change the hash of block n-2, and so on.

Thus, to change a transaction, the hacker must change all blocks to comply with the blockchain’s consensus mechanism.

Why Does a Blockchain Need a Consensus Mechanism?
Ensuring Nodes Perform Their Roles Correctly

Blockchains operate in a decentralized manner, relying on a network of many nodes globally, without any intermediary controlling or manipulating the blockchain.

So how can we ensure that these nodes validate transactions correctly, operate the blockchain properly, and avoid fraud? This is where consensus mechanisms come into play. Nodes are obligated to adhere to the consensus algorithm to perform their roles correctly. Otherwise, they are penalized according to a slashing mechanism.

Making Blockchain a Byzantine Fault Tolerant (BFT) System

The “Byzantine Generals Problem” is a thought experiment that describes the challenge faced by a group of Byzantine generals who need to communicate with each other to reach a consensus on their next action (attack or defend). Specifically:

  • When a minority attacks and the rest defend, they will lose..
  • When all (or a majority) agree to attack, they will win.

It also became a challenging problem to apply to the field of computer science. The question arose: In an environment where communication errors can occur, how can we ensure consistency between parties for smooth operation?

However, thanks to consensus algorithms, blockchain has been able to solve the above problem. As a result, blockchain becomes a Byzantine Fault Tolerant (BFT) system. This means that the blockchain network can still operate normally even if some nodes fail, commit fraud, or engage in malicious behavior (as long as the majority of the remaining nodes adhere to the mechanism).

Note that blockchains have different reward and punishment mechanisms to encourage nodes to comply with the consensus mechanism.

Learn more: What is Byzantine Fault Tolerance?

Common Blockchain Consensus Algorithms
Proof of Work (PoW)

Proof of Work (PoW) is the first decentralized consensus mechanism, used to secure the Bitcoin blockchain.

PoW requires nodes to use their computing power to solve mathematical problems and generate hashes. The first node to solve the problem and win the right to validate a transaction receives a reward in the blockchain’s native coin (such as BTC or ETH). This process is called “mining,” and this node is called a miner node.

If a miner node solves the problem, validates, and records a transaction onto a new block, this block is sent to all other nodes in the network. When a sufficient number of nodes validate the block, they reach a consensus, and the transaction is processed.

However, PoW has some drawbacks, such as:

  • PoW uses computing power to secure the blockchain, thus requiring high energy consumption and expensive hardware.
  • A block on a PoW blockchain takes longer to be created and validated, making this algorithm less efficient and more resource-intensive (and even environmentally unfriendly) than other consensus algorithms.

This is the consensus mechanism associated with Bitcoin (BTC), Litecoin (LTC), and others.

Before implementing The Merge upgrade, the Ethereum (ETH) network also operated under the PoW mechanism, but has now transitioned to PoS.

Proof of Stake (PoS)

Proof of Stake (PoS) is currently the most popular consensus algorithm, first introduced by Peercoin in 2013.

Instead of using computing power, Proof of Stake requires nodes participating in transaction validation to stake a certain amount of the blockchain’s native coin to gain the right to participate in validating and creating blocks.

This staked amount ensures that nodes operate properly. If a node goes offline for too long or engages in fraudulent behavior, a portion or all of their staked tokens can be confiscated, depending on the severity and slashing regulations.

In the PoS mechanism, nodes act as validators instead of miners as in PoW.

Validators in a PoS network receive transaction fees as rewards. When a transaction occurs, validators are chosen to validate it based on the number of tokens they have staked and the staking duration. The more tokens staked and the longer the staking period, the higher the chance of being selected.

With this mechanism, Proof of Stake is a more cost-effective and environmentally friendly algorithm than Proof of Work. Becoming a validator node is also simpler and doesn’t require the use of excessively powerful specialized hardware.

Example: Initially, the Ethereum blockchain used the PoW consensus mechanism, but transitioned to PoS in 2022. Now, to become an Ethereum validator, users must stake at least 32 ETH.

Delegated Proof of Stake (DPoS)

Delegated Proof of Stake (DPoS) is a consensus algorithm that evolved from Proof of Stake.

Instead of becoming validators themselves, DPoS allows token holders to stake their tokens and choose a representative (delegator) to delegate transaction validation and maintain blockchain security. In return, token holders share in the rewards from indirectly operating the network.

Typically, delegators are chosen based on their reputation (rather than their assets) and there is a limited number of them, around 20-100 delegators per block.

Compared to PoS, DPoS is considered faster and more efficient. DPoS helps ensure transparency, fairness, and trustworthiness by continuously conducting voting and shuffling activities within the system to ensure that the selected delegators are honest and responsible.

Some projects using this mechanism are: Cosmos (ATOM), EOS (EOS), Tron (TRX), etc.

Proof of Authority (PoA)

Proof of Authority (PoA) is a reputation-based consensus algorithm, developed based on Proof of Stake.

Instead of staking coins, validators stake their “reputation” to participate in the network of nodes that validate transactions and blocks on the blockchain, while also acting as the system’s operators.

PoA emphasizes identity value, meaning that those chosen to be validators must be truly trustworthy. This causes PoA blockchains to face a trade-off between decentralization and scalability:

  • Due to the nature of selecting only reputable and trustworthy individuals, PoA blockchains typically have fewer validator nodes, leading to less decentralization compared to other consensus algorithms.
  • PoA has a limited number of validators, which helps reduce transaction confirmation times, increase throughput, and improve network scalability.

In other words, the PoA consensus algorithm is more suitable for centralized systems.

Some blockchains that use the PoA mechanism: VeChain (VET), HECO Chain (HECO), etc.

Other Consensus Mechanisms

In addition, there are many other consensus algorithms, such as Proof of Weight (PoWeight), Proof of Capacity (PoC), Proof of Burn (PoB), Direct Acyclic Graph Tangle (DAG), etc.

It is important to note that although nodes and consensus mechanisms allow blockchains to operate without third-party control, that does not mean they are completely decentralized. Some consensus mechanisms are more centralized (like PoA) than others because they suit the operational purpose of that blockchain.

As each network serves diverse needs and different goals, we will likely see the emergence of even more consensus mechanisms in the future.

Leave a Comment

Your email address will not be published. Required fields are marked *