Skip to main content

Crate lux_consensus

Crate lux_consensus 

Source
Expand description

§Lux Consensus Rust SDK

Complete Quasar consensus implementation with Wave, FPC, Photon, Focus protocols. Full post-quantum support via Pulsar (Module-LWE threshold) hybrid signatures.

§Features

  • Wave: Threshold voting with FPC-based adaptive thresholds
  • FPC: Fast Probabilistic Consensus via PRF-derived thresholds
  • Photon: Light-based validator sampling with luminance tracking
  • Focus: Confidence accumulation through β consecutive rounds
  • Quasar: Post-quantum finality with hybrid BLS + Pulsar signatures
  • Vote: A signed vote on the wire, and the tally that turns arriving votes into a certificate the whole cert predicate has already passed
  • Zap: The transport frame those votes travel under — the same wire Go and C++ speak

§Example

use lux_consensus::*;

fn main() {
    // Create Quasar consensus engine (full protocol stack)
    let config = QuasarConfig::mainnet();
    let mut engine = QuasarEngine::new(config);
    engine.start().unwrap();

    // The committee. Only its members' ballots are counted.
    for i in 0..20 {
        engine.add_validator(NodeID::from([i; 20]), 1).unwrap();
    }

    // Add a block
    let block = Block::new(
        ID::from([1u8; 32]),
        ID::from([0u8; 32]),
        1,
        b"Hello, Lux!".to_vec(),
    );
    engine.add(block.clone()).unwrap();

    // Record votes (20 for mainnet quorum)
    for i in 0..20 {
        let vote = Vote::new(
            block.id.clone(),
            VoteType::Preference,
            NodeID::from([i; 20]),
        );
        engine.record_vote(vote).unwrap();
    }

    assert!(engine.is_accepted(&block.id));
    engine.stop().unwrap();
}

Re-exports§

pub use crate::finality::canonical_vote_message;
pub use crate::finality::crash_tolerance;
pub use crate::finality::half_stake_floor;
pub use crate::finality::nova_beta;
pub use crate::finality::nova_quorum;
pub use crate::finality::nova_signer_floor;
pub use crate::finality::two_thirds_count;
pub use crate::finality::two_thirds_stake_floor;
pub use crate::finality::weighted_quasar;
pub use crate::finality::Finality;
pub use crate::finality::Position;
pub use crate::finality::QC_FINALITY;
pub use crate::finality::QUORUM_CERT_VERSION;
pub use crate::finality::VOTE_MESSAGE_LEN;
pub use crate::finality::VOTE_TAG;
pub use crate::vote::SignedVote;
pub use crate::vote::Slot;
pub use crate::vote::Tally;
pub use crate::vote::VoteTransport;
pub use crate::vote::VOTE;
pub use crate::types::*;
pub use crate::errors::*;
pub use crate::fpc::*;
pub use crate::photon::*;
pub use crate::focus::*;
pub use crate::wave::*;
pub use crate::quasar::*;
pub use crate::engine::*;

Modules§

cert
The quorum certificate — the predicate that decides.
engine
errors
finality
The finality standard, in Rust.
focus
fpc
photon
pop
Node-bound proof of possession — the Rust side of the standard the Go oracle froze in luxfi/conformance/vectors/pop.json.
quasar
types
vote
A vote on the wire, and the rule that turns votes into a certificate.
wave
zap
The ZAP transport frame, in Rust.

Functions§

generate_block_id
Generate a random block ID
new_block
Create a new block helper
new_vote
Create a new vote helper
quick_start
Quick start a consensus engine
sha256
SHA-256. The crate’s one hash, from the BLS library already linked here.
version
Get SDK version