Module 3
Module 3
The GARAY model has influenced the design and analysis of many blockchain
protocols beyond Bitcoin, including those based on proof-of-stake (PoS).
Researchers have extended it to account for different consensus mechanisms,
network assumptions, and adversarial behaviors.
Limitations
1. Participants:
o Honest Participants (Nodes): Nodes that follow the protocol rules.
o Adversarial Participants: Nodes that attempt to subvert the
blockchain.
2. Blockchain Growth:
o Blocks: Represented as a chain of linked blocks, growing linearly.
o Chain Growth Property: Ensures blocks are added at a consistent
rate.
3. Security Properties:
o Chain Quality: The proportion of blocks contributed by honest
nodes.
o Common Prefix: Ensures the first part of the blockchain is agreed
upon by all honest nodes.
4. Adversary Model:
o Represents the adversary's control over computational resources and
the network.
5. Environment:
o Network Assumptions: Synchronous or partially synchronous
communication.
o
1. Honest Nodes:
o Nodes that strictly adhere to the protocol, contribute to valid block
creation, and maintain consensus.
2. Adversarial Nodes:
o Malicious participants aiming to manipulate the blockchain, for
example, by creating forks or double-spending.
3. Blockchain Growth:
o Visualized as an expanding chain of blocks, where the rate of
addition is constrained by the proof-of-work mechanism and the
chain growth property.
4. Security Properties:
o Chain Quality: Ensures adversarial blocks do not dominate.
o Common Prefix: Honest nodes agree on a shared prefix of the
blockchain, ensuring consistency.
5. Blockchain Consensus:
o Highlights the importance of PoW for ensuring honest contributions
and the difficulty adjustment mechanism.
6. Secure Blockchain:
o The culmination of the model ensures a secure, decentralized ledger
with robust guarantees against tampering.
Explain Proof of Work as Random Oracle
Proof of Work (PoW) is often modelled as a random oracle in theoretical
analyses to simplify and formalize its behaviour. This approach is central to
frameworks like the GARAY model. Here’s an explanation of PoW as a random
oracle:
In PoW-based blockchains:
Benefits of Modelling PoW as a Random Oracle
1. Staking:
o Participants in the network lock up a certain amount of
cryptocurrency (their "stake") to become validators.
o The size of the stake often determines the likelihood of being chosen
to propose or validate a block.
2. Validator Selection:
o Validators are selected to propose or validate blocks based on factors
like:
▪ The amount of cryptocurrency staked.
▪ Randomization to ensure fairness.
▪ Age of the stake (in some implementations).
3. Block Validation:
o The chosen validator creates a new block and adds it to the
blockchain.
o Other validators verify the block's validity.
4. Incentives and Penalties:
o Validators earn rewards for creating valid blocks (e.g., transaction
fees or new tokens).
o Misbehavior, such as creating fraudulent blocks, can result in
"slashing," where part or all of the validator's stake is forfeited.
1. Energy Efficiency:
o Unlike PoW, PoS does not require extensive computational power,
making it significantly more energy-efficient.
2. Decentralization:
o PoS can enable greater decentralization by lowering the barriers to
entry compared to PoW, which requires specialized hardware.
3. Economic Security:
o Validators are financially incentivized to act honestly since their
stake is at risk if they attempt to defraud the system.
4. Deterministic Finality:
o Some PoS systems provide deterministic finality, where transactions
are considered final once included in a block, eliminating the
possibility of chain reorganization.
1. Random Selection:
o PoS chains often use pseudo-random mechanisms to select
validators to prevent predictability and gaming of the system.
o Techniques like Verifiable Random Functions (VRFs) ensure
secure and unbiased randomness.
2. Sybil Resistance:
o The staking requirement acts as a deterrent to Sybil attacks by
making it expensive to acquire enough stake to control the network.
3. Slashing:
o Validators are punished for malicious actions, like double-signing or
staying offline, to enhance security.
1. Energy Efficiency:
o PoS drastically reduces energy consumption compared to PoW.
2. Scalability:
o PoS systems can achieve higher transaction throughput, making
them more suitable for large-scale adoption.
3. Reduced Hardware Requirements:
o Validators do not need specialized hardware, lowering entry costs.
Challenges and Criticisms
1. Wealth Centralization:
o Large stakeholders have a higher chance of being selected as
validators, potentially leading to centralization.
2. Nothing-at-Stake Problem:
o Validators may validate multiple conflicting chains since there’s no
computational cost involved, which could compromise security.
3. Initial Token Distribution:
o The fairness of the PoS system heavily depends on the initial
distribution of tokens.
1. Ethereum 2.0:
o Transitioned from PoW to PoS in 2022 (The Merge).
o Requires a minimum of 32 ETH to become a validator.
2. Cardano (ADA):
o Utilizes a PoS protocol called Ouroboros, which combines
randomness and stake-weighted selection.
3. Polkadot (DOT):
o Employs a Nominated Proof of Stake (NPoS) system where
nominators back validators with their stake.
4. Solana (SOL):
o Uses a hybrid PoS and Proof of History (PoH) mechanism for high
throughput.
Blockchain – Proof of Work (PoW)
•
Proof of Work consensus is the mechanism of choice for the majority of
cryptocurrencies currently in circulation. The algorithm is used to verify the
transaction and create a new block in the blockchain. The idea for Proof of
Work(PoW) was first published in 1993 by Cynthia Dwork and Moni Naor and
was later applied by Satoshi Nakamoto in the Bitcoin paper in 2008. The term
“proof of work” was first used by Markus Jakobsson and Ari Juels in a
publication in 1999.
Cryptocurrencies like Litecoin, and Bitcoin are currently using PoW. Ethereum
was using PoW mechanism, but now shifted to Proof of Stake(PoS).
Principle: A solution that is difficult to find but is easy to verify.
Purpose of PoW
This model is particularly useful for evaluating security guarantees like liveness,
safety, and fairness in both Proof-of-Work (PoW) and Proof-of-Stake (PoS)
systems.
1. Proof-of-Work Systems:
o Analyzing scenarios like selfish mining, where an adversary
attempts to manipulate the mining process to gain disproportionate
rewards.
o Evaluating the chain growth and quality under adversarial
conditions, ensuring that honest miners dominate.
2. Proof-of-Stake Systems:
o Assessing the security of stake-based protocols, including resistance
to long-range attacks (reorganizations by adversaries controlling
old stakes).
o Ensuring fair block proposal and validation processes in PoS.
3. Hybrid and New Consensus Mechanisms:
o Designing robust hybrid systems (e.g., PoW + PoS) by balancing
resource constraints across different mechanisms.
o Testing novel protocols like Delegated Proof of Stake (DPoS) and
Byzantine Fault Tolerance (BFT) under adversarial assumptions.
Key Insights from the RLA Model
1. Threshold Assumptions:
o Blockchain security relies on honest majority assumptions. The
RLA model helps quantify these thresholds:
▪ In PoW, the adversary must control less than 50% of
computational power.
▪ In PoS, the adversary must control less than 50% of the total
stake.
2. Adversarial Strategies:
o The model identifies strategies that adversaries might use, such as:
▪ Block withholding.
▪ Forking attacks.
▪ Eclipse attacks (isolating nodes from the network).
3. Trade-offs:
o Security vs. Performance: Increasing security (e.g., higher
confirmation times) can reduce performance.
o Decentralization vs. Efficiency: More centralized systems may offer
better efficiency but are less resilient to adversaries.
solidity
Copy code
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleBlockchain {
// Block structure
struct Block {
uint256 index; // Block number
uint256 timestamp; // Block creation time
string data; // Data stored in the block
bytes32 previousHash; // Hash of the previous block
bytes32 hash; // Current block's hash
}
// Blockchain array
Block[] public blockchain;
blockchain.push(genesisBlock);
}
blockchain.push(newBlock);
}
Explanation
1. Block Structure:
o The Block struct defines the block's attributes:
▪ index: The position of the block in the chain.
▪ timestamp: The block creation time.
▪ data: The information stored in the block.
▪ previousHash: The hash of the previous block.
▪ hash: The current block's hash, calculated using keccak256.
2. Genesis Block:
o Created in the constructor using the createGenesisBlock function.
o Contains predefined data ("Genesis Block") and a placeholder
previousHash (zero bytes).
3. Adding a New Block:
o Uses the addBlock function to append a new block to the
blockchain.
o The new block’s previousHash is set to the hash of the last block.
4. Hash Calculation:
o Hashes the block's attributes using keccak256 for integrity.
5. Retrieving Blocks:
o The getBlock function allows retrieval of a block's details by index.
o The getBlockchainLength function returns the number of blocks.
vbnet
Copy code
index: 0
timestamp: 1679041608
data: "Genesis Block"
previousHash:
0x0000000000000000000000000000000000000000000000000000
000000000000
hash: 0xabcd... (calculated hash)
vbnet
Copy code
index: 1
timestamp: 1679041615
data: "First Block Data"
previousHash: 0xabcd... (hash of Genesis Block)
hash: 0xefgh... (calculated hash)
Types of Forking
1. Hard Fork
Key Features:
Use Cases:
Key Features:
Use Cases:
3. Accidental Fork
An accidental fork occurs when two miners produce a block at the same time,
creating a temporary split in the blockchain. These forks are resolved when
subsequent blocks are mined, and the longest chain is accepted as the valid one.
Key Features:
A chain split is a type of hard fork where the community disagrees on the
protocol changes, leading to the creation of two separate blockchains. Both
chains continue to exist independently, each with its own set of rules and
participants.
Key Features:
Use Cases:
Key Features:
6. Development Fork
Key Features:
Use Cases:
Comparative Table
Backward- Permanent
Type Use Case
Compatible Split
Minor changes,
Soft Fork Yes No
optimizations
Unintentional, resolved
Accidental Fork N/A No
automatically
User-Activated Community-driven
Yes or No Yes or No
Fork changes
Development
N/A No Testing and development
Fork
Conclusion
1. Enhanced Security:
o Combines the robust, decentralized security of PoW with the
economic-based security of PoS.
o Provides double layers of protection against attacks like 51%
attacks or long-range attacks.
2. Energy Efficiency:
o PoW is computationally intensive but is typically used less
frequently in hybrid models, while PoS handles most transaction
validation efficiently.
3. Decentralization and Incentives:
o PoW ensures fair initial distribution of tokens by rewarding miners,
while PoS incentivizes long-term network participation through
staking.
4. Flexibility in Governance:
o PoS can facilitate governance mechanisms like voting on network
upgrades, while PoW ensures a secure and immutable ledger.
1. Improved Security:
o Double-layered security makes it challenging for an adversary to
control both mining resources and staking tokens.
o Reduces vulnerabilities like long-range attacks (common in PoS)
and selfish mining (common in PoW).
2. Energy Optimization:
o Reduces reliance on energy-intensive PoW by delegating most
operations to PoS, improving sustainability.
3. Fair Token Distribution:
o PoW ensures fair and decentralized token distribution during the
network's early stages.
4. Scalability:
o PoS can handle a higher transaction throughput, enabling scalability
for real-world applications.
5. Governance and Flexibility:
o Stakeholders in PoS systems can vote on protocol upgrades,
enhancing community-driven development.
1. Increased Complexity:
o Integrating PoW and PoS adds technical and design complexity.
o May require sophisticated mechanisms to resolve disputes between
PoW miners and PoS validators.
2. Potential Centralization:
o PoS layer may still face centralization risks if a small number of
entities hold a significant share of tokens.
3. Economic Implications:
o Dual incentive systems (mining rewards and staking rewards) must
be balanced to prevent economic exploitation.
4. Fork Management:
o Combining PoW and PoS consensus can complicate chain
reorganization and fork resolution processes.
1. Decred (DCR):
o Uses PoW for mining and block creation.
o PoS validators vote on block validity, ensuring governance and
security.
o Introduces a treasury system where stakeholders decide on fund
allocation.
2. Hybrix (HY):
o Operates on a multi-layer blockchain with PoW for basic security
and PoS for validation.
o Designed for interoperability and scalability.
3. Hcash (HC):
o Combines PoW for mining and PoS for staking to secure the
network.
o Focuses on cross-chain compatibility.
4. Qtum:
o Implements PoW to bootstrap the network and PoS for long-term
operation and governance.
Workflow Example in a Hybrid PoW+PoS Model
1. Block Mining:
o Miners compete to solve a computational puzzle (PoW) and generate
a block.
o The block includes transaction data and miner rewards.
2. Block Validation:
o PoS validators review the mined block based on their stake.
o Validators vote to accept or reject the block, ensuring consensus.
3. Incentive Distribution:
o Miners receive rewards for block generation.
o Validators earn rewards proportional to their stakes for validating
blocks.
4. Periodic Adjustments:
o The system may dynamically adjust the roles of PoW and PoS based
on network conditions, such as security threats or increased
transaction load.
1. Financial Systems:
o Secure, scalable platforms for decentralized finance (DeFi)
applications.
2. Enterprise Solutions:
o Energy-efficient systems for enterprises needing high transaction
throughput and robust security.
3. Token Distribution and Governance:
o Fair token distribution in early stages using PoW, transitioning to
PoS for long-term governance.
4. Cross-Chain Interoperability:
o Facilitates secure and efficient operations between multiple
blockchain networks.
Conclusion
Advantages:
1. Freedom for Major Changes: Allows developers to implement substantial
changes, such as scalability improvements, new features, or governance
modifications.
2. Enables Community Choice: If there are disagreements, communities can
split and follow their preferred blockchain, enabling innovation on both
chains.
3. Scalability Enhancements: Major improvements such as increasing block
size or transaction speed can boost the overall network's efficiency.
4. Improved Security: Hard forks can introduce important security patches that
would be difficult to achieve with minor updates.
5. New Development Paths: The creation of a new chain allows for further
experimentation and development without affecting the stability of the old
chain.
Disadvantages:
1. Risk of Community Split: Hard forks can fracture the community, leading to
competing blockchains and reduced network effects.
2. Security Issues: Users may inadvertently send tokens to the wrong chain,
leading to duplicate transactions or loss of assets.
3. Resource Intensive: Older nodes become obsolete and may require upgrades
or abandonment, which can be costly and time-consuming.
4. Confusion for Users: Users must decide which chain to support, and there
can be confusion about the value and security of assets on each chain.
5. Disrupts Consensus: The forking process requires substantial network
coordination, which may disrupt normal operations temporarily.
Example:
One of the most famous examples of a hard fork is the split between Bitcoin and
Bitcoin Cash. Due to disagreements about block size and scalability, the
community split into two, with Bitcoin Cash implementing a larger block size.
Features:
1. Backward Compatibility: Older nodes can still interact with the updated
blockchain, ensuring that no permanent split occurs.
2. Tightens Existing Rules: Soft forks usually introduce more restrictive or
refined rules, such as reducing block size or changing transaction formats.
3. No Chain Split: Since old and new nodes can coexist, soft forks do not result
in separate blockchains.
4. Lower Consensus Requirement: A soft fork requires a smaller portion of the
network to upgrade, making it easier to implement.
5. Seamless Upgrade: Allows for more seamless and less disruptive updates
compared to hard forks, with fewer compatibility issues.
Advantages:
1. Backward Compatibility: Ensures that nodes running older versions can still
participate in the network without upgrading.
2. Reduced Risk of Chain Split: No permanent chain split occurs, keeping the
community unified and avoiding competing blockchains.
3. Less Disruptive: Easier to implement and transition to without requiring
massive coordination or resource updates.
4. Tighter Rules: Enhances security by making the rules more restrictive
without breaking existing functionality.
5. Fewer Resource Requirements: Soft forks don’t require as much
infrastructure or computational power, as there’s no need to run two
blockchains.
Disadvantages:
1. Limited Scope: Soft forks are constrained by the need to maintain
compatibility with older versions, limiting the scale of changes.
2. Potential Inconsistencies: If a significant portion of the network doesn't
upgrade, the new rules might not be enforced consistently.
3. Temporary Confusion: As nodes upgrade at different times, there may be
temporary inconsistencies or confusion in transaction validation.
4. Enforcement Challenges: Soft forks rely on a majority of miners adopting
the update, which can lead to uneven enforcement of the new rules.
5. Slower Innovation: Because soft forks need to be backward-compatible, they
tend to limit more radical innovations or protocol changes.
Example:
The SegWit (Segregated Witness) update in the Bitcoin blockchain is a soft fork.
It was implemented to solve issues like transaction malleability and to increase
the block size without splitting the blockchain into two separate entities.
Hard Fork vs Soft Fork
Below are the differences between Hard Fork and Soft Fork:
Backward
Not backward-compatible. Backward-compatible.
Compatibility
Old nodes can't validate new Old nodes can still validate
Impact on Nodes transactions. transactions.
Aspect Hard Fork Soft Fork
Consensus
Requires majority consensus. Requires less consensus.
Requirement
Conclusion
Forks are a fundamental part of blockchain evolution, allowing communities to
implement upgrades, resolve disputes, and introduce new features. Hard forks are
more disruptive but allow for greater changes to blockchain protocols, while soft
forks offer incremental updates without dividing the network.