Skip to main content

A high-fidelity blockchain discrete event simulator for research and education

Project description

BlockSimPy

PyPI version Python License

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

Architecture

Configuration guide

License

Apache License 2.0 - see LICENSE for details.

Project 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.3.1.tar.gz (42.6 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.3.1-py3-none-any.whl (44.3 kB view details)

Uploaded Python 3

File details

Details for the file blocksimpy-1.3.1.tar.gz.

File metadata

  • Download URL: blocksimpy-1.3.1.tar.gz
  • Upload date:
  • Size: 42.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for blocksimpy-1.3.1.tar.gz
Algorithm Hash digest
SHA256 d6aa64df41a97dc0a56311786f80ed58cf056f8a3940f50f00d6ca792f1c3849
MD5 29f223a36a4c5d3a06691debad2e058f
BLAKE2b-256 34b739548f104ed064f95bbbdf080de1f901c7196abf1ed3f7991107e283e622

See more details on using hashes here.

Provenance

The following attestation bundles were made for blocksimpy-1.3.1.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.3.1-py3-none-any.whl.

File metadata

  • Download URL: blocksimpy-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 44.3 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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ef86d7a6633102a2d1aee7246dfb89ae9f5c50292666ea9c6053d423d34c49e
MD5 dd726370dac35e56aca2c8e62231d066
BLAKE2b-256 4f11c92e7be34e29a66ca2bee0afecc86a32867460831e5eeedfd700cf79e89c

See more details on using hashes here.

Provenance

The following attestation bundles were made for blocksimpy-1.3.1-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.

Supported by

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