DEV Community

CoinMonks
CoinMonks

Posted on • Originally published at Medium on

A Beginner’s Guide to Understanding the Blockchain (Part 2: Blockchain Consensus Mechanisms)

Source: https://www.logicsolutions.com/

Consensus and Blockchains

As mentioned in the previous article on blockchains (access it here if you haven’t already), consensus is a concept that is central to any blockchain, or distributed, system.

Why is this the case?

Think of it this way: in a normal centralized organisation, all decisions are made by a leader, a group of leaders, or by a board of decision-makers. In this case, no consensus between all parties in the whole organisation is required, because decision-making power is vested in the leaders in the upper echelons of the hierarchy. The authority figures will make the final decisions for everyone.

In contrast, blockchains are decentralized systems, fully peer-to-peer, and with no central authority figure or third party to make decisions. While such systems have its merits, where they are less corruptible by a single source, and have more redundancies in place to prevent a single point of failure, they also have their issues.

In such a system, and with no restrictions on the types of, and number of ‘peers’ coming into and going from the system, where anyone and everyone can just enter and leave this network as and when they please, how can users then make any decision as a collective? No one will be able to trust each other because they will know nothing about each others’ backgrounds!

How then, can they even get anything done?

This is where the concept of consensus is of utmost importance — only through such a group decision-making process where group members develop, and agree to support a decision in the best interest of the whole, can anything in the blockchain get done.

But how can such consensus be achieved without a dedicated and central third party to oversee such a tenuous operation? We are talking about helping an unlimited number of trustless users come to consensus here  — surely it must be impossible to do so without someone to oversee everything?

There is actually a way, and yes, you guessed it — we can do so through consensus mechanisms!

At this point, if you have not already read my previous article on blockchains, please do so at this link before proceeding on, if not you will definitely be lost in the next section!

Trust without Trust in Blockchains: Consensus Mechanisms

Explained in its simplest terms, consensus mechanisms in blockchains are methods by which agreements between disparate parties in a group (who don’t know, and don’t trust each other) are achieved without the involvement of any third party.

In the world of blockchain, there are numerous different consensus mechanisms. The main ones include, but are not limited to:

  1. Proof-of-Work
  2. Proof-of-Stake
  3. Proof-of-Activity
  4. Proof-of-Space
  5. Proof-of-Elapsed-Time
  6. Proof-of-Authority
  7. Proof-of-View

Although they may sound drastically different, all these mechanisms serve the same ultimate purpose: to ensure that the record of transactions on a blockchain are true and honest, where all participants are in agreement with regard to the history of transactions.

The difference between them lies in the way such a consensus is reached.

For the sake of not overloading you with too much information, this article will only focus on the Proof-of-Work (POW) and Proof-of-Stake (POS) consensus mechanisms.

Source: https://timestampmag.com/

Proof-of-Work (POW)

In a blockchain that utilises the POW mechanism, a system of proposers and voters is established to ensure that no one user or group of users can make any decisions on their own. Such siloed decisions will never be beneficial to the network, because they are likely to be in the self-interests of said user/group of users.

Instead, updates to the ledger (or Google sheet, as referenced in the previous article) are proposed by one user at a time, and every other user in the network will vote on whether or not to accept the proposal.

Any user who wants to make a transaction on this blockchain sends the transaction to everyone in the entire network, and not just the recipient of the transaction. Everyone on the network then casts votes based on whether the transaction they saw was valid or not. Only after receiving a certain number of votes, say a majority, does the transaction get saved.

This protects the collective from any malicious behavior, as everyone will get to verify the transaction, before voting it into the ledger. It seems like our consensus problem has been solved!

What a double spend looks like. Source: https://www.chowles.com/

Alas, there is one fatal flaw that we have missed out on: what if a malicious user swarms a blockchain network with multiple identities that he has created, in order to vote his malicious transaction (usually a double spending attack) in? This will essentially destroy the blockchain.

For example, imagine if 51% or more of a network’s users (thus, a network majority) are all controlled by the same entity — this will mean that any transaction that said entity proposes, malicious or honest, will always be accepted into the blockchain, destroying the integrity of the network.

This method of overwhelming voting systems by flooding the network with multiple identities is referred to as a Sybil Attack, and is one of the more common vectors of attack on a distributed system.

Sybil attacks are only possible in networks where there is little-to-no-cost to vote. In such a situation, there’s no longer any value in a vote because anyone with spare time can make as many identities as they want to. True consensus can never be achieved in a network like this.

This is where the ‘work’ from POW comes into play.

To solve the problem, we have to make voting expensive. We have to make it such that anyone trying to vote has the same amount of voting power as anyone else, regardless of how many different identities they may have.

Therefore, each vote must be cast with resources — scarce, valuable, tangible assets. Let’s take the example of Bitcoin (since it utilises the POW consensus) to understand this better.

In his whitepaper, Satoshi Nakamoto (the creator(s) of Bitcoin) envisioned a “1-CPU-1-vote” network, rather than the traditional “1-identity-1-vote” system, in order to prevent Sybil Attacks from pervading the Bitcoin network.

To do so, Satoshi identified computing power as the scarce, valuable and tangible resource that users had to provide, in exchange for a vote.

Whenever someone wants to make a proposal to the rest of the Bitcoin network, they first have to solve a computationally difficult problem. This problem is uniquely generated based on the information within the proposed block, and thus its solution cannot be predicted beforehand.

Instead, it’s similar to brute forcing a password: all you can do is trial and error. Your computer will try a bunch of inputs until it finds a solution to the problem, at which point it will submit the successful input along with the proposed block to the rest of the network.

These people who lend their computational power to the network (and so doing, help verify transactions on the network) are called miners.

The unpredictability of the form of correct inputs ensures that there’s no way for miners to game the system, keeping any of them from cheating. By having every user solve this uncheatable brute force problem, you have a reasonable expectation that they’ve done a lot of (computational) work to solve it.

In tethering voting power to such immense computing power, Satoshi ensured that all users will have scarce voting power.

It is this method of voting and generating consensus that made Bitcoin the first successful cryptocurrency. It also inspired the voting mechanisms (even alternatives to POW) for practically every other cryptocurrency that followed.

Proof-of-Stake (POS)

Although the POW system is one that is utilised by many projects, including — as aforementioned — the most popular cryptocurrency, Bitcoin, it still has many drawbacks.

For example, in order to solve the computationally difficult problem required of all miners before they can add a block to the network, a massive amount of energy will need to be consumed. This has dire repercussions for the environment, and also renders it such that only those who can afford powerful and expensive computers can be miners (not in line with the whole decentralized rhetoric!).

To solve some of these issues, Proof-of-Stake was introduced.

Proof-of-Stake is a consensus mechanism where voting power is directly proportional to economic stake locked up in the network, instead of computational power and resources. Each participant stakes a certain amount of native currency (by locking it up in the network), and each node is given a probability of being chosen as the next validator, weighted by how much was at stake/locked up. Once a validator is chosen, they can propose a valid block and receive a reward.

With this scheme, how much power a participant has in the network is limited by the amount they are willing to stake. Rather than relying on rewards for security (like what the POW system does), Proof-of-Stake relies on penalties. If a participant places stake on a dishonest block, they are penalized and lose however much they put at stake. In this, acting maliciously is penalized much more heavily than the gain from acting honestly.

Users on the network are now more disincentivized to act maliciously due to the explicit consequences of doing so. This security comes from locking up capital (the stake prerequisite) for long periods of time.

Let’s apply this to a real-life scenario.

Picture a group of treasure hunters vying for a chest. The chest is rewarded based on a lottery system. To participate, each hunter has to buy lottery tickets from the chest itself.

This act of the hunters buying lottery tickets from the chest represents the staking/locking of the validators’ currency into the network. The more each hunter buys, the higher the chance of winning. Correspondingly — the more native currency a participant in the network stakes, the higher chance he/she will get to validate a new block coming in, and in so doing — get a reward.

In sum, Proof-of-Stake is a particular type of consensus mechanism that assumes all voting power is tied to financial resources.

Fundamentally, the idea is: the more tokens or currency an actor holds within a Proof-of-Stake system, the stronger the incentive for them to be good stewards of said system; if the system grows the wealthier the actor becomes.

Thus in Proof-of-Stake, we give these individuals the most power as validators, because we trust that they will not want any harm to befall the network.

Prev: A Beginner’s Guide to Understanding the Blockchain (Part 1: How Does a Blockchain Work?)

Next: A Beginner’s Guide to Understanding the Blockchain (Part 3: Smart Contracts)

Join Coinmonks Telegram Channel and learn about crypto trading and investing

Also, Read


Top comments (0)