Understanding Consensus

shutterstock_605120594_Consensus_250X208Anyone interested in the crypto or the blockchain world is aware of the word “Consensus.” 

Consensus as per the dictionary means: “a general agreement.” In the crypto and the blockchain world, it is defined as the mechanism and guidelines used by the network to come to an agreement on the state of the ledger storing the transactional data.

The consensus is one of the most commonly used words; still, it is shrouded in mystery. Many people have tried to explain it (and have done an exceptional job at it!) in simple terms, laying down the pros and cons, and the applicability areas of each consensus mechanism. 

However, the more significant questions, which need to be answered in the first place to have a better understanding of the blockchain system, are:

  1. What is the need of consensus?
  2. What are the challenges to achieve consensus?

What is the need of consensus?

Every system in use today relies on a   or a golden copy of the record (wherein the value of data is consistent across different sources) to provide the information or to maintain the (value of the particular record at any given point of time). Any e-commerce system being used today retains the details and the state of the order that you have placed. So, the problem at hand is simple: if we have a single source of truth usually a database, which is replicated over different geographical zones to provide redundancy and fail-safe, there is no need of consensus. However, as you start adding multiple participants, each holding a local copy of data source using consensus becomes imperative.

In case of a centralized system, one thing is for sure that if all the rules are followed, then the state or object is committed to the database. However, when moving from a centralized to a distributed system, the real challenge that crops up is how to ensure that all the participants agree on the state of the object to maintain consistency.

To understand things better, let us make this problem slightly complicated:  For instance, you have multiple participants holding the latest state of truth locally. If everyone is holding the state of truth locally, which may be different from each other, how do they agree which state of truth to accept? Therefore, the main problem statement behind consensus is determining who is the leader, or the node, or whose new block needs to be accepted as the next block. 

What are the challenges of leader election?

  1. How do you accept a node to be the leader?
  2. How do you ascertain the leader-elect is working for the interest of the network and is not trying to corrupt the network?
  3. How do you validate and accept the next block being formed in the blockchain?
  4. How do you ensure fairness in the leader election process (true democratization)?
  5. What is the incentivization for the leader-elect to form the block?
  6. How to address the situation when multiple blocks have been created by different nodes? Which one to accept?
  7. How to handle the rejected blocks?

How does the bitcoin network address all these challenges?

The consensus algorithm used by bitcoin to address these challenges is PoW (Proof of Work). The candidate node proposing a new block must provide a solution to a cryptography problem, which involves a lot of computation to solve the puzzle, i.e., the mechanism called “Proof of Work.”

Let us look at how the bitcoin network addresses these challenges using consensus:

  1. How do you accept a node to be the leader?
    It is a race condition. The first node has to solve the puzzle correctly, and it proposes the candidate block which becomes the next block in the chain after the validation is carried out by the peer.
  2. How do you determine the leader-elect (node forming the next block) is working in the best interest of the network and not trying to corrupt the network?
    If the candidate block being proposed has some doctored transaction or data, the network validation will fail. Hence, all the computation work done to solve the puzzle will be of no use, which indirectly correlates to dollar value.
  3. How do you validate and accept the next block being formed in the blockchain?
    Peer nodes in the network validate the candidate block individually. And, if validation fails, the block is rejected.
  4. How do you ensure fairness in the leader election process (true democratization)?
    With the computation being distributed, every node has an equal right to create a block.
  5. What is the incentivization for the leader-elect to form the block?
    Block rewards in terms of BTC (Bitcoin) for each block created. It serves the dual purpose of generating new bitcoins and incentivizing the miners (computers trying to solve a cryptographic puzzle to form the new block).
  6. How to manage when different nodes have created multiple blocks? Which one to accept?
    The consensus mechanism does lay down specific rules to select a block in case multiple blocks are created. E.g., chain length (longest chain wins), hashing power spent to create a block, to name a few.
  7. How to handle the rejected blocks?
    Rejected blocks result in transaction going back to the unmined transaction pool, where they are picked up again to become part of the next candidate block.

Conclusion

Understanding the two key points – what consensus is and what are the characteristics of the mechanism to address the problem – is the first step. Different consensus mechanisms are being explored which will be discussed in further posts.