Consensus Algorithms: How to Balance Efficiency with Decentralization?

In traditional accounting, there are ledgers where all transactions are written. The ledger is stored in one centralized server, and there is only one authorized entity that can update it. This organization has to be transparent and trusted if it wants to attract and retain users. But in any case, it has the means to change the information in the ledger arbitrarily at any time.

In blockchains, this is impossible unless the network isn’t attacked. The technology is also called distributed ledger — transaction records are stored across a decentralized network of nodes, where every member has a complete copy of these records that is updated simultaneously for everyone. But how do you update a distributed ledger?

This is achieved through a consensus that is reached through special rules allowing the network to agree on which version of the blockchain (transactions database) is correct. Consensus algorithms are the very heart of cryptocurrencies — depending on the type of algorithm, the coin works differently in technical means and the ways in which users interact with it.

Consensus algorithms and decentralization of ledger allow people to operate their funds without the need to trust intermediaries, i.e. in a trustless way. Let’s see how this works and how different consensus algorithms ensure the security of cryptocurrencies.

Consensus algorithms general features

Different consensus algorithms share the same principle: a user puts in a certain stake, and this gives them the right to validate transactions, maintain the security of the network, and get rewarded in return. This stake can be hardware that the user needs to invest in (like in Bitcoin’s Proof of Stake), a sum of money that they have to lock in a wallet (in Proof of Stake: Ethereum 2.0 or Cardano), reputation, or something else depending on the algorithm.

For doing their job, nodes (network participants) in every consensus algorithm get rewarded. For an attempt of validating in a malicious and dishonest way, many consensus algorithms have the punishment that can cut the size of a stake. Accordingly, algorithms have special tools to find malicious actors: these tools check if the data that the node is trying to add to the blockchain is valid.

Proof of Work (PoW)

Proof of Work is the first consensus algorithm that has ever existed: it was implemented in Bitcoin and many other cryptos later. However, the Bitcoin inventor Satoshi Nakamoto didn’t invent Proof of Work: it had already been proposed in the 1990s as a way to discourage DoS attacks.

In PoW, network participants, or nodes, are called miners. To add a block with recent transactions to the blockchain, they need to perform a mathematical operation known as hashing. This is done via a hash function — an algorithm that transforms any text into hash, a unique string of 64 symbols. Hashing a block means passing transaction data and the hash of the previous block through the hash function. Here’s what the hash of the block 702296 mined on September 26, 2021, looks like:

00000000000000000009e520e01f0e8493ff7d4235b6a2c0916d4e0c66e22448

Hashing is very easy, but if you simply hash a block, you’ll first get a random string of numbers, whereas the hash needs to comply with the rule: there has to be a certain number of zeros at the beginning. Finding such a hash is only possible with billions of trials and errors by varying a random number in the block called the nonce (for more details, see here). Since this is a difficult and energy-consuming process, expensive powerful hardware is required.

When the needed hash is found, it’s very easy to check if it’s valid. When a miner finds it, they demonstrate it to the network as proof of work. Nodes check it and let the miner add the block to the blockchain and receive their reward. Blockchain in all the nodes gets updated.

Since you have to invest a lot of money in hardware, it’s extremely expensive to control at least 51% of the network’s hashrate to attack it. That’s why Bitcoin is so secure. However, a lot of energy is consumed, and that is a huge concern. To resolve this issue, energy-efficient consensus algorithms were created.

PoW pros:

  • The algorithm was time-tested on many of the large cryptocurrencies with millions of users.
  • The structure of incentives ensures that the bigger the network, the more secure it is.

PoW cons:

  • A lot of electricity is consumed, which is harmful to the environment.
  • In many PoW networks, only the biggest players can afford full-fledged solo mining.
  • This creates the risk of centralization: the one with more money has more control over the blockchain.

Proof of Work cryptocurrencies:

  • Bitcoin (BTC) and its forks: Bitcoin Cash (BCH), Litecoin (LTC), Dogecoin (DOGE)
  • Ethereum (ETH) until 2022
  • Monero (XMR)
  • Zcash (ZEC)

Some of the largest coins run on Proof of Work, whereas most of the new coins don’t implement pure PoW. They use different kinds of it, but more often, leverage such an algorithm as Proof of Stake.

Proof of Stake (PoS)

Proof of Stake is the most widespread alternative to Proof of Work. It doesn’t require much computing power — rather, you need to have a stake in a given coin to get the right to validate transactions and add them to the blockchain. The concept of PoS emerged relatively early — back in the days when Bitcoin didn’t consume as much energy as today. The first PoS crypto was Peercoin created in 2012.

In Proof of Stake, validators confirm transactions instead of miners, add them to the ledger, and get rewarded. If you want to validate, you’d need to lock some coins in your wallet (however, not all PoS cryptocurrencies require this). Then, the system distributes the stakers’ chances to validate blocks either by the stake size or randomly. In the former case, like in PoW, it creates the risks of centralization — the one with a bigger stake has more chances to validate blocks and therefore more control.

Same as in PoW, there is a control of correct block validation in PoS. This consensus algorithm also leverages hashing — but instead of the ‘trial and error’ mechanism, you have to get the right to hash a block, and whenever you do, you simply hash the block data in one step. If you’re trying to present an invalid hash to the system, your stake will be slashed.

PoS pros:

  • No huge computational resources are needed to validate blocks.
  • If a protocol is implemented favorably for small stakers, the coin can be very decentralized and resistant to attacks.

PoS cons:

  • If the algorithm is implemented in a way that the richest stakers win, the risk of centralization and hence lack of security is high.
  • If there’s a disagreement regarding which block is valid, the coin risks getting split in two (which is called a hard fork). In Proof of Work, it’s profitable for miners to work only for one chain not to divide their resources, whereas in PoS, validators don’t care. That’s why, theoretically, the risk of hard forks in PoS coins is higher.

Proof of Stake cryptocurrencies:

  • Ethereum 2.0
  • Cardano (ADA)
  • Tezos (XTZ)

Delegated Proof of Stake (DPoS)

Delegated Proof of Stake was created in 2014 to increase the throughput of PoW and PoS. Compared to the basic Proof of Stake, in DPoS, validation of blocks is done by delegates rather than all stakers. The latter choose delegates based on their approval ratings and delegate them their coins. With a bigger stake, delegates get the right to validate blocks and distribute block rewards proportionally between those who voted for them.

If a delegator acts maliciously, their ratings drop, and stakers won’t vote for them anymore. This is a great incentive to act honestly.

Terra (LUNA) and EOS running on DPoS are much faster and have a greater throughput compared to PoS and PoW coins because fewer nodes need to reach consensus. However, this also poses a risk of centralization — richer actors can create “stakers” and vote for themselves to become delegates.

Other kinds of consensus algorithms

Today, there is an abundance of different consensus algorithms aimed to improve the drawbacks of the existing ones. Here are some of them:

  • Proof of Authority. There are only a handful of approved accounts authorized to validate blocks, and their reputation (‘authority’) is at stake. VeChain (VET), Binance Smart Chain leverage PoA with a limited number of nodes. This is a deliberate “no” to true decentralization in favor of efficiency.
  • Proof of Importance. This one is similar to PoS, but nodes are ranked by their “importance” level before getting the right to validate blocks: it depends on how long they’ve been holding the coin for and how actively they were using it. NEM (XEM) uses PoI consensus.
  • Combined PoW and PoS in Decred (DCR). Miners validate blocks and get 60% of a block reward, and then these blocks are additionally confirmed by stakers who get 30%. The remaining 10% goes to the dev fund. Such a combination makes an attack on DCR even more expensive than on Bitcoin: you’d have to control not only mining but also staking.

Now that you’ve got familiar with consensus algorithms, head on to our blockchain 101 article to find out how Bitcoin miners process blocks and why this consumes so much energy.

ChangeNOW is an instant cryptocurrency exchange service for limitless crypto conversions. We support over 200 coins and are account-free! https://changenow.io/