bft

package
v1.22.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

README

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

Documentation

Overview

Package bft provides a thin wrapper around github.com/luxfi/bft (Simplex BFT) for integration with the Lux consensus engine interface.

Simplex BFT is maintained as an external MPL-licensed package. This wrapper provides glue code to integrate it with the consensus engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	NodeID      string
	Validators  []string
	EpochLength uint64
	EpochConfig luxbft.EpochConfig // Pass-through to Simplex
}

Config for BFT engine wrapper

type Engine added in v1.22.1

type Engine struct {
	// contains filtered or unexported fields
}

Engine wraps the Simplex BFT consensus engine

func New added in v1.22.1

func New(cfg Config) (*Engine, error)

New creates a new BFT consensus engine using Simplex For full Simplex configuration, use Config.EpochConfig

func (*Engine) GetSimplex added in v1.22.1

func (e *Engine) GetSimplex() *luxbft.Epoch

GetSimplex returns the underlying Simplex BFT engine Use this for direct access to Simplex features like: - ProposeBlock() - AddNode() - OnQC()

func (*Engine) HealthCheck added in v1.22.1

func (e *Engine) HealthCheck(ctx context.Context) (interface{}, error)

HealthCheck returns the health status

func (*Engine) IsBootstrapped added in v1.22.1

func (e *Engine) IsBootstrapped() bool

IsBootstrapped returns whether the engine has finished bootstrapping

func (*Engine) Start added in v1.22.1

func (e *Engine) Start(ctx context.Context, startReqID uint32) error

Start starts the BFT engine

func (*Engine) Stop added in v1.22.1

func (e *Engine) Stop(ctx context.Context) error

Stop stops the BFT engine

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL