Documentation
¶
Overview ¶
Package local provides network configuration for local development and testing. For key management, use github.com/luxfi/keys package directly.
Index ¶
- Constants
- Variables
- func DefaultKeyPath() string
- func DefaultKeysPath() string
- func FormatAddress(chainID string, hrp string, shortID ids.ShortID) (string, error)
- func NewCanonicalCustomConfig(binaryPath string, numNodes uint32) (network.Config, error)
- func NewCanonicalDevnetConfig(binaryPath string, numNodes uint32) (network.Config, error)
- func NewCanonicalMainnetConfig(binaryPath string, numNodes uint32) (network.Config, error)
- func NewCanonicalTestnetConfig(binaryPath string, numNodes uint32) (network.Config, error)
- func NewConfigForNetwork(binaryPath string, numNodes uint32, networkID uint32) (network.Config, error)
- func NewConfigForNetworkWithCustomGenesis(binaryPath string, numNodes uint32, genesisJSON string) (network.Config, error)
- func NewConfigFromMnemonic(binaryPath string, networkID uint32, numNodes uint32) (network.Config, error)
- func NewConfigWithPreExistingKeys(binaryPath string, networkID uint32, keysDir string) (network.Config, error)
- func NewDefaultConfig(binaryPath string) network.Config
- func NewDefaultConfigNNodes(binaryPath string, numNodes uint32) (network.Config, error)
- func NewDefaultNetwork(log log.Logger, binaryPath string, reassignPortsIfUsed bool) (network.Network, error)
- func NewLocalConfig(binaryPath string, numNodes uint32) (network.Config, error)
- func NewLocalConfigFromMnemonic(binaryPath string, numNodes uint32) (network.Config, error)
- func NewMainnetConfig(binaryPath string, numNodes uint32) (network.Config, error)
- func NewMainnetConfigFromMnemonic(binaryPath string, numNodes uint32) (network.Config, error)
- func NewMainnetConfigWithKeys(binaryPath string, keysDir string) (network.Config, error)
- func NewNetwork(log log.Logger, networkConfig network.Config, rootDir string, ...) (network.Network, error)
- func NewNetworkFromSnapshot(log log.Logger, snapshotName string, rootDir string, snapshotsDir string, ...) (network.Network, error)
- func NewTestnetConfig(binaryPath string, numNodes uint32) (network.Config, error)
- func NewTestnetConfigFromMnemonic(binaryPath string, numNodes uint32) (network.Config, error)
- func NewTestnetConfigWithKeys(binaryPath string, keysDir string) (network.Config, error)
- type KeyInfo
- type NetworkState
- type NodeProcess
- type NodeProcessCreator
- type TestMsg
Constants ¶
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
const (
DefaultNumNodes = 5
)
const (
MaxPort = math.MaxUint16
)
Variables ¶
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
FormatAddress formats a ShortID as an X or P chain address with the given HRP
func NewCanonicalCustomConfig ¶ added in v1.14.34
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
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
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
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 ¶
NewDefaultConfig creates a new default network config
func NewDefaultConfigNNodes ¶
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
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
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
NewMainnetConfig creates a network config for LUX Mainnet (network ID 96369)
func NewMainnetConfigFromMnemonic ¶ added in v1.6.1
NewMainnetConfigFromMnemonic creates mainnet config from LUX_MNEMONIC
func NewMainnetConfigWithKeys ¶ added in v1.6.1
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
NewTestnetConfig creates a network config for LUX Testnet (network ID 96368)
func NewTestnetConfigFromMnemonic ¶ added in v1.6.1
NewTestnetConfigFromMnemonic creates testnet config from LUX_MNEMONIC
Types ¶
type KeyInfo ¶ added in v1.6.1
KeyInfo contains computed addresses from a private key. Deprecated: Use github.com/luxfi/keys.ValidatorKey instead.
func ComputeKeyInfo ¶ added in v1.6.1
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.
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
}