Documentation
¶
Overview ¶
Package builder provides genesis byte generation for Lux networks. This package depends on node types and is responsible for building the actual genesis state from genesis config.
Index ¶
- Variables
- func Aliases(genesisBytes []byte) (map[string][]string, map[ids.ID][]string, error)
- func AliasesFor(letter string) []string
- func ForDevMode(cfg DevModeConfig, stakingCfg *StakingConfig) ([]byte, ids.ID, error)
- func FromConfig(config *genesiscfg.Config) ([]byte, ids.ID, error)
- func FromDatabase(networkID uint32, dbPath string, dbType string, stakingCfg *StakingConfig) ([]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 GetConfig(networkID uint32) *genesiscfg.Config
- func VMAliasesMap() map[ids.ID][]string
- func VMGenesis(genesisBytes []byte, vmID ids.ID) (*pchaintxs.Tx, error)
- func XAssetIDFromGenesisBytes(genesisBytes []byte) (ids.ID, bool, error)
- type Bootstrapper
- type ChainSpec
- type DevModeConfig
- type StakingConfig
- type TxFeeConfig
Constants ¶
This section is empty.
Variables ¶
var ( PChainAliases = AliasesFor("P") XChainAliases = AliasesFor("X") CChainAliases = AliasesFor("C") DChainAliases = AliasesFor("D") QChainAliases = AliasesFor("Q") AChainAliases = AliasesFor("A") BChainAliases = AliasesFor("B") TChainAliases = AliasesFor("T") ZChainAliases = AliasesFor("Z") GChainAliases = AliasesFor("G") KChainAliases = AliasesFor("K") // Network-specific genesis messages (Latin for mainnet, descriptive for others) // Mainnet: "Lux et Libertas" - Light and Liberty MainnetChainGenesis = `{"version":1,"message":"Lux et Libertas"}` // Testnet: "Per Aspera ad Astra" - Through hardships to the stars TestnetChainGenesis = `{"version":1,"message":"Per Aspera ad Astra"}` // Devnet: "In Silico Veritas" - Truth in silicon DevnetChainGenesis = `{"version":1,"message":"In Silico Veritas"}` // Local/Custom: "Carpe Diem" - Seize the day LocalChainGenesis = `{"version":1,"message":"Carpe Diem"}` // VMAliases is the default (VMID -> aliases) map for the node's VM // manager. Chain entries are derived from Registry; fx entries are // the static feature-extension aliases (secp256k1fx, nftfx, ...). VMAliases = VMAliasesMap() )
Chain alias vars are derived from the single source of truth (Registry in registry.go). Rebranding a chain — adding/removing aliases or renaming the letter — edits one row in Registry; these vars and the VMAliases map re-derive at package init.
var ( MainnetDynamicFeeConfig = gas.Config{ Weights: gas.Dimensions{ gas.Bandwidth: 1, gas.DBRead: 1, gas.DBWrite: 1, gas.Compute: 1, }, MaxCapacity: 1_000_000, MaxPerSecond: 100_000, TargetPerSecond: 50_000, MinPrice: 1, ExcessConversionConstant: 5_000, } TestnetDynamicFeeConfig = gas.Config{ Weights: gas.Dimensions{ gas.Bandwidth: 1, gas.DBRead: 1, gas.DBWrite: 1, gas.Compute: 1, }, MaxCapacity: 1_000_000, MaxPerSecond: 100_000, TargetPerSecond: 50_000, MinPrice: 1, ExcessConversionConstant: 5_000, } LocalDynamicFeeConfig = gas.Config{ Weights: gas.Dimensions{ gas.Bandwidth: 1, gas.DBRead: 1, gas.DBWrite: 1, gas.Compute: 1, }, MaxCapacity: 1_000_000, MaxPerSecond: 100_000, TargetPerSecond: 50_000, MinPrice: 1, ExcessConversionConstant: 5_000, } MainnetValidatorFeeConfig = fee.Config{ Capacity: 20_000, Target: 10_000, MinPrice: 512, ExcessConversionConstant: 1_587, } TestnetValidatorFeeConfig = fee.Config{ Capacity: 20_000, Target: 10_000, MinPrice: 512, ExcessConversionConstant: 1_587, } LocalValidatorFeeConfig = fee.Config{ Capacity: 20_000, Target: 10_000, MinPrice: 512, ExcessConversionConstant: 1_587, } )
Default dynamic fee parameters
var Registry = []ChainSpec{ {Letter: "P", VMID: constants.PlatformVMID, Aliases: []string{"platform"}, Name: "P-Chain"}, {Letter: "X", VMID: constants.XVMID, Aliases: []string{"xvm"}, Name: "X-Chain"}, {Letter: "C", VMID: constants.EVMID, Aliases: []string{"evm"}, Name: "C-Chain"}, {Letter: "D", VMID: constants.DexVMID, Aliases: []string{"dex", "dexvm"}, Name: "D-Chain"}, {Letter: "Q", VMID: constants.QuantumVMID, Aliases: []string{"quantum", "quantumvm", "pq"}, Name: "Q-Chain"}, {Letter: "A", VMID: constants.AIVMID, Aliases: []string{"attest", "ai", "aivm"}, Name: "A-Chain"}, {Letter: "B", VMID: constants.BridgeVMID, Aliases: []string{"bridge", "bridgevm"}, Name: "B-Chain"}, {Letter: "T", VMID: constants.ThresholdVMID, Aliases: []string{"threshold", "thresholdvm", "mpc"}, Name: "T-Chain"}, {Letter: "Z", VMID: constants.ZKVMID, Aliases: []string{"zk", "zkvm"}, Name: "Z-Chain"}, {Letter: "G", VMID: constants.GraphVMID, Aliases: []string{"graph", "graphvm", "dgraph"}, Name: "G-Chain"}, {Letter: "K", VMID: constants.KeyVMID, Aliases: []string{"key", "keyvm"}, Name: "K-Chain"}, }
Registry is the canonical list of primary-network chains.
Order is fixed and matches the optIn order in FromConfig — reordering shifts the P-Chain genesis byte layout for chains that share a presence/absence shape, so this slice is append-only.
P-Chain is implicit (the platform genesis itself); listed here so the alias machinery has a row for it, but FromConfig does not iterate this slice to emit CreateChainTx for P.
Functions ¶
func AliasesFor ¶ added in v1.27.14
AliasesFor returns the full chain alias list for a chain by letter. The letter itself is prepended, e.g. AliasesFor("D") -> ["D", "dex", "dexvm"]. Returns nil for unknown letters.
func ForDevMode ¶ added in v1.22.67
func ForDevMode(cfg DevModeConfig, stakingCfg *StakingConfig) ([]byte, ids.ID, error)
ForDevMode creates a genesis configuration suitable for single-node development mode. It creates a single validator with far-future stake time and funds the treasury address.
func FromConfig ¶
FromConfig builds genesis bytes from a config.
X-Chain is opt-in via config.XChainGenesis (a small JSON descriptor like
{"symbol":"LUX","name":"Lux","denomination":9}
). When set, the builder constructs an XVM genesis whose primary asset is that descriptor (initial holders sourced from config.Allocations) and emits an X-Chain entry in the primary-network CreateChainTx set. When empty, no XVM genesis is built and X-Chain is omitted from the chain set — the path used by P-only L2s whose value capture lives on a downstream EVM (Liquid EVM etc.).
The LUX asset ID returned is always the network-wide constant (constants.UTXO_ASSET_ID), independent of whether X-Chain is baked. This is what decouples the asset from any specific chain's genesis bytes — P-Chain stake/UTXO references stay byte-stable across both shapes of primary network.
func FromDatabase ¶
func FromDatabase(networkID uint32, dbPath string, dbType string, stakingCfg *StakingConfig) ([]byte, ids.ID, error)
FromDatabase returns genesis data for database replay mode
func FromFile ¶
FromFile loads genesis config from file and builds genesis bytes. Caller owns the choice — if a genesis file is set, we use it. No "is this networkID standard?" guard, no allow-flag. Operator-owned chainset.
func FromFlag ¶
func FromFlag(networkID uint32, genesisContent string, stakingCfg *StakingConfig) ([]byte, ids.ID, error)
FromFlag parses base64-encoded genesis content and builds genesis bytes. Same contract as FromFile — caller owns the override.
func GetConfig ¶
func GetConfig(networkID uint32) *genesiscfg.Config
GetConfig returns the genesis config for the given network ID
func VMAliasesMap ¶ added in v1.27.14
VMAliasesMap returns the union of chain VM aliases (from Registry) and the static fx VM aliases (from fxVMAliases). This is the map the node's VM manager consumes via builder.VMAliases.
The values are fresh slice copies so callers cannot mutate Registry rows through the returned map.
func XAssetIDFromGenesisBytes ¶ added in v1.27.14
XAssetIDFromGenesisBytes returns the X-Chain native asset ID encoded in a platform-genesis blob. It parses the platform genesis, finds the X-Chain CreateChainTx (vmID == constants.XVMID), then decodes that chain's embedded XVM genesis bytes to recover the runtime asset ID (the same value vm.initGenesis assigns to the first GenesisAsset).
Returns (ids.Empty, false, nil) when the platform genesis contains no X-Chain (P-only mode) — callers fall back to whatever default they prefer (e.g. constants.UTXOAssetIDFor(networkID)).
Returns a non-nil error when the platform genesis is unparseable or the X-Chain genesis bytes embedded inside it are malformed; both are unrecoverable on a primary-network bootstrap.
Used by config.getGenesisData when it loads genesis via the cached / raw paths that skip FromConfig — those paths historically returned constants.UTXOAssetIDFor(networkID), but on sovereign L1s that value disagrees with what's actually in the genesis bytes. Wiring this helper through getGenesisData means the node always reports the genesis-derived asset ID via platform.getStakingAssetID regardless of which load path was taken.
Types ¶
type Bootstrapper ¶
Bootstrapper represents a network bootstrap node with parsed types. Supports both IP addresses and hostnames for the endpoint.
func GetBootstrappers ¶
func GetBootstrappers(networkID uint32) ([]Bootstrapper, error)
GetBootstrappers returns parsed bootstrappers for the network
func ParseBootstrapper ¶
func ParseBootstrapper(b genesiscfg.Bootstrapper) (Bootstrapper, error)
ParseBootstrapper converts a genesis config bootstrapper to a parsed Bootstrapper. The IP field can be either an IP:port (e.g., "1.2.3.4:9631") or a hostname:port (e.g., "luxd-0.luxd-headless.lux-mainnet.svc.cluster.local:9631").
func SampleBootstrappers ¶
func SampleBootstrappers(networkID uint32, count int) ([]Bootstrapper, error)
SampleBootstrappers returns a random sample of bootstrappers for the network
func (Bootstrapper) IP ¶
func (b Bootstrapper) IP() endpoints.Endpoint
IP returns the IP address if this is an IP-based endpoint. For hostname endpoints, this returns an invalid AddrPort. Deprecated: Use Endpoint directly for new code.
type ChainSpec ¶ added in v1.27.14
type ChainSpec struct {
// Letter is the canonical single-character chain code ("P", "X", ...).
// Used as the first element of the chain alias list and as the
// bech32 chain prefix.
Letter string
// VMID is the VM that runs this chain. The (VMID -> aliases) map
// VMAliasesMap() is derived from Registry by collecting Aliases
// for each ChainSpec.
VMID ids.ID
// Aliases are the non-letter aliases for this chain. The full
// chain alias list returned by AliasesFor is [Letter] ++ Aliases.
// These are also the VM aliases registered with the alias manager.
Aliases []string
// Name is the human-readable chain name ("P-Chain", "C-Chain", ...).
// Embedded into the primary-network CreateChainTx.
Name string
}
ChainSpec is one row in the primary-network chain registry.
Registry is the single source of truth for: canonical letter, VMID, bech32 chain prefix used in addresses, alias list, and the human-readable name. Rebranding or renaming a chain edits one row; the prior switch-ladders in Aliases() and var blocks of {P,X,C,...}ChainAliases re-derive from this table.
type DevModeConfig ¶ added in v1.22.67
type DevModeConfig struct {
NodeID ids.NodeID // The validator node ID
BLSPublicKey string // BLS public key hex
BLSPopProof string // BLS proof of possession hex
RewardAddress ids.ShortID // Reward/allocation address
CChainGenesis string // C-Chain genesis JSON
StartTime uint64 // Genesis start time (if 0, uses time.Now())
}
DevModeConfig holds configuration for dev mode genesis
type StakingConfig ¶
type StakingConfig struct {
UptimeRequirement float64
MinValidatorStake uint64
MaxValidatorStake uint64
MinDelegatorStake uint64
MinDelegationFee uint32
MinStakeDuration time.Duration
MaxStakeDuration time.Duration
RewardConfig reward.Config
// BLS key information for genesis replay
NodeID string `json:"nodeID"`
BLSPublicKey []byte `json:"blsPublicKey"`
BLSProofOfPossession []byte `json:"blsProofOfPossession"`
}
StakingConfig is the staking configuration with time.Duration types
func GetStakingConfig ¶
func GetStakingConfig(networkID uint32) StakingConfig
GetStakingConfig returns the staking config with time.Duration types
type TxFeeConfig ¶
type TxFeeConfig struct {
TxFee uint64 `json:"txFee"`
CreateAssetTxFee uint64 `json:"createAssetTxFee"`
DynamicFeeConfig gas.Config `json:"dynamicFeeConfig"`
ValidatorFeeConfig fee.Config `json:"validatorFeeConfig"`
}
TxFeeConfig contains transaction fee configuration This includes the basic fee config from genesis plus dynamic/validator fees
func GetTxFeeConfig ¶
func GetTxFeeConfig(networkID uint32) TxFeeConfig
GetTxFeeConfig returns the tx fee config