Blockchain Consensus Mechanisms | A Beginner’s Guide
A blockchain is a decentralized peer-to-peer network that stores append-only (add to the end of) data and verifies the integrity of that information across the network. Collectively validating the accuracy of said data (reaching consensus) is one of the defining features of a blockchain.
The idea of a blockchain goes back to at least the 1990s. The basic theory was to copy data across a network of computers using a type of consensus algorithm to agree on any data to be added. Then, use cryptographic hash-chaining to make the database virtually immutable.
For more information on blockchains and hashing, check out our Blockchain article. Below, however, we’ll focus specifically on the various ways that different types of blockchains reach consensus on data added to their sequences (chains) of data (blocks) through these topics:
- Blockchain Consensus Defined
- What is the Byzantine Generals Problem?
- Proof of Work (PoW)
- Proof of Stake (PoS)
- Leased Proof of Stake (LPoS)
- Delegated Proof of Stake (DPoS)
- Proof of Importance (PoI)
- Hybrid Proof of Work and Proof of Stake
- Practical Byzantine Fault Tolerance (PBFT)
The main differences in the various blockchain consensus mechanisms center around how the right to add data to the blockchain is distributed among network participants, and how this data is validated by the network as an accurate account of transactions.
The set of computer processes that solve these problems is called the consensus algorithm, which, as alluded to, is the mechanism responsible for securely updating the state of data across a given blockchain network.
Each node (computer) in the network independently verifies and processes every transaction and therefore must have access to the database’s current state, the modification requested by a given transaction and a digital signature proving a transaction’s origin and accuracy. The question then, is how all of the nodes reach consensus (agreement) on the data. The biggest problem that blockchains aim to solve is called the “Byzantine Generals’ Problem”.
This problem, which has been around for longer than blockchain itself, is basically this: How do you keep a network of entities who are focused on the same goal in alignment based purely on messages passed between them, without the information being corrupted by a malicious actor within the network? For example, if one is trying to send cryptocurrency through a network, how can you be certain that the transaction details haven’t been tampered with and changed by a malicious node in the network?
This is where a consensus mechanism comes in to make sure the network remains in sync and data remains untampered with. The following are a few of the solutions different groups have come up with to achieve this outcome.
Proof of work is presently the most popular consensus mechanism for blockchains. The ‘proof of work’ that the name describes is the process by which the blockchain network proves that a miner network node (network nodes that group transactions into blocks and validate them) has done the work needed to create a valid block (group of transactions). Although it’s hard for nodes to generate a valid block (it takes a lot of computer processing power), it is quite easy for the network to verify that a block is valid.
This is all done through what is called a hash function, which creates a unique digital fingerprint for a given piece of data. Since hashes are very sensitive to change, and even a tiny modification will result in a completely different hash output, hashes can be used to validate and secure blocks.
For a block to be confirmed as valid, miners must create two hashes: a hash of all of the transactions in the block, and a hash proving they have expended the energy needed to generate the block by solving a special cryptographic puzzle with a pre-set level of difficulty. Specifically, the puzzle is to find a number that, when combined with the data in the transactions and passed through the hash algorithm, comes up with a number within a specified range set by the cryptocurrency’s program.
The difficulty of solving the puzzle is automatically adjusted in PoW systems to create a consistent time period for blocks of transactions to be added to the blockchain and to release network fees and newly created cryptocurrency rewards to miners.
A hash is a one-way function. It cannot be reversed. In this way, it can be confirmed that each block has required work to generate it. Each block also contains the hash of the previous block, so once all blocks are combined in the blockchain, it makes it virtually impossible to modify them since doing so would require redoing all the work done to generate every single block in the blockchain.
In summary, a miner creates a block of valid transactions, then runs the PoW algorithm on it to find a valid hash, racing against all other miners to solve the puzzle first. When a valid block is generated through such action, the block is added to the blockchain and the miner receives network fees as well as newly created cryptocurrency.
There are different hashing algorithms used for PoW consensus mechanisms, the most common of which are SHA-256 (e.g Bitcoin) and Scrypt (e.g. Litecoin). Others include SHA-3, CryptoNight, Blake-256, Quark, scrypt-jane and hybrid systems that use more than one hashing function.
Although PoW is theoretically near impossible to hack since it uses resources in the physical world to secure the network, this is also where one of its largest criticisms comes from: the resource being used is electricity, and lots of it.
In fact, science magazine Motherboard Vice, reports that 1.6 U.S. households could be powered for a day by the electricity used by a single Bitcoin transaction. By 2020, Bitcoin could consume as much electricity as the entire country of Denmark. And that’s just one cryptocurrency (albeit the most popular).
From an efficiency and environmental perspective, this is not ideal and would be very difficult to scale to mainstream usage. Making matters worse, the computing power and electricity costs needed to stay competitive in mining has increased dramatically over time. This has produced significant centralization in mining networks, as only the largest and most powerful organizations can really compete.
A few large companies and mining pools now dominate the most popular blockchains, which is completely counter to the founding decentralization principle of blockchains.
Besides the questionable ethics of this issue, centralization also leads to a potential security problem called a 51% attack. This is when a miner, likely a pool or large conglomerate, controls 51% of a blockchain network’s computing power. If this were ever to happen, they could disrupt the entire network by invalidating real transactions or validating their own fraudulent transactions to “double spend” funds (using the same funds more than once).
Fortunately, these problems with PoW are not without potential solutions.
PoS is based on the assumption that when nodes in the network are stakeholders (that is, when they own currency of the given blockchain) they will have an incentive to remain honest and benign in operating network nodes.
PoS works by miners locking up some of their own cryptocurrency so they can’t be used into special ‘staked’ accounts. Nodes who have staked tokens can then verify blocks of transactions just as in PoW systems, but the cryptographic calculations needed to verify blocks are much simpler (and therefore require much less computer power). Instead of using complicated puzzles that give advantages to more powerful computers as in PoW, PoS systems are structured such that nodes that have more cryptocurrency staked have a higher chance of solving the cryptographic puzzle.
In this way, although PoS is more efficient than PoW, it does not completely solve the problem of centralization of mining power, since logically, the risk is that the currency used by such systems will still concentrate into fewer and fewer hands.
One of the other key problems of PoS is the ‘nothing at stake’ problem, wherein miners may have nothing to lose by voting for multiple blockchain histories in the event of a fork (a blockchain split into two). In the event of a fork, the most lucrative strategy for a miner is to mine on each chain, therefore gaining rewards regardless of which fork is recognized by the network.
This could in theory lead to consensus never being reached by the network, or to double spending wherein an attacker may be able to send a transaction, then start a fork of the blockchain from one block behind the transaction and send the money to themselves instead of where it was sent before. This is more possible in a PoS system than PoW since the cost of working on several chains is much lower.
One problem that PoS does help to mitigate, however, is the 51% problem. Even if a miner owned 51% of a cryptocurrency, it would not be in their interest to attack a system in which they owned a majority of the stake. This does not, of course, take into account malicious, well funded actors who may simply want to bring down a blockchain network at any cost.
Some examples of blockchains using this consensus mechanism are Litecoin and Cardano.
With classic PoS, miners with small balances are unlikely to mine a block, in the same way that PoW miners with little computer power are unlikely to mine a block. Not only could this be seen as less fair, it may also lead to a less secure network, since if small miners were incentivized better, the network would have more nodes and thus be more secure.
LPoS incentivizes less powerful nodes by allowing them to lease their cryptocurrency balances to “staking nodes” that have more staked tokens and are consequently more likely to mine a valid block. All coins leased to such nodes increase the “weight” of the staking node, which increases its chances of adding a block to the blockchain. Rewards received by staking nodes are then proportionally shared between all leasers. Leasers can still move or spend their tokens at any time, thus automatically “breaking the lease” so to speak.
In this way, the issue of centralization of mining and/or monetary power can be better limited by allowing all nodes to have the potential to earn mining rewards.
The main example of a project using this type of consensus algorithm is Waves.
In DPoS, cryptocurrency token holders use their balances to elect a list of nodes that will be able to stake blocks to add to the blockchain. With the yet-to-launch EOS blockchain, for example, there will be 21 “block producer nodes” that are elected by the network.
Although this solves some problems, such as the potential for forks to happen (all nodes will not switch to a fork that isn’t finalized by 15 out of 21 producer nodes), and scalability issues that occur with PoW and PoS, a DPoS blockchain is by definition more centralized, and does not provide accessible entry points for anyone to mine blocks and earn rewards.
Projects that use this type of consensus mechanism include Bitshares and EOS.
Blockchains don’t have to settle for just one type of consensus mechanism. The most popular type of hybrid chain is the PoW/PoS hybrid, which typically uses an initial PoW consensus in a limited manner, and then uses PoS to validate blocks added to the blockchain. Using PoS solves the 51% attack problem while using less energy; PoW solves the nothing at stake problem while ensuring another layer of blockchain immutability.
Peercoin is one blockchain using this hybrid method.
PoI is similar to PoS, but the consensus mechanism also takes into account other factors in giving nodes an advantage in mining blocks.
With NEM, the first blockchain to implement PoI, for example, nodes are rewarded for their productivity in the network, which includes their balance, as well as their number and value of transactions, among other ‘reputation’ factors.
In this consensus mechanism, each node publishes a public key. Transactions passing through the node are signed by the node and verified, and once enough identical responses are reached within the network, a consensus is met through that the transaction is valid. This simple mechanism does not require any hashing power and is particularly useful for storage systems.
PBFT has two potential problems. First, all involved parties must agree on the exact list of trusted participants. Secondly, the membership of such an agreement system is typically set by a central authority. Although these factors may not make it suitable for a public, decentralized cryptocurrency, it may be useful for other things such as private digital asset holding platforms.
PBFT is the consensus mechanism used by Hyperledger.
Before blockchains came along, there was no practical way to ensure that data in a distributed network (for example, a digital currency ledger) would remain secure from tampering by malicious or compromised nodes. With the birth of Bitcoin and PoW, a whole new generation of programmers and engineers set to work on solving this problem.
Many consensus mechanisms have sprung up as a result, most purporting to solve the same (Byzantine Generals) Problem. As blockchain is still a relatively new field, it is unclear which consensus mechanisms will prove themselves most useful and which ones will fall out of favor. As it stands now, differing consensus mechanisms are one of the fundamental factors that differentiates different cryptocurrencies.