Blockchain Byte - Week 9 : Consensus
Table of Contents
- Recap
- Consensus
- Node
- Types of Consensus Mechanisms
- Parting Questions
Recap
To recap, last week we explained decentralization. When we say Blockchain is decentralized, it means that a Blockchain has :
- Decentralized storage
- Decentralized computation
- Decentralized Communication
Some questions to consider -
- When there is no centralized authority or server which authorizes transactions or manages database but just multiple computers linked to each other, how are the parts linked to create a whole system?
- 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.
Consensus
In the context of Blockchain, Consensus simply means that people who are part of a group have to agree on a truth and ensure everyone reflects the same truth in their respective ledgers after checking their validity.
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.
- 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,C & D check if A has the balance to make the transfer and whether A has actually authorized the transaction
- 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
Node
In a centralized set up, a trusted authority or third party validates & authorizes transactions. In a decentralized or distributed set up, the 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. There are set of conditions which the systems will check to ensure the validity of a transaction or set of transactions.
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. The consensus mechanism ensures that
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?
Consensus protocols substitute the work of centralized authorities on validation & authorization of transactions. 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.
Types of Consensus Mechanisms
The most popular consensus mechanisms are :
- Proof of Work (PoW)
- Proof of Stake (PoS)
There are others but we will focus on the above two as we move forward.
Parting Questions
- 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?