local

package
v1.14.22 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// MicroLux is the base unit for UTXO chains (P/X)
	// 1 LUX = 1,000,000 MicroLux
	MicroLux uint64 = 1_000_000 // 10^6

	// OneBillionLUX is 1B LUX in MicroLux (UTXO base unit)
	// 1,000,000,000 * 10^6 = 10^15 MicroLux
	OneBillionLUX uint64 = 1_000_000_000 * MicroLux

	// OneMillionLUX is 1M LUX in MicroLux (UTXO base unit)
	// 1,000,000 * 10^6 = 10^12 MicroLux
	OneMillionLUX uint64 = 1_000_000 * MicroLux

	// OnePercentLUX is 1% of 1B = 10M LUX in MicroLux
	OnePercentLUX uint64 = OneBillionLUX / 100

	// SecondsPerYear for vesting calculations
	SecondsPerYear uint64 = 365 * 24 * 3600

	// Jan1_2020 is Unix timestamp for Jan 1, 2020 00:00:00 UTC (vesting start)
	Jan1_2020 uint64 = 1577836800
)

UTXO chain constants (P/X chains)

UTXO Base Unit: MicroLux (10^-6 LUX) - consensus constraint, uses uint64 UTXO Decimals: 6

EVM Base Unit: WeiLux (10^-18 LUX) - presentation only, uses uint256 ERC20 Decimals: 18

View Source
const (
	DefaultNumNodes = 5
)
View Source
const DefaultValidatorStake uint64 = OneMillionLUX

DefaultValidatorStake is 1M LUX per validator in μLUX

View Source
const ImmediateUnlockLUX uint64 = OneBillionLUX * 5 / 100

ImmediateUnlockLUX is 5% of 1B = 50M LUX for immediate spending (fees, transactions)

View Source
const (
	MaxPort = math.MaxUint16
)

Variables

View Source
var (
	ErrSnapshotNotFound = errors.New("snapshot not found")
)

interface compliance

Functions

func DefaultKeyPath added in v1.6.1

func DefaultKeyPath() string

DefaultKeyPath returns the default path for lux keys

func FormatAddress added in v1.6.1

func FormatAddress(chainID string, hrp string, shortID ids.ShortID) (string, error)

FormatAddress formats a ShortID as an X or P chain address with the given HRP

func GenerateAllocationsFromKeys added in v1.14.8

func GenerateAllocationsFromKeys(keys []KeyInfo, hrp string) ([]map[string]interface{}, error)

GenerateAllocationsFromKeys creates genesis allocations for loaded keys with vesting The first key gets immediately spendable funds (locktime=0) for transaction fees. Other keys get vesting schedules starting from Jan 1, 2020.

func GenerateCChainAllocFromKeys added in v1.14.8

func GenerateCChainAllocFromKeys(keys []KeyInfo) map[string]map[string]string

GenerateCChainAllocFromKeys creates C-chain genesis allocations for loaded keys

func GenerateVestingSchedule added in v1.14.8

func GenerateVestingSchedule() []map[string]interface{}

GenerateVestingSchedule creates an unlock schedule with: - 5% immediately available (locktime=0) for transaction fees - 1% per year for 95 years starting from Jan 1, 2020 This ensures the wallet has spendable funds for chain creation and other operations.

func NewConfigForNetwork added in v1.6.1

func NewConfigForNetwork(binaryPath string, numNodes uint32, networkID uint32) (network.Config, error)

NewConfigForNetwork creates a network config for the specified network ID. This uses the proper genesis configuration from github.com/luxfi/genesis/configs. For non-local networks (mainnet/testnet), it dynamically injects initial stakers based on the generated node staking keys.

When LUX_MNEMONIC environment variable is set, validator keys are derived deterministically from the mnemonic, ensuring consistent node identities and P-Chain allocations across network restarts.

Supported network IDs:

  • 96369: LUX Mainnet
  • 96368: LUX Testnet
  • 1337: Local development network

func NewConfigForNetworkWithCustomGenesis added in v1.6.1

func NewConfigForNetworkWithCustomGenesis(binaryPath string, numNodes uint32, genesisJSON string) (network.Config, error)

NewConfigForNetworkWithCustomGenesis creates a network config with a custom genesis string. Use this for networks not defined in the configs package or for testing.

func NewDefaultConfig

func NewDefaultConfig(binaryPath string) network.Config

NewDefaultConfig creates a new default network config

func NewDefaultConfigNNodes

func NewDefaultConfigNNodes(binaryPath string, numNodes uint32) (network.Config, error)

NewDefaultConfigNNodes creates a new default network config, with an arbitrary number of nodes

func NewDefaultNetwork

func NewDefaultNetwork(
	log luxlog.Logger,
	binaryPath string,
	reassignPortsIfUsed bool,
) (network.Network, error)

