configs

package
v1.12.14 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package configs provides genesis configuration loading for Lux networks. This package is used by CLI, netrunner, and node to obtain genesis JSON for different network IDs.

Dynamic P-Chain Allocations: P-Chain allocations can be specified dynamically at runtime via:

  • PCHAIN_ALLOCS: JSON string of allocations
  • PCHAIN_ALLOCS_FILE: Path to allocations JSON file
  • ~/.lux/genesis/{network}/pchain.json: Standard override location

The C-Chain genesis remains embedded and immutable.

Index

Constants

View Source
const (
	// Network IDs (P-Chain). These identify the PRIMARY network.
	MainnetID = 1
	TestnetID = 2
	DevnetID  = 3
	// LocalID is the canonical local single/multi-node dev network.
	// Pair with LocalChainID = 31337 on the C-Chain (Anvil convention).
	LocalID = 1337

	// CustomID is the sentinel for any network ID outside the well-known
	// {1, 2, 3, 1337} set — i.e. genuinely user-defined networks. It is
	// deliberately NOT 1337 so callers can distinguish "this is the local
	// dev network" (LocalID) from "this is some other custom network the
	// caller will configure via --genesis-file" (CustomID).
	CustomID uint32 = 0

	// LocalnetID is a deprecated alias for LocalID; existing callers
	// should migrate to LocalID. Kept here so older code keeps building
	// during the rollout.
	LocalnetID = LocalID

	// Chain ID constants (C-Chain EVM).
	MainnetChainID = 96369
	TestnetChainID = 96368
	DevnetChainID  = 96370
	// LocalChainID is the canonical local C-Chain EVM ID (Anvil convention).
	LocalChainID = 31337
	// CustomChainID is the sentinel C-Chain EVM ID for any chain outside
	// the well-known {96369, 96368, 96370, 31337} set. Mirrors CustomID
	// at the network-ID layer; the two should always be paired (a peer
	// presenting CustomID at the network layer also presents
	// CustomChainID at the EVM layer unless overridden via genesis-file).
	CustomChainID uint32 = 0
	// LocalnetChainID is a deprecated alias for LocalChainID.
	LocalnetChainID = LocalChainID
)

Network ID constants (P-Chain) mainnet, testnet, devnet: proper public networks localnet: local development with LIGHT mnemonic (networkID=1337, EVM chainID=31337) anything else is custom (override via --genesis-file)

Variables

This section is empty.

Functions

func GetCanonicalGenesisBytes

func GetCanonicalGenesisBytes(networkID uint32) ([]byte, error)

GetCanonicalGenesisBytes returns the canonical genesis bytes for a network. This function builds the genesis from split files (network.json, pchain.json, cchain.json) to ensure cChainGenesis is properly serialized as a JSON string.

CRITICAL: The embedded genesis.json stores cChainGenesis as an object for easy editing, but luxd requires it to be a JSON-encoded string. This function handles the conversion.

func GetConfig

func GetConfig(networkID uint32) (*genesis.Config, error)

GetConfig returns the parsed genesis Config for a network ID.

func GetGenesis

func GetGenesis(networkID uint32) ([]byte, error)

GetGenesis returns the genesis JSON bytes for a network ID. It supports dynamic P-Chain allocations via environment variables or files:

  • PCHAIN_ALLOCS: JSON string of allocations
  • PCHAIN_ALLOCS_FILE: Path to allocations JSON file
  • ~/.lux/genesis/{network}/pchain.json: Standard override location

C-Chain genesis remains embedded and immutable.

func GetGenesisWithAllocations

func GetGenesisWithAllocations(networkID uint32, allocations []genesis.AllocationJSON) ([]byte, error)

GetGenesisWithAllocations returns genesis with custom P-Chain allocations. This allows booting networks with custom validator allocations.

func IsCustom added in v1.9.2

func IsCustom(networkID uint32) bool

IsCustom reports whether the networkID is a user-defined network outside the well-known {Mainnet, Testnet, Devnet, Local + their C-Chain aliases} set. Mirrors luxfi/constants.IsCustom; both the genesis layer and the constants layer agree on the classification so a network can be classified consistently end-to-end.

Types

This section is empty.

Jump to

Keyboard shortcuts

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