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 ¶
- func DefaultProfileForNetwork(networkName string) string
- func GetProfileMap(name string) (map[string]interface{}, error)
- func IsByzantineSafe(sampleSize, quorumSize int) bool
- func ListProfiles() []string
- func ValidateProfile(data map[string]interface{}) error
- type ConsensusConfig
- type HealthConfig
- type NetworkConfig
- type Profile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultProfileForNetwork ¶
DefaultProfileForNetwork returns the default profile name for a network type. For local development, all networks use turbo for ultra-fast consensus.
func GetProfileMap ¶
GetProfileMap loads a profile and returns it as map[string]interface{}. Useful for direct JSON manipulation.
func IsByzantineSafe ¶ added in v1.18.0
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 ¶
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 ¶
GetProfile loads a profile by name. Returns error if profile not found or invalid.
func MustGetProfile ¶
MustGetProfile loads a profile by name or panics on error.
func (*Profile) ToNodeConfig ¶
ToNodeConfig converts a profile to luxd node configuration flags. Returns a map of flag keys to values suitable for JSON config.