The Different Types of Consensus Algorithms in Blockchain Platforms
José Oramas November 28, 2022 Latest news 0
A consensus algorithm is a procedure used in computer science in which participants of a distributed network agree on the state of the network or the state of a single data value and establish trust among unknown peers in the network. Consensus algorithms are designed so that members of a blockchain come to an agreement to validate a transaction on the network, change network parameters, decide which nodes are trustworthy to process new blocks, and other important functions. Don’t let the technical nature of this article throw you off– finding “consensus” is around us everywhere– it’s a very human notion, but just applied to something that can be automated. For starters, in centralized systems, consensus tasks are carried out by a central authority. In decentralized systems like Bitcoin, we have a network composed of hundreds, thousands, and even hundreds of thousands of miners or nodes that join to perform one or multiple tasks and provide a reliable and efficient ecosystem. Thinking about the decentralized consensus with this example, suppose you’re in a group of four friends, and one of the members, Alex, introduces a fifth person, Bob. When Bob leaves, most likely, the group will start talking about Bob (this is the protocol) to see if they liked him (the result will be the “consensus”) José: “Bob seems like a cool guy.” Kevin: “Yeah, cool guy. How’d you meet him?” Alex: “He was in one of my finance classes back in college; we would share crypto trading tips, and he ended up being a pretty funny guy.” Kevin: “Nice, but his memes were just super weird.” John: “You just don’t get meme culture.” José: “Yeah you don’t spend a lot of time scrolling through TikTok—I thought they were pretty funny.” In this example, a “consensus” was reached on whether Bob integrates well into the friend group. There is often a necessary consensus of opinion even absent of specific commitments or contracts made. One participant, Kevin, is reluctant about letting Bob into the group, but José, Alex, and John are cool with Bob. In this case, if we were to codify the above example into a consensus algorithm: Then it will be 3 “he’s cool” and 1 “he’s cool but I’m unsure about XYZ” still results in a “he’s cool.” The majority wins, so Bob will get to hang out with the cool kids despite Kevin’s opinion. Bitcoin, for example, is built to find consensus on whether new transactions are valid (“cool”) or not. Here we’ll review the most popular —and not so popular— types of blockchain consensus algorithms across public and private networks.
What is Proof of Work?Proof of Work (PoW) is the most popular and oldest consensus algorithm that came with the creation of Bitcoin in 2009 by Satoshi Nakamoto. A PoW system consists of a global network of miners —called network nodes— that compete to solve mathematical puzzles. The miner that successfully solves the puzzle wins the right to add a new block to the blockchain and receives a reward paid in newly-created cryptocurrency. Proof of work is basically a miner’s way of showing evidence that they have provided computational power to achieve network consensus and validate the authenticity of each block. Further, each block (transaction) is arranged in sequential order, eliminating the risk of double spending. So far, PoW has been the most secure consensus mechanism for cryptocurrency blockchains. Altering the network would require an attacker to re-mine all existing blocks in the chain. The more the blockchain grows, the harder it’s to monopolize the network’s computing power since it would require enormous energy consumption and expensive equipment. Once a miner solves a puzzle, he finds a nonce (short for number used once) that produces a hash with a value lower than or equal to that set by the network difficulty. The nonce is a central part of PoW systems since it will allow the miner to create a block header hashed with the SHA-256 hash function, which means putting a reference number for a block in a chain. The block header also contains a timestamp and the hash of the previous block.
The Cons of PoWMiners need to provide considerable computational power to solve the puzzles. But since the computations are complex, the amount of energy that a single S9 Antminer consumes is usually between 1400 – 1500 watts per hour for a hashrate of 14.5 TH/s. The S19, a more powerful version, consumes 3250 watts per hour at a hashrate of 110 TH/s. With some math, we can calculate the amount of energy that data centers or mining companies consume with hundreds or thousands of mining rigs in a single location daily. High energy consumption and environmental damage is the main criticism drawn from proof of work. To put this in perspective, Before Ethereum switched to Proof of Stake, Ethereum miners worldwide were consuming around 10 TWh/yr, the same as the Czech Republic. The loud noise also harms human hearing levels —above 80 dBa. This is why mining rigs are usually kept in basements or mining facilities to avoid disturbing everyday activities.
What is Proof of Stake?Proof of Stake (PoS) is the second most popular consensus algorithm. Instead of miners, PoS blockchains have network validators who use their coins/tokens as evidence of their commitment to the network rather than computing power. Staking means “locking” crypto assets for a period in a blockchain platform, which, in return, rewards users with more cryptocurrency.
PoW vs. PoS: Main DifferencesIn PoS, users can stake a portion of their assets for the sole purpose of generating passive income. The other option is becoming a validator. Unlike PoW systems, validators do not compete to create new blocks since they are randomly chosen by an algorithm. The more coins/tokens a user stake, the greater their chances of becoming a validator and creating new blocks in the blockchain. In PoW systems, the time for generating new blocks is determined by the mining difficulty; the more participants join the network, the bigger the hashpower, i.e., the computational power required to mine new blocks. By contrast, PoS blockchains have a fixed block generation time divided into slots —the time it takes to create a block— and epochs, which are units of time consisting of slots. To explain this better, a slot in Ethereum consists of 12 seconds, which is the amount of time it takes the network to create a block, and 32 slots create an epoch. Therefore, one epoch is 6.4 minutes. Each slot in a PoS blockchain has a predetermined number of validators who vote on the validity of the block being proposed. If the block is valid, it’s added to the chain, and the block proposer and the attestors receive rewards in ETH. PoS blockchains punish malicious actors for attacking the network with 51% style attacks, which is called slashing, where honest validators eject the malicious validator from the network and drain their balance. This discourages malicious actors from attacking the network since the required number of staked funds is considerably high. In the case of Ethereum, 32 ETH. Pros of PoS:
- Less energy intensive compared to PoW
- More suitable to work with layer-2 solutions than PoW
- Capable of achieving a higher throughput since consensus is established before blocks are passed.
- Less expensive than PoW blockchains since it doesn’t require elite hardware to create new blocks.
- PoS systems are still subject to centralization if validators with a large number of staked tokens can influence the network.
- Less proven in terms of security compared to PoW blockchains.
What is Proof of History?Proof of History (PoH) is a consensus algorithm presented by the Solana blockchain and consists of placing a timestamp to all events on the network to prove they took place at a given time. PoH can be described as a cryptographic clock that confirms transactions in sequential order. Solana combines its PoH approach with PoS. Therefore, network participants have to stake SOL to become validators and process new blocks, and the PoH mechanism verifies the validity of those transactions taking place in real-time. In other words, PoH maintains security, while PoS brings a network of validators that can verify the timestamps and confirm the transactions. However, Solana sacrifices decentralization to provide lightning-fast transaction throughput. The blockchain relies on a semi-centralized architecture in which a single node is elected as the leader who’s in charge of implementing a single source of time, i.e., the PoH clock, and all other nodes must follow the sequences of time accordingly. Leaders are periodically elected via PoS elections. While Solana is one of the fastest blockchains in the industry, it does regularly suffer from downtimes. Since its launch in 2020, the network has suffered roughly ten downtimes, five of which occurred in 2022. The main reason for these outages is a “misconfigured node.”
What is Delegated Proof of Stake?Delegated Proof of Stake (DPoS) is a variation of the PoS concept in which the community plays a centric role. In DPoS blockchains, the community members stake their cryptocurrencies to vote for the next witnesses or delegates for block production. To do this, users must pool their tokens into the blockchain’s staking pool and then link the funds to a specified delegate. DPoS was developed by former EOS CTO Dan Larimer, who implemented the algorithm on BitShares in 2015. Larimer and other DPoS proponents have said that DPoS broadens the democratic scope since it’s the community that chooses the next validator. Today, blockchains like TRON and Cardano use DPoS. However, the criticism for DPoS is that its methodology favors wealthy users. Those with a large number of tokens can have a bigger influence in the network. Vitalik Buterin was one of the first DPoS detractors, claiming in a blog post that this consensus algorithm incentivizes witnesses to form cartels and bribe voters for support.
What is Proof of Authority?Proof of Authority (PoA) is a consensus algorithm in which only permissioned members can interact with the blockchain, perform transactions, make or suggest network parameter changes, review transaction history, etc. The term was coined by Gavin Wood, a blockchain developer who co-founded Ethereum, Polkadot, and Kusama Network. In a PoA blockchain, everything is about reputation —network participants are staking their identities instead of coins. They provide a higher level of scalability and throughput since it only relies on a limited number of validators. We may think this is a heavily centralized model, but PoA blockchains are usually private and fit better with enterprises and organizations that use blockchain technology to enhance businesses and operational systems.
What is Proof of Elapsed Time?Proof of Elapsed Time (PoET) is another consensus algorithm that works best with private blockchains. The PoET algorithm was first presented by Intel software developers and implemented to Hyperledger Sawtooth, targeted at private blockchains and institutions. The algorithm might not be as popular as other blockchains since it wasn’t adequately defined. But the idea was to present a ready-made, Nakamoto-style engine that allowed private blockchains to choose the next block producer. And how do they differ? Well, the algorithm generates a “random wait time” for each network node, and during that time the node must “sleep.” The node with the shortest wait period wakes up first and wins the right to produce a block in the chain. So, the main difference is that miners in PoET are not running 24/7 and consume less energy. Further, in a PoW network, miners compete to hash the next block header, whereas in PoET it’s more of a random selection system.
Consensus Algorithms FAQ:Will Ethereum become faster now that it has transitioned to PoS? A common misconception is that Ethereum will automatically scale now that it’s a PoS-based blockchain. However, this transition was made to enhance Ethereum by:
- Lowering energy consumption
- Lowering barriers to entry by eliminating hardware requirements
- Allowing economic penalties for node misbehavior
- Introducing a new model for token emissions
- And a better infrastructure to work with Ethereum Layer-2 solutions.