Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
8 views8 pages

Mod 3 Block

The document explains consensus algorithms used in blockchain networks, detailing their purpose, popular types like PoW, PoS, PoA, PBFT, IBFT, and RAFT, and their specific workings. It also discusses the concept of gas in blockchain transactions, including gas limits and their importance, as well as the differences between soft and hard forks in blockchain protocols. Overall, it provides a comprehensive overview of key concepts in blockchain technology.

Uploaded by

devaanirudh323
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)
8 views8 pages

Mod 3 Block

The document explains consensus algorithms used in blockchain networks, detailing their purpose, popular types like PoW, PoS, PoA, PBFT, IBFT, and RAFT, and their specific workings. It also discusses the concept of gas in blockchain transactions, including gas limits and their importance, as well as the differences between soft and hard forks in blockchain protocols. Overall, it provides a comprehensive overview of key concepts in blockchain technology.

Uploaded by

devaanirudh323
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/ 8

Consensus Algorithm

07 May 2025 12:07

A Consensus Algorithm is a set of rules that helps everyone in a blockchain


network agree on valid transactions, even though there is no central
authority.
It is needed to:
• Validate all transactions
• Allow strangers to work together
• Prevent fraud like double-spending (using the same coin twice)

Popular Consensus Algorithms

1. PoW (Proof of Work)


• How it works: To add a new block to the blockchain, you need to solve
difficult puzzles. It requires a lot of effort and time. Once you solve it, it's
easy for others to check if your solution is correct.
2. PoS (Proof of Stake)
• How it works: The more coins (or stake) you have, the more chances you
get to add a block. You are rewarded based on how much you have
invested.
3. PoA (Proof of Authority)
• How it works: Only trusted nodes (authorities) can validate and add
blocks. It’s usually used for private blockchains where the network is
controlled by a trusted group.
4. PBFT (Practical Byzantine Fault Tolerance)

5. IBFT (Istanbul Byzantine Fault Tolerance)

6. RAFT
• How it works: Used in private systems. It assumes that one node (the
leader) is trusted. Other nodes can be followers or candidates for
becoming a leader. It's easy to manage and works well in controlled
environments.
• In simple words: One trusted leader controls the network, and the others
follow.

1. RAFT – Detailed Working

RAFT is a consensus algorithm.


Roles of Nodes:
 Follower: Waits for messages from the leader.
 Candidate: (tries to become leader)
 Leader: Takes decisions and coordinates others.
Main Processes in RAFT:
1. Leader Election:
 All nodes start as followers.
 If a follower doesn't hear from a leader, it becomes a
candidate.
 The candidate asks for votes.
 If it gets a majority, it becomes the leader.
 The leader then sends messages to followers to
maintain control.
2. Log Replication:
 The leader collects new transactions.
 It sends the new transactions to all followers.
 If a majority accepts, the transaction is committed.
In short: RAFT keeps one leader at a time, who sends updates to
others. It is easy to manage, but assumes the leader is trusted.

2. PoA (Proof of Authority) – Detailed Working


PoA is used in private blockchains, where only trusted nodes (called
Authorities) can add blocks.
Working:
□ A few selected trusted nodes are given the authority.
□ Only one authority node signs a block at a time.
□ It is very fast since there’s no competition like in PoW or
PoS.
Limitations:
□ It only works well if all authorities are trusted.
□ If there are more than 4 authorities, forks can occur (two
blocks at the same time).
In short: Fast and efficient for private networks, but depends heavily
on trust in selected nodes.

3. PBFT (Practical Byzantine Fault Tolerance) – Detailed


Working
PBFT is designed to work even if some nodes are faulty or dishonest.
It is commonly used in systems where safety is more important than
speed.
Key Features:
□ Can tolerate up to f faulty nodes if there are at least 3f + 1
total nodes.
□ Uses one leader (primary) and other backup nodes.
□ The leader changes regularly to ensure fairness.
PBFT Steps:
1. Client Request:
 The client sends a request (like a transaction) to the
leader.
2. Multicast by Leader:
 The leader sends this request to all other nodes.
3. Execution & Reply:
 Nodes process the request and send the reply back to
the client.
4. Client Acceptance:
 The client accepts the result only if it gets f+1
matching replies, which proves correctness.

4. IBFT (Istanbul Byzantine Fault Tolerance) – Detailed


