A Byte of Blockchain - Week 9 
Consensus

A Byte of Blockchain - Week 9 Consensus

·

4 min read

Table of contents

No heading

No headings in the article.

To recap, last week we explained decentralization. When we say blockchain is decentralized, what do we mean by that? It means that a blockchain has :

  1. Decentralized storage

  2. Decentralized computation

  3. Decentralized Communication

Now, when there is no centralized authority or server which authorizes transactions or manages database but just multiple computers linked to each other, how does an application work in such an environment?

How do all the linked computers work together in sync?

How do they reflect the same ledger balances or transactions?

This is done through a mechanism called consensus. An offshoot of decentralization is decentralized consensus.

What does consensus mean? In the context of blockchain, it simply means that people who are part of a group have to agree on a truth and ensure everyone adds and reflects the same truth in their ledgers after checking for their validity. Slide2.JPG

Let us revisit our example from Week 6 where four people (A, B, C & D) share a common ledger and A wants to pay D $ 10. What happens in a blockchain?

a. A initiates the transaction & asks B, C & D to add the transaction (Reduce A's balance by $10 & increase D's balance by $10) to their ledgers

b. B,C & D check if A has the balance to make the transfer and whether A has actually authorized the transaction

c. If A has the funds and A has actually authorized the transaction, then the transaction is authorized by B,C & D and added to the common ledger.

Here B,C & D, after checking the above have to agree on the validity of the transaction before adding it to the ledger. This "agreement" is called Consensus

As per Merriam Webster, consensus is

: a general agreement about something : an idea or opinion that is shared by all the people in a group

Consensus.jpg

In a centralized set up, a trusted authority or third party validates the transaction. In a decentralized or distributed set up, a consensus mechanism is used to agree on the validity of transactions. A computer which forms part of a decentralized or distributed system is called a NODE. All nodes are capable of sending & receiving messages to and from each other.

In distributed or decentralized systems with consensus, all nodes work in a co-ordinated fashion to ensure that the end user sees it as a single logical system.

Do the people behind the nodes know or trust each other? No. So we will add one more dimension to our definition as below:

Consensus is a process of agreement between nodes who do not trust each other on a final state of data.

Final state of data means all the nodes show the same balances or transactions even though the ledgers are maintained in their individual systems and they should agree on which transactions are valid and which are not. In other words, all nodes in the system can agree on a single source of truth.

We saw that the nodes in a blockchain need not trust each other. Yet they should reflect the single source of truth by synchronizing & agreeing with each other. How does this sync work in a blockchain? This is done through consensus mechanism. These are protocols to ensure

a. All nodes are synchronized with each other

b. Nodes agree on which transactions are legitimate and added to the blockchain

Why do we need consensus mechanism in a blockchain?

These are needed to ensure all transactions are constantly checked and validated by all nodes. Without good consensus mechanisms, blockchains are at risk of attacks & reflecting invalid transactions.

The most popular consensus mechanisms are :

  1. PROOF OF WORK (PoW)

  2. PROOF OF STAKE (PoS)

We will discuss the above as we move forward plus other mechanisms too.

Now, why should nodes which do not trust each other care about coordinating with each other? What is the incentive to synchronize & maintain the network? What happens if a node or multiple nodes turn into bad actors to destabilize the network?

Photo by Hannah Busing on Unsplash