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.
- 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
- Dynamic network conditions (optimal, congested, severely congested)
- Configurable latency and packet loss modeling
- Impact analysis of network conditions on consensus performance
- True distributed validation where all miners independently validate blocks
- Realistic consensus achievement modeling requiring majority approval
- Network conditions affecting validation success rates
- 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
- Transaction throughput (TPS)
- Energy consumption
- Block propagation times
- Network resilience
- Finality guarantees
- Consensus mechanism comparison
- Block time analysis
- Security vulnerability assessment
The simulation framework is designed with a modular architecture that separates concerns while enabling realistic interaction between 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
- Clone the repository:
git clone https://github.com/Amogh-2404/Consensus-Scheme-Survey
cd Consensus-Scheme-Survey- Create and activate a virtual environment (recommended):
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install required dependencies:
pip install matplotlib numpy seabornTo run the complete simulation with default parameters:
python main.pyThis will execute the simulation for all five consensus mechanisms, generate metrics, and produce visualization plots.
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)After running the simulation, the following plots will be generated:
average_block_times.png- Basic comparison of block timesblock_time_line_plot.png- Block time progressionblock_time_histogram.png- Block time distributionconsensus_comparison.png- Comprehensive consensus mechanism comparisonnetwork_impact.png- Impact of network conditionssecurity_analysis.png- Security vulnerability analysisperformance_metrics.png- Performance metrics over time
βββ 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
| 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 |
- Efficiency Trade-offs: PoS and PoB offer significant efficiency improvements over PoW while maintaining strong security characteristics
- Security Profiles: Each consensus mechanism exhibits a unique security profile with specific strengths and vulnerabilities
- Network Resilience: PoS shows the best resilience under degraded network conditions
- Energy Efficiency: PoS and PoET are the most energy-efficient options, with PoW consuming significantly more resources
Contributions are welcome! Here's how you can contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
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
This project is licensed under the MIT License - see the LICENSE file for details.
- 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"




