School / Consensus Mechanisms

Consensus Mechanisms

Consensus Mechanisms

Consensus mechanisms are the reason blockchains cannot be banned or censored. But what are they exactly and how do they work?

Consensus mechanisms are literally vital to a blockchain. Without a consensus mechanism, a blockchain “dies”, in other words, it becomes unusable and unused. But what is a consensus mechanism, and why is it essential? In this lesson, you will learn:

  • What a consensus mechanism is
  • Why blockchains require them
  • The mechanics of the most commonly used consensus mechanisms
  • The advantages and disadvantages of these consensus mechanisms

What is a consensus mechanism?

To answer this question, let's recall how a blockchain works. A blockchain is a distributed ledger that records transactions. Let's say Joe wants to send Donald $100 for his excellent work. He could go to a bank, and the bank would verify and approve this transaction. The bank is a central source of authority.

But with a blockchain, Joe would need people to verify he gave Donald the money. Donald would then confirm he received it. So Joe and Donald call up Nancy and Mike to verify the transaction in their copies of the blockchain. So far, so good. But what if Nancy says Joe paid, but Mike disagrees?

This is where a consensus mechanism comes in. We need nodes, in our example Nancy and Mike, to agree on one truth to keep adding blocks to the blockchain (blocks that contain the transactions). As you can see, having only two nodes is not ideal since it could happen that no consensus is reached. So having a third node, maybe Barack, would solve this problem. In this example, people would accept the copy of Barack's and Nancy's blockchain to contain the truth and would continue using that one.

Consequently, a consensus mechanism is the manner you arrive at a consensus, so everyone agrees to the ledger being correct. In this example, there was a consensus, but so far we didn't cover how the nodes reached it.

Why do blockchains need a consensus mechanism?

Before covering how it makes sense to cover the why. Why would Joe and Donald use a blockchain instead of using a bank?

Firstly, a bank can be fraudulent. If Joe decides to wire $10M instead of $100, a bank might choose to dash off with the money. It could also try to retroactively tinker with the transaction or deny it ever happened. Unless there is a way to force the bank to open its books, Joe has no independent proof he actually paid the money. A bank could also get robbed or hacked.

A blockchain solves all of these problems. However, a blockchain needs a consensus mechanism to verify the info added to its ledger is valid. If not, the double-spending problem arises, where Joe claims he sent Donald the money but never actually did and is then able to spend his $100 again. This consensus mechanism also prevents forking. For instance, Mike would continue with his copy of the blockchain where Donald never received the money, and whoever believes in this truth would continue using it as well. In the blockchain world, this is called a hard fork.

How consensus mechanisms work

With the what and why clear, it's time to turn to the how. The choice of consensus mechanism impacts the security and economic framework of a blockchain. Different consensus mechanisms have different levels of security, as well as implications for the governance of blockchains. Depending on the choice of mechanism, actors behave in different ways.

Let's look at the most commonly used examples and their upsides and downsides.

Proof-of-Work (PoW)

Imagine anyone could volunteer to verify Joe's transaction. In order to verify it, volunteers first have to solve a complex mathematical puzzle. The first person to succeed gets a reward and can add the transaction to the blockchain if the others agree. Let's say there are five volunteers, and Barack solves the puzzle first. He concludes Joe really sent the $100, and the others agree with him. Everyone adds the transaction to their copy of the blockchain.

That's the essence of proof-of-work. The volunteers (miners) have to solve a puzzle (a hash function) to receive a reward (the mining reward). Only people that have solved the puzzle have a say in verifying transactions.

For the next transaction, Mike brings his son, a math prodigy, to help him with the puzzle and win the reward. Soon after, everyone starts bringing helpers. It's not too long before all volunteers are working with industrial equipment to solve the increasingly difficult puzzle. This is what happens in reality with proof-of-work consensus mechanisms. After a while, economies of scale result in profitability for the best-equipped miners. Because the puzzle is complex to solve but easy to verify and can only be solved through brute force, only more computing power leads to better results.