NewDefaultNetwork returns a new network using a pre-defined network configuration. The following addresses are pre-funded (treasury address): X-Chain Address: X-lux1c7wevm4667l4umtzh93r25wpxlpsadkhka6gv6 P-Chain Address: P-lux1c7wevm4667l4umtzh93r25wpxlpsadkhka6gv6 C-Chain Address: 0x9011E888251AB053B7bD1cdB598Db4f9DEd94714 Keys are dynamically generated per network - see ~/.lux/keys/ The following nodes are validators: * NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg * NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ * NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN * NodeID-GWPcbFJZFfZreETSoWjPimr846mXEKCtu * NodeID-P7oB2McjBGgW2NXXWVYjV8JEDFoW9xDE5

func NewLocalConfig added in v1.6.1

func NewLocalConfig(binaryPath string, numNodes uint32) (network.Config, error)

NewLocalConfig creates a network config for local development (network ID 1337) This is equivalent to NewDefaultConfigNNodes but uses the configs package.

func NewMainnetConfig added in v1.6.1

func NewMainnetConfig(binaryPath string, numNodes uint32) (network.Config, error)

NewMainnetConfig creates a network config for LUX Mainnet (network ID 96369)

func NewNetwork

func NewNetwork(
	log luxlog.Logger,
	networkConfig network.Config,
	rootDir string,
	snapshotsDir string,
	reassignPortsIfUsed bool,
) (network.Network, error)

NewNetwork returns a new network that uses the given log. Files (e.g. logs, databases) default to being written at directory [rootDir]. If there isn't a directory at [dir] one will be created. If len([dir]) == 0, files will be written underneath a new temporary directory. Snapshots are saved to snapshotsDir, defaults to defaultSnapshotsDir if not given

func NewNetworkFromSnapshot

func NewNetworkFromSnapshot(
	log luxlog.Logger,
	snapshotName string,
	rootDir string,
	snapshotsDir string,
	binaryPath string,
	pluginDir string,
	chainConfigs map[string]string,
	upgradeConfigs map[string]string,
	pChainConfigs map[string]string,
	flags map[string]interface{},
	reassignPortsIfUsed bool,
) (network.Network, error)

NewNetwork returns a new network from the given snapshot

func NewTestnetConfig added in v1.6.1

func NewTestnetConfig(binaryPath string, numNodes uint32) (network.Config, error)

NewTestnetConfig creates a network config for LUX Testnet (network ID 96368)

Types

type KeyInfo added in v1.6.1

type KeyInfo struct {
	PrivKeyHex string
	EthAddr    string
	ShortID    ids.ShortID
}

KeyInfo contains computed addresses from a private key

func ComputeKeyInfo added in v1.6.1

func ComputeKeyInfo(privKeyHex string) (KeyInfo, error)

ComputeKeyInfo derives addresses from a hex-encoded private key

func GenerateValidatorAllocations added in v1.6.1

func GenerateValidatorAllocations(numValidators uint32, hrp string) ([]map[string]interface{}, []KeyInfo, error)

GenerateValidatorAllocations creates P-Chain allocations for a given number of validators. Each validator gets DefaultValidatorStake (1M LUX) with funds immediately available. The first validator gets extra funds for transaction fees and chain creation.

func LoadOrGenerateKeys added in v1.6.1

func LoadOrGenerateKeys(keyPath string, count int) ([]KeyInfo, error)

LoadOrGenerateKeys loads validator keys from the specified path or generates new ones if missing. Keys are stored as hex-encoded private keys in files named validator_XXX.pk

type NetworkState

type NetworkState struct {
	// Map from chain id to elastic chain tx id
	ChainID2ElasticChainID map[string]string `json:"chainID2ElasticChainID"`
}

NetworkState defines dynamic network information not available on chain db

type NodeProcess

type NodeProcess interface {
	// Sends a SIGINT to this process and returns the process's
	// exit code.
	// If [ctx] is cancelled, sends a SIGKILL to this process and descendants.
	// We assume sending a SIGKILL to a process will always successfully kill it.
	// Subsequent calls to [Stop] have no effect.
	Stop(ctx context.Context) int
	// Returns the status of the process.
	Status() status.Status
}

NodeProcess as an interface so we can mock running Lux binaries in tests

type NodeProcessCreator

type NodeProcessCreator interface {
	GetNodeVersion(config node.Config) (string, error)
	NewNodeProcess(config node.Config, args ...string) (NodeProcess, error)
}

NodeProcessCreator is an interface for new node process creation

type TestMsg

type TestMsg struct {
	// contains filtered or unexported fields
}

func NewTestMsg

func NewTestMsg(op message.Op, bytes []byte, bypassThrottling bool) *TestMsg

func (*TestMsg) BypassThrottling

func (m *TestMsg) BypassThrottling() bool

func (*TestMsg) Bytes

func (m *TestMsg) Bytes() []byte

func (*TestMsg) BytesSavedCompression

func (*TestMsg) BytesSavedCompression() int

func (*TestMsg) Op

func (m *TestMsg) Op() message.Op

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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