0% found this document useful (0 votes)
67 views26 pages

Unit 3-1

Uploaded by

deepakkundwani3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views26 pages

Unit 3-1

Uploaded by

deepakkundwani3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

UNIT-3

• Introducing the consensus problem,


• Analysis and design,
• Classification,
• Algorithms: CFT algorithms, BFT algorithms,
• Choosing an algorithm
Introducing the consensus problem and the fundamentals of distributed
consensus theory

• Consensus is a fundamental problem in distributed systems


• recently, with the advent of blockchain technology, a renewed interest has arisen in developing
distributed consensus algorithms that are suitable for blockchain networks
• Distributed systems are classified into two main categories, namely message passing and shared
memory.
• Blockchain uses message passing within participants on the network to communicate with each other

• Blockchain is a distributed system that relies upon a consensus mechanism, which ensures the safety
and liveness of the blockchain network.
• Two types, permissioned and public (non-permissioned), the distinction lies in whether the design of
the network is open for anyone to participate (permissionless) or limited only to designated participants
(permissioned)
• The consensus is also classified based on these two paradigms. For example, Bitcoin is a public
blockchain. It runs PoW, sometimes called Nakamoto consensus
• In contrast, many permissioned blockchains tend to run variants of traditional or classical distributed
consensus. Example Ripple (XRP) currency

• Permissionless blockchains tend to be used in applications with a strong financial component or that
require highly decentralized blockchains, such as the following:
 Digital asset trading.
 Crowdfunding and donations.
 Distributed file storage, such as blockchain storage.

Permissioned blockchains have enabled new applications that depend on privacy and security,
including the following:
 Supply chain provenance tracking.
 Claims settlement.
 Identity verification.
The Byzantine generals problem
• The problem of reaching agreement in the presence of faults
• To be successful, the generals must coordinate their plan and decide whether to attack or retreat
• The requirement now becomes that every honest general must somehow agree on the same decision
even in the presence of disloyal generals.
• In the digital world, generals are represented by computers (nodes) and communication links are
messengers carrying messages. Disloyal generals are faulty nodes. we'll see how agreement can be
achieved using consensus algorithms even in the presence of faults.

Fault tolerance
• A fundamental requirement in a consensus mechanism is that it must be fault-tolerant. In other words, it
must be able to tolerate a number of failures in a network and should continue to work even in the
presence of faults.
• Based on the requirement of fault tolerance, consensus algorithms are also called fault-tolerant
algorithms, and there are two types of fault-tolerant algorithms
• The first is Crash fault-tolerance (CFT) and the other is Byzantine fault tolerance (BFT)
• CFT covers only crash faults or, or simpler faults. In contrast, BFT deals with the type of faults that are
arbitrary/random and can even be malicious
Replication
• Replication is a standard approach to make a system fault-tolerant. Replication results in a
synchronized copy of data across all nodes in a network. This technique improves the fault
tolerance and availability of the network.
• This means that even if some of the nodes become faulty, the overall system/network remain
available due to the data being available on multiple nodes.
• There are two main types of replication techniques, Active replication, Passive replication.
• Active replication, which is a type where each replica becomes a copy of the original state
machine replica
• Passive replication, which is a type where there is only a single copy of the state machine in the
system kept by the primary node, and the rest of the nodes/replicas only maintain the state.

• State machine replication, which is a standard technique used to achieve fault tolerance in
distributed systems (relevant concept)
State machine replication
de facto technique, the recognition that is based on 'a fact, used to achieve fault tolerance in a distributed
system
State machine?
• It is a mathematical model that is used to describe a machine that can be in different states.
• A state machine can only have one state at a time. A state machine stores a state of the system and
transitions it to the next state as a result of input received
State machine replication

The fundamental idea behind SMR can be summarized as follows:


1. All servers always start with the same initial state.
2. All servers receive requests in a totally ordered fashion (sequenced as generated from clients).
3. All servers produce the same deterministic output for the same input.

• State machine replication is implemented under a primary/backup pattern, where a primary node is
responsible for receiving and broadcasting client requests. This broadcast mechanism is called total order
broadcast or atomic broadcast, which ensures that backup or replica nodes receive and execute the same
requests in the same sequence as the primary.
• Consequently, this means that all replicas will eventually have the same state as the primary, thus resulting
in achieving consensus. In other words, this means that total order broadcast and distributed consensus are
equivalent problems; if you solve one, the other is solved too.
Lower bound results and FLP impossibility

