What is Consensus, and how to achieve it in a Blockchain ecosystem

Consensus + Blockchain… Can you explain me everything please?

When reading/talking about cryptocurrencies or blockchain, you always hear about “consensus”, consensus here, consensus there, consensus protocol, consensus in the network… but what does it really mean? In this article I want to drill down into this word and explain everything about it.

(To understand this article, you need to have a fairly good idea of what a blockchain is, if you are not sure, go check out some earlier articles. )

It’s important to understand that what makes a blockchain fundamentally work is the fact that there is consensus among adopting members. In order for any distributed ledger (a synonym of blockchain) to be valid and adopted by all (or majority of) network members, we need consensus among participants. Exactly as we need consensus between humans for many many things in our society.

consensus role in society

Let’s stop for a bit now and think, what is consensus? Well, consensus it’s just a way for a diverse group of individuals/entities to make decisions together and move together towards a common goal.

In a prehistoric world consensus is needed to create a tribe and grow it into a bigger society, guaranteeing high chances of survival for everyone. In the blockchain world consensus is needed to achieve a functional, honest and transparent financial system and an internet of value. We’ll expand on the “consensus in blockchain world” example in a bit.

Edward Shils, a distinguished sociology professor at the “Committee of Social Thought” and at the University of Chicago, affirms that there are three fundamental things needed to achieve consensus:
1- The common acceptance of laws, rules and norms
2- The common acceptance of institutions that apply these laws and rules
3- A sense of identity/unity, so that group members accept that they’re equal in respect to the consensus.

This makes absolute sense, it is how our cities, governments and states were born.

But how is consensus fundamental to this new decentralized computer-based technologies such as blockchain?

In decentralized distributed ledgers, consensus is necessary to have every member agree on the value of the data inside these ledgers. By data I mean for example transactions that will be included in the ledger universally, and accepted as common truth.

Let me repeat it in other words: a mechanism of consensus establishes the basis for a coherent set of facts that every node of the network swears by as the only truth. In Bitcoin for example, these facts are that I own 5 tokens, that Mr. X owns 100 tokens, and that Mr. Y just sent 6 tokens to Miss Z.

We can call them mechanisms of consensus or consensus algorithms, and there are many of them, so which one to choose for a blockchain application? Well it really depends on requirements such as performance, scalability, consistency, data capacity, governance, security, and failure redundancy.

Let’s now explore different consensus algorithms that are now implemented in the blockchain ecosystem. Remember that the goal of these algorithms is for decentralized network members to agree on a common truth about adding new blocks of transactions/data to the decentralized and shared ledger.

Proof of Work (PoW)

In a proof of work algorithm, participants of the network (miners specifically in the bitcoin protocol) compete with each other using computational power to “mine” the next block of transactions into the shared/distributed blockchain. They compete by trying to solve a really complex cryptographic puzzle based on cryptography.

What does being a miner feels like? Imagine yourself in school, competing with your classmates for who will solve the long math equation first. Instead of using your brain power, you have computers using CPU power to solve math problems that always take fairly long time to solve.

Whoever solves the complex math problem first will get a nice reward (tokens created from zero plus transaction fees inside the block), and second, will have the right to add that block to the blockchain, which is then accepted as a common truth by all network participants. The race immediately starts again, and somebody again will win, get the rewards and mine the next block.

All the miners consume an important amount of energy (electricity) in order to solve the problem and mine the block, hence why this mechanism is called proof of WORK. By finding the solution you proved to everyone that you expended a lot of energy, since it’s the only way possible to solve that problem.

Some Projects Implementing PoW:

Proof of Stake (PoS)

In this consensus algorithm, instead of expending computational power (electricity), the miners will alternatively become “validators” and risk their own tokens/coins into the system in order to mine new blocks, ultimately growing the blockchain.

Here you have no distribution of coins as a reward like in proof of work, here the coins all exist from day one, and the validators are strictly rewarded in transaction fees.

In this algorithm the chances of you being picked to mine a new block in the blockchain are proportional to how many coins you are placing “at stake” (at risk) for the network. Quick simple example: a validator with 500 coins at stake has 5 times more chances to be picked as a validator than another one with 100 coins at stake.

Validators are incentivized not to be malicious. Why? Because if they try to boycott/cheat the blockchain by validating false information, they will lose their coins at stake.

