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.
Metadata
Release files for blocksimpy 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| blocksimpy-1.5.0.tar.gz | 48.0 kB | With provenance | Details for blocksimpy-1.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| blocksimpy-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for blocksimpy-1.5.0-py3-none-any.whl |
Total release size: 97.9 kB
Release files / blocksimpy-1.5.0.tar.gz
| Download URL | blocksimpy-1.5.0.tar.gz |
|---|---|
| Size | 48.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db541ce3ea117eedf874213b3f0b99f3758b57cab65a12977b27a2a85e3be08c
|
|
BLAKE2b-256 checksum How to use checksums |
c3dbe58289a3f9b04d0863cc3c909c6b5e12eed76108ee7fb9982b6ab1aac042
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 29, 2026.
Transparency logRelease files / blocksimpy-1.5.0-py3-none-any.whl
| Download URL | blocksimpy-1.5.0-py3-none-any.whl |
|---|---|
| Size | 49.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4657defcfa5aef3bf8667dcdd0e3647f6aa92bc43acd1a5716a3fd3bb530495e
|
|
BLAKE2b-256 checksum How to use checksums |
489a5552bcb612e10e4c414adc9c411b9e9dd5b234966de609f9427b983f3ae7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 29, 2026.
Transparency logSecurity for blocksimpy 1.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for blocksimpy-1.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.