A high-fidelity blockchain discrete event simulator for research and education
Project description
BlockSimPy
A discrete event simulator for blockchain networks that models mining competition, block propagation, difficulty adjustment, and economic incentives. The simulator enables controlled experimentation with blockchain protocols without operating live cryptocurrency nodes.
Supported chains: Bitcoin, Bitcoin Cash, Litecoin, Dogecoin
Features:
- Proof-of-Work mining simulation with realistic exponential timing
- Network propagation with configurable topology
- Difficulty adjustment and halving events
- Attack simulations (selfish mining, 51% double-spend, eclipse)
- Checkpoint/resume and metrics export
Installation
pip install blocksimpy
Quick Start
Run a Bitcoin simulation for 100 blocks:
blocksimpy --chain btc --blocks 100
or
bsim --chain btc --blocks 100
Run a custom blockchain:
blocksimpy --blocktime 30 --blocks 50 --miners 5
See all options:
blocksimpy --help
Attack Simulations
Simulate known blockchain attacks for research and education:
# Selfish mining - attacker withholds blocks to gain unfair rewards
blocksimpy --chain btc --blocks 100 --attack selfish --attacker-hashrate 0.3
# 51% double-spend - attacker reverses confirmed payments
blocksimpy --chain btc --blocks 100 --attack double-spend --attacker-hashrate 0.51
# Eclipse - isolate victim nodes from honest network
blocksimpy --chain btc --blocks 100 --attack eclipse --victim-nodes 2
Testing
Validate the simulator works correctly:
python tests/test_validation.py
This runs simulations for Bitcoin, Litecoin, Dogecoin, and Bitcoin Cash, validating that metrics match expected values.
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.3.0.tar.gz.
File metadata
- Download URL: blocksimpy-1.3.0.tar.gz
- Upload date:
- Size: 42.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfe54fe7f2c7d3bacd0e81745137b1b9a3e813f2ef80fe4058bc2bc97783a2ad
|
|
| MD5 |
8352c5b39f1a78f3023c0cfcac314c7b
|
|
| BLAKE2b-256 |
b75497983791cd931133ca4d403a4d6791b1d1ff4ca86cd2080193f9762e59ec
|
Provenance
The following attestation bundles were made for blocksimpy-1.3.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.3.0.tar.gz -
Subject digest:
bfe54fe7f2c7d3bacd0e81745137b1b9a3e813f2ef80fe4058bc2bc97783a2ad - Sigstore transparency entry: 866902140
- Sigstore integration time:
-
Permalink:
btursunbayev/blocksimpy@9b6fa08a57cae8bed7fbe75b9410393382ee8d2b -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/btursunbayev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@9b6fa08a57cae8bed7fbe75b9410393382ee8d2b -
Trigger Event:
release
-
Statement type:
File details
Details for the file blocksimpy-1.3.0-py3-none-any.whl.
File metadata
- Download URL: blocksimpy-1.3.0-py3-none-any.whl
- Upload date:
- Size: 44.2 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 |
af1f52581c13c04f56a0f07ab46640444914faf3d1b8f454a115912fe7609184
|
|
| MD5 |
75e587181a98a0dca790c59333018594
|
|
| BLAKE2b-256 |
faf03c6113d1a50ba38fa121d416810aa65a994b8df0fc31851f683b16a6dae5
|
Provenance
The following attestation bundles were made for blocksimpy-1.3.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.3.0-py3-none-any.whl -
Subject digest:
af1f52581c13c04f56a0f07ab46640444914faf3d1b8f454a115912fe7609184 - Sigstore transparency entry: 866902141
- Sigstore integration time:
-
Permalink:
btursunbayev/blocksimpy@9b6fa08a57cae8bed7fbe75b9410393382ee8d2b -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/btursunbayev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@9b6fa08a57cae8bed7fbe75b9410393382ee8d2b -
Trigger Event:
release
-
Statement type: