A high-fidelity blockchain discrete event simulator for research and education
Project description
BlockSimPy
A discrete event simulator for blockchain networks supporting Proof-of-Work and Proof-of-Stake consensus mechanisms. Models mining competition, validator selection, block propagation, difficulty adjustment, and economic incentives. Includes attack simulations (selfish mining, 51% attacks, eclipse attacks) for security research and education. Enables controlled experimentation with blockchain protocols without operating live cryptocurrency nodes.
Supported chains: Bitcoin, Bitcoin Cash, Litecoin, Dogecoin, Ethereum 2.0
Features:
- PoW consensus with exponential mining time distribution
- PoS consensus with stake-weighted validator selection
- Network propagation with configurable topology and peer connections
- Difficulty adjustment algorithms and reward halving schedules
- Attack simulations: selfish mining, 51% double-spend, eclipse attacks
- Metrics export, checkpoint/resume, and reproducible simulations
Installation
pip install blocksimpy
Quick Start
Simulate Bitcoin for 100 blocks:
blocksimpy --chain btc --blocks 100
Simulate Ethereum 2.0 Proof-of-Stake:
blocksimpy --chain eth2 --blocks 100
Create custom blockchain with specific parameters:
blocksimpy --blocktime 30 --blocks 50 --miners 5
Short alias available:
bsim --chain btc --blocks 100
Attack Simulations
Selfish mining attack where adversary withholds blocks to gain unfair mining rewards:
blocksimpy --chain btc --blocks 100 --attack selfish --attacker-hashrate 0.3
51% double-spend attack where majority hashrate reverses confirmed transactions:
blocksimpy --chain btc --blocks 100 --attack double-spend --attacker-hashrate 0.51
Eclipse attack isolating victim nodes from the honest network:
blocksimpy --chain btc --blocks 100 --attack eclipse --victim-nodes 2
Testing
Run validation tests that verify simulator accuracy against known blockchain metrics:
python tests/test_validation.py
Documentation
License
Apache License 2.0 - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file blocksimpy-1.5.0.tar.gz.
File metadata
- Download URL: blocksimpy-1.5.0.tar.gz
- Upload date:
- Size: 48.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db541ce3ea117eedf874213b3f0b99f3758b57cab65a12977b27a2a85e3be08c
|
|
| MD5 |
e8d41ed2d084feb1d17bce33f785879d
|
|
| BLAKE2b-256 |
c3dbe58289a3f9b04d0863cc3c909c6b5e12eed76108ee7fb9982b6ab1aac042
|
Provenance
The following attestation bundles were made for blocksimpy-1.5.0.tar.gz:
Publisher:
ci.yml on btursunbayev/blocksimpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blocksimpy-1.5.0.tar.gz -
Subject digest:
db541ce3ea117eedf874213b3f0b99f3758b57cab65a12977b27a2a85e3be08c - Sigstore transparency entry: 869353594
- Sigstore integration time:
-
Permalink:
btursunbayev/blocksimpy@646dce3da824b12aa2e198e17c63268d44c7e6ba -
Branch / Tag:
refs/tags/v1.5.0 - Owner: https://github.com/btursunbayev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@646dce3da824b12aa2e198e17c63268d44c7e6ba -
Trigger Event:
release
-
Statement type:
File details
Details for the file blocksimpy-1.5.0-py3-none-any.whl.
File metadata
- Download URL: blocksimpy-1.5.0-py3-none-any.whl
- Upload date:
- Size: 49.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4657defcfa5aef3bf8667dcdd0e3647f6aa92bc43acd1a5716a3fd3bb530495e
|
|
| MD5 |
01c9e2393a92151d6bdf40c500f948ef
|
|
| BLAKE2b-256 |
489a5552bcb612e10e4c414adc9c411b9e9dd5b234966de609f9427b983f3ae7
|
Provenance
The following attestation bundles were made for blocksimpy-1.5.0-py3-none-any.whl:
Publisher:
ci.yml on btursunbayev/blocksimpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blocksimpy-1.5.0-py3-none-any.whl -
Subject digest:
4657defcfa5aef3bf8667dcdd0e3647f6aa92bc43acd1a5716a3fd3bb530495e - Sigstore transparency entry: 869353596
- Sigstore integration time:
-
Permalink:
btursunbayev/blocksimpy@646dce3da824b12aa2e198e17c63268d44c7e6ba -
Branch / Tag:
refs/tags/v1.5.0 - Owner: https://github.com/btursunbayev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@646dce3da824b12aa2e198e17c63268d44c7e6ba -
Trigger Event:
release
-
Statement type: