Expand description
Guts Consensus Engine
This crate provides the BFT consensus layer for Guts, transforming it from a replicated multi-node system into a truly decentralized network.
§Architecture
The consensus engine is built on top of commonware primitives and provides:
- Simplex BFT Consensus: 2 network hops for proposals, 3 for finalization
- Transaction Ordering: Total ordering of all state-changing operations
- Byzantine Fault Tolerance: Tolerates f < n/3 Byzantine nodes
- Validator Management: Dynamic validator sets with epoch transitions
§Components
Transaction: All state-changing operations (git push, PRs, issues, etc.)Block: Ordered container of transactionsMempool: Pending transaction poolValidatorSet: Set of validators participating in consensusGenesis: Initial network configurationsimplex: Real Simplex BFT consensus engine (production)
§Real Simplex BFT Consensus
The simplex module provides a production-ready BFT consensus implementation
using the commonware-consensus library. This is the recommended way to run
Guts in a multi-validator network.
ⓘ
use guts_consensus::simplex::{Engine, Config};
use commonware_p2p::authenticated::discovery;
// Create configuration
let config = Config::new(
blocker,
my_public_key,
my_private_key,
validator_public_keys,
);
// Create and start engine with P2P channels
let engine = Engine::new(context, config).await;
engine.start(pending, recovered, resolver, broadcast, marshal);§Transaction Flow
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Client │────▶│ API Layer │────▶│ Mempool │
│ (git push) │ │ (validate) │ │ (pending) │
└──────────────┘ └──────────────┘ └──────┬───────┘
│
┌────────────────────────────┘
▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Broadcast │◀────│ Leader │◀────│ Consensus │
│ to Peers │ │ Proposes │ │ Selects │
└──────────────┘ │ Block │ │ Leader │
└──────┬───────┘ └──────────────┘
│
▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Validators │────▶│ Notarize │────▶│ Finalize │
│ Vote │ │ (2f+1) │ │ (2f+1) │
└──────────────┘ └──────────────┘ └──────┬───────┘
│
▼
┌──────────────────────────────────┐
│ Apply to State │
│ (git refs, PRs, issues, etc.) │
└──────────────────────────────────┘Modules§
- simplex
- Simplex BFT consensus implementation for Guts.
Structs§
- Block
- A full block containing header and transactions.
- Block
Header - A block header containing metadata.
- BlockId
- A unique block identifier (SHA-256 hash of the block header).
- Branch
Protection Spec - Serializable branch protection rules for consensus.
- Consensus
Engine - The consensus engine.
- Consensus
Params - Consensus parameters from genesis.
- Engine
Config - Configuration for the consensus engine.
- Finalize
Message - Vote to finalize a block.
- Finalized
Block - Block with consensus metadata (votes, signatures).
- Genesis
- Complete genesis configuration.
- Genesis
Repository - Genesis repository (for testnet seeding).
- Genesis
Validator - Genesis configuration for a validator.
- Issue
Update - Update to an issue.
- Mempool
- The transaction mempool.
- Mempool
Config - Configuration for the mempool.
- Mempool
Stats - Statistics about the mempool.
- NoOp
Application - A no-op application for testing.
- Notarize
Message - Vote to notarize a block.
- Nullify
Message - Nullify vote when leader is unresponsive.
- OrgUpdate
- Update to an organization.
- Propose
Message - Block proposal message from the leader.
- Pull
Request Update - Update to a pull request.
- Serializable
Public Key - Serializable public key (hex-encoded Ed25519 public key).
- Serializable
Signature - Serializable signature (hex-encoded Ed25519 signature).
- Sync
Request Message - Request missing blocks from a peer.
- Sync
Response Message - Response with requested blocks.
- Team
Spec - Serializable team specification for consensus.
- Transaction
Id - A unique transaction identifier (SHA-256 hash of the transaction).
- Transaction
Message - Broadcast a new transaction to the network.
- Validator
- A validator in the consensus network.
- Validator
Config - Configuration for validator set behavior.
- Validator
Set - The validator set for a given epoch.
- Vote
Collector - Vote collection for tracking quorum.
Enums§
- Comment
Target Spec - Comment target specification.
- Consensus
Error - Errors that can occur during consensus operations.
- Consensus
Event - Events emitted by the consensus engine.
- Consensus
Message - Consensus message types exchanged between validators.
- Engine
State - State of the consensus engine.
- Transaction
- Transactions that require consensus ordering.
Constants§
- CONSENSUS_
CHANNEL - Channel ID for consensus messages (high priority).
- SYNC_
CHANNEL - Channel ID for block sync requests.
- TRANSACTION_
CHANNEL - Channel ID for transaction broadcast.
Traits§
- Consensus
Application - Application interface for the consensus engine.
Functions§
- generate_
devnet_ genesis - Helper to generate a devnet genesis with test validators.
Type Aliases§
- Result
- Result type for consensus operations.