Skip to content

fschutt/pbft-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

pbft-rs

Practical Byzantine Fault Tolerance in Rust

Algorithm Overview

Castro and Liskov's pBFT provides Byzantine fault tolerance for state machine replication, tolerating up to f < n/3 faulty nodes through a three-phase protocol.

Key Implementation Components

Three-Phase Consensus Protocol:

pub enum PbftMessage {
    PrePrepare(PrePrepareMessage),
    Prepare(PrepareMessage), 
    Commit(CommitMessage),
    ViewChange(ViewChangeMessage),
    NewView(NewViewMessage),
}

Pre-prepare Phase: Primary orders requests and broadcasts pre-prepare messages Prepare Phase: Replicas validate and broadcast prepare messages
Commit Phase: After 2f+1 matching prepares, replicas broadcast commits

View Change Protocol:

  • Timeout-based primary failure detection
  • View change messages with prepared request proofs
  • New primary computes new view message with complete pre-prepare set

Async/Concurrent Architecture:

struct PbftConsensus {
    state: Arc<RwLock<PbftNode>>,
    network: NetworkManager,
    service: Box<dyn Service>,
}

Production Features:

  • Tokio-based async networking
  • Message authentication with HMAC-SHA256
  • Efficient batching and pipelining
  • Read-only request optimization
  • Checkpoint and garbage collection
  • Persistent state management

Performance Optimizations:

  • Request batching reduces consensus overhead
  • Parallel signature verification
  • Memory pool management for frequent allocations
  • Zero-copy message processing where possible

About

Practical Byzantine Fault Tolerance in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published