BFT Consensus Implementation Deep Dive

⏱️ Duration: 1.5–2 hours 📊 Difficulty: Intermediate 🎯 Hyperscale-rs Specific

Learning Objectives

Where BFT Lives in the Flow

In the Transaction Flow, BFT consensus corresponds to the steps where the node proposes blocks, collects votes, and forms quorum certificates (QCs). The main implementation is in the BFT crate and related types in crates/types.

Block Proposal Flow

The proposer (leader for the current round) builds a block containing transactions from the mempool, then broadcasts it. In hyperscale-rs:

Key files to open: look for Proposal, Propose, or similar event types and their handlers in the BFT/consensus crate.

Vote Collection and QC Formation

Validators send votes on the proposed block. When a node has collected a quorum of votes (e.g. 2f+1 of 3f+1), it can form a Quorum Certificate (QC) and use it to justify a commit or to advance the round.

Cryptography: votes are usually signed (e.g. BLS); the crate may use an aggregation step to produce a single QC signature. See crates/types for Vote, QuorumCertificate, and the crypto crate for aggregation.

Commit Rules

Commit rules define when a block is considered committed (safe to execute and to build on). In HotStuff-style protocols:

Trace the code path from “QC formed” to “block committed” and “execution triggered” to see how hyperscale-rs ties consensus to execution.

Practical Trace

To trace through the code:

  1. Start from crates/node or the top-level state machine that composes BFT.
  2. Find where BFT Events are fed (e.g. Proposal, Vote, ProposalTimer).
  3. Follow the handler for one round: proposal → votes → QC → commit (or timeout → next round).
  4. Check crates/types for block, vote, and QC types so you can read the structures used in the flow.