0% found this document useful (0 votes)
4 views49 pages

Module 2_Consensus Protocol

..................................................................................................

Uploaded by

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

Module 2_Consensus Protocol

..................................................................................................

Uploaded by

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

CONSENSUS PROTOCOL

AND BITCOIN Module 2


BLOCKCHAIN
CONSENSUS PROTOCOL
• In blockchain, consensus refers to the mechanism by which all nodes in a
decentralized network agree on the validity of transactions and the state of the
ledger — without needing a central authority.

• Ensures data integrity, prevents double spending, and maintains trust in a


decentralized environment.
• Participants (Nodes) must agree on which transactions are valid and in what
order they're added to the blockchain.
PROOF OF WORK
The Core Idea:
"Work" = solving a hard mathematical problem.
"Proof" = showing the solution, which anyone can quickly verify.
It was introduced by Satoshi Nakamoto in the Bitcoin whitepaper
(2008) as a way to secure a decentralized network.
Proof-of-Work (PoW) is a consensus mechanism used in blockchain
networks to validate transactions and add new blocks to the chain.

It requires participants (miners) to solve complex computational


puzzles, demonstrating effort ("proof of work") before a new block can
be added.

This process secures the network by making it computationally


expensive for malicious actors to manipulate the transaction history
HOW IT WORKS:
Miners compete:
In a PoW system, miners use computational power to solve cryptographic puzzles.
Finding a hash:
These puzzles involve finding a specific hash value that meets certain criteria (e.g., a
certain number of leading zeros) when applied to the block data.
Adding a new block:
The first miner to find the correct hash is rewarded with cryptocurrency and has the right to
add a new block to the blockchain.
Transaction validation:
All other nodes on the network verify the miner's solution and the validity of the
transactions in the new block before accepting it as part of the chain.
SECURITY AND
DECENTRALIZATION:
Deters malicious activity:
By making it computationally expensive to manipulate the blockchain, PoW ensures
its security and prevents fraud.
Decentralized consensus:
PoW enables a decentralized network to reach agreement on the state of the
blockchain without relying on a central authority.
No single point of failure:
Since all nodes participate in the validation process, there is no single point of failure
that could be exploited to compromise the system.
ADVANTAGES:
High security:
PoW is considered a very secure consensus mechanism due to the computational effort
required.
Decentralization:
It allows for a decentralized and trustless system where no single entity controls the
network.
Strong track record:
PoW has been successfully used by Bitcoin and other cryptocurrencies for many years.
DISADVANTAGES:

Energy consumption:
PoW requires significant energy consumption due to the computational power needed for
mining.
Scalability issues:
It can be less scalable than other consensus mechanisms due to the time it takes to validate
blocks.
Centralization risks:
Mining can become centralized as large mining pools dominate the process, potentially
impacting decentralization.
Example:
Bitcoin is the most well-known example of a cryptocurrency that uses PoW.
Other cryptocurrencies like Litecoin, Ethereum, and Dogecoin also utilize PoW.

In conclusion, Proof-of-Work is a fundamental concept in blockchain technology,


providing a secure and decentralized way to validate transactions and maintain the
integrity of the distributed ledger. While it has some drawbacks, its proven security and
track record make it a popular choice for many cryptocurrencies and blockchain
applications.
CHALLENGES WITH POW
The Proof-of-Work consensus mechanism has some issues which are as follows:
The 51% risk: If a controlling entity owns 51% or more than 51% of nodes in the
network, the entity can corrupt the blockchain by gaining the majority of the
network.

Time-consuming: Miners have to check over many nonce values to find the right
solution to the puzzle that must be solved to mine the block, which is a
time-consuming process.
Resource consumption: Miners consume high amounts of computing power in
order to find the solution to the hard mathematical puzzle.
It leads to a waste of precious resources(money, energy, space, hardware). It is
expected that 0.3% of the world's electricity will be spent to verify transactions by
the end of 2028.

