config

package
v1.22.45 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ConsensusSuperMajority is the 69% threshold for Byzantine fault tolerance
	// This provides an additional 2% safety margin above traditional 67% BFT
	ConsensusSuperMajority = 0.69

	// ConsensusSimpleMajority is the simple majority threshold
	ConsensusSimpleMajority = 0.51

	// MaxByzantineWeight is the maximum tolerable Byzantine weight (31%)
	MaxByzantineWeight = 0.31
)

Consensus threshold constants (LP-CONSENSUS-69)

Variables

View Source
var (
	ErrParametersInvalid  = errors.New("invalid consensus parameters")
	ErrInvalidK           = errors.New("k must be >= 1")
	ErrInvalidAlpha       = errors.New("alpha must be between 0.5 and 1.0")
	ErrInvalidBeta        = errors.New("beta must be >= 1")
	ErrBlockTimeTooLow    = errors.New("block time must be >= 1ms")
	ErrRoundTimeoutTooLow = errors.New("round timeout must be >= block time")
)

Error variables for parameter validation

Functions

func AlphaForK

func AlphaForK(k int) int

AlphaForK calculates the appropriate Alpha value for a given K to achieve 69% consensus threshold

func CalculateQuorum

func CalculateQuorum(totalWeight uint64) uint64

CalculateQuorum calculates the minimum weight needed for 69% consensus

func CanTolerateFailure

func CanTolerateFailure(byzantineWeight, totalWeight uint64) bool

CanTolerateFailure checks if the Byzantine weight is within tolerance

func HasSimpleMajority

func HasSimpleMajority(weight, totalWeight uint64) bool

HasSimpleMajority checks if the given weight meets simple majority

func HasSuperMajority

func HasSuperMajority(weight, totalWeight uint64) bool

HasSuperMajority checks if the given weight meets the 69% threshold

Types

type FPCConfig

type FPCConfig struct {
	// Enable indicates whether FPC is enabled (default: true)
	Enable bool

	// Rounds is the number of FPC rounds to run
	Rounds int

	// Threshold is the confidence threshold for FPC
	Threshold float64

	// SampleSize is the number of nodes to sample per round
	SampleSize int
}

FPCConfig represents Firing Photon Cannon configuration

func DefaultFPC

func DefaultFPC() FPCConfig

DefaultFPC returns the default FPC configuration

type Parameters

type Parameters struct {
	K                     int
	Alpha                 float64 // For compatibility with Quasar
	Beta                  uint32  // For compatibility with Quasar
	AlphaPreference       int
	AlphaConfidence       int
	BetaVirtuous          int
	BetaRogue             int
	ConcurrentPolls       int
	ConcurrentRepolls     int
	OptimalProcessing     int
	MaxOutstandingItems   int
	MaxItemProcessingTime time.Duration
	Parents               int
	BatchSize             int
	BlockTime             time.Duration // For compatibility
	RoundTO               time.Duration // For compatibility
}

Parameters defines consensus parameters

func DefaultParams

func DefaultParams() Parameters

DefaultParams returns default parameters with 69% threshold

func LocalParams

func LocalParams() Parameters

LocalParams returns local parameters with 69% threshold

func MainnetParams

func MainnetParams() Parameters

MainnetParams returns mainnet parameters with 69% threshold

func SingleValidatorParams added in v1.19.10

func SingleValidatorParams() Parameters

SingleValidatorParams returns parameters for single validator mainnet (K=1) This configuration is used for POA mode with a single staking validator

func TestnetParams

func TestnetParams() Parameters

TestnetParams returns testnet parameters with 69% threshold

func XChainParams

func XChainParams() Parameters

XChainParams returns X-Chain parameters with 69% threshold

func (Parameters) Valid

func (p Parameters) Valid() error

Valid validates parameters with 69% threshold enforcement

func (Parameters) Validate

func (p Parameters) Validate() error

Validate validates parameters (compatibility method)

func (Parameters) WithBlockTime

func (p Parameters) WithBlockTime(blockTime time.Duration) Parameters

WithBlockTime returns a copy of Parameters with updated block time

func (Parameters) WithFPC

func (p Parameters) WithFPC(fpc FPCConfig) Parameters

WithFPC adds FPC configuration to Parameters

type WaveConfig

type WaveConfig struct {
	Enable              bool
	VoteLimitPerBlock   int
	ExecuteOwned        bool
	ExecuteMixedOnFinal bool
	EpochFence          bool
	VotePrefix          []byte
}

func DefaultWave

func DefaultWave() WaveConfig

Jump to

Keyboard shortcuts

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