But what if one day Mike, Mitch, and Ron conspire to dispute a transaction? Since it's three against two, the consensus would be their truth is the one that gets added to the blockchain. That would be a 51% attack. A reason to do that would be to share the mining reward between the three of them. However, the mining reward would need to be big enough for the three to split between themselves. Because if a miner other than them solves the next puzzle first, they would need to bribe him as well to keep their erroneous version of the blockchain going.

This incentive structure makes it difficult and improbable for miners to collude and cheat. In essence, validating transactions has to be so expensive that there is no incentive to cheat. In proof of work, the currency is computational power. That is also why proof-of-work is a probabilistic consensus mechanism. As soon as a puzzle is solved, it is verified if enough nodes agree to a truth. The more blocks are added to a blockchain, the less likely it is that the last block contained false transactions.

Advantages: Proof-of-work blockchains offer a high degree of security since attacking the network is very expensive. Because computational power is necessary to solve the hash function (the puzzle), miners have an incentive to behave correctly.

Disadvantages: Becoming a node carries a high cost of participation, precisely because of the expensive hardware. Moreover, it is energy-intensive, which is why Bitcoin is the target of so much criticism for "wasting" more energy than some countries use. Miners also have different incentives than developers because they also receive a part of the transaction fees. Thus it makes sense for miners to keep transaction fees high (which is bad for users).

Proof-of-Stake (PoS)