Not instantaneous transaction: Transaction confirmation takes about 10–60


minutes.
So, it is not an instantaneous transaction; because it takes some time to mine the
transaction and add it to the blockchain thus committing the transaction.
PROOF-OF-STAKE :
1. Coin-age based selection:

In a coin-age based selection system for validator nodes in a blockchain, the probability of a
validator being chosen to validate the next block is directly proportional to the length of time
its tokens have been staked.
Essentially, older validators, meaning those who have had their coins staked for a longer
period, have a higher chance of being selected.
2. RANDOM BLOCK SELECTION:

• The validator is chosen with a combination of ‘lowest hash value’ and ‘highest stake’.

• The node having the best weighted-combination of these becomes the new validator. Because it
introduces a degree of randomness and fairness to the block selection process.

• This prevents the richest validators from always being selected and promotes a more decentralized
and secure network

• Nodes on a network stake an amount of cryptocurrency to become candidates to validate the new
block and earn the fee from it. Then, an algorithm chooses from the pool of candidates the node
which will validate the new block.
• This selection algorithm combines the quantity of stake (amount of cryptocurrency) with other
factors (like coin-age based selection, randomization process) to make the selection fair to
everyone on the network.
VALIDATORS
Role:
Validators are the core of a blockchain's security and decentralization. They review and verify
transactions, ensuring that only valid ones are added to the blockchain.
Process:
Validators use various methods, depending on the consensus mechanism (e.g., Proof-of-Work,
Proof-of-Stake), to confirm transactions and prevent fraud.
Importance:
Validators are crucial for maintaining the integrity and security of the blockchain. They prevent
double-spending, ensure accurate transaction processing, and contribute to the immutability of the
ledger.
FORGES
Role:
Forges are entities, often referred to as miners in Proof-of-Work systems, that create new blocks in
the blockchain.
Process:
In Proof-of-Work, forgers (miners) compete to solve complex cryptographic puzzles, and the first
one to find the solution adds a new block to the chain. In Proof-of-Stake, forgers (stakers) are
chosen based on their stake (amount of tokens they hold) and are rewarded for creating new blocks.
Importance:
Forges play a key role in block creation and network consensus, ensuring the blockchain continues
to grow and evolve.
DIFFERENCE BETWEEN
VALIDATORS AND FORGES
Validators focus on verifying transactions, while forges are primarily involved in creating
new blocks.
In some blockchain systems, the roles of validator and forger may be combined, with the
same entities performing both functions.
In simpler terms: Imagine a library.
Validators are like librarians, checking each book (transaction) to make sure it's not a fake or
a duplicate before adding it to the shelves (blockchain).
Forges are like the book publishers, creating new books and adding them to the collection.
PROOF OF ELAPASED TIME
(POET)
Proof of Elapsed Time (PoET) is a network consensus algorithm that prevents high
resource utilization and energy consumption.

It implements a fair lottery system to keep the process more efficient.

It's a consensus mechanism, particularly used in permissioned blockchain, that allows


nodes to participate in block validation based on the time they have spent waiting.

This mechanism aims to provide a fairer and more energy-efficient alternative to


Proof-of-Work (PoW)
A PoET mechanism starts by assigning and maintaining a randomly generated amount
of time to each node, which must then sleep for this specific duration and will only be
permitted to add a new block to the network once it has fulfilled the allotted ‘time’.

This ensures that when a node’s waiting time has ended, and it ‘wakes up’, it can forge
and submit a new block of transactions and a cryptographic test for verification.
In comparison to the Proof of Work (PoW) mechanism, PoET is much more time and
energy efficient since it does not demand constant computation work from every node
(or miner) to add a new block.
Instead, PoET enables the nodes to pursue other tasks during the ‘sleep’ time, thereby
improving the network efficiency.
An example of the PoET consensus algorithm is Hyperledger Sawtooth.
PROOF OF AUTHORITY (POA)
Proof of Authority (PoA) is a blockchain consensus mechanism where a limited
number of pre-approved validators, known for their identity and reputation,
secure the network.

Unlike Proof of Work (PoW) or Proof of Stake (PoS), PoA relies on trusted
individuals rather than computational power or staked assets.

This approach prioritizes speed and efficiency but sacrifices some degree of
decentralization.
In blockchain platforms, consensus mechanisms can be divided into
permissionless (eg., Ethereum, Bitcoin) and permissioned
(eg Hyperledger, Ethereum Private).

Unlike permissionless blockchain where anyone can become node, in


permissioned blockchain all nodes are pre-selected. This allows to use
consensus types with high scalability and bandwidth.

One of these consensus types is Proof-of-Authority (PoA)


consensus which provides high performance and fault tolerance.
Trusted Validators:
In a PoA blockchain, a select group of validators, chosen based on their identity and reputation,
are responsible for validating transactions and creating new blocks.

No Mining or Staking:
Unlike PoW (which relies on miners solving complex computations) or PoS (which relies on
validators staking their tokens), PoA bypasses these energy-intensive or capital-intensive processes.

Speed and Efficiency:


PoA networks can achieve significantly faster transaction speeds and lower transaction costs
due to the reduced need for consensus among a large number of participants.

Decentralization Trade-off:
While PoA offers efficiency, it inherently involves a degree of centralization because the
validators are known and trusted, which can lead to potential vulnerabilities if a validator becomes
compromised or malicious.
WHAT IS BYZANTINE GENERALS
PROBLEM?
The Byzantine Generals' Problem is an analogy used in distributed computing to
illustrate the challenge of achieving consensus among a group of nodes in the presence of
faulty or malicious actors.
In the problem, a group of generals, each commanding a portion of an army, must
coordinate their attack or retreat plans through messengers.
However, some generals may be traitors, sending conflicting messages to disrupt the
decision-making process.
BYZANTINE FAULT TOLERANCE
IN DISTRIBUTED SYSTEM
Byzantine Fault Tolerance (BFT) in distributed systems refers to the ability of a system to
continue operating and reaching consensus correctly, even in the presence of malicious or
faulty nodes that may behave arbitrarily or send conflicting information to other nodes.

BFT addresses this by ensuring the system can tolerate faults, including those caused by
Byzantine failures, where nodes may act arbitrarily.

This is important for systems where trust is limited, such as in decentralized networks or
environments with potential attackers.

BFT aims to maintain consistency and correctness even when some nodes fail or behave
incorrectly.
The elements of the problem include:

•Generals: Representing the nodes or processes in a distributed system.

•Messengers: Corresponding to the communication channels through which nodes exchange information.

•Traitors: Nodes that may behave arbitrarily, sending contradictory or false messages.

The goal is for the loyal generals to reach a consensus despite the presence of traitors.

This problem highlights the challenge of ensuring fault tolerance and agreement in distributed systems, as
nodes must contend with the possibility of unreliable or malicious behavior from other nodes.

Solving the Byzantine Generals' Problem requires protocols and algorithms that can tolerate Byzantine faults,
such as Byzantine Fault Tolerance (BFT) protocols.

These protocols employ redundancy, cryptographic verification, and consensus algorithms to enable nodes to
reach agreement even in the presence of malicious actors.
PRACTICAL BYZANTINE FAULT
TOLERANCE (PBFT)
Practical Byzantine Fault Tolerance (PBFT) is a consensus algorithm designed to achieve
agreement among a distributed set of nodes, even when some nodes are faulty or
malicious (Byzantine faults).

It's a practical solution for maintaining consistency and security in distributed systems,
especially in blockchain applications, by ensuring that all honest nodes agree on the same
state or transaction.

Byzantine Fault Tolerance:


