How do consensus mechanisms like proof-of-work (PoW) and proof-of-stake (PoS) work?
Everything you need to know about consensus mechanisms, including Proof of Work (PoW) and Proof of Stake.
In this article:
- What is a blockchain consensus mechanism?
- What is the 'Byzantine generals problem'?
- What is Proof of Work (PoW)?
- What is Proof of Stake (PoS)?
- What is delegated Proof of Stake (dPoS)
- What is Federated Byzantine Agreement (FBA)?
- What are some other consensus types?
What is a blockchain consensus mechanism?
A consensus mechanism in blockchain refers to the way changes to the blockchain are agreed upon. Because blockchains are a series of ledgers held within numerous servers on a peer-to-peer system, we need a way to confirm that any changes to the ledger are valid and void of any forms of corruption.
Without a central authority having the final say on what transactions are valid, blockchain technology uses decentralized consensus algorithms to reach an agreement on what changes to the ledger are valid. This agreement is known as the blockchain's consensus mechanism, and its sole purpose is to solve what's known as the Byzantine generals problem.
What is the 'Byzantine generals problem'?
In decentralized systems, like blockchain technology, the parties involved need to establish the truth while at the same time not having to trust the others involved in the decision-making.
This problem is known as the 'Byzantine generals problem', a game theory analogy that describes the issue of decentralized parties reaching consensus without a central, trusted authority.
The theory presents a fictional army that requires multiple generals to agree on attacking a city at precisely the same moment to ensure victory. However, the generals are spread out around the city and can only communicate by sending messages through the city to each other. As these messages could be tampered with during the transfer, there's no way to validate the authenticity of the messages themselves and could lead to the generals attacking at different times. This represents the problem of a communications channel that cannot necessarily be trusted.
So how do we confirm that the messages have not been tampered with?
In blockchain, the solutions are known as consensus algorithms, starting with the pseudonymous person (or persons) Satoshi Nakamoto who published the Bitcoin whitepaper in 2008. In the following sections, you can think of the network miners and nodes as the generals sending and receiving the messages.
What is Proof of Work (PoW)?
Satoshi Nakamoto invented the Proof of Work consensus mechanism and outlined the network details within the Bitcoin whitepaper. The whitepaper is regarded as one of the most groundbreaking technologies since the internet and started a wave of peer-to-peer electronic payment methods.
The Proof of Work consensus algorithm is performed by miners on the network. These miners compete with each other to solve a complex mathematical problem. The first miner to solve the problem is awarded the right to add a new block to the blockchain and is compensated with newly created Bitcoin as a reward.
The problem to be solved is generating a SHA256 hash that is equal to, or lower, than the target hash.
For example, if you had to randomly generate a number less than 128 out of 256, it wouldn't take you very long to do so. However, if the difficulty is increased to generating a number less than 0.00128 out of 256, you can see that the amount of work needed would increase greatly. On the Bitcoin blockchain, the difficulty is increased by adding preceding zeros to the target hash. Miners then compete to generate a hash less than or equal to the target hash.
For instance, the target hash for block 724190 is 000000000000000000085ea8030e6f76666c79d70e8beed93ea4db25eb0dc597
The target hash is calculated and adjusted for every 2016 blocks by the miners on the network. The aim is to have new blocks created every 10 minutes, so if the past 2016 blocks have taken less time, the difficulty will be increased. If the past blocks have taken more than 10 minutes on average, the difficulty will be decreased.
All miners run the same algorithm, using the same data from the blockchain to determine the difficulty change to the target hash. Because every miner shares the same blockchain data, the resulting difficulty changes are equally determined.
Popular Proof of Work coins in Exodus: Bitcoin (BTC), Ethereum (ETH), Dogecoin (DOGE), Litecoin (LTC), Bitcoin Cash (BCH), Ethereum Classic (ETC), and Monero (XMR).
What is Proof of Stake (PoS)?
Proof of Stake (PoS) blockchains reach consensus using a different method than Proof of Work. Validators (equivalent to Proof of Work miners) produce the next block based on the number of tokens they hold, rather than compete to solve a puzzle.
Currently, the second most popular blockchain, Ethereum, is migrating from a Proof of Work consensus model to Proof of Stake. More information on this transition can be found here.
In the same way that miners on Proof of Work blockchains are required to spend energy to secure the network, in Proof of Stake blockchains, validators are required to spend money by purchasing the governing asset and holding a large 'stake' in the network in order to validate transactions and provide security.
Proof of Stake blockchains also offer rewards and incentivize network security, just like Proof of Work. Each blockchain has a determined set of rewards that are granted to validators for producing a new block.
The idea is that those with the most coins have the most to lose, and are positioned to work in the best interest of the network.
As Proof of Stake does not require energy-intensive competition for validating transactions, it allows for faster transactions speeds, lower network usage costs (gas fees), and a lower barrier to entry for those looking to earn rewards for helping to secure the network.
Popular Proof of Stake coins in Exodus: Solana (SOL), Binance Coin (BNB), Cardano (ADA), Avalance (AVAX), Polkadot (DOT), Cosmos (ATOM), Algorand (ALGO).
What is Delegated Proof of Stake (dPoS)?
Delegated Proof of Stake (dPoS) is similar to the Proof of Stake consensus model, however, it relies on elected delegates to generate new blocks, therefore, making the process more democratic.
Users vote for a delegate by pooling their assets with others in a staking pool which are linked to a particular delegate. Each block on a dPoS network is validated by multiple delegates and new delegates will be chosen for each ensuing block thereafter.
Each delegate that is chosen to validate a block receives their portion of the block rewards and distributes them to users who have staked their assets within the delegate's pool. The rewards distributed to users are equivalent to their share of the total staking pool's balance. Therefore, if your portion of the staking pool is 1%, you'll receive 1% of the distributed block rewards.
Proponents of dPoS networks believe it's a more democratic way to choose block producers and allows smaller stakeholders to participate and earn rewards.
Popular Delegated Proof of Stake coins on Exodus: EOS (EOS), Terra (LUNA), Tron (TRX), and Tezos (XTZ).
Federated Byzantine Agreement
To understand Federated Byzantine Agreement (FBA) we must first understand Byzantine Fault Tolerance (BFT). BFT is the feature that allows a system to continue to function when one or more of the validating components fails without the quality of the operations being decreased. In blockchain technology, this refers to the network's ability to continue solving the Byzantine generals problem while experiencing faults like network congestion and malicious attacks.
While the traditional Byzantine Agreement mechanism relies on a chosen group of validators to agree upon the solution to a given problem, it sacrifices decentralization and relies on validating nodes selected by a central authority.
This is where FBA comes in. In FBA blockchains there is no such list that is chosen by a central authority. Instead, the validating nodes choose the other validators they trust and add/remove those to the list they trust, known as their quorum slice. This means that anyone can run a validator and participate in the network as long as a current participating validator includes them in their quorum slice, further decentralizing the network.
It also does not require the validators to own large amounts of resources in order to validate a block, like Proof of Stake networks. Instead, a small validator has as much power as a large and wealthy validator requiring both to remain honest. If validators, big or small, act dishonestly within the network, they'll be removed from the quorum slice and therefore no longer contribute to the validation of future blocks.
As no block rewards are distributed to the validating nodes, and all tokens on the networks are created during the genesis (first) block, it creates a truly deflationary environment as the transaction fees are burned instead of being rewarded. In FBA consensus blockchains, validating nodes are not financially incentivized but rather contribute their resources to the network solely to help provide security and stability of the network.
Popular Federated Byzantine Agreement coins on Exodus: XRP (XRP), Stellar (XLM).
What are some other consensus types?
Some other consensus types include:
Directed Acyclic Graphs (DAGs)
Instead of linking blocks together like Proof Of Work blockchains, DAGs stack transactions, known as vertices, and link them in specific directions. More information about DAGs can be found here.
Proof of Authority (PoA)
Proof of Authority (PoA) is similar to Proof of Stake (PoS), however, instead of staking the monetary value, a validator’s identity performs the role of stake. More information about PoA can be found here.
Proof of Capacity (PoC)
Proof of Capacity leverages space on participant's hard drive to mine a crypto-asset native to the network. Working with any hard drive, including mobile devices, the consensus mechanism is recognized as energy efficient and accessible. More information about PoC can be found here.
Proof of Burn (PoB)
Proof of Burn allows miners to “burn” virtual currency tokens as they are granted the right to create blocks relative to the coins being burnt. More information about PoB can be found here.
Proof of Elapsed Time (PoET)
Proof of Elapsed Time is similar to Proof of Work but removes the need for an energy-intensive process as it's replaced with a randomized timer system for network participants. More information about PoET can be found here.