mirror of
https://github.com/luxfi/consensus.git
synced 2026-09-24 00:26:58 +00:00
- 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
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?
- License: BFT is MPL (different from consensus package license)
- Maintenance: BFT is actively maintained as separate project
- Size: BFT is a complete BFT implementation (~87KB epoch.go alone)
- Separation: Clean boundary between protocols
Integration
The wrapper provides:
Start/Stop()methods matching consensus engine interfaceHealthCheck()for monitoringGetSimplex()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 .