• Concept of impossibility results, in distributed computing


• The requirement of minimum available resources is known as lower bound results. The problems
that are not solvable under any conditions are known as unsolvability results
• FLP impossibility is a fundamental unsolvability result in distributed computing theory that states
that in an asynchronous environment, the deterministic consensus is impossible, even if only one
process is faulty

To avoid FLP impossibility, several techniques include:


• Failure detectors, which can be seen as oracles associated with processors to detect failures.
• Randomized algorithms, The core idea behind the randomized protocols is that the processors in
such protocols can make a random choice of decision value if the processor does not receive the
required presence of trusted messages.
• Synchrony assumptions, where additional synchrony and timing assumptions are made to ensure
that the consensus algorithm terminates and makes progress.
Analysis and design for consensus algorithms
In order to understand a consensus algorithm, we need to define a model under which our algorithm will run.
This model provides assumptions about the operating environment of the algorithm and provides a way to
study about the various properties of the algorithm.

• Model: A computational model, represents processes, network conditions, timing assumptions, and how all
these entities interact and work together
• Processes: called message-passing distributed systems
• Timing assumptions: timing assumptions that are made when designing consensus algorithms.
• Synchrony: there is a known upper bound on the communication and processor delays. At a fundamental
level, in a synchronous system, a message sent by a processor to another is received by the receiver in the
same communication round as it is sent
• Asynchrony: there is no upper bound, designed to run on asynchronous networks without any timing
assumptions, unpredictability of message transfer (communication) delays and processing delays
• Partial Synchrony: is when, the systems are synchronous, but there are arbitrary but bounded asynchronous
periods
Classification
• The consensus algorithms can be classified into two broad categories:
• Traditional—voting-based consensus
• Lottery-based—Nakamoto and post-Nakamoto consensus
Two main types of fault-tolerant algorithms, CFT and BFT.
CFT and BFT are two different categories of consensus algorithms used to achieve
agreement among nodes in a distributed network. They address different types of faults
and have distinct levels of fault tolerance.

Crash Fault Tolerance:


• CFT algorithms are designed to tolerate a specific type of fault known as a "crash fault.“
• A crash fault occurs when a node in the system suddenly stops responding or crashes
• well-suited for environments where the probability of nodes crashing is high but
malicious behavior is less of a concern.
• One example of a CFT algorithm is the Practical Byzantine Fault Tolerance (PBFT).
• Also, Raft and Paxos algorithm, used to build a reliable system that works correctly,
even in the presence of faults
Byzantine Fault Tolerance:
• BFT algorithms are designed to tolerate more general types of faults, including
malicious behavior, in addition to crash faults
• A Byzantine fault occurs when a node behaves arbitrarily, sending incorrect or
conflicting information, and may try to disrupt the consensus process.
• Byzantine fault tolerance is more robust than crash fault tolerance
• BFT algorithms are essential in decentralized and open networks where nodes may be
controlled by different parties with potentially conflicting interests

• Example, PBFT, Other well-known BFT algorithms include the HoneyBadgerBFT and
Tendermint algorithms.

• Both CFT and BFT algorithms have their advantages and trade-offs, and the choice will depend on the
requirements and constraints of the distributed system or blockchain network being deployed
PBFT and IBFT consensus protocols

• PBFT (Practical Byzantine Fault Tolerance) and IBFT (Istanbul Byzantine Fault Tolerance)
are both consensus protocols designed to achieve BFT in distributed systems.
• They address the issue of reaching consensus in the presence of faulty or malicious
nodes

Practical Byzantine Fault Tolerance:


• The goal of PBFT is to enable a set of nodes (replicas) in a distributed network to agree
on a sequence of values or transactions, even in the presence of faulty or malicious
nodes.
• Byzantine fault tolerance refers to the ability of a system to reach consensus and
function correctly despite up to one-third of the nodes behaving arbitrarily, sending
incorrect messages, or even colluding to disrupt the consensus process.
Key Features and How PBFT Works

1) In PBFT, the network consists Replicas and Quorums


• set of replicas (nodes)
• the network is divided into groups known as "quorums." A quorum is a set of replicas
that must agree for a decision to be considered valid.

2) To reach consensus, PBFT uses a three-phase protocol:


a. Pre-Prepare: The primary replica (leader) proposes a new block or transaction to all
other replicas in the network.
b. Prepare: Upon receiving the proposal, the other replicas validate it and send a
"prepare" message to other replicas, indicating they are ready to commit the proposed
value if a supermajority agrees on it.
c. Commit: Once a replica receives enough "prepare" messages to form a quorum, it
sends a "commit" message to other replicas. If a replica receives a quorum of "commit"
messages, it commits the proposed value.
Key Features and How PBFT Works

3. Finality: Once a replica receives enough "Commit" messages, it considers the block as
finalized and adds it to its local copy of the blockchain. The block is considered
confirmed by the network at this stage.
4. View Change: If the primary node becomes faulty or unresponsive, the system
initiates a view change to select a new primary node. This ensures the protocol can
continue operating even if the primary node fails.

Benefits of PBFT include its high throughput, low latency, and ability to tolerate up to
(n-1)/3 faulty nodes, where n is the total number of replicas in the network.
However, PBFT is primarily suited for permissioned blockchains and not so much on
public blockchain networks
Key Features and How IBFT Works

Istanbul Byzantine Fault Tolerance:


• IBFT is a consensus protocol designed to provide fault tolerance and consensus in
private or permissioned blockchain networks. It is an improvement over the original
PBFT (Practical Byzantine Fault Tolerance) algorithm and is specifically tailored for
Ethereum-based blockchains.

• IBFT was first introduced in the Ethereum network as a consensus mechanism for
private Ethereum networks, where all participating nodes are known and trusted.

• It is one of the several consensus protocols available in the Ethereum ecosystem,


including Proof of Work (PoW), Proof of Stake (PoS), and others.
Here's how the IBFT protocol works:

1.Validators: In IBFT, the participants in the network are called validators. Validators
are known and explicitly defined entities responsible for proposing and validating
blocks.
2.Block Proposal: In each round, one validator is chosen as the block proposer. The
block proposer creates a new block containing a set of transactions to be added
to the blockchain.
3.Round Robin Selection: The selection of the block proposer is done in a round-
robin fashion. Each validator takes turns being the proposer for a specific round,
ensuring fairness in block proposal opportunities.
4.Proposal and Voting: Once the block proposer creates a block, it broadcasts the
block proposal to all other validators. Other validators receive the proposal,
validate it, and if it meets the consensus rules, they vote to approve the block.
5. Majority Vote: For a block to be considered valid and added to the blockchain, it
requires a threshold number of votes from validators. IBFT typically requires 2/3+1 (or
67%+) of validators to vote in favor of the proposed block for it to be accepted.
6. Finality: Once the required number of votes is achieved, the block is considered
finalized and added to the blockchain. The consensus on the block is irrevocable, meaning
it cannot be changed or rolled back without the agreement of the network's majority.

Benefits of IBFT include fast block finality and high throughput, as only a fraction of the
validators need to reach a consensus on each block.
However, it is important to note that IBFT requires a known set of validators and is not
suitable for fully decentralized and permissionless networks like the public Ethereum
network.
IBFT is primarily used in private and consortium blockchains, where participants are
known and trusted entities.
DISTRIBUTED CONSENSUS MECHANISMS/POS AND POW

what is the use of consensus?


who proposes the block?
Obviously, not every node should propose a block to the rest of the nodes at the same
time, because it is only going to create a mess;
And grouping transactions into blocks is important for obvious reasons and consensus is
required on a block by block basis, so what different “consensus mechanisms” are used?

Consensus mechanisms actually come from game theory. Your system should be
designed such that the nodes get the most benefit if they play by the rules.
• reward for honest behavior and punish for fraudulent activities
• Example of Bitcoin
• the term mining, would mean generating new blocks
Proof Of Work (POW)

• The idea behind the PoW algorithm is that certain work is done for a block of transactions
before it gets proposed to the whole network. The overall goal is to sustain attacks
• Hence, it involves verifying a transaction through the mining process

• In blockchain, if some amount of compute-intensive work is to be performed before


producing a block, then it can help in two ways:
• one is that it will definitely take some time and the second is, if a node is trying to inject a
fraudulent transaction in a block, then rejection of that block by the rest of the nodes will
be very costly
• The Proof of Work consensus algorithm involves solving a computationally challenging
puzzle in order to create new blocks in the Bitcoin blockchain
• The process is known as ‘mining’, and the nodes in the network that engages in mining are
known as ‘miners’
Proof of Work
• The basic idea is that consensus mechanisms such as proof of work make it more financially
rewarding to be honest than to lie
• If multiple different nodes are working to solve such a computational puzzle, then you will
never know which node would solve it first.
• This can be leveraged to select a random node that solves the puzzle and proposes the block.

