Skip to content →

Blockchain Basics: Consensus

In this second post in my Blockchain Basics series, I’d like to discuss another term that you will encounter when studying blockchains, which is “consensus

How does a blockchain reach consensus?

Just like with the term “trust“, I often find that this is a hard one to explain. This has to do with the way the whole way of the blockchain arrives at the result we want (ie. a trustworthy ledger without a central administrating party) is basically by turning the process upside-down.

We saw this with trust: we don’t start by analysing past behaviour and then project it into the future. Instead, we set up a bunch of rules to make sure we don’t need to worry about it in the future.

The same kind of counter-intuitive step is recognisable in the blockchain’s treatment of consensus.

The Old Way

Merriam-Webster served us the last time, so let’s use it to define “consensus” for us, this time.

  1. a:  general agreement :  unanimity the consensus of their opinion, based on reports … from the border — John Hersey

    b:  the judgment arrived at by most of those concerned the consensus was to go ahead

  2. group solidarity in sentiment and belief

For our current topic, definition #1 will serve.

When we want to reach consensus, we mean we agree on something. Our usual method of doing this, is to check the thing we want to reach consensus on from all angles (whether this is a material thing like a parcel or an immaterial thing like an opinion). We look at it from all sides and test it and then either arrive at a common conclusion that the thing is the thing or not. When there is ambiguity, we can do further tests and either accept these or not.

From experience, we know there are many things we can disagree on, so we have devised rules to make sure we can break dead-locks, like “when more than 50% of the people allowed to decide agree, we go with that decision” where the percentage can vary (66% is also popular).

Of course, also being human, people may have reasons to game the consensus. They can do this in many ways, for instance plain lying about the object, and by persuading others to do so, too.

Sometimes, we delegate the responsibility for the checking and prodding to someone we trust (and this is where we link to the first article in our series!) to make this assesment for us.

As I already covered in my first article, there can be problems associated with trust. Because consensus is presupposes trust in the others honesty, these problems spill over into consensus-making. As it’s these problems that blockchains want to solve, we need to arrive at consensus a different way.

How does a blockchain reach consensus? Redundancy!

What we want a blockchain to do is simple: to create a ledger, without a central authority, where we can be sure that it’s true.

The way we do it in blockchains, is once again “by the rules”.

When we think of consensus, we tend to think of all functions (asking, testing, checking) as being done all in one go. A blockchain doesn’t do it like this.

Each and every step is taken on it’s own and done independently by each full network node!

That’s right: every full participant on the network will make the checks necessary. No node will trust what it receives without checking it.

The list goes as follows:

  • Every transaction that is sent to the network is checked to a list of criteria. If it fails, the node will not send it on. If it passes, it gets sent on.
    • This means that any badly formed transaction will get filtered out very quickly.
  • Every node that wants to make a block will need to make sure it can be tested for integrity.
    • This is what “mining” is actually all about! Mining is simply letting loose a mathematical function on the contents of a block, together with information from the *previous* block. This mathematical function works in such a way that a predetermined solution takes a
      • set time to arrive at (you can calculate this using probability maths)
      • certain form (in this case a so-called SHA256 hash)
      • can be verified to be correct very easily

This is where I stop a while to appreciate the cleverness of the consensus solution. Instead of arriving at consensus about the content and having to check each and every block, the blockchain outsources this work to everyone, ensuring we’re already sure about this *before a block is even made*!

The only thing that it then needs to worry about, is whether the block is created correctly, with a function that also makes sure we cannot predict who will create the block with certainty (the process of getting the solution is random), will ensure when we need to check it we can do it very simply (once a hash is found, it’s really simple to recreate and see it’s correct) and that will take on average a set time (ensuring blocks and thus transactions are generated at a predictable rate).

Couple this with the brilliance of making the solution dependent on the information of the previous block (which is dependent on the one before it, in a “proof” going back to the first block!) and the severe redundancy of everything (making it very unlikely (I mean, REALLY unlikely!) that anyone can get around the rules) and you get an immensely strong resistance to tampering.

The elegance of the solution to such a complex problem is just beautiful to me…

But we’re not done yet:

  • Each block that is created, is always checked and tested by each full node. If correct, it is added to the chain
    • This ensures that if correct, we all agree on the same block being added to the end of a chain
  • Lastly, the network has the rule that the blockchain with the “most cumulative work” will be the correct chain
    • This last provision means that in a situation where we have two blocks created at the same time (which can happen), once another block is found on one of these chains, this will become the correct chain (most work done on it). This rule prevents forks and also means that anyone who is attacking the chain by trying to make a competing one will need to “outrun” the main one. This would mean they would have to have more than half the power of all other nodes on a given network (the famous 51% attack). That’s VERY expensive, and hence VERY unlikely.

You can find more on this in the book Mastering Bitcoin, chapter 8, if you really want the nitty-gritty.

Even more simple

In short, the blockchain creates rules for every step where humans would need to put trust. These rules are mathematical, and all nodes of the network independently need to follow them by design.

Consensus is not “reached”, as in a concious decision. Consensus “emerges” from the rules. Once a transaction has been checked and added, a block created and a solution found, we only need to check it and we can be sure it’s correct.

Hence: you don’t need to decide on the correct chain. Once you are on it, you know it is.

 

 

Bas Wisselink
Follow me

Bas Wisselink

Co-founder and trainer at Blockchain Workspace
Bas Wisselink is active as a community manager and thinker in the blockchain space, specifically the Nxt Blockchain. He is a writer, public speaker and trainer/founder at Blockchain Workspace.
Bas Wisselink
Follow me

Latest posts by Bas Wisselink (see all)

Published in Articles Blockchain Basics