DEV Community

Cover image for Consensus Mechanism in Blockchain

Posted on

Consensus Mechanism in Blockchain

Did you ever got a question, Without any central authority how does Blockchain works and how a decision made in Blockchain? Normally in central authority, there will be an elected leader, to make a decision.

But in the blockchain, it is not possible to have a leader. For the blockchain to make decisions, they need to come to consensus called “consensus mechanism”

Let’s see how decisions are made in Blockchain,

1. What is Consensus?

In simple terms, the Consensus is a dynamic way of reaching an agreement in a group. While voting just settles for a majority rule without any thought for the feelings and well-being of the minority, a consensus, on the other hand, makes sure that an agreement is reached which could benefit the entire group as a whole.

“From a more idealistic point-of-view, Consensus can be used by a group of people scattered around the world to create a more equal and fair society.”
A method by which consensus decision-making is achieved is called “consensus mechanism”.

2. How does the Consensus work?

A Consensus is a group of people coming to an agreement. 
Let’s take an example, A node suggests one agreement and another node suggests another agreement and now the majority of people will choose the better consensus which could benefit the entire group. 

To make it more clear, a group of people create fair and equal rights to all nodes.

Characteristics of consensus decision-making include(Wikipedia):

Collaborative: Participants contribute to a shared proposal and shape it into a decision that meets the concerns of all group members as much as possible.

Cooperative: Participants in an effective consensus process should strive to reach the best possible decision for the group and all of its members, rather than competing for personal preferences.

Egalitarian: All members of a consensus decision-making body should be afforded, as much as possible, equal input into the process. All members have the opportunity to present and amend proposals.

Inclusive: As many stakeholders as possible should be involved in the consensus decision-making process.

Participatory: The consensus process should actively solicit the input and participation of all decision-makers.

Now we know about the Consensus mechanism, let see the most used consensus mechanism right now.

1. Proof of Work

Before going to that, I want to tell you a small story. When I was in 1st grade my teacher used to ask us to solve a maths problem and reward for that would be a bar of chocolate:
For eg: 10 + ? = 12, who solves the first, the reward is given to them.
10 + 1 = 11
10 + 2 = 12

After getting the answer, I use to rush to my teacher and showed my answer but Unfortunately, some other kid has solved it before me and he walked away with that chocolate bar.

The teacher also realised that the problem was too easy for the kids. For the next chocolate, she increased the difficulty level. This time the class is asked to solve:


Now taking the same scenario in the Blockchain:

Miners are like Students, competing with each other to solve the puzzle to earn rewards. Here “2” is the nonce - a number which can be used only once to solve the puzzle.“12” is the difficulty level, which ensures the teacher has control over the number of chocolates distributed.

Blockchain uses the difficulty level to control the generation of 1 block/~ 10 minutes. The person who solves the cryptographic puzzle will win the rewards and places the block in the blockchain.

The main drawback of POW is an extremely inefficient process because of the sheer amount of power and energy that it eats up.

You can see all the details of the block here:

2. Proof of Stake

This is one of the best Consensus mechanism and Ethereum is soon planning to move from Proof of Work to Proof of Stake.

To keep it simple, there will be no miners in the Proof of Stake. Yes, you heard it right. There will be only Validators who will validate the transaction in the Blocks.

To Validate the transaction the validator has to place a certain amount of bet,
The size of the stake determines the chances of a validator to be chosen to validate the next block. Now, you may have a question, a person with more stake will always choose to validate, but in reality, it’s much fairer. 

For Eg: A Node has been chosen to validate the next block, he’ll check if all the transactions within it and adds it to the blockchain. After the block is on the blockchain, the node receives a fee for each transaction. After some time the validator will receive his deposited money.

What if Validators approve fraudulently transaction?

Validators will lose a part of their stake if they approve fraudulent transactions. The amount stake is much more than the fee which they receive from the transactions. So we can trust the validators to their job correctly. If not, they will lose more money then the gain.

The person with more stake will validate that transaction and receives the transaction fee and after that, he will receive the deposit money

Alt Text

Other Consensus Mechanism

3. Delegated Proof Of Stake (DPOS)

DPOS is implemented in EOS and its works on Stake-weighting voting system. Where the Stake of the person determines the weight of their vote.

Delegated Proof of Stake is like an election, where people need to vote for the delegates. Delegates are a person or an organisation used to produce the blocks on the network and the delegates will receive the reward for creating the block. The reward will be like in Proof of Stake, transaction fee or fixed amount of Coins. 

How delegates are chosen to produce the Block?

For Eg: Nodes will vote for the delegates with their stake and the person with the highest votes will get chance to produce the block on the network. It is same as an election where we need to choose the delegate of our choice and need to do our voting. The weight of their vote depends on their stake. 

For Eg: If “A” stakes 50 coins for the delegate and “B” stakes 10 coins for a delegate, then A’s vote is 5 times more weight then the B vote. 

Since delegates want to receive as many votes as possible, they are constantly incentivized to create things valuable to the community, as they are likely to receive extra votes for doing so.

4. Proof Of Capacity (POC)

Proof of Capacity is a consensus mechanism, uses a process called Plotting, In Proof of Work, miners use a lot of computational to solve the puzzle to create a block, however in Proof of Capacity all the solutions are pre-stored in Storages like Hard Disks. After storage has filled with solutions he can take part in the block creation process. This process is called Plotting.

The person who solves the puzzle fast will get to create a new block. This mechanism is like, Storage capacity is directionally proportional to the higher chances of creating the new block.

"All the consensus mechanism approach is different but the intentions and goals are the same for all the consensus, yet perfect consensus mechanism doesn’t exist. Still, there are many and yet to come and hope there will be an efficient consensus mechanism over a period of time".

Top comments (0)