DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,864 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Demystifying Consensus Mechanisms in Blockchains
Desmond Obisi
Desmond Obisi

Posted on • Updated on

Demystifying Consensus Mechanisms in Blockchains

Welcome to another article where we demystify complex blockchain terminologies. In this piece, we will be explaining what consensus mechanism is, what it means for a blockchain network and its effect on the impact of products built on the network.

INTRODUCTION
Imagine a centralised system where an entity validates the authenticity of data supplied to the system (database). The entity alone has the sole power to modify, accept, and reject data according to the set metrics used to measure the data authenticity.

Now think of a consensus mechanism in a decentralised web as some set of rules or algorithms that entities operate on to authenticate, verify and validate block production or transactions in the block itself to avoid fraudulent activities.

In such a dynamically changing status of the blockchain, these publicly shared ledgers need an efficient, fair, real-time, functional, reliable, and secure mechanism to ensure that all the transactions occurring on the network are genuine and all participants agree on a consensus on the status of the ledger. This all-important task is performed by the consensus mechanism, which is a set of rules that decides on the legitimacy of contributions made by the various participants (i.e., nodes or transactors) of the blockchain.

We will be learning the two most used consensus mechanisms in this article: Proof of Work, Proof of Stake. Other consensus mechanisms like: Delegated Proof of Work, Proof of Authority, Proof of Activity, Proof of Elapsed Time etc will be discussed in the second part of this article.

PROOF OF WORK (PoW)
The PoW concept was adapted to securing digital money by Hal Finney in 2004 through the idea of "reusable proof of work" using the SHA-256 hashing algorithm. PoW describes a system where a significant and feasible amount of effort is used to deter fraudulent or malicious use of computing power. The concept of block productions and block spending is designed to not allow double spending in a block by any of the validators. PoW requires nodes on a network to provide evidence that they have expended computational power (i.e. work) in order to achieve consensus in a decentralized manner and to prevent bad actors from overtaking the network.

proof-of-work
A pictorial representation of how PoW consensus mechanism works

PROOF OF STAKE (PoS)
In the bid to solve the scalability and environmental sustainability issues that come with PoW consensus mechanism, a more better approach to validating and approving blocks of transactions in blockchain was birthed, Proof of Stake (PoS).

Proof of Stake is therefore a consensus mechanism or algorithm where validators of blocks no longer need too much computational power through works(mining activities) to approve or generate blocks but stake a certain amount in the pool to be able to validate transactions.

Proof-of-stake changes the way blocks are verified using the machines of coin owners. The owners offer their coins as collateral for the chance to validate blocks. Coin owners with staked coins become "validators''. Validators are then selected randomly to "mine," or validate the block. This system randomizes who gets to "mine" rather than using a competition-based algorithm like PoW.
To become a validator, a coin owner must "stake" a specific amount of coins. Blocks are validated by more than one validator, and when a specific number of the validators verify that the block is accurate, it is finalized and closed.
Security is also more guaranteed in the PoS consensus mechanism as it will take a validator with upto 51% of the staked liquidity to overrun the network. But then, it is very possible for a single validator to own half of he staked liquidity and have the power to double spend or confirm fraudulent transactions but the PoS algorithm is built in a way that the validator will lose all the staked currency when he sign or approved any illegal block production or transaction thus this creates an incentive for miners to act in good faith for the benefit of the cryptocurrency and the network else the hack will not be profitable.

proof-of-stake
A pictorial representation of how PoS consensus mechanism works

Proof of Work Vs Proof of Stake (PoW and PoS) – Key Differences

  • Working
    The first pointer for comparing proof of work and proof of stake algorithms would obviously refer to their working. PoW involves bundling a group of transactions in a mempool, and miners have to verify validity of transactions by solving a cryptographic puzzle. As compared to PoW, the PoS algorithms do not rely on mathematical puzzles. On the contrary, the algorithm selects validators randomly according to their stake in the network. Proof of Stake algorithm does not involve the creation of any type of coin, especially with all coins created from the start.

  • Security
    Among the many factors for deciding the better alternative between PoS and PoW, security would obviously take foremost priority. In the event of forking in PoW-based blockchain systems, miners must focus on the actual blockchain or shift to the new blockchain fork. Constant forking can present a formidable economic disadvantage and could help hackers gain control over 51% of computation power for carrying out malicious attacks. On the other hand, PoS consensus does not impose restrictions on forking. No financial incentive for validating multiple transaction copies on a blockchain. It is difficult for hackers to own 51% of stake in a blockchain network and if they do, they will lose their staking power and staked currencies making it unprofitable.

  • Energy
    The next critical factor for differentiating between PoW and PoS consensus algorithms refers to energy efficiency. PoW consensus algorithm focuses on identifying the user who could modify the ledger by leveraging a competitive race. Participants in the race or miners have to use computational energy for proposing valid blocks that follow the network rules. On the other hand, PoS presents better scope for energy efficiency. However, PoW miners have the flexibility for using any type of energy sources such as wind, hydropower and other sustainable energy sources. PoS consensus is highly energy-efficient although at higher costs of resources.

  • Rewards
    The comparison of proof of stake vs proof of work would also focus on the factor of reward distribution. Which consensus mechanism serves a better fit for miners? In the case of PoW consensus, Rewards are given to the first miner successful in solving the cryptographic puzzle for every block. However, validators do not receive any block reward rather they settle for network fees as their reward.

CONCLUSION
Whether a network is using PoW or PoS consensus mechanism to validate their blocks, produce blocks etc, we have learnt a great deal of how these work under the hood and the economical, environmental and financial implications of using any of the consensus algorithms.
We will conclude the discussion about the other existing consensus mechanisms in the final part of this article on β€œDemystifying Consensus Mechanism in Blockchains”.
Do well to share your thoughts, share with others and suggest what you want us to break down in our next piece.

Top comments (2)

Collapse
 
yongchanghe profile image
Yongchang He

Thank you for sharing this knowledge~!

Collapse
 
desmondsanctity profile image
Desmond Obisi Author

Glad you find it interesting

About Real-time

Join DEV and MongoDB to build a front-end application using MongoDB Atlas. Change streams to display live updates as your database changes for your entry in the DEV x MongoDB Atlas Hackathon 2022.

β†’ Join the Hackathon