Skip to content

Amogh-2404/Consensus-Scheme-Survey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Blockchain Consensus Mechanisms Simulation Framework

Architecture Diagram

πŸ“‹ Overview

This project provides a comprehensive simulation framework for comparing and analyzing five blockchain consensus mechanisms under realistic network conditions and security threats. It offers detailed performance metrics, visualizations, and security analysis to help researchers and developers understand the trade-offs between different consensus approaches.

Implemented Consensus Mechanisms

  • Proof of Work (PoW) - Miners solve computationally intensive puzzles to create blocks
  • Proof of Stake (PoS) - Block creators are selected based on their stake in the system
  • Proof of Elapsed Time (PoET) - Participants wait for a randomly chosen time period
  • Proof of Burn (PoB) - Participants burn virtual currency to gain mining rights
  • Proof of Authority (PoA) - Approved validators with assigned authority levels create blocks

✨ Key Features

🌐 Realistic Network Simulation

  • Dynamic network conditions (optimal, congested, severely congested)
  • Configurable latency and packet loss modeling
  • Impact analysis of network conditions on consensus performance

Network Impact Analysis

πŸ”„ Distributed Validation System

  • True distributed validation where all miners independently validate blocks
  • Realistic consensus achievement modeling requiring majority approval
  • Network conditions affecting validation success rates

πŸ”’ Comprehensive Security Analysis

  • Double Spend Attack: Simulates attempts to spend the same funds twice
  • Selfish Mining: Models miners withholding blocks for advantage
  • 51% Attack: Evaluates the danger when a single entity controls majority resources
  • Sybil Attack: Evaluates resilience against identity-based attacks
  • DoS Attack: Simulates network degradation under denial of service conditions

Security Analysis

πŸ“Š Detailed Performance Metrics

  • Transaction throughput (TPS)
  • Energy consumption
  • Block propagation times
  • Network resilience
  • Finality guarantees

Performance Metrics

πŸ“ˆ Advanced Visualizations

  • Consensus mechanism comparison
  • Block time analysis
  • Security vulnerability assessment

Consensus Comparison

πŸ—οΈ Architecture

The simulation framework is designed with a modular architecture that separates concerns while enabling realistic interaction between components:

Core Components

  • Blockchain Core: Implements the Block, Transaction, and Blockchain classes
  • Transaction Generator: Creates and validates transactions for the simulation
  • Consensus Mechanisms: Implements the five consensus algorithms
  • Network Simulation: Models realistic network conditions
  • Security Attack Simulation: Implements various attack vectors
  • Blockchain Metrics: Collects and analyzes performance data
  • Visualization: Generates comprehensive analysis plots

πŸš€ Installation

  1. Clone the repository:
git clone https://github.com/Amogh-2404/Consensus-Scheme-Survey
cd Consensus-Scheme-Survey
  1. Create and activate a virtual environment (recommended):
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install required dependencies:
pip install matplotlib numpy seaborn

πŸ’» Usage

Running the Simulation

To run the complete simulation with default parameters:

python main.py

This will execute the simulation for all five consensus mechanisms, generate metrics, and produce visualization plots.

Customizing Simulation Parameters

You can modify the simulation parameters in main.py:

# Example parameter customization
simulation_params = {
    'block_count': 100,            # Number of blocks to simulate
    'miner_count': 10,             # Number of miners/validators
    'transaction_pool_size': 500,  # Size of transaction pool
    'network_condition': NetworkCondition.OPTIMAL,  # Network condition
    'attack_intensity': 0.5        # Intensity of security attacks (0-1)
}

# Then pass these parameters to the simulation
threaded_simulation.run_threaded_simulation_runner(**simulation_params)

Available Plots

After running the simulation, the following plots will be generated:

  1. average_block_times.png - Basic comparison of block times
  2. block_time_line_plot.png - Block time progression
  3. block_time_histogram.png - Block time distribution
  4. consensus_comparison.png - Comprehensive consensus mechanism comparison
  5. network_impact.png - Impact of network conditions
  6. security_analysis.png - Security vulnerability analysis
  7. performance_metrics.png - Performance metrics over time

πŸ“ Project Structure

β”œβ”€β”€ main.py                     # Entry point for simulation execution
β”œβ”€β”€ attacks/                    # Security attack simulations
β”‚   β”œβ”€β”€ security_simulation.py  # Orchestrates security attack simulations
β”‚   └── simulators/             # Modular attack simulation components
β”œβ”€β”€ plots/                      # Visualization components
β”‚   └── plot_results.py        # Comprehensive visualization tools
β”œβ”€β”€ report/                     # Documentation
β”‚   └── blockchain_simulation_report.tex  # LaTeX report
β”œβ”€β”€ simulations/                # Core simulation components
β”‚   β”œβ”€β”€ blockchain.py          # Core blockchain data structures (Block, Blockchain)
β”‚   β”œβ”€β”€ blockchain_metrics.py  # Performance metrics collection
β”‚   β”œβ”€β”€ consensus_base.py      # Base class for all consensus mechanisms
β”‚   β”œβ”€β”€ network_simulation.py  # Network condition simulator
β”‚   β”œβ”€β”€ poa.py                 # Proof of Authority implementation
β”‚   β”œβ”€β”€ pob.py                 # Proof of Burn implementation
β”‚   β”œβ”€β”€ poet.py                # Proof of Elapsed Time implementation
β”‚   β”œβ”€β”€ pos.py                 # Proof of Stake implementation
β”‚   β”œβ”€β”€ pow.py                 # Proof of Work implementation
β”‚   β”œβ”€β”€ threaded_simulation.py # Simulation orchestration
β”‚   └── transaction_generator.py # Transaction creation and validation
└── *.png                      # Generated visualization outputs

πŸ“ˆ Results Summary

Consensus Performance Comparison

Metric PoW PoS PoET PoB PoA
Transaction Throughput (TPS) 79.74 106.23 57.16 101.38 92.45
Average Block Time (sec) 0.458 0.409 0.541 0.422 0.437
Energy Consumption (units/block) 800 10 10 132 15
Network Resilience (%) 87.5 92.3 84.1 90.2 94.8
Fraudulent Transaction Detection (%) 99.96 99.96 99.96 99.96 99.96

Key Findings

  1. Efficiency Trade-offs: PoS and PoB offer significant efficiency improvements over PoW while maintaining strong security characteristics
  2. Security Profiles: Each consensus mechanism exhibits a unique security profile with specific strengths and vulnerabilities
  3. Network Resilience: PoS shows the best resilience under degraded network conditions
  4. Energy Efficiency: PoS and PoET are the most energy-efficient options, with PoW consuming significantly more resources

🀝 Contributing

Contributions are welcome! Here's how you can contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Future Development

We're looking for contributions in these areas:

  • Additional consensus mechanisms (DAG-based, hybrid approaches)
  • Enhanced scalability testing
  • Sharding simulation
  • Smart contract execution metrics
  • Cross-chain interaction modeling

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“š References

  • Nakamoto, S. (2008). "Bitcoin: A peer-to-peer electronic cash system"
  • King, S. and Nadal, S. (2012). "PPCoin: Peer-to-peer crypto-currency with proof-of-stake"
  • Chen et al. (2017). "On security analysis of proof-of-elapsed-time (PoET)"
  • Stewart, I. (2012). "Proof of burn"
  • De Angelis et al. (2018). "PBFT vs proof-of-authority: Applying the CAP theorem to permissioned blockchain"

About

Survey and Implementation of Various Consensus Schemes in Blockchain

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors