You are on page 1of 70

Tutor: Dr Prasanna B T

Associate Professor
Dept. of CS&E
Sri Jayachamarajendra College
of Engineering
JSS Science and Technology
University

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
BLOCKCHAIN:UNIT 3

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
We know that Blockchain is a distributed decentralized network that
provides immutability, privacy, security, and transparency. There is no
central authority present to validate and verify the transactions, yet
every transaction in the Blockchain is considered to be
completely secured and verified. This is possible only because of the
presence of the consensus protocol which is a core part of any
Blockchain network.

A consensus algorithm is a procedure through which all the peers of the


Blockchain network reach a common agreement about the present
state of the distributed ledger. In this way, consensus algorithms achieve
reliability in the Blockchain network and establish trust between
unknown peers in a distributed computing environment. Essentially, the
consensus protocol makes sure that every new block that is added to
the Blockchain is the one and only version of the truth that is agreed
upon by all the nodes in the Blockchain.
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
A consensus mechanism is a fault-tolerant mechanism that is used in computer and
blockchain systems to achieve the necessary agreement on a single data value or a single state
of the network among distributed processes or multi-agent systems, such as with
cryptocurrencies. It is useful in record-keeping, among other things.

On the Bitcoin blockchain, for instance, the consensus mechanism is known as Proof-of-
Work (PoW), which requires the exertion of computational power in order to solve a difficult
but arbitrary puzzle in order to keep all nodes in the network honest

Dr Prasanna B T, Associate
Prof, Dept of CSE, SJCE,
A consensus mechanism refers to any number
of methodologies used to achieve agreement,
trust, and security across a decentralized
computer network.

In the context of blockchains and


cryptocurrencies, proof-of-work (PoW) and
proof-of-stake (PoS) are two of the most
prevalent consensus mechanisms.
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Proof-of-Work
Proof-of-Stake
Delegated Proof-of-Stake
Leased Proof-Of-Stake
Proof of Elapsed Time
Practical Byzantine Fault Tolerance
Simplified Byzantine Fault Tolerance
Delegated Byzantine Fault Tolerance
Directed Acyclic Graphs
Proof-of-Activity
Proof-of-Importance
Proof-of-Capacity
Proof-of-Burn
Proof-of-Weight

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
The proof of work (PoW) is a common consensus
algorithm used by the most popular cryptocurrency
networks like bitcoin and litecoin. It requires a
participant node to prove that the work done and
submitted by them qualifies them to receive the
right to add new transactions to the
blockchain. However, this whole mining mechanism
of bitcoin needs high energy consumption and a
longer processing time.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Energy consumption: PoW consensus, which uses a network of powerful
computers to secure the network, is extremely expensive and energy-
intensive. Miners need to use specialized hardware with high computing
capacity in order to perform mining and get rewards. A large amount of
electricity is required to run these mining nodes continuously. Some people
also claim these cryptographic hash calculations are useless as they can't
produce any business value. At the end of 2018, the Bitcoin network across
the Globe used more power than Denmark.

Vulnerability: PoW consensus is vulnerable to 51% attacks, which means, in


theory, dishonest miners could gain a majority of hashing power and
manipulate the blockchain to their advantage.

Centralization: Winning a mining game requires specified and expensive


hardware, typically an ASIC type of machine. Expenses grow
unmanageable, and mining becomes possible only for a small number of
sophisticated miners. The consequence of this is a gradual increase in the
centralization of the system, as it becomes a game of riches.
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
The proof of stake (PoS) is another common
consensus algorithm that evolved as a low-cost,
low-energy consuming alternative to the PoW
algorithm. It involves the allocation of
responsibility in maintaining the public ledger to a
participant node in proportion to the number of
virtual currency tokens held by it. However, this
comes with the drawback that it incentivizes
cryptocoin hoarding instead of spending.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Pros Cons

Not as proven in terms of security as proof of


Energy-efficient.
work.

Provides fast and inexpensive transaction Validators with large holdings can have
processing. excessive influence on transaction verification.

Some proof-of-stake cryptocurrencies require


Doesn't require special equipment to
locking up staked coins for a minimum amount
participate.
of time.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
DPoS (Delegated Proof of Stake): The principle of DPoS is
to let nodes who hold stake vote to elect block verifiers
(i.e., block creators).

This way of voting makes the stakeholders give the right


of creating blocks to the delegates they support instead of
creating blocks themselves, thus reducing their
computational power consumption to 0.

Compared to PoW and PoS, DPoS is a low-cost and high-


