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.0.tar.gz (42.4 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.0-py3-none-any.whl (44.2 kB view details)

Uploaded Python 3

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

Hashes for blocksimpy-1.3.0.tar.gz
Algorithm Hash digest
SHA256 bfe54fe7f2c7d3bacd0e81745137b1b9a3e813f2ef80fe4058bc2bc97783a2ad
MD5 8352c5b39f1a78f3023c0cfcac314c7b
BLAKE2b-256 b75497983791cd931133ca4d403a4d6791b1d1ff4ca86cd2080193f9762e59ec

See more details on using hashes here.

Provenance

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

Hashes for blocksimpy-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af1f52581c13c04f56a0f07ab46640444914faf3d1b8f454a115912fe7609184
MD5 75e587181a98a0dca790c59333018594
BLAKE2b-256 faf03c6113d1a50ba38fa121d416810aa65a994b8df0fc31851f683b16a6dae5

See more details on using hashes here.

Provenance

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

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