profiles

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: BSD-3-Clause Imports: 5 Imported by: 1

Documentation

Overview

Package profiles provides embedded network tuning profiles for the Lux SDK. These profiles configure consensus, health, and network parameters for different deployment scenarios (mainnet, testnet, devnet, dev mode).

Available profiles:

  • standard: Conservative mainnet settings for production-safe operation
  • fast: Balanced testnet settings for development
  • turbo: Aggressive 3-node local network with 2/3 quorum
  • ultra: Maximum aggression for single-node dev mode with K=1 consensus

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultProfileForNetwork

func DefaultProfileForNetwork(networkName string) string

DefaultProfileForNetwork returns the default profile name for a network type. For local development, all networks use turbo for ultra-fast consensus.

func GetProfileMap

func GetProfileMap(name string) (map[string]interface{}, error)

GetProfileMap loads a profile and returns it as map[string]interface{}. Useful for direct JSON manipulation.

func IsByzantineSafe added in v1.18.0

func IsByzantineSafe(sampleSize, quorumSize int) bool

IsByzantineSafe reports whether a sample/quorum pair satisfies the consensus engine's Byzantine-safety invariant. Use it to validate any consensus config.

func ListProfiles

func ListProfiles() []string

ListProfiles returns names of all available profiles, sorted alphabetically.

func ValidateProfile

func ValidateProfile(data map[string]interface{}) error

ValidateProfile checks that a profile has required fields.

Types

type ConsensusConfig

type ConsensusConfig struct {
	SampleSize            int    `json:"sample-size"`
	PreferenceQuorumSize  int    `json:"preference-quorum-size"`
	ConfidenceQuorumSize  int    `json:"confidence-quorum-size"`
	CommitThreshold       int    `json:"commit-threshold"`
	ConcurrentRepolls     int    `json:"concurrent-repolls"`
	OptimalProcessing     int    `json:"optimal-processing"`
	MaxProcessing         int    `json:"max-processing"`
	FrontierPollFreq      string `json:"frontier-poll-frequency"`
	ProposerMinBlockDelay string `json:"proposer-min-block-delay,omitempty"`
}

ConsensusConfig holds consensus tuning parameters.

func Consensus added in v1.18.0

func Consensus(n int) ConsensusConfig

Consensus derives the sampling-consensus parameters (the lux/consensus engine's alpha-of-K snowball/snowman knobs: K=sample, alpha=quorum, beta=commit) for a validator set of size n. Consensus is Byzantine-fault-tolerant by construction — there is no non-BFT variant — so the result always satisfies the engine invariant 2*alpha - K >= floor((K-1)/3)+1; "BFT" is implied, not a flavor.

This is the ENGINE/agreement layer, NOT post-quantum finality. Quasar (lux/quasar, the per-round QuasarCert + pqLayers in the CR's spec.consensus) seals each agreed event in a PQ weighted certificate ON TOP of this — a separate concern; this struct carries no PQ config.

It is the single source of truth for sampling safety: a deploy derives K/alpha from the LIVE validator count, never hardcodes them (the live K=5/alpha=3 drift was sub-BFT — 2*3-5 = 1 < floor((5-1)/3)+1 = 2 — which the engine correctly refuses).

  • K (sample size) = min(n, 20) — Avalanche caps the poll sample at 20.
  • alpha (quorum) = ceil(0.75*K) — Avalanche's 15/20 = 75% ratio (K>=4). For K<=3, 75% would force unanimity, so the Byzantine floor is used to preserve liveness (one tolerable fault).

Examples: n=5 -> K=5,alpha=4 (80%); n=20+ -> K=20,alpha=15 (exactly Avalanche); n=3 -> K=3,alpha=2 (67%, BFT-minimal).

type HealthConfig

type HealthConfig struct {
	CheckFrequency   string `json:"check-frequency"`
	AveragerHalflife string `json:"averager-halflife"`
}

HealthConfig holds health check tuning parameters.

type NetworkConfig

type NetworkConfig struct {
	MaxReconnectDelay     string `json:"max-reconnect-delay"`
	InitialReconnectDelay string `json:"initial-reconnect-delay"`
	InitialTimeout        string `json:"initial-timeout"`
	MinimumTimeout        string `json:"minimum-timeout"`
	MaximumTimeout        string `json:"maximum-timeout"`
	TimeoutHalflife       string `json:"timeout-halflife"`
	ReadHandshakeTimeout  string `json:"read-handshake-timeout"`
	PingTimeout           string `json:"ping-timeout"`
	PingFrequency         string `json:"ping-frequency"`
}

NetworkConfig holds network tuning parameters.

type Profile

type Profile struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Consensus   ConsensusConfig `json:"consensus"`
	Health      HealthConfig    `json:"health"`
	Network     NetworkConfig   `json:"network"`
}

Profile represents a network tuning profile.

func GetProfile

func GetProfile(name string) (*Profile, error)

GetProfile loads a profile by name. Returns error if profile not found or invalid.

func MustGetProfile

func MustGetProfile(name string) *Profile

MustGetProfile loads a profile by name or panics on error.

func (*Profile) ToNodeConfig

func (p *Profile) ToNodeConfig() map[string]interface{}

ToNodeConfig converts a profile to luxd node configuration flags. Returns a map of flag keys to values suitable for JSON config.

Jump to

Keyboard shortcuts

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