Cryptocurrency Consensus Mechanisms Explained

Cryptocurrency Consensus Mechanisms Explained

Ryan S. Gladwin's photo
Ryan S. Gladwin
·May 23, 2022·

10 min read

Play this article

Table of contents

Consensus Mechanisms are a hot topic that touches on the environment, scalability, and security. But what exactly are they?

What Is a Consensus Mechanism? 🔐

In the cryptocurrency world, consensus mechanisms are protocols and algorithms that enable a network of computers to work together to secure the network.

51% of the nodes in the network must agree on the global state of the network in order to reach a consensus.

In a way, it's just a big-brain way of saying, "This is the method we're going to use to make sure we all agree with each other".

hey arnold gif, can we agree on that

What Are We Agreeing On? 👍

Blockchain technology consists of blocks that are verified and then added to a chain (hence the name).

Each block contains a list of verified transactions from a specific time period. This is available for everyone to see; meaning, you can go back and see every transaction ever made on the blockchain.

Consensus mechanisms are used to verify the transactions added to the blockchain.

Some more advanced blockchain projects will also use a consensus mechanism to verify stored data, smart contracts, etc.

But on the basic level, consensus mechanisms are used to verify transactions.

How Do Consensus Mechanisms Work? 🤔

Well, it depends on the model that a blockchain decides to use. There are two main types of consensus mechanisms: proof-of-work (PoW) and proof-of-stake (PoS).

What Is Proof-of-Work 🔨

Proof-of-work is the consensus mechanism that Bitcoin uses. Other cryptocurrency projects that use it are Ethereum 1.0, Dogecoin, and Litecoin.

It was originally developed in 1992 by Cynthia Dwork and Moni Naor as a way to prevent spam emails. Despite being the first presentation of the model, they did not call it proof-of-work at the time. Instead, it was called ”the pricing function”.

Fast forward to 2009, Satoshi Nakamoto created Bitcoin, which uses proof-of-work as a consensus mechanism. It’s used to validate transactions, as well as create new blocks on the blockchain.

Since then, it's grown to become a widely used consensus mechanism for cryptocurrency projects.

How Does Proof-of-Work Work?

Nodes on the network will attempt to answer hard-to-solve, but easy-to-verify cryptographic puzzles — the nodes trying to solve the puzzles are called miners. Once a miner has completed a puzzle, they’ll broadcast this to the blockchain so that other miners can verify the solution.

The answer to the cryptographic puzzle is a random number called ”NONCE”, which stands for number only used once. This number cannot be predicted, it can only be guessed.

This means you must invest a lot of time to find the NONCE.

Once combined with the data inside of the block and passed through a hash function, NONCE will produce a result with a set of conditions. This is the process that miners will go through to verify if the solution is correct.

When the valid NONCE is combined with a block, it creates a blockhash. This is then stored on the validated block as proof of the miner’s work The block will then be created and added to the blockchain.

Now you have proof that you put in work to solve the puzzle. Thus, you’re given a reward ,called the miner’s reward, in the form of crypto.

This is only given to the person who finds NONCE first, regardless of how much energy others might’ve put into attempting to solve the puzzle.

regardless of how much energy

Proof-of-work Energy Problem

Bitcoin mining is a way to create passive income for yourself due to the miner reward, which is why individuals and big corporations invest in being a miner.

The more computational power and the better the equipment you have to solve cryptographic puzzles, the more likely you'll receive money as rewards.

In other words, a super computer is more likely to find NONCE than a 2008 Dell.

This resulted in an insane amount of energy being used on the Bitcoin network. It led environmental activists against the proof-of-work consensus mechanism.

The Bitcoin network is responsible for 0.66% of the global electricity consumption, and 0.23% of the global energy consumption.

The amount of electricity consumed by Bitcoin is enough to power the University of Cambridge for 1,081 years, or power all tea kettles in the UK for 33 years (that's a lot of tea).

However, not all is bad. The high amount of computing power that the Bitcoin network consumes actually means the network is more secure.

This is because, in order to attack the blockchain, you need to control 51% of the computing power on the network (called a 51% attack). It would possibly cost billions of dollars to have this much computing power, making it financially unviable.

What Is Proof-of-Stake 💰

Proof-of-stake is the consensus mechanism used by Solana, Cardano, and Tezos.

It was first created on the Bitcoin talk forum in 2011 as an alternative to proof-of-work, to improve on where the old consensus mechanism falls short. In 2012, we saw the first cryptocurrency project adopt proof-of-stake — Peercoin.

Ethereum 2.0 will see the blockchain move from proof-of-work to proof-of-stake. In an attempt to be "more scalable, more secure, and more sustainable".

This method uses a lot less computing power than the proof-of-work method. And, therefore, projects using it are seen as more environmentally friendly.

How Does Proof-of-Stake Work?

The proof-of-stake consensus mechanism forges blocks rather than mining them, like in the proof-of-work method.

In proof-of-work projects, tokens are created as rewards for the miners, but in proof-of-stake projects, transaction fees are used as rewards. Therefore, proof-of-stake projects launch by selling pre-mined tokens or launch initially as proof-of-work, then transition to proof-of-stake.

If you want to be involved with forging blocks, you must stake your tokens. The staking process requires you to lock your tokens into the network, meaning, you’re unable to use them during this time.

This is because if you are a bad actor, you’ll have your staked tokens taken away from you as punishment — making it financially viable to act in such a way.

Stakers, also known as validators, take on a similar role to the miners in proof-of-work.

seems valid to me gif

Next, validators are selected using a pseudo-random selection method. Three of the most popular methods are node wealth, coin age selection, and randomized block selection.

Let's take a closer look at each method.

Node Wealth 🤑

Simply, the more tokens you have staked, the higher your chance is to be selected to validate the next block.

If this is the only variable used to select validators, only the wealthiest stakers will be able to secure the network; making the project less decentralized and more at risk to bad actors.

Coin Age Selection 👴

A node will be selected based on how long tokens have been staked for, using this formula:

Coin age = number of days staked x number of coins staked

Once a node has completed forging a block, its coin age is reset to zero. So, they must wait a period of time before they can forge another block. This prevents wealthy stakers from dominating the forging process. In turn, making the blockchain more decentralized.

Randomized Block Selection 🤷

Randomized block selection will choose the next forger by looking for the node with the lowest hash value and the highest stake.

It's important to note that each cryptocurrency project using the proof-of-stake consensus mechanism uses its own set of rules and methods when selecting forgers.

Back to Validating a Block...

When a node is finally chosen, it’ll validate the transactions on the block. Each transaction is signed with the sender’s private key.

The validator will use this key to find the sender’s public key and address. Using this information, they’ll then verify if the sender actually has the money they're spending, as well as if they haven’t spent the token more than once (known as the double-spending problem).

Next, the hash function groups the verified hashed transactions into a Merkle tree. Then, the forger signs the block using its private key, and broadcasts it to the blockchain for other validators (now called attestors) to attest that the block is valid.

Slots and epochs are used to divide time. A slot is the time set to create a block (12 seconds for Ethereum 2.0).

An epoch is a larger defined period of time, which often signals when a new group of validators will be selected (32 slots, around 6 minutes and 24 seconds for Ethereum 2.0).

Normally, every slot will produce a block on the blockchain. However, this can be empty if a forger fails to produce the block in time.

Once the block has been validated and added to the blockchain, the forging node will get a reward in the form of crypto.

As mentioned earlier, this is often derived from transaction fees. Attestors also get a reward if they correctly attest.

Not all proof-of-stake projects will follow this exact method and slightly tweak the system.

Delegated Proof-of-Stake

Some proof-of-stake projects allow you to delegate your tokens to other validators rather than having to set a node up yourself. This lowers the barrier to entry to staking rewards.

Individuals choose which validator to delegate their tokens to based on track record and reputation. Other factors can also determine where someone delegates their tokens, such as if they’re using eco-friendly energy and if there’s a percentage donation to charity.

Differences Between Proof-of-Work and Proof-of-Stake

Okay, that was a lot of information. Let's sum up the differences in the consensus mechanisms real quick.

Proof-of-work

  • Bitcoin uses it
  • Blocks are mined
  • Miners solve cryptographic puzzles
  • A lot of computing power is required to mine
  • Only the people who solve the puzzle get given rewards
  • Very bad for the environment

Proof-of-stake

  • Cardano uses it
  • Blocks are forged
  • Keys and signatures are used to validate transactions
  • Validators must stake their token to be selected to forge a block
  • Both validators and attestors are given rewards
  • More environmentally friendly

staking proof of work

Alternative Consensus Mechanisms

Although these are the two most popular consensus mechanisms, they aren't the only ones. In fact, more are being created as we speak.

Here are a few examples of alternative consensus mechanisms:

Proof-of-Space-and-Time 👽

This consensus mechanism allows the project to store data rather than just verify transactions.

Essentially, the model sets up a way for information to be put onto a hard drive, and then will randomly check if the information is still there.

People pay for their information to be stored, then those who store the data are paid for the storage.

Proof-of-Authority 🕴

This is a more centralized version of proof-of-stake.

Instead of allowing anyone to be a validator, proof-of-authority projects choose a few nodes that they trust. This is done to process transactions quicker, as well as reduce the environmental impact even further.

Unique Node List 📜

This is the consensus mechanism that Ripple (XRP) uses.

Similar to proof-of-authority, you select a few nodes that you trust. This time, nodes aren't required to stake anything, they just have to validate transactions.

Transactions are sent to loads of nodes and they’re asked to sign the valid ones. If a transaction doesn't get many signatures, it’s assumed that it wasn’t valid, so it’s thrown out.

If you’re interested , watch this video by MIT that dives into the topic of alternative consensus mechanisms further:

Consensus mechanisms are essential to secure the blockchain and make it what it has become today. We started with proof-of-work and are currently evolving to proof-of-stake as a way to reduce our harm to the planet.

But will this be the consensus mechanism for the rest of time? Or will we soon see another evolution?


This article is a part of the Hashnode Web3 blog, where a team of curated writers are bringing out new resources to help you discover the universe of web3. Check us out for more on NFTs, DAOs, blockchains, and the decentralized future.

 
Share this