Files
consensus/engine/bft
zeekay 4aac78700d Refactor: remove dead code, add thread safety, improve test coverage
- Remove unused packages: engine/dag/{getter,bootstrap,vertex/vertexmock},
  engine/pq/{bootstrap,block}, core/{tracker,verify}
- Add sync.RWMutex to protocol/wave for thread-safe map access
- Increase engine/dag test coverage from 11.7% to 98.3%
- Add comprehensive tests for DAG consensus, vertex, and engine
- All 27 packages pass tests, 16 at 100% coverage
2025-12-13 07:42:01 +00:00
..
2025-12-12 17:00:55 -08:00

BFT Consensus Engine

Thin wrapper around github.com/luxfi/bft (Simplex BFT) for integration with Lux consensus.

About Simplex BFT

Simplex is a state-of-the-art Byzantine Fault Tolerant consensus protocol:

  • Peer-reviewed: Published in TCC 2023
  • Simple: No view change sub-protocol
  • Censorship-resistant: Leader rotation instead of timeouts
  • MPL Licensed: Maintained as external package

Paper: https://eprint.iacr.org/2023/463

Architecture

Lux Consensus Package
    └── engine/bft/ (this package)
         └── Thin wrapper glue code
              └── github.com/luxfi/bft
                   └── Full Simplex BFT implementation

Design: Keep BFT as external MPL dependency, minimal glue code here.

Usage

import (
    "github.com/luxfi/consensus/engine/bft"
    luxbft "github.com/luxfi/bft"
)

// Create BFT engine with Simplex configuration
cfg := bft.Config{
    NodeID:      "node-1",
    Validators:  []string{"node-1", "node-2", "node-3", "node-4"},
    EpochLength: 100,
    EpochConfig: luxbft.EpochConfig{
        // Full Simplex configuration
        MaxProposalWait: 5 * time.Second,
        // ... see github.com/luxfi/bft for all options
    },
}

engine, err := bft.New(cfg)
if err != nil {
    panic(err)
}

// Access underlying Simplex for advanced features
simplex := engine.GetSimplex()
simplex.ProposeBlock(block)

Direct Simplex Usage

For full control, use Simplex directly:

import luxbft "github.com/luxfi/bft"

cfg := luxbft.EpochConfig{
    // Full Simplex configuration
}

epoch, err := luxbft.NewEpoch(cfg)

Why Keep BFT External?

  1. License: BFT is MPL (different from consensus package license)
  2. Maintenance: BFT is actively maintained as separate project
  3. Size: BFT is a complete BFT implementation (~87KB epoch.go alone)
  4. Separation: Clean boundary between protocols

Integration

The wrapper provides:

  • Start/Stop() methods matching consensus engine interface
  • HealthCheck() for monitoring
  • GetSimplex() for direct access to full Simplex features

See wrapper.go for implementation (minimal glue code).

Testing

# Test wrapper
go test ./engine/bft

# Test full Simplex
cd ~/work/lux/bft
go test .

Learn More