Rust Market Ledger

Consensus algorithm comparison with simulated market data.

Goal

Compare consensus algorithms using the same test blocks to understand performance trade-offs and trilemma characteristics.

Experimental Context: This is a conceptual demonstration using simulated data and simplified consensus implementations. Metric values are illustrative and reflect simulator characteristics rather than production system performance. The trilemma metrics follow the taxonomy from Aliyu, Kannengießer & Sunyaev (2025). See "Data & Environment Setup" tab for simulation details.

Metric Definitions

  • Latency (ms): Time from block proposal to consensus result (average across all blocks)
  • Throughput (blocks/sec): Total blocks processed / total execution time
  • Commit Rate (%): (Committed blocks / Total blocks) × 100
  • Error Rate (%): (Blocks with errors / Total blocks) × 100
  • Trilemma Scores: Qualitative assessment (1-5 scale) based on algorithm characteristics
  • Trilemma Metrics (arXiv:2505.03768): Degree of decentralization (block proposal randomness, geographic diversity, hash power distribution, token concentration, wealth distribution), scalability (availability, confirmation latency, max throughput), and security (cost of attack, fault tolerance, reliability, stale block rate).

Consensus Algorithms

  • PBFT - Practical Byzantine Fault Tolerance (BFT, requires majority voting: 2f+1 out of 3f+1)
  • Gossip - Epidemic/gossip protocol (no majority voting, uses fanout propagation)
  • Eventual - Time-based commitment (eventual consistency, fixed delay)
  • Quorum-less - Weighted voting based on reputation (threshold-based, no fixed quorum)
  • Flexible Paxos - Flexible quorum Paxos (Q1 for phase-1, Q2 for phase-2, Q1 + Q2 > N ensures intersection where N is total nodes)

Data Simulation Process

  1. Generate 100 test blocks with mock market data (BTC price variations)
  2. Each strategy runs on the same 100 blocks for fair comparison
  3. Repeat 5 rounds per strategy to calculate mean ± std dev
  4. For each block: measure execution time from strategy.execute(block) start to end
  5. Collect metrics: latency, throughput, commit/error rates

Sample Market Data

Note: The table and chart below show a sample of 10 blocks for illustration. The actual experiment uses 100 blocks per round for statistical significance.

Each block contains simulated BTC price data. Example block structure (10-block sample):

Block Hash BTC Price (USD) Source Timestamp
a3f8c2d1e9b4... 50,240 CoinGecko 2025-01-17 08:00:00
7b2e9f4a1c6d... 49,890 CoinGecko 2025-01-17 08:10:00
5d1a8c9e3b7f... 50,560 CoinGecko 2025-01-17 08:20:00
2e4b9f7a8d3c... 51,120 CoinGecko 2025-01-17 08:30:00
9a3d7e2f6b8c... 50,680 CoinGecko 2025-01-17 08:40:00
4c1f9e8b7a2d... 49,950 CoinGecko 2025-01-17 08:50:00
8e5b3a9d2f7c... 50,430 CoinGecko 2025-01-17 09:00:00
3f7a2e9c6b4d... 51,290 CoinGecko 2025-01-17 09:10:00
6b8d4f2a9e7c... 50,710 CoinGecko 2025-01-17 09:20:00
1d5a8f3e9b7c... 50,180 CoinGecko 2025-01-17 09:30:00

Note: Price pattern: simulated fluctuations around 50,000 USD (sample of 10 blocks shown, simulated for demonstration).

BTC Price Time Series

Scenario Parameters

Blocks per round 100
Rounds per strategy 5
Total nodes 4
PBFT Quorum 3 (2f+1)
Gossip Fanout 2
Eventual Delay 500ms
Quorum-less Threshold 5.0
Flexible Paxos Q1/Q2 2/3

Environment Setup

Simulation Environment:
  • Single machine execution (no actual network)
  • Mock market data (not real feeds)
  • Simplified consensus implementations for demonstration
  • No Byzantine faults or adversarial load tested
Note: Values shown are illustrative and based on simulator characteristics. For detailed analysis, see experimental design documentation. These metrics demonstrate relative trade-offs between algorithms rather than production benchmarks.

Performance Metrics (Basic)

Strategy Latency (ms) Throughput (blocks/sec) Commit Rate (%) Error Rate (%)
PBFT 1500.0 ± 50.0 66.67 100.0 0.0
Gossip 300.0 ± 10.0 333.33 100.0 0.0
Eventual 500.0 ± 5.0 200.0 100.0 0.0
Quorum-less 0.5 ± 0.1 2000.0 100.0 0.0
Flexible Paxos 800.0 ± 30.0 125.0 100.0 0.0

Extended Trilemma Metrics (arXiv:2505.03768)

15 metrics across three dimensions: Decentralization (5), Scalability (3), Security (4). Metric taxonomy based on Aliyu, Kannengießer & Sunyaev (2025).

Note on DoD Metrics: Some metrics (Geographic Diversity, Hash Power Distribution, Token Concentration, Wealth Distribution) are marked as N/A because they cannot be accurately measured in a single-machine simulation environment. These metrics would require actual geographic node distribution, proof-of-work hashing power data, or token economics data which are not available in this simulator.

Degree of Decentralization (DoD) - 5 Metrics

Strategy Block Proposal Randomness Geographic Diversity Hash Power Distribution Token Concentration Wealth Distribution
PBFT 0.80 N/A N/A N/A N/A
Gossip 0.80 N/A N/A N/A N/A
Eventual 0.80 N/A N/A N/A N/A
Quorum-less 0.80 N/A N/A N/A N/A
Flexible Paxos 0.80 N/A N/A N/A N/A

Scalability - 3 Metrics

Strategy Availability (%) Confirmation Latency (ms) Max Throughput (TPS)
PBFT 100.0 1500.0 66.67
Gossip 100.0 300.0 333.33
Eventual 100.0 500.0 200.0
Quorum-less 100.0 0.5 2000.0
Flexible Paxos 100.0 800.0 125.0

Security - 4 Metrics

Strategy Cost of Attack Fault Tolerance Reliability (%) Stale Block Rate (%)
PBFT 0.75 0.25 100.0 0.0
Gossip 0.30 0.10 100.0 0.0
Eventual 0.30 0.10 100.0 0.0
Quorum-less 0.30 0.10 100.0 0.0
Flexible Paxos 0.75 0.25 100.0 0.0

Trilemma Scores (Qualitative)

Scored from 1 (low) to 5 (high) based on algorithm characteristics.

PBFT

Decentralization: 4.0/5.0

Security: 5.0/5.0

Scalability: 2.0/5.0

Gossip

Decentralization: 5.0/5.0

Security: 3.0/5.0

Scalability: 5.0/5.0

Eventual

Decentralization: 4.0/5.0

Security: 2.0/5.0

Scalability: 4.0/5.0

Quorum-less

Decentralization: 4.0/5.0

Security: 3.5/5.0

Scalability: 4.5/5.0

Flexible Paxos

Decentralization: 4.0/5.0

Security: 4.5/5.0

Scalability: 3.0/5.0

Codebase & Repository

GitHub Repository:
https://github.com/egpivo/rust-market-ledger

Project Structure:

  • src/etl/ - ETL pipeline (extract, transform, load)
  • src/consensus/ - Consensus algorithms and comparison framework
  • src/consensus/algorithms/ - Individual consensus implementations (PBFT, Gossip, Eventual, Quorum-less, Flexible Paxos)
  • examples/ - Example code and experiments
  • examples/shared/ - Shared utilities for metrics calculation

Example Code & Commands

Trilemma Comparison Experiment

Compare all consensus algorithms with performance metrics and trilemma scores:

cargo run --example trilemma_comparison

This runs the full comparison experiment shown in the Results tab.

Experiments

Individual consensus algorithm experiments:

  • No-Consensus: cargo run --example no_consensus_example
  • Simple Majority: cargo run --example simple_majority_example
  • PBFT Baseline: cargo run --example pbft_baseline_example
  • Run All: cargo run --example run_all_comparisons

Documentation

Prerequisites

  • Rust: 1.70+ (rustup.rs)
  • Clone: git clone https://github.com/egpivo/rust-market-ledger.git
  • Build: cargo build