dineshpinto / gossip-protocol-rs

Simulating a gossip protocol with Byzantine nodes in Rust with PyO3 Python bindings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

test codecov

gossip-protocol-rs

A blazingly-fast implementation of a synchronous gossip protocol in Rust with PyO3 Python bindings.

Build Rust library

cargo build --release
cargo run --release

Build Python bindings (optional, for data analytics)

Add crate-type = ["cdylib"] under [lib] to Cargo.toml, then:

poetry install --no-root
poetry run maturin build --release
poetry add target/wheels/*.whl

Call the Rust functions from Python

>>> from gossip_protocol_rs import pyrun_gossip_protocol
>>> res = pyrun_gossip_protocol(num_honest_sample=3000, num_adversarial_sample=2000,
    num_non_sample=100000, num_peers=8, cycles=50)

Simulation

Results Results

See dineshpinto/synchronous-gossip-protocol for a pure Python implementation, along with additional theoretical details.

Benchmark

Uses criterion to benchmark the library.

cargo bench
Param Value
num_non_sample 1000
num_honest 6
num_adversarial 4
num_peers 6
cycles 200

create_nodes_pdf connect_nodes_to_random_peers_pdf evolve_state_pdf

About

Simulating a gossip protocol with Byzantine nodes in Rust with PyO3 Python bindings

License:MIT License


Languages

Language:Rust 96.4%Language:Python 3.6%