efficiency consensus protocol. There are also some
cryptocurrencies adopting DPoS such as BitShares, EOS.
The new version of EOS has turned DPoS to BFT-DPoS
(Byzantine Fault Tolerance-DPoS) .
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Proof of Capacity (PoC) which allow sharing of
memory space of the contributing nodes on the
blockchain network. The more memory or hard
disk space a node has, the more rights it is granted
for maintaining the public ledger.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
The Byzantine Problem
Byzantine Fault Tolerance is a
mechanism that enables a decentralized,
trustless network to function even in the
presence of malfunctioning or malicious
nodes. For a trustless network to
function successfully, participants
adhere to a predetermined consensus
mechanism

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
The Byzantine problem is defined in a paper
published by Leslie Lamport, Robert Shotak,
and Marshall Pease in 1982. The paper was
named The Byzantine Generals Problem. It
stated an allegory for the problems of achieving
consensus in a decentralized system.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
The allegory goes like this: “Before battle, the
Byzantine generals, commanding different army
battalions, try to decide whether they should attack or
retreat. This has to achieve by passing the messages
via messengers between them and coming to an
agreement. However, there is a problem. There is a
possibility that some of the generals and/or some
messengers may be traitors to the cause. These
traitorous generals and messengers may alter the
message and pass the malicious response sabotaging
the plans of the loyal generals. So, the loyal generals
need to find a way to reach a consensus having the
above information in hand.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
PBFT (Practical Byzantine Fault Tolerance)
A PBFT paper published in 1999 by Miguel Castro and Barbara
Liskov describes a practical algorithm for state machine
replication that tolerates Byzantine faults. The algorithm offers
both liveness (client finally receiving correct replies to their
requests) and safety, provided:
•At most ‘(n-1)/3’ nodes are faulty out of ‘n’ nodes
•Delay ‘t’ does not grow faster than indefinitely.
Here, delay is the time between the moment when a message
is sent for the first time and the moment when it is received by
its destination (assuming the sender keeps retransmitting the
message until it is received).

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
Explaining 3f+1
If ‘f’ nodes are byzantine failures, then the system needs to
deal with two types of problems. First is not sending the
message at all and second is maliciously sending a different
message. So the system needs to function well after ‘(n-f)’
nodes. However, it is possible that the ‘f’ replicas that did not
respond are not faulty and, therefore, the ‘f’ replicas that
responded might be faulty. So, if we want the non-faulty
nodes to outnumber the faulty ones; we need at least ‘(n-f)-f
> f’. Therefore, ‘n > 3f+1’ is optimal.
PBFT is currently used in Hyperledger fabric along with the
Kafka ordering system. Kafka provides crash fault tolerance
and finality. But it is important to note that while Kafka is
crash fault tolerant, it is not Byzantine fault tolerant, which
prevents the system from reaching agreement in the case of
malicious or faulty nodes.
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
BFT (Practical Byzantine Fault Tolerance): PBFT is a Byzantine Fault
Tolerance protocol with low algorithm complexity and high practicality
in distributed systems.

PBFT contains five


phases: request, preprepare, prepare, commit and reply.

The primary node forwards the message sent by the client to the
other three nodes.
In the case that node 3 is crashed, one message goes through five
phases to reach a consensus among these nodes.
Finally, these nodes reply to the client to complete a round of
consensus.
PBFT guarantees nodes maintain a common state and take a
consistent action in each round of consensus.
PBFT achieves the goal of strong consistency, thus it is an absolute-
finality consensus protocol.
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Proof of Activity (PoA), used on the blockchain, is
a hybrid that makes use of aspects of both PoW
and PoS.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Proof-of-activity (PoA) is a blockchain consensus algorithm
that is a combination of two other blockchain consensus
algorithms: proof-of-work (PoW) and proof-of-stake (PoS).
The PoA system is an attempt to combine the best aspects of
both the PoW and the PoS systems; the mining process begins
like a PoW system, but after a new block has been successfully
mined, the system switches to resemble a PoS system.
Decred (DCR) is the most well-known cryptocurrency that
uses the PoA consensus mechanism.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
Mining Process in a Proof-of-Activity (PoA) System
The PoA system is an attempt to combine the best aspects
of both the PoW and the PoS systems. In PoA, the mining
process begins the same way as in a PoW process, with
various miners trying to outpace each other with higher
computing power to find a new block. When a new block
is found (or mined), the system switches to PoS, with the
newly found block containing only a header and the
miner's reward address.

Based on the header details, a new, random group of


validators from the blockchain network is selected; they
are required to validate or sign the new block. The more
coins a validator owns, the more chances they have for
being selected as a signer.
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Once all the validators sign the newly-found block, it gains the
status of a complete block, it gets identified and added to the
blockchain network, and transactions start getting recorded
on it. In the event that some of the selected signers are
unavailable to sign the block to completion, the process
moves to the next winning block with a new set of validators
being chosen at random (depending on their coin stake). This
process continues until a winning block receives the required
number of signers and becomes a complete block. The mining
fees/rewards are split among the miner and the various
validators who contributed in their respective roles to sign off
on the block.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
Since the PoA system marries PoW and PoS, it draws criticism
for its partial use of both. Too much power is still needed to
mine blocks during the PoW phase, and coin hoarders still
have more chances of getting on the signers' list and
accumulating more virtual currency rewards.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Proof of elapsed time (PoET) is a blockchain network
consensus mechanism algorithm that prevents high
resource utilization and high energy consumption and
keeps the process more efficient by following a fair
lottery system. The algorithm uses a randomly
generated elapsed time to decide mining rights and
block winners on a blockchain network. By running a
trusted code within a secure environment, the PoET
algorithm also enhances transparency by ensuring
lottery results are verifiable by external participants.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
Proof of elapsed time (PoET) is a consensus algorithm
developed by Intel Corporation that enables
permissioned blockchain networks to determine block
winners and mining rights.

PoET follows a lottery system that spreads the chances


of winning equally across network participants, giving
every single node the same chance of winning.

The PoET algorithm generates a random wait time for


each node in the blockchain network; each node must
go to sleep for that duration.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
The node with the shortest wait time will wake up first and
will win the block, thus being allowed to commit a new
block to the blockchain.

The PoET workflow is similar to Bitcoin's proof of work


(PoW) but consumes less power because it allows a miner’s
processor to sleep and switch to other tasks for the specified
time, thereby increasing efficiency.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
Another, called Proof of History (PoH), developed by the
Solana Project and similar to Proof of Elapsed Time
(PoET), encodes the passage of time itself
cryptographically to achieve consensus without
expending many resources.

Dr Prasanna B T, Associate Prof, Dept of CSE


, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru
Dr Prasanna B T, Associate Prof, Dept of CSE
, SJCE, Mysuru

You might also like