A discrete-event blockchain simulator for a P2P cryptocurrency network with capability of PoW performance analysis and simulation of Selfish Mining attack.
- The project is divided into two folders.
normal_libcontains the code for running a blockchain simulator with various configurable parameters without attacks.attack_libcontains the code for running a blockchain simulator with multiple clients acting as Selfish Miner.Normal-Report.pdfandAttack-Report.pdfcontains a performance analysis of both the simulators with detailed explanation.
- Setup the Project -
bash setup.sh - Activate the Virtual Environment -
source venv/bin/activate - Run simulator with default parameters -
python3 normal_lib/main.py
- Number of nodes in the P2P network:
-nor--num_nodes - Percentage of slow nodes:
-z0or--percentage_slow - Percentage of nodes having low CPU power:
-z1or--percentage_lowcpu - Mean inter-arrival time between transactions:
-ttxor--mean_inter_arrival - Average time taken to mine a block:
-Ior--average_block_mining_time - Total time for which the P2P network is simulated:
-Tor--simulation_time - Example -
python3 main.py -n 10 -z0 0.5 -z1 0.5 -ttx 10 -I 600 -T 6000
- Setup the Project -
bash setup.sh - Activate the Virtual Environment -
source venv/bin/activate - Run simulator with default parameters -
python3 attack_lib/main.py
- Number of honest nodes in the P2P network:
-nor--num_honest_nodes - Hashing Power of first Selfish Node:
-z1or--zeta1 - Hashing Power of second Selfish Node:
-z2or--zeta2 - Mean inter-arrival time between transactions:
-ttxor--mean_inter_arrival - Average time taken to mine a block:
-Ior--average_block_mining_time - total time for which the P2P network is simulated:
-Tor--simulation_time - Example -
python3 main.py -n 10 -z1 0.3 -z2 0.3 -ttx 10 -I 300 -T 6000
Network graph, Blockchain graph and log for each node is saved inside normal_lib/outputs and attack_lib/outputs folder after the end of simulation.

