Documentation
¶
Index ¶
- Constants
- Variables
- func Aliases(genesisBytes []byte) (map[string][]string, map[ids.ID][]string, error)
- func FromConfig(config *Config) ([]byte, ids.ID, error)
- func FromFile(networkID uint32, filepath string, stakingCfg *StakingConfig) ([]byte, ids.ID, error)
- func FromFlag(networkID uint32, genesisContent string, stakingCfg *StakingConfig) ([]byte, ids.ID, error)
- func GetCheckpoints(networkID uint32, chainID ids.ID) set.Set[ids.ID]
- func GetConsensusParameters(networkID uint32) sampling.Parameters
- func GetValidators(networkID uint32) set.Set[ids.NodeID]
- func LUXAssetID(xvmGenesisBytes []byte) (ids.ID, error)
- func VMGenesis(genesisBytes []byte, vmID ids.ID) (*pchaintxs.Tx, error)
- type Allocation
- type Bootstrapper
- type BootstrapperRaw
- type ChainConfig
- type ChainGrouping
- type Config
- type ConsensusParams
- type EightChainsConfig
- type LockedAmount
- type Params
- type Staker
- type StakingConfig
- type TxFeeConfig
- type UnparsedAllocation
- type UnparsedConfig
- type UnparsedStaker
- type WorkloadDistribution
Constants ¶
const ( VMRQKeyStr = "vmRQiZeXEXYMyJhEiqdC2z5JhuDbxL8ix9UVvjgMu2Er1NepE" VMRQKeyFormattedStr = secp256k1.PrivateKeyPrefix + VMRQKeyStr EWOQKeyStr = "ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN" EWOQKeyFormattedStr = secp256k1.PrivateKeyPrefix + EWOQKeyStr )
Variables ¶
var ( QChainAliases = []string{"Q", "quantum"} // Q-Chain aliases PChainAliases = []string{"Q", "quantum", "P", "platform"} // Deprecated: Use QChainAliases. Includes legacy P aliases for compatibility XChainAliases = []string{"X", "xvm"} CChainAliases = []string{"C", "evm"} VMAliases = map[ids.ID][]string{ constants.QuantumVMID: {"quantum", "platform"}, constants.XVMID: {"xvm"}, constants.EVMID: {"evm"}, secp256k1fx.ID: {"secp256k1fx"}, nftfx.ID: {"nftfx"}, propertyfx.ID: {"propertyfx"}, } )
var ( VMRQKey *secp256k1.PrivateKey EWOQKey *secp256k1.PrivateKey // LocalConsensusParameters are the consensus parameters for local networks (5 nodes) // Optimized for 10Gbps local network with maximum pipelining LocalConsensusParameters = sampling.Parameters{ K: 5, AlphaPreference: 4, AlphaConfidence: 4, Beta: 4, ConcurrentRepolls: 4, } // LocalParams are the params used for local networks LocalParams = Params{ ConsensusParameters: LocalConsensusParameters, TxFeeConfig: TxFeeConfig{ CreateAssetTxFee: units.MilliLux, TxFee: units.MilliLux, DynamicFeeConfig: gas.Config{ Weights: gas.Dimensions{ gas.Bandwidth: 1, gas.DBRead: 1_000, gas.DBWrite: 1_000, gas.Compute: 4, }, MaxCapacity: 1_000_000, MaxPerSecond: 100_000, TargetPerSecond: 50_000, MinPrice: 1, ExcessConversionConstant: 2_164_043, }, ValidatorFeeConfig: fee.Config{ Capacity: 20_000, Target: 10_000, MinPrice: gas.Price(1 * units.NanoLux), ExcessConversionConstant: 865_617, }, }, StakingConfig: StakingConfig{ UptimeRequirement: .8, MinValidatorStake: 2 * units.KiloLux, MaxValidatorStake: 3 * units.MegaLux, MinDelegatorStake: 25 * units.Lux, MinDelegationFee: 20000, MinStakeDuration: 24 * time.Hour, MaxStakeDuration: 365 * 24 * time.Hour, RewardConfig: reward.Config{ MaxConsumptionRate: .12 * reward.PercentDenominator, MinConsumptionRate: .10 * reward.PercentDenominator, MintingPeriod: 365 * 24 * time.Hour, SupplyCap: 720 * units.MegaLux, }, }, } )
var ( // MainnetConsensusParameters are the consensus parameters for mainnet (21 nodes) MainnetConsensusParameters = sampling.Parameters{ K: 21, AlphaPreference: 13, AlphaConfidence: 18, Beta: 8, ConcurrentRepolls: 8, } // MainnetParams are the params used for mainnet MainnetParams = Params{ ConsensusParameters: MainnetConsensusParameters, TxFeeConfig: TxFeeConfig{ CreateAssetTxFee: 10 * units.MilliLux, TxFee: units.MilliLux, DynamicFeeConfig: gas.Config{ Weights: gas.Dimensions{ gas.Bandwidth: 1, gas.DBRead: 1_000, gas.DBWrite: 1_000, gas.Compute: 4, }, MaxCapacity: 1_000_000, MaxPerSecond: 100_000, TargetPerSecond: 50_000, MinPrice: 1, ExcessConversionConstant: 2_164_043, }, ValidatorFeeConfig: fee.Config{ Capacity: 20_000, Target: 10_000, MinPrice: gas.Price(512 * units.NanoLux), ExcessConversionConstant: 1_246_488_515, }, }, StakingConfig: StakingConfig{ UptimeRequirement: .8, MinValidatorStake: 2 * units.KiloLux, MaxValidatorStake: 3 * units.MegaLux, MinDelegatorStake: 25 * units.Lux, MinDelegationFee: 20000, MinStakeDuration: 2 * 7 * 24 * time.Hour, MaxStakeDuration: 365 * 24 * time.Hour, RewardConfig: reward.Config{ MaxConsumptionRate: .12 * reward.PercentDenominator, MinConsumptionRate: .10 * reward.PercentDenominator, MintingPeriod: 365 * 24 * time.Hour, SupplyCap: 720 * units.MegaLux, }, }, } )
var ( // TestnetParams are the params used for the testnet testnet TestnetParams = Params{ TxFeeConfig: TxFeeConfig{ CreateAssetTxFee: 10 * units.MilliLux, TxFee: units.MilliLux, DynamicFeeConfig: gas.Config{ Weights: gas.Dimensions{ gas.Bandwidth: 1, gas.DBRead: 1_000, gas.DBWrite: 1_000, gas.Compute: 4, }, MaxCapacity: 1_000_000, MaxPerSecond: 100_000, TargetPerSecond: 50_000, MinPrice: 1, ExcessConversionConstant: 2_164_043, }, ValidatorFeeConfig: fee.Config{ Capacity: 20_000, Target: 10_000, MinPrice: gas.Price(512 * units.NanoLux), ExcessConversionConstant: 51_937_021, }, }, StakingConfig: StakingConfig{ UptimeRequirement: .8, MinValidatorStake: 1 * units.Lux, MaxValidatorStake: 3 * units.MegaLux, MinDelegatorStake: 1 * units.Lux, MinDelegationFee: 20000, MinStakeDuration: 24 * time.Hour, MaxStakeDuration: 365 * 24 * time.Hour, RewardConfig: reward.Config{ MaxConsumptionRate: .12 * reward.PercentDenominator, MinConsumptionRate: .10 * reward.PercentDenominator, MintingPeriod: 365 * 24 * time.Hour, SupplyCap: 720 * units.MegaLux, }, }, } )
Functions ¶
func FromConfig ¶
FromConfig returns:
- The byte representation of the genesis state of the platform chain (ie the genesis state of the network)
- The asset ID of LUX
func FromFile ¶ added in v0.1.1
FromFile returns the genesis data of the Platform Chain.
Since an Lux network has exactly one Platform Chain, and the Platform Chain defines the genesis state of the network (who is staking, which chains exist, etc.), defining the genesis state of the Platform Chain is the same as defining the genesis state of the network.
FromFile accepts: 1) The ID of the new network. [networkID] 2) The location of a custom genesis config to load. filepath
If filepath is empty or the given network ID is Mainnet, Testnet, or Local, returns error. If filepath is non-empty and networkID isn't Mainnet, Testnet, or Local, loads the network genesis data from the config at filepath.
FromFile returns:
- The byte representation of the genesis state of the platform chain (ie the genesis state of the network)
- The asset ID of LUX
func FromFlag ¶ added in v0.1.1
func FromFlag(networkID uint32, genesisContent string, stakingCfg *StakingConfig) ([]byte, ids.ID, error)
FromFlag returns the genesis data of the Platform Chain.
Since an Lux network has exactly one Platform Chain, and the Platform Chain defines the genesis state of the network (who is staking, which chains exist, etc.), defining the genesis state of the Platform Chain is the same as defining the genesis state of the network.
FromFlag accepts: 1) The ID of the new network. [networkID] 2) The content of a custom genesis config to load. [genesisContent]
If [genesisContent] is empty or the given network ID is Mainnet, Testnet, or Local, returns error. If [genesisContent] is non-empty and networkID isn't Mainnet, Testnet, or Local, loads the network genesis data from [genesisContent].
FromFlag returns:
- The byte representation of the genesis state of the platform chain (ie the genesis state of the network)
- The asset ID of LUX
func GetCheckpoints ¶ added in v0.1.1
GetCheckpoints returns all known checkpoints for the chain on the requested network.
func GetConsensusParameters ¶ added in v0.1.1
func GetConsensusParameters(networkID uint32) sampling.Parameters
func GetValidators ¶ added in v0.1.1
GetValidators returns recent validators for the requested network.
Types ¶
type Allocation ¶ added in v0.1.1
type Allocation struct {
ETHAddr ids.ShortID `json:"ethAddr"`
LUXAddr ids.ShortID `json:"luxAddr"`
InitialAmount uint64 `json:"initialAmount"`
UnlockSchedule []LockedAmount `json:"unlockSchedule"`
}
func (Allocation) Compare ¶ added in v0.1.1
func (a Allocation) Compare(other Allocation) int
func (Allocation) Unparse ¶ added in v0.1.1
func (a Allocation) Unparse(networkID uint32) (UnparsedAllocation, error)
type Bootstrapper ¶ added in v0.1.1
type Bootstrapper struct {
ID ids.NodeID `json:"-"`
Host string `json:"-"` // Original host string for reference
IP netip.AddrPort `json:"-"` // Resolved IP address
}
Represents the relationship between the nodeID and the nodeIP. The bootstrapper is sometimes called "anchor" or "beacon" node.
func GetBootstrappers ¶ added in v0.1.1
func GetBootstrappers(networkID uint32) []Bootstrapper
GetBootstrappers returns all default bootstrappers for the provided network.
func SampleBootstrappers ¶ added in v0.1.1
func SampleBootstrappers(networkID uint32, count int) []Bootstrapper
SampleBootstrappers returns the some beacons this node should connect to
func (*Bootstrapper) ResolveIP ¶ added in v0.1.1
func (b *Bootstrapper) ResolveIP() error
ResolveIP attempts to resolve the hostname to an IP address if not already resolved
func (*Bootstrapper) UnmarshalJSON ¶ added in v0.1.1
func (b *Bootstrapper) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling to support hostnames
type BootstrapperRaw ¶ added in v0.1.1
type BootstrapperRaw struct {
ID ids.NodeID `json:"id"`
Host string `json:"host"` // Can be hostname:port or ip:port
}
BootstrapperRaw represents the raw JSON format with hostname support
type ChainConfig ¶ added in v1.14.2
type ChainConfig struct {
// Chain identification
ChainID ids.ID `json:"chainID"`
VMID ids.ID `json:"vmID"`
ChainName string `json:"chainName"`
// Consensus parameters
ConsensusParams ConsensusParams `json:"consensusParams"`
// Resource allocation
ProcessorAffinity []int `json:"processorAffinity"` // CPU cores
MemoryLimit uint64 `json:"memoryLimit"` // In bytes
DiskQuota uint64 `json:"diskQuota"` // In bytes
// Network settings
MaxMessageSize int `json:"maxMessageSize"`
MaxPendingMessages int `json:"maxPendingMessages"`
GossipFrequency time.Duration `json:"gossipFrequency"`
GossipBatchSize int `json:"gossipBatchSize"`
// Performance tuning
BlockCacheSize int `json:"blockCacheSize"`
StateCacheSize int `json:"stateCacheSize"`
TransactionPoolSize int `json:"transactionPoolSize"`
// Chain-specific settings
CustomConfig interface{} `json:"customConfig,omitempty"`
}
ChainConfig represents per-chain configuration
type ChainGrouping ¶ added in v1.14.2
type ChainGrouping struct {
FastChains []string // A, X - Low latency requirements
SecureChains []string // M, Z - High security requirements
BalancedChains []string // B, C, P, Q - Balanced requirements
}
ChainGrouping represents how chains are grouped for optimization
func GetChainGrouping ¶ added in v1.14.2
func GetChainGrouping() ChainGrouping
GetChainGrouping returns the logical grouping of chains
type Config ¶
type Config struct {
NetworkID uint32 `json:"networkID"`
Allocations []Allocation `json:"allocations"`
StartTime uint64 `json:"startTime"`
InitialStakeDuration uint64 `json:"initialStakeDuration"`
InitialStakeDurationOffset uint64 `json:"initialStakeDurationOffset"`
InitialStakedFunds []ids.ShortID `json:"initialStakedFunds"`
InitialStakers []Staker `json:"initialStakers"`
CChainGenesis string `json:"cChainGenesis"`
Message string `json:"message"`
}
Config contains the genesis addresses used to construct a genesis
var ( // MainnetConfig is the config that should be used to generate the mainnet // genesis. MainnetConfig Config // TestnetConfig is the config that should be used to generate the testnet // genesis. TestnetConfig Config // LocalConfig is the config that should be used to generate a local // genesis. LocalConfig Config // LuxMainnetConfig is the config that should be used to generate the Lux // mainnet genesis with network ID 96369. LuxMainnetConfig Config // LuxTestnetConfig is the config that should be used to generate the Lux // testnet genesis with network ID 96368. LuxTestnetConfig Config )
func GetConfigContent ¶ added in v0.1.1
GetConfigContent loads a *Config from a provided environment variable
func GetConfigFile ¶ added in v0.1.1
GetConfigFile loads a *Config from a provided filepath.
func (*Config) InitialSupply ¶ added in v0.1.1
func (Config) Unparse ¶ added in v0.1.1
func (c Config) Unparse() (UnparsedConfig, error)
type ConsensusParams ¶ added in v1.14.2
type ConsensusParams struct {
K int `json:"k"`
AlphaPreference int `json:"alphaPreference"`
AlphaConfidence int `json:"alphaConfidence"`
Beta int `json:"beta"`
MaxItemProcessingTime time.Duration `json:"maxItemProcessingTime"`
// Additional tuning
ConcurrentRepolls int `json:"concurrentRepolls"`
OptimalProcessing int `json:"optimalProcessing"`
MaxOutstandingItems int `json:"maxOutstandingItems"`
MaxItemProcessingRetry int `json:"maxItemProcessingRetry"`
ParentCheckInterval time.Duration `json:"parentCheckInterval"`
}
ConsensusParams defines consensus parameters for a chain
type EightChainsConfig ¶ added in v1.14.2
type EightChainsConfig struct {
// Core chains
AChainConfig ChainConfig `json:"aChain"` // AI VM
BChainConfig ChainConfig `json:"bChain"` // Bridge VM
CChainConfig ChainConfig `json:"cChain"` // EVM
MChainConfig ChainConfig `json:"mChain"` // MPC VM
PChainConfig ChainConfig `json:"pChain"` // Platform VM
QChainConfig ChainConfig `json:"qChain"` // Quantum VM
XChainConfig ChainConfig `json:"xChain"` // Exchange VM
ZChainConfig ChainConfig `json:"zChain"` // ZK VM
// Network-wide settings
NetworkID uint32 `json:"networkID"`
ProcessorCount int `json:"processorCount"`
}
EightChainsConfig defines the configuration for all 8 chains
func Default8ChainsConfig ¶ added in v1.14.2
func Default8ChainsConfig() *EightChainsConfig
Default8ChainsConfig returns the default configuration for 8 chains
func (*EightChainsConfig) OptimizeFor8Cores ¶ added in v1.14.2
func (c *EightChainsConfig) OptimizeFor8Cores()
OptimizeFor8Cores adjusts parameters for optimal 8-core performance
type LockedAmount ¶ added in v0.1.1
type Params ¶ added in v0.1.1
type Params struct {
StakingConfig
TxFeeConfig
ConsensusParameters sampling.Parameters `json:"consensusParameters"`
}
type Staker ¶ added in v0.1.1
type StakingConfig ¶ added in v0.1.1
type StakingConfig struct {
// Staking uptime requirements
UptimeRequirement float64 `json:"uptimeRequirement"`
// Minimum stake, in nLUX, required to validate the primary network
MinValidatorStake uint64 `json:"minValidatorStake"`
// Maximum stake, in nLUX, allowed to be placed on a single validator in
// the primary network
MaxValidatorStake uint64 `json:"maxValidatorStake"`
// Minimum stake, in nLUX, that can be delegated on the primary network
MinDelegatorStake uint64 `json:"minDelegatorStake"`
// Minimum delegation fee, in the range [0, 1000000], that can be charged
// for delegation on the primary network.
MinDelegationFee uint32 `json:"minDelegationFee"`
// MinStakeDuration is the minimum amount of time a validator can validate
// for in a single period.
MinStakeDuration time.Duration `json:"minStakeDuration"`
// MaxStakeDuration is the maximum amount of time a validator can validate
// for in a single period.
MaxStakeDuration time.Duration `json:"maxStakeDuration"`
// RewardConfig is the config for the reward function.
RewardConfig reward.Config `json:"rewardConfig"`
}
func GetStakingConfig ¶ added in v0.1.1
func GetStakingConfig(networkID uint32) StakingConfig
type TxFeeConfig ¶ added in v0.1.1
type TxFeeConfig struct {
CreateAssetTxFee uint64 `json:"createAssetTxFee"`
TxFee uint64 `json:"txFee"`
DynamicFeeConfig gas.Config `json:"dynamicFeeConfig"`
ValidatorFeeConfig fee.Config `json:"validatorFeeConfig"`
}
func GetTxFeeConfig ¶ added in v0.1.1
func GetTxFeeConfig(networkID uint32) TxFeeConfig
type UnparsedAllocation ¶ added in v0.1.1
type UnparsedAllocation struct {
ETHAddr string `json:"ethAddr"`
LUXAddr string `json:"luxAddr"`
InitialAmount uint64 `json:"initialAmount"`
UnlockSchedule []LockedAmount `json:"unlockSchedule"`
}
func (UnparsedAllocation) Parse ¶ added in v0.1.1
func (ua UnparsedAllocation) Parse() (Allocation, error)
type UnparsedConfig ¶ added in v0.1.1
type UnparsedConfig struct {
NetworkID uint32 `json:"networkID"`
Allocations []UnparsedAllocation `json:"allocations"`
StartTime uint64 `json:"startTime"`
InitialStakeDuration uint64 `json:"initialStakeDuration"`
InitialStakeDurationOffset uint64 `json:"initialStakeDurationOffset"`
InitialStakedFunds []string `json:"initialStakedFunds"`
InitialStakers []UnparsedStaker `json:"initialStakers"`
CChainGenesis string `json:"cChainGenesis"`
Message string `json:"message"`
}
UnparsedConfig contains the genesis addresses used to construct a genesis
func (UnparsedConfig) Parse ¶ added in v0.1.1
func (uc UnparsedConfig) Parse() (Config, error)
type UnparsedStaker ¶ added in v0.1.1
type UnparsedStaker struct {
NodeID ids.NodeID `json:"nodeID"`
RewardAddress string `json:"rewardAddress"`
DelegationFee uint32 `json:"delegationFee"`
Signer *signer.ProofOfPossession `json:"signer,omitempty"`
}
func (UnparsedStaker) Parse ¶ added in v0.1.1
func (us UnparsedStaker) Parse() (Staker, error)
type WorkloadDistribution ¶ added in v1.14.2
type WorkloadDistribution struct {
// Chunk size for parallel processing
ChunkSize int
// Worker pool sizes per chain type
FastChainWorkers int
SecureChainWorkers int
BalancedChainWorkers int
// Message batching
BatchSizes map[string]int
}
WorkloadDistribution defines how work is distributed across chains
func GetOptimalWorkloadDistribution ¶ added in v1.14.2
func GetOptimalWorkloadDistribution() WorkloadDistribution
GetOptimalWorkloadDistribution returns optimal workload distribution for 8 chains