Documentation
¶
Index ¶
- Constants
- Variables
- func AlphaForK(k int) int
- func CalculateQuorum(totalWeight uint64) uint64
- func CanTolerateFailure(byzantineWeight, totalWeight uint64) bool
- func HasSimpleMajority(weight, totalWeight uint64) bool
- func HasSuperMajority(weight, totalWeight uint64) bool
- type FPCConfig
- type Parameters
- type WaveConfig
Constants ¶
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 ¶
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 ¶
AlphaForK calculates the appropriate Alpha value for a given K to achieve 69% consensus threshold
func CalculateQuorum ¶
CalculateQuorum calculates the minimum weight needed for 69% consensus
func CanTolerateFailure ¶
CanTolerateFailure checks if the Byzantine weight is within tolerance
func HasSimpleMajority ¶
HasSimpleMajority checks if the given weight meets simple majority
func HasSuperMajority ¶
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
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