• Example: Say you have 1 Bitcoin in your crypto wallet. What does that actually mean? It
means that users worldwide have copies of the historical record of transactions using Bitcoin,
and those records are all in agreement about the balance in your account.
• But what if someone wants to submit a fraudulent transaction trying to spend that same
Bitcoin again after they had previously paid it to you?
• This is why miners must check every new transaction, each of which has unique identifying
information, against the historical record to ensure it adds up. And they have a strong
incentive to do this
Proof of Stake

• The Proof of Stake (PoS) algorithm is another consensus algorithm that is quite popular
for distributed consensus, But it isn’t about mining, it is about validating blocks of
transactions
• So, there are no mining rewards due to generation of new blocks, there are only
transaction fees for the miners (more accurately validators)

• In PoS systems, the validators have to bond their stake (mortgage the amount of
cryptocurrency they would like to keep at stake) to be able to participate in validating the
transactions.
• The probability of a validator producing a block is proportional to their stake; the more
the amount at stake, the greater is their chance to validate a new block of transactions.
Proof of Stake

• simple example: let’s say there’s a new change to the blockchain that needs verification.
Ten nodes volunteer to validate it, and they each stake one crypto coin for the privilege.
That means that they each have an equal 10 percent chance of being awarded the work

• Let’s say that one volunteer really wants to win the work. They could up the odds by
staking three coins on the deal. If everyone else kept their stake at one coin, they would
up their chance of winning the work to 25 percent, while everyone else’s chances would
go down to 8.3 percent.

• Since the creator of a block in a PoS system is deterministic (based on the amount at
stake), it works much faster compared with PoW systems
• The PoS systems may provide better protection against malicious attacks
• Also, since it does not require burning a lot of electricity and consuming CPU cycles, it
gets priority over PoW systems where applicable.
S.No. Proof of Work (PoW) Proof of Stake (PoS)

The probability of validating a new block is


1.
The probability of mining a block is determined by determined by how large of a stake a person holds
how much computational work is done by miner.
(how many coins they possess).

2.
A reward is given to first miner to solve The validator do not receive a block reward instead
cryptographic puzzle of each block. they collect network fee as their reward.

To add each block to chain, miners must compete to


3. solve difficult puzzles using their computer process There is no competition as block creator is .chosen
power by an algorithm based on user stake.

Hackers would need to own 51% of


4.
Hackers would need to have 51% of computation all cryptocurrency on network, which is practically
power to add malicious block. impossible.

5.
Proof of work systems are less energy efficient and Proof of Stake systems are much more cost and
are less costly but more proven. energy efficient than POW systems but less proven.

6. Specialized equipment to optimize processing power. Standard server grade unit is more than enough.
Sr No Proof of Work (PoW) Proof of Stake (PoS)

Initial investment to buy stake and build


7. Initial investment to buy hardware. reputation.

Bitcoin is most well known crypto with a Proof- Some of cryptocurrencies that use different
8.
of-Work consensus building algorithm which variants of proof-of-stake consensus are: EOS
uses most well known proof-of-work function (EOS), Tezos (XTZ), Cardano (ADA), Cosmos
is called SHA256. (ATOM), Lisk (LSK).
QB
• State and explain the Byzantine general’s problem.
• What is Fault tolerance and explain the types of fault-tolerant consensus.
• Illustrate the Proof of Work (PoW), Proof of Stake (PoS) algorithm.
• How consensus algorithms are classified? Explain the fundamental requirements of consensus algorithms.
• Explain the term FLP impossibility. How it can be circumvented.
• How to analyze and understand a consensus algorithm. Explain in detail.
• Explain the difference between the PBFT and IBFT protocols.
• Explain the following terms in a model that is useful for describing and analyzing consensus mechanisms.
• i) Model ii) Processes iii) Timing assumptions
• iv) Synchrony v) Asynchrony vi) Partial synchrony

• What are the several types of PoS algorithm. Explain.


• Choosing a consensus algorithm depends on several factors. Explain in detail.
• Explain working of PoW consensus mechanism.

You might also like