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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blocksimpy-1.5.0.tar.gz (48.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blocksimpy-1.5.0-py3-none-any.whl (49.9 kB view details)

Uploaded Python 3

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

Hashes for blocksimpy-1.5.0.tar.gz
Algorithm Hash digest
SHA256 db541ce3ea117eedf874213b3f0b99f3758b57cab65a12977b27a2a85e3be08c
MD5 e8d41ed2d084feb1d17bce33f785879d
BLAKE2b-256 c3dbe58289a3f9b04d0863cc3c909c6b5e12eed76108ee7fb9982b6ab1aac042

See more details on using hashes here.

Provenance

The following attestation bundles were made for blocksimpy-1.5.0.tar.gz:

Publisher: ci.yml on btursunbayev/blocksimpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for blocksimpy-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4657defcfa5aef3bf8667dcdd0e3647f6aa92bc43acd1a5716a3fd3bb530495e
MD5 01c9e2393a92151d6bdf40c500f948ef
BLAKE2b-256 489a5552bcb612e10e4c414adc9c411b9e9dd5b234966de609f9427b983f3ae7

See more details on using hashes here.

Provenance

The following attestation bundles were made for blocksimpy-1.5.0-py3-none-any.whl:

Publisher: ci.yml on btursunbayev/blocksimpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.5.0 This release

2 files

1.4.0

2 files

1.3.1

2 files

1.3.0

2 files

1.2.0

2 files

1.1.1

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page