If they follow the network rules correctly they will not lose their staked coins but they will actually earn more coins from the correct transaction fees. So you can see that there is no advantage in being malicious.

Some Projects Implementing PoS:

Delegated Proof of Stake (DPoS)

This one tries to combine proof of work with proof of stake. It is based on a decentralized voting process where participants of the network (shareholders) picks a set amount of “witnesses”. Becoming a witness is a privilege in the network, because witnesses earn rewards for their service, and therefore everyone wants to become a witness, creating a constant high competition among all network members.

Competition will ensure that only the witnesses that are fair and do not cheat the system stay witnesses, otherwise another more honest member of the network will take his spot, creating dynamics that will constantly flush out bad actors.

This consensus algorithm can be called a ‘digital democracy’. And it is like being able for an employee to fire his as**ole boss. The goal is to avoid centralization as much as possible.

In summary, the shareholders always remain in control through their voting power, the witnesses are in power, but if witnesses misbehave, they are quickly down-voted by the shareholders and lose their privileges. There is no incentive here for anyone to go against the rules of the network.

Some Projects Implementing DPoS:

Leader-Based Consensus (LBC)

The nodes of the network temporarily elect one node to be a leader, which is responsible to validate and include transactions.

So everyone sends their transactions to the leader node, and the leader then outputs these transactions in order, as a newly created block.

I think personally this is not the most clever consensus system. From a cybersecurity perspective, I can see a DDoS attack directed towards the leader, which will bring it down. Even if the network picks a new leader, it can continuously be taken down by the same malicious adversaries.

The leader is also corruptible since it decides what order the transactions are included. The leader puts the timestamps on the transactions, not the peers.

Some Projects Implementing LBC:

Round Robin (RR)

Round Robin is mostly used in private blockchains, where mining is restricted only to select identifiable entities. This prevents the problem that private blockchains might have, which is monopolization of the mining process.

So how does it work in simple terms? Every miner in a given time window can only create a finite number of blocks, creating a round robin schedule where only permitted miners can create blocks in rotation, generating a fair non-monopolized blockchain.

Some Projects Implementing RR:

Federated Consensus / Federated Byzantine Agreement (FC / FBA)

This is based on quorum slices, which are individual trust decision made by each node that together determine system-level quorums.

Fundamentally, there is a set of validators that need to mine transactions and data into the blockchain. In this consensus mechanism these validators are not chosen ahead of time, but are continuously voted on the spot by all the nodes.

Nodes will choose validators based on who they trust, which is what I called a “quorum slice” two paragraphs earlier. As a node, by looking at what every other node votes as their most trusted validators you can get a precise map of who are the most trusted nodes.

By continuous voting, the data is validated and then voted again to be committed and added to the blockchain.

Some Projects Implementing FC / FBA:

Practical Byzantine Fault Tolerance (PBFT)

Each node in the network maintains an internal state (=data/information). When a node receives a message they run a computation/operation against their internal state. This in turn tells that node what to think about that message they just received, and if they should accept it and re-broadcast it to other nodes or reject it.

The total decisions submitted by every node determine the consensus decision. This method of consensus is less effort than other methods, but it comes at the cost of anonymity on the system.

There are other variations of this consensus mechanism, such as Derived PBFT (used by hpyerledger), RBFT (redundand byzantine fault tolerance) and SBFT (simplified byzantine fault tolerance).

Some Projects Implementing PBFT:

Proof of Activity (PoA)

This is another approach that aims to achieve a hybrid between proof of work and proof of stake.

This mechanism starts as proof of work, meaning miners start solving a cryptographic puzzle. The blocks mined will not immediately contain transactions inside, but they will have only a header, the id of the miner that solved the puzzle, and an empty content area.

At this point the system switches to proof-of-stake. Based on what the header says, a group of validators is chosen and will sign this new block.

The more coins/tokens a validator puts at stake/risk, the more likely he is chosen. The content that was empty before, now gets filled as the validators sign it.

The reward in fees is split between the miner that did the proof of work and the validators that signed it.

Some Projects Implementing PoA:

Proof of burn (PoB)

This one is interesting, instead of pouring capital into expensive mining equipment, you “burn” coins by sending them to an address where they will be irretrievable.

By doing this you are showing the network that you committed these coins without a chance to get them back, so you earn a temporary privilege to mine on the system based on a random selection process.

There are a few ways in which this process is implemented: you can burn the project’s native token, or other tokens belonging to other chains, but these are just details. The really important thing to know here is that the more coins you burn, the better chance you have of being selected to mine the next block.

As time passes by, your stake in the system decays, so you will have to burn more coins in order to keep your chances high for being picked as the new “winner”. This mimics proof of work because in proof of work you also need to always invest capital to buy better and newer mining equipment to maintain a strong hashing power and mine blocks.

The coin that uses this protocol is Slimcoin, which is a cryptocurrency based on peercoin, and uses a combination of PoW, PoS and PoB.

Some Projects Implementing PoB:

Proof of Capacity (PoC)

Here you ‘pay’ with your hard drive space. The more hard drive space you put to the service of the network, the higher chances of you mining the next block and earn the block reward.

How does this work exactly? This algorithm starts by generating large and heavy data sets called “plots“,which you are required to store on the hard drive space. The more plots you have, the better your chances of finding the next block in the chain.

By investing in terabytes of hard drive space, you buy yourself a better chance to mine the next block, because you are able to store more plots.

The only problem here is that you put nothing at stake/risk to deter bad actors from cheating the system. If you remember proof-of-stake, the bad actors will forever lose their staked coins if they try to go against the network rules to gain unfair advantages.

Variations of this consensus algorithm include: proof of space and proof of storage. The only cryptocurrency that uses a form of proof of capacity is called Burstcoin.

Some Projects Implementing PoC:

Proof of Elapsed Time (PoET)

Intel, the famous chipmaker, created its own consensus protocol, called proof of elapsed time. This system works similarly to proof of work, but consumes way less electricity and energy.

Instead of having miners solve cryptographic puzzles, the algorithm uses a Trusted Execution Environment (TEE), such as SGX, to make sure that blocks are produced in a random lottery way.

TEE provides a guaranteed wait time, and according to Intel, this consensus algorithm can scale to thousands of nodes and it will run efficiently on any intel processor that supports SGX.

I like this algorithm, it is technically well thought, but my only issue is that here we are again putting trust in a single centralized company: intel. Remember that blockchains were fundamentally created to be decentralized and not rely on a single business or entity.

Some Projects Implementing PoET:

Distributed concurrence / Node to Node (N2N)

This mechanism is a bit different, as it does not rely directly on cryptocurrencies, blockchains or any sidechain.

There is not too much information online as much as the other algorithms, but as I understood it, this algorithm is based on a set of rules that all participants have agreed upon, in an environment where everyone has access to the same data. Each hash is recorded so that it can’t be disputed at all.

With this model, only the nodes involved know that a transaction exist. On the flipside, like in Ethereum, all nodes are aware of transactions.

I know this description is a bit vague, so if I can find more information about this algorithm I will update the article.

Some Projects Implementing PoET:

Conclusion

In conclusion, I showed you a whole rainbow of mechanisms through which peer-to-peer network participants can agree on specific situations. In the blockchain ecosystem they all need to agree on how to include a new block of transactions/data into the blockchain and have everyone happily accept it as universal truth.

I believe there is no point in going into the nitty gritty details of every algorithm unless you are developing your own coin/project, or have a burning curiosity to see how things works (in that case you should look for the whitepapers). This is why I gave you a brief description of everyone without diving too deep. This way when you are at a conference or talking with experts, you will know what a certain consensus mechanism does on a broad level and you will not be confused.

Do you see mistakes? You don’t agree with something? Want to add more consensus algorithms or information? Please comment below and start a discussion anytime.

2 thoughts on “What is Consensus, and how to achieve it in a Blockchain ecosystem”

  1. Federico,

    Thanks a bunch for this very educational and comprehensive article. I was shocked to realise how little of the consensu algorithms I was aware of. Now, at least, I know the rainbow of choices in consensus algorithms and the major blockchain technologies that are implementing them. If necessary, I can dig in deeper into any of them. This is very practical information and thanks for taking the time to post such a coherent piece.

    1. Thank you so much for the comment Anil! Yes there really is a “rainbow” of choices out there! And we will probably see more algorithms coming out as new tokens/blockchains are developed/improved! Exciting stuff!

Comments are closed.