local

package
v1.15.0 Latest Latest
Warning

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

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

Documentation

Overview

Package local provides network configuration for local development and testing. For key management, use github.com/luxfi/keys package directly.

Index

Constants

View Source
const (
	MicroLux              = keys.MicroLux
	Lux                   = keys.Lux
	MegaLux               = keys.MegaLux
	GigaLux               = keys.GigaLux
	OneMillionLUX         = keys.MegaLux
	OneBillionLUX         = keys.GigaLux
	DefaultValidatorStake = keys.DefaultValidatorStake
)

Re-export constants from keys package for backward compatibility Deprecated: Use github.com/luxfi/keys constants directly

View Source
const (
	DefaultNumNodes = 5
)
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. Deprecated: Use keys.NewKeyStore("").

func DefaultKeysPath added in v1.6.1

func DefaultKeysPath() string

DefaultKeysPath returns the default path for pre-existing validator 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 NewCanonicalCustomConfig added in v1.14.34

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

NewCanonicalCustomConfig creates a custom (local) network config using the CANONICAL genesis bytes. See NewCanonicalMainnetConfig for details on why this is critical.

func NewCanonicalDevnetConfig added in v1.14.34

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

NewCanonicalDevnetConfig creates a devnet network config using the CANONICAL genesis bytes. See NewCanonicalMainnetConfig for details on why this is critical.

func NewCanonicalMainnetConfig added in v1.14.34

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

NewCanonicalMainnetConfig creates a mainnet network config using the CANONICAL genesis bytes. This function loads the pre-serialized genesis.json file directly, ensuring byte-for-byte deterministic output. Use this to avoid "db contains invalid genesis hash" errors on restart.

CRITICAL: For mainnet/testnet, always use this function or NewCanonicalTestnetConfig rather than functions that regenerate genesis (which causes non-deterministic bytes).

func NewCanonicalTestnetConfig added in v1.14.34

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

NewCanonicalTestnetConfig creates a testnet network config using the CANONICAL genesis bytes. See NewCanonicalMainnetConfig for details on why this is critical.

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 mainnet/testnet, this function: 1. Uses embedded validator keys from defaultNetworkConfig (not generating new ones) 2. Preserves initialStakers from the genesis package (already matches embedded keys) 3. Generates P-chain allocations for the embedded validators (10M LUX each) 4. Preserves cchainGenesis from the genesis package

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 NewConfigFromMnemonic added in v1.6.1

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

NewConfigFromMnemonic creates a network config by deriving validator keys from LUX_MNEMONIC. This is the preferred method for starting mainnet/testnet.

IMPORTANT: Keys are derived from mnemonic ONCE and persisted to disk (~/.lux/netrunner-validators/). On subsequent runs, keys are loaded from disk to maintain stable NodeIDs. This follows Avalanche's pattern where identity = persistent staking keys.

The mnemonic is used to derive: - EC keys (for P-chain allocations) - deterministic from mnemonic - TLS staking certs (for NodeID) - generated once, then persisted - BLS keys (for consensus) - deterministic from mnemonic

func NewConfigWithPreExistingKeys added in v1.6.1

func NewConfigWithPreExistingKeys(binaryPath string, networkID uint32, keysDir string) (network.Config, error)

NewConfigWithPreExistingKeys creates a network config using pre-existing validator keys. This is useful for: - Maintaining consistent NodeIDs across network restarts - Using keys with pre-configured BLS signers - Deploying to mainnet/testnet with known validator identities

The keysDir should contain subdirectories (e.g., node1, node2) with: - staker.crt and staker.key for TLS identity - bls/signer.key for BLS signer (optional) - ec/private.key for P-Chain addresses (optional)

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 log.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 NewLocalConfigFromMnemonic added in v1.6.1

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

NewLocalConfigFromMnemonic creates local network config from LUX_MNEMONIC This uses network ID 1337 with "custom" HRP, which is simpler for testing

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 NewMainnetConfigFromMnemonic added in v1.6.1

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

NewMainnetConfigFromMnemonic creates mainnet config from LUX_MNEMONIC

func NewMainnetConfigWithKeys added in v1.6.1

func NewMainnetConfigWithKeys(binaryPath string, keysDir string) (network.Config, error)

NewMainnetConfigWithKeys creates a mainnet config using pre-existing validator keys

func NewNetwork

func NewNetwork(
	log log.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 log.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)

func NewTestnetConfigFromMnemonic added in v1.6.1

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

NewTestnetConfigFromMnemonic creates testnet config from LUX_MNEMONIC

func NewTestnetConfigWithKeys added in v1.6.1

func NewTestnetConfigWithKeys(binaryPath string, keysDir string) (network.Config, error)

NewTestnetConfigWithKeys creates a testnet config using pre-existing validator keys

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. Deprecated: Use github.com/luxfi/keys.ValidatorKey instead.

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. Deprecated: Use keys.NewAllocationBuilder directly.

func LoadOrGenerateKeys added in v1.6.1

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

LoadOrGenerateKeys loads validator keys using the keys package. Deprecated: Use keys.KeyStore.LoadAll() or keys.KeyStore.GenerateMultiple().

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