Imagine Joe wants to send Donald 100 ETH instead of $100. (Ethereum does not use PoS yet, but it's planning to do so in the near future.) Then, Mike, Nancy, and all the other nodes would be called validators and have to have a certain amount of ETH to validate transactions. Any node can be a validator if it locks up enough Ether.

In PoS, there is no puzzle. Instead, it uses a lottery to determine who gets to validate first. The validators would need to lock up these ether with the network for a chance to participate in the lottery. The more ETH you locked up, the higher your chance to win. The winner gets to validate the transaction and a share of the transaction fee as a reward.

There is also a possibility to cheat in proof-of-stake, but the network levies a penalty on nodes that try to cheat. This is a major difference between PoS and PoW. In PoW, miners are incentivised to behave correctly, in PoS, validators are penalized for incorrect behavior.

Advantages: Proof-of-stake isn't nearly as energy-intensive as PoW. Hence why Ethereum, which is currently still a proof-of-work blockchain, wants to switch to proof-of-stake. Another difference is that the interests of validators and the network are aligned. Since validators deposit the network token, they have an interest in its value appreciation. Therefore, PoS is well-suited to platforms that have static coin supply without inflation from block rewards.

Disadvantages: PoS in its simplest form can become quite centralized. Since participation also carries an upfront cost, locking up enough tokens only makes sense for those that can afford it. It is also liable to 51% attacks, especially if the entire network value isn't too big and a majority of coins can be acquired at an acceptable cost.

Delegated Proof-of-Stake (dPoS)

Delegated proof-of-stake has one key difference compared to proof-of-stake. It gives nodes the option to delegate their coins to someone else to validate transactions. Say you want to participate in validating but have only 1ETH, you could delegate your ETH to Barack and would receive a share of the rewards for doing so. In this case, Barack would be a delegate. So its a similar concept to setting up a syndicate to reduce to cost of participation. Since ineffective delegates can be replaced, they have an incentive to behave correctly.

Advantages: This consensus mechanism is more egalitarian than PoS and, therefore, also more widespread. For instance, Polkadot uses delegated proof-of-stake as consensus mechanism. It's also quicker because only a small group of validators needs to be involved. This is generally beneficial for transaction speed and, consequently, for the scalability of the blockchain.

Disadvantages: Evidently, a small group of validators results in more centralization. Since blockchains aim to be as decentralized as possible, that goes against one of the core tenets of the crypto space.

Proof-of-Authority (PoA)

VeChain uses PoA, a reputation-based model where validators are pre-approved and have to put down a certain stake to participate. In the other mechanisms, we actually don't know the identity of Nancy, Mike, and the other validators or miners. In PoA they agree to put their reputation on the line for the privilege of being able to validate transactions. In reality, these are often institutional investors or strategic partners that disclose their identity for accountability.

Other than that, the consensus mechanism works like PoS. It is semi-centralized since the investors have social capital on the line and are hand-picked as validators. That is not in line with the permissionless nature that other blockchains pursue. Also, while having an incentive to behave correctly, wealthier nodes could eat a financial loss more easily than less wealthy nodes, which doesn't make the mechanism very democratic. In reality, though, it would be improbable for them to do so.

Pure Proof-of-Stake (PPoS)

This is another variant of PoS, which Algorand uses. Anyone can be selected as a validator in pure proof-of-stake, even with only 1 ALGO at stake. There is no penalty for misbehaving since any node can be selected. As long as two-thirds of the nodes agree to a consensus, the network is functional. It is essentially a democratized version of PoS.

However, critics say it's very similar to regular PoS and thus nothing innovative. Also, network security might be a problem because there is no penalty mechanism for malicious behavior.

Proof-of-History (PoH)

The Solana blockchain uses proof-of-history, which is a version of proof-of-stake. In normal PoS blockchains, Joe's transaction arrives at the validators simultaneously with thousands of others. Ordering these transactions takes time and slows the blockchain down.

In PoH, the blockchain randomly chooses one validator to order transactions. Each transaction receives a unique cryptographic verifier that makes the order of the transactions identifiable. For instance, we know whether Joe's transaction is first in line or third. This makes it easier for validators to do their job and, as a result, improves the speed of the blockchain. On the flip side, it generates a lot more data in comparison to slower blockchains, which raises the cost of participation.

DAG used by Iota

There is one blockchain that isn't even a real blockchain. Iota uses a consensus mechanism which is called DAG (direct acrylic graph). Here, it gets quite complicated since this is a concept used in programming. The highly simplified explanation is a DAG is a chain of events where you know the beginning.

For instance, a tree has a clear beginning (the root). There is no trunk without a root and no branches without a trunk preceded by a root. Every apple from an apple tree has an unambiguous predecessor, i.e., a branch cannot suddenly grow into another branch and form a loop.

This concept is used in IOTA. Each transaction validates two more transactions, but they can never form a loop. Instead, they always point in one direction, just as a tree does. A minor proof-of-work puzzle validates each transaction, which is nowhere near as complicated as for Bitcoin. It would also be finalistic, unlike the probabilistic consensus mechanism of proof-of-work, because transactions are immediately finalized and cannot be changed.

The upside of this system is that it's very cheap and potentially very scalable. For this reason, IOTA plans to use it not as a payment system, but for the Internet of Things, where machines make micro transactions and communicate securely between themselves without being slowed down by transaction fees. The downside is it is not proved in reality yet and currently relies on a master node that coordinates everything, hence it is for now centralized.

Conclusion

So far, PoW is the dominant and only stress-tested consensus mechanism. Several blockchains use PoS, but they are far less used and less popular than Bitcoin and Ethereum. Ethereum plans to switch to PoS in 2022, which would mark a major change in blockchain history.

Crypto School Exam
Copy the Best Traders
Copy the Best Traders

eToro is one of the easiest places to buy crypto and a recognised brand in the financial industry. You can also follow and copy the most successful traders on the site! A great site for beginners.

eToro Review
eToro Review

eToro is a social trading platform that allows you to buy into cryptocurrencies, international stocks and shares and more complex financial assets. It also has an innovative Copy Trader feature where you can choose to follow other successful traders and automatically copy their trades to hopefully share in their success

Kraken Review
Kraken Review

Kraken has a good reputation for security and protection of your funds and operates across the USA (except NY), Canada, the EU and Japan

Beginners Guide to Cryptocurrency
Beginners Guide to Cryptocurrency

What is cryptocurency? What gives it value? How do you buy and store it? Beginners questions answered in plain English.

Badly Reviewed Banks
Badly Reviewed Banks

Crypto gets a lot of criticism sometimes but what sort of job are the current banks doing at looking after their customers. Who are the best and the worst banks to be with?

Ripple Review
Ripple Review

This is a specific digital coin running on a series of servers. XRP promises utility in handling cross-border transactions to compete with the SWIFT interbank payment system. Being controlled by banks, many question if it is a true cryptocurrency.

Litecoin Review
Litecoin Review

An early alternative to Bitcoin, LTC aimed to be a coin for easy, fast, low-fee spending. LTC offers a faster block time and a higher transaction capacity in comparison to Bitcoin.