Slide 8 Consensus Mechanisms
Slide 8 Consensus Mechanisms
2
Consensus
A group of friends wants to spend time
together.
Two opinions - watching a movie or
going to a local sight seeing place.
Ultimately, they decide to watch a
movie, some very happy, some remain
indifferent between the two choices.
Decision is based on a consensus.
3
Consensus
A general agreement on a decision amongst all participants
in a group.
All participants accept and support the decision.
Mechanism
An established process with defined rules to achieve specific
goals.
4
Consensus Mechanism in Blockchains
A fault-tolerant mechanism that is used in a blockchain network to
achieve the necessary agreement on a single state of the network
among distributed processes in a decentralized way.
It facilitates verification and validation of information being added to
the blockchain ledger.
The mechanism ensures that only authentic transactions are
recorded on the blockchain.
5
Objectives
Unified agreement
Preventing double spending
Aligning incentives
Fair and transparent
Fault tolerant
6
Consensus Mechanisms
Various consensus algorithms exist for different blockchains.
The first consensus mechanism called ‘Proof of Work” (PoW) was introduced
by Satoshi Nakamoto when he created bitcoin.
PoW is the most common and robust consensus mechanism for blockchain
technology. Also known as mining algorithm.
It is computationally expensive \ memory hard.
PoW is not energy efficient.
PoW also suffers from centrality issues, only those with very high computing power
can be miners.
7
Have a look at a Bitcoin mining centre in USA!
8
Proof of Stake
Proof of Stake (PoS) is based on a node’s stake in the system, typically
measured in terms of the wealth, the amount of currency a node holds.
Nodes ( users) validate their stake by demonstrating ownership of some
cryptocurrency on the network by temporarily locking an amount.
Keeping the currency on stake also helps secure the network – one can
lose the staked currency in case of malfunction – intentionally or
unintentional.
Energy efficient and more decentralized as compared to PoW.
9
Proof of Stake
10
Ethereum Proof of Stake
11
Step 1
To become eligible as a validator, a user first deposits 32 ETH into the deposit
contract.
Deposit contract
Deposits 32 ETH
12
Step 2
Then the user installs Execution client
Consensus client
Validator client
This puts the user /node in an activation queue to join the group of validators.
13
Next Stage
Once the node becomes a validator, it receives new blocks for
validation.
It verifies all the transactions and checks their correctness.
Then it validates the block by attesting the block, it is called voting in
favour of the block. This is communicated to the network.
14
15
16
17
Transactions and Block Creation
A user proposes a transaction and signs using their private key.
The amount of base fee + tip is also specified by the user in the
transaction proposal.
The tip is paid as an incentive to a validators.
The base fee is utilized in transaction verification and validation.
The transaction is submitted to an execution client (of a node) which
verifies its validity – that the user has sufficient amount of ETH to fulfill
the transaction and that the key is authentic.
18
Transactions and Block Creation …
All valid transactions are pushed to the local mempool ( memory pool of
unconfirmed transactions ) by the execution client, and are broadcast to
other nodes using the gossip protocol.
In each slot, the block creator node selected randomly collects
transactions from the local mempool and bundles them using their
execution client.
The execution client executes them locally to generate a state change.
Once the execution payload ( the block under process) is generated, the
same is handled by the consensus client of the node.
19
Transactions and Block Creation …
All valid transactions are pushed to the local mempool ( memory pool of
unconfirmed transactions ) by the execution client, and are broadcast to
other nodes using the gossip protocol.
In each slot, the block creator node selected randomly collects
transactions from the local mempool and bundles them using their
execution client.
The execution client executes them locally to generate a state change.
Once the execution payload ( the block under process ) is generated,
the same is handled by the consensus client of the node.
20
Transactions and Block Creation …
The block under construction is called a beacon block.
The beacon block contains information about rewards, penalties,
slashings, attestations etc that enable the network to agree on the
sequence of blocks at the head of the chain.
21
22
Transaction Finality
The time it takes to finalize that a transaction on the blockchain can not
be altered or reversed is known as transaction finality.
A transaction that is recorded in the most recent block may be
vulnerable.
The attacks may try to exploit these vulnerabilities.
Therefore, the first block of each epoch is used as a “checkpoint”
(around 6.4 minutes).
If the blocks after the previous checkpoints are validated by atleast 2/3rd
of the total validators, the current checkpoint is called a ‘justified’ block.
23
24
Security after Finalization
To modify/ revert any transaction of a finalized block, an attacker should
be putting at stake at least one-third of the total staked ETH that have
been staked, to modify/ revert any transaction of a finalized block.
◦ The attacker can do it only by voting with one-third of the total stake.
Cons
◦ Relatively new, not tested like PoW.
◦ More complex to implement than PoW.
◦ Ethereum's proof-of-stake requires three different software components to run on a
node, to participate in the PoS.
26
Delegated Proof of Stake
Validators don’t work to validate blocks by themselves, they hire
delegates to do the validation for them.
There are 21–100 selected delegates (miners) usually.
Unlike PoW and PoS, in DPoS miners can collaborate to develop
blocks.
27
Delegated Proof of Stake
If the delegates miss their blocks on a regular basis or publish invalid
transactions, the validators vote them out and replace them with some
other selected delegate.
With a collaborative effort and a partially centralized process, DPoS
performs faster than any other consensus algorithm.
The selected delegates are changed periodically and are assigned an
order to deliver their blocks.
28
Image Source: Consensus mechanism overview, WisdomTree MARKET INSIGHT, August, 2021
Source: Zhang, S., & Lee, J. H. (2020). Analysis of the main consensus protocols of blockchain. ICT express, 6(2), 93-97. 29
Byzantine Fault Tolerance
30
Two Generals Problem
31
Byzantine Fault Tolerance (BFT)
Coordinated attack – victory
Uncoordinated attack – defeat
Are there some risks ?
Not all generals may be trustworthy;
some may be traitors.
Not all messengers may be trustworthy;
A messenger could be caught by the
enemy and a fake (enemy) messenger
relays a fake message. Image source: Wikipedia
32
Two Generals’ Problem
Since the possibility of the message not getting through is always > 0,
the generals can never reach an agreement with 100% confidence.
Due to multiple risks, there need to be certain processes that can
guarantee:
Proof of Weight
◦ Weights associated to increase the proof of stake, in terms of other parameters like
reputation etc.
37
Summary
Consensus algorithms used by various blockchain platforms are decided
by the type of applications.
Consensus models are selected based on intended network, the
relationships between participants, and both functional and non-
functional aspects.
Proof of Work, Proof of Stake, Delegated Proof of Stake and Practical
Byzantine Fault Tolerance are some of the extensively used consensus
mechanisms.
Variants are introduced for different cryptocurrencies and other
blockchain platforms.
38
Next Week
1. Transaction ledgers in blockchain networks, Public and private
ledgers.
2. Permissionless and permissioned blockchain
3. Enterprise level blockchains.
39
Reference and Useful Resources
Ethereum Proof of Stake Page
Zhang, S., & Lee, J. H. (2020). Analysis of the main consensus
protocols of blockchain. ICT express, 6(2), 93-97
40