Consensus refers to the process, or protocol, that network participants use to agree upon the correct state of data on the blockchain and to synchronize the data across all nodes in the distributed network. Consensus algorithms are the main way in which nodes secure the blockchain.
In current business scenarios, systems must often reconcile transactions that occur throughout the day (e.g. banks, supply chains, etc.) through batch processing, sending, receiving, exporting, and importing data. With blockchain, reconciliation of data occurs in near real-time across all participants within the blockchain network.
In order to achieve consensus, blockchain technology uses consensus algorithms to ensure that data that reside in the shared ledgers maintained by each node are the same across all nodes in the network, and to prevent malicious actors from attempting to alter the data.
Different blockchain platform implementations use different consensus algorithms. Examples include:
The main consensus algorithms currently used today are described below:
Proof of Work (PoW)
The Proof of Work (PoW) consensus algorithm involves solving a computational challenging problem in order to create new blocks in the blockchain, referred to as ‘mining’ conducted by miners. It is the consensus algorithm used by Ethereum and is the most commonly used consensus algorithm to date.
The winner receives a reward in the form of payment (such as tokens). The problem is solved by randomly guessing a value for a nonce, which is added to a hashed block, and when rehashed, meets the difficulty level restrictions. When a miner finds a solution, the miner creates a block and broadcasts the nonce to the network, finalizing that block.
Due to the requirement to randomly guess values paired with there being no limit on the number of guesses that can be made, miners that have more computational power available to solve the problem have a higher probability of finding the solution first.
Issues related to PoW include the large amount of hardware and energy that must be expended for these heavy computational requirements. Often, a concentration of mining is done in countries where electricity is cheaper and powerful hardware is inexpensive and widely available. Even for powerful computers, mining takes time, so appending a new block to the blockchain takes time. Therefore, there is often a high latency (slowness) of transaction validation that does not scale for the volume of transactions that may be needed for some scenarios, such as payments. For example, in Bitcoin a new block is appended approximately every 10 minutes. Bitcoin transactions can be batched onto blocks, so the actual transaction throughput ranges between 3.3 and 7 transactions per second. Various solutions have been proposed to alleviate this performance constraint, and are currently being researched. See Bitcoin scalability problem for more on this.
PoW algorithms can be susceptible to the ‘51% attack,’ which refers to a scenario where a group of miners controlling more than 50% of the network's computing power can collude to conduct an attack on a blockchain. Since its first use in 2009, such an attack has rarely been successful but are becoming more regular . This attack becomes less feasible as the size of the blockchain network grows, and there are more and more miners that would have to collude to reach higher than the 50% threshold.
Proof of Stake (PoS)
With the Proof of Stake (PoS) algorithm, nodes are considered ‘validators’ rather than miners, where nodes validate each transaction in order to earn a transaction fee. Nodes place a ‘stake’ of their own assets, and the block forger is randomly selected from all of the nodes with staked assets. The selection process is weighted based on the size of the stake, so a user that stakes twice as much as another user is twice as likely to be called to validate the block. The PoS algorithm saves the need to obtain a large amount of computational resources used in mining under the PoW consensus algorithm.