Skip to main content

BlockSimPy

PyPI version Python License

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

Architecture

Configuration guide

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)

Source distribution for blocksimpy 1.5.0
File Size Uploaded
blocksimpy-1.5.0.tar.gz 48.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for blocksimpy 1.5.0
File Interpreter ABI Platform
blocksimpy-1.5.0-py3-none-any.whl Python 3 none any Details

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 log

Release 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 log

Release history Release notifications | RSS feed

This release

1.5.0 This release

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page