PBFT is designed to tolerate a certain number of faulty or malicious nodes within the
system.
Primary Node and Replica Nodes:
▪ The algorithm typically involves a primary node (leader) and multiple
replica nodes.
▪ The primary node proposes new blocks or transactions, and the replica
nodes verify and agree on the proposed changes.
Three-Phase Protocol:
PBFT uses a three-phase protocol (pre-prepare, prepare, and commit) to
ensure that all honest nodes reach a consistent view of the system state.
HOW IT WORKS:
1. Client Request:
A client sends a request to the primary node.
2. Pre-prepare Phase:
The primary node multicasts a pre-prepare message to all replica nodes, including a
sequence number and the request.
3. Prepare Phase:
Replica nodes verify the pre-prepare message and broadcast a prepare message to all
other nodes, including their own signature.
4. Commit Phase:
When a replica node receives prepare messages from more than 2f (where f is the
maximum number of faulty nodes) nodes, it broadcasts a commit message.
PROOF OF BURN (POB):
In PoB, participants destroy (burn) tokens by sending them to an
unspendable address. The proof of burning tokens is used as a
consensus mechanism to mine or validate blocks.

PoB requires participants to "burn"—i.e., destroy or make


unusable—some cryptocurrency tokens to gain the right to mine or validate
blocks.
HOW DOES PROOF OF BURN
WORK?
▪ Participants send coins to an unspendable address—a special wallet from which those
coins cannot be recovered or spent. This is called “burning” the coins because they are
effectively removed from circulation forever.
▪ By burning coins, miners or validators prove their commitment and “investment” in the
network.
▪ The amount of coins burned influences the participant’s chance to mine or validate the
next block.
▪ The more coins burned, the greater the chance to be selected, similar to how staking
more coins increases chances in Proof of Stake.
Comparison Between Protocols
Proof of Authority (PoA): PoA is a consensus algorithm where block validators are known and
reputable entities (authorities) rather than anonymous miners.
It's commonly used in private or consortium blockchains.

Leased Proof of Stake (LPoS): LPoS is a variation of PoS where token holders can lease their coins
to a staking pool, which then uses the combined stake to validate blocks. Rewards are
distributed based on the amount staked.

Practical Byzantine Fault Tolerance (pBFT): This is a family of consensus algorithms designed to
be resilient against Byzantine faults (malicious nodes). It's used in permissioned blockchains and
aims for low-latency finality of transactions.
Life of a Miner:
Refers to the activities and challenges faced by miners in blockchain networks, including setting up
mining rigs, competing to solve cryptographic puzzles, and earning rewards in the form of
cryptocurrency.
In the context of blockchain, a "miner" refers to an individual or entity that participates in the process
of validating and adding new transactions to the blockchain, often by solving cryptographic
puzzles. This process, known as mining, is crucial for maintaining the security and integrity of the
blockchain.

The Mining Process:


Solving Cryptographic Puzzles:
Miners compete to solve complex mathematical problems, known as proof-of-work puzzles, to validate
transactions and add new blocks to the blockchain.
Hardware and Software:
Miners utilize specialized hardware (ASICs for Bitcoin, GPUs for other cryptocurrencies) and software
to perform the necessary computations.
Rewards:
The first miner to solve the puzzle and add a block to the chain receives a reward in the form of
cryptocurrency.
2. Challenges and Considerations:
Competition:
Mining is a competitive process, and the difficulty of the puzzles adjusts based on the overall computing power of
the network.

Cost of Hardware and Energy:


Mining requires significant investment in hardware and a substantial amount of electricity, which can impact
profitability.

Profitability:
The profitability of mining is influenced by factors like cryptocurrency price, mining difficulty, and energy costs.

Security Risks:
Miners are vulnerable to security threats like hacking and malware, which can lead to the theft of mining rewards or
sensitive data.

Environmental Concerns:
Bitcoin mining, in particular, has been criticized for its high energy consumption and environmental impact.
MINING DIFFICULTY:
This adjusts automatically in PoW-based blockchains to maintain a consistent rate of
block creation. It increases as more computational power (hashrate) is added to the
network, ensuring that blocks are mined at a predictable rate.
WHAT IS A MINING POOL?
A mining pool is a group of cryptocurrency miners who connect their mining machines over a
network to boost their chances of earning the reward for opening a new block.
Mining pools are collaborations of miners who combine their computational resources to
increase their chances of mining a block and receiving rewards.
New blocks are opened when a miner discovers the solution to the problem the entire
blockchain network is trying to solve. This process is time-consuming, energy-intensive, and
requires a computer that can generate and check trillions of hexadecimal numbers per second.
Because it can take years to become profitable after purchasing, running, cooling, and
maintaining mining machines capable of this, joining a mining pool is the most affordable way
to increase the odds of receiving a cryptocurrency reward.
Methods used by mining pools include pay-per-share (PPS), proportional (PROP), and others,
which determine how rewards are distributed among pool members.
WHAT IS BITCOIN?
Bitcoin (BTC) is a cryptocurrency (a virtual currency) designed to act as money and a form of
payment outside the control of any one person, group, or entity. This removes the need for
trusted third-party involvement (e.g., a mint or bank) in financial transactions. It is rewarded to
blockchain miners who verify transactions and can be purchased on several exchanges.
BITCOIN COMMON
TERMINOLOGIES
Private Key: A secret number that allows bitcoins to be spent. Each Bitcoin wallet contains one or more
private keys, which are saved in the wallet file. The private key(s) are mathematically related to all
Bitcoin addresses generated for the wallet.

Public Key: Derived from the private key through a cryptographic algorithm. The public key is used to
generate a Bitcoin address.

Bitcoin Address: A unique identifier that represents a possible destination for a Bitcoin payment. It is
derived from the public key through a series of cryptographic processes.

Full Nodes: Nodes that download and validate the entire blockchain.

Light Nodes (SPV Nodes)(Partial Node): Nodes that do not download the entire blockchain but verify
transactions by connecting to full nodes.
Bitcoin Mining:
Bitcoin mining is the process of adding new transactions to the Bitcoin blockchain. Miners use
powerful computers to solve complex mathematical problems (proof of work), and the first to
solve the problem gets to add the next block to the blockchain and is rewarded with new
bitcoins.
Hashcash:
Hashcash is a proof-of-work algorithm used by Bitcoin miners. It requires miners to find a
nonce that, when hashed with the block header, produces a hash with a specific number of
leading zeros.
Block Propagation and Relay :
When a new block is mined, it is propagated to other nodes in the network.
This propagation process involves:
Block Propagation:
The process of distributing newly mined blocks to all nodes in the network.
Relay Networks:
Special networks that enhance the speed and efficiency of block propagation.
TRANSACTION IN THE BITCOIN
NETWORK
A Bitcoin transaction involves transferring bitcoins from one address to another.
Key components of a transaction include:
Inputs: References to previous outputs being spent.
Outputs: The destination addresses and the amounts being sent.
Fees: Incentives for miners to include the transaction in the blockchain.
The transaction process typically involves:
Creating a Transaction: A user creates a transaction specifying inputs, outputs, and fees.
Broadcasting: The transaction is broadcast to the Bitcoin network.
Verification: Nodes verify the transaction to ensure it is valid.
Inclusion in a Block: Miners include the transaction in a newly mined block.
Confirmation: Once the block is added to the blockchain, the transaction is considered confirmed.
BITCOIN SCRIPTS:
Bitcoin Scripts: Scripts are simple programs embedded in transactions that define
spending conditions (e.g., requiring multiple signatures or a specific time delay)
known as ScriptPubKey and ScriptSig.
Transactions in the Bitcoin Network:
Transaction: A transfer of value between Bitcoin wallets. It gets included in the
blockchain once confirmed by miners.
Transaction Structure: Each transaction contains inputs (references to previous
transactions' outputs) and outputs (Bitcoin addresses and amounts to transfer).

You might also like