Working
IBFT is an improved version of PBFT, designed especially for
blockchains.
Key Features:
□ Uses a group of validators instead of open participation.
□ A Proposer is selected randomly to suggest a new block.
□ If 66% or more validators agree, the block is finalized and
added to the chain.
□ Leadership rotates regularly to maintain fairness.
Additional Features:
□ Validators can be added or removed by voting.
□ Finalized blocks cannot be changed, ensuring no forks.
□ Offers fast performance and high security.
Benefits of IBFT:
□ Final blocks — no undo.
□ No forks or double blocks.
□ High speed and performance.
□ Secure and trustworthy.
□ Flexible validator management.
In short: IBFT is a fast, secure, and flexible algorithm, ideal for
enterprise blockchains.
Gas & Gas Limit in Blockchain
07 May 2025 16:37

Gas = Fuel for blockchain transactions

We will be performing actions in block chain and each and every action needs
some Gas to get performed

What is Gas Limit?


• Gas limit = The max amount of gas you’re willing to spend on a
transaction.
o Example: Like telling a taxi driver, "I’ll pay up to $20 for this ride."
• If the actual cost exceeds your limit, the transaction fails (but you still
lose the gas spent up to that point).
• If the cost is lower, you only pay for what was used.

How Gas Limits Work


• Gas Price: How much you pay per unit of gas (like $0.10 per liter of fuel).
• Gas Limit: The max gas you allow for the transaction (like filling 50 liters
max).
• Total Fee = Gas Price × Gas Used (up to your limit).

Setting the Gas Limit


• Too low? Transaction fails ("out of gas") and you lose the gas spent.
• Too high? You pay only for what’s used (extra is refunded).
• Just right? Transaction succeeds, and you pay the exact cost.

What Happens if a Transaction Fails?


• You lose the gas spent (no refunds!).
• The transaction either:
o Gets dropped from the network.
o Stays stuck in the waiting area forever

Why Do We Need Gas?


• Pay miners:
They get paid in gas fees to verifying transactions.
• Stop spam:
○ Makes it expensive to flood the network with junk transactions.
○ Since each and every action needs a gas to get performed spammers
think twice before doing an action
• Prioritize transactions:
Higher gas fees = faster processing.
Gas in Simple vs. Complex Transactions

For simple transactions we need less gas and for complex transactions we
need more gas
• Sending crypto: Cheap (low gas).
• Deploying a smart contract: Expensive (high gas).

In public block chains gas is needed but in private block chains gas is not
needed
Forks
07 May 2025 16:28

1. Soft Fork
• A soft fork is a backward-compatible change in the blockchain.
• Old nodes (not updated) can still validate new transactions, as the
changes are stricter but understandable by older rules.
• It does not split the blockchain.

Key Features:
No chain split (only one blockchain remains).
Old nodes still validate transactions (but miss new features).
Easier to implement (only miners need to upgrade).
Tightens rules (e.g., smaller block size, stricter security)
• Example: SegWit in Bitcoin.

2. Hard Fork
• A hard fork is a non-backward-compatible change in the blockchain
protocol.
• Old nodes cannot understand the new rules, leading to a permanent split
in the blockchain into two separate chains.
• Example: Bitcoin and Bitcoin Cash.
Key Features:
Creates two separate blockchains (old & new).
Old nodes stop working if they don’t upgrade.
Requires majority consensus (most users/miners must agree).
Allows major changes (e.g., bigger blocks, new security rules).
Users get coins on both chains if they held tokens before the fork.
Hard Fork and Soft Fork – Story-Based Explanation
Imagine a digital village called Blockland, where all computers (called nodes)
follow the same rulebook to record transactions. This rulebook is known as the
Blockbook.

Soft Fork – A Friendly Update


One day, some villagers suggested a minor change to make rules stricter (e.g.,
only better-quality transactions).
This change was backward-compatible, meaning even villagers who didn’t
update their rulebook could still understand the new transactions.
Everyone continued living in the same village peacefully.
This is called a Soft Fork – the blockchain rules are updated, but the chain
does not split.

Hard Fork – A Major Split


Later, another group of villagers proposed a major change in the rules. These
new rules were so different that old villagers couldn’t understand or accept
them.
As a result, the village split into two:
• One group followed the old rules.
• The other followed the new rules and started a new blockchain.
This is called a Hard Fork – the chain splits into two separate blockchains.

You might also like