Documentation
¶
Overview ¶
Package chain provides chain configuration management with an overlay model.
Config precedence (highest → lowest):
- CLI flags / inline JSON
- Per-run overrides (in run dir)
- User global chain configs (~/.lux/chain-configs/<chain-id>/config.json)
- Built-in defaults
The run directory chainConfigs are treated as rendered output, not source.
Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Index ¶
- Constants
- Variables
- func CheckNodeIsInSubnetPendingValidators(subnetID ids.ID, nodeID string) (bool, error)
- func CopySubnetChainConfigsToNetwork(app *application.Lux, networkDir string) error
- func DefaultEVMConfig() map[string]interface{}
- func EnsureNetworkRunDir(baseRunsDir, network string) (string, error)
- func GetCurrentSupply(subnetID ids.ID) error
- func GetDefaultSubnetAirdropKeyInfo(app *application.Lux, blockchainName string) (string, string, string, error)
- func GetFirstEndpoint(clusterInfo *rpcpb.ClusterInfo, chain string) string
- func GetLocallyDeployedNetIDs(app *application.Lux) ([]string, error)
- func GetLocallyDeployedSubnetIDs(app *application.Lux) ([]string, error)
- func GetLocallyDeployedSubnets() (map[string]struct{}, error)
- func GetLocallyDeployedSubnetsFromFile(app *application.Lux) ([]string, error)
- func GetPublicSubnetValidators(subnetID ids.ID, network models.Network) ([]platformvm.ClientPermissionlessValidator, error)
- func GetSubnetValidators(subnetID ids.ID) ([]platformvm.ClientPermissionlessValidator, error)
- func HasEndpoints(clusterInfo *rpcpb.ClusterInfo) bool
- func IsSubnetValidator(subnetID ids.ID, nodeID ids.NodeID, network models.Network) (bool, error)
- func IssueAddPermissionlessValidatorTx(kc keychain.Keychain, subnetID ids.ID, nodeID ids.NodeID, stakeAmount uint64, ...) (ids.ID, error)
- func IssueRemoveSubnetValidatorTx(kc keychain.Keychain, subnetID ids.ID, nodeID ids.NodeID) (ids.ID, error)
- func IssueTransformSubnetTx(elasticSubnetConfig climodels.ElasticChainConfig, kc keychain.Keychain, ...) (ids.ID, ids.ID, error)
- func PrepareCanonicalChainConfigs(app *application.Lux) (string, error)
- func SetDefaultSnapshot(snapshotsDir string, force bool) error
- func ValidateSubnetNameAndGetChains(subnetName string) error
- func WaitForChainHealthyWithTimeout(cli client.Client, chainName string, timeout time.Duration, rootDir string, ...) (*rpcpb.ClusterInfo, error)
- func WaitForHealthy(ctx context.Context, cli client.Client) (*rpcpb.ClusterInfo, error)
- type Config
- func (c *Config) Effective() map[string]interface{}
- func (c *Config) EffectiveJSON() (string, error)
- func (c *Config) EnableAdmin()
- func (c *Config) LoadGlobal() error
- func (c *Config) Render(runDir string) error
- func (c *Config) SaveGlobal() error
- func (c *Config) SetCLIOverride(key string, value interface{})
- func (c *Config) SetCLIOverrides(overrides map[string]interface{})
- type LocalDeployer
- func (d *LocalDeployer) BackendStartedHere() bool
- func (d *LocalDeployer) DeployBlockchain(chain string, chainGenesis []byte) (ids.ID, ids.ID, error)
- func (d *LocalDeployer) DeployToLocalNetwork(chain string, chainGenesis []byte, genesisPath string) (ids.ID, ids.ID, error)
- func (d *LocalDeployer) SetupLocalEnv() (string, error)
- func (d *LocalDeployer) StartServer() error
- type Manager
- func (m *Manager) AddChain(chainID string) *Config
- func (m *Manager) AddChainWithAlias(chainID, alias string) *Config
- func (m *Manager) EnableAdminAll()
- func (m *Manager) GetConfig(chainIDOrAlias string) *Config
- func (m *Manager) LoadDeployedChains() error
- func (m *Manager) RenderAll(runDir string) error
- func (m *Manager) ToNetrunnerMap() map[string]string
- type PublicDeployer
- func (d *PublicDeployer) AddValidator(controlKeys []string, subnetAuthKeysStrs []string, subnetID ids.ID, ...) (bool, *txs.Tx, []string, error)
- func (d *PublicDeployer) Commit(tx *txs.Tx) (ids.ID, error)
- func (d *PublicDeployer) ConvertL1(controlKeys []string, subnetAuthKeysStrs []string, subnetID ids.ID, ...) (bool, ids.ID, *txs.Tx, []string, error)
- func (d *PublicDeployer) CreateAssetTx(subnetID ids.ID, tokenName string, tokenSymbol string, denomination byte, ...) (ids.ID, error)
- func (d *PublicDeployer) DeployBlockchain(controlKeys []string, subnetAuthKeysStrs []string, subnetID ids.ID, ...) (bool, ids.ID, *txs.Tx, []string, error)
- func (d *PublicDeployer) DeploySubnet(controlKeys []string, threshold uint32) (ids.ID, error)
- func (d *PublicDeployer) ExportToPChainTx(subnetID ids.ID, subnetAssetID ids.ID, owner *secp256k1fx.OutputOwners, ...) (ids.ID, error)
- func (d *PublicDeployer) ImportFromXChain(subnetID ids.ID, owner *secp256k1fx.OutputOwners) (ids.ID, error)
- func (d *PublicDeployer) IncreaseValidatorPChainBalance(validationID ids.ID, balance uint64) error
- func (d *PublicDeployer) RegisterL1Validator(balance uint64, blsInfo signer.ProofOfPossession, message []byte) (ids.ID, ids.ID, error)
- func (d *PublicDeployer) RemoveValidator(controlKeys []string, subnetAuthKeysStrs []string, subnetID ids.ID, ...) (bool, *txs.Tx, []string, error)
- func (d *PublicDeployer) Sign(tx *txs.Tx, subnetAuthKeysStrs []string, subnet ids.ID) error
- func (d *PublicDeployer) TransformSubnetTx(controlKeys []string, subnetAuthKeysStrs []string, ...) (bool, ids.ID, *txs.Tx, []string, error)
- type Publisher
- type RunManager
- func (r *RunManager) ChainConfigDir(nodeNum int) (string, error)
- func (r *RunManager) CleanOldRuns(keep int) error
- func (r *RunManager) CurrentLink() string
- func (r *RunManager) CurrentRunDir() (string, error)
- func (r *RunManager) EnsureRunDir(fresh, newRun bool) (string, error)
- func (r *RunManager) ListRuns() ([]string, error)
- func (r *RunManager) NodeDir(nodeNum int) (string, error)
- func (r *RunManager) ProfileDir() string
- func (r *RunManager) SetCurrent(runDir string) error
- type WarpSpec
Constants ¶
const ( WriteReadReadPerms = 0o644 // ChainHealthTimeout is the maximum time to wait for a newly deployed chain to become healthy ChainHealthTimeout = 30 * time.Second )
Variables ¶
var ErrNoSubnetAuthKeysInWallet = errors.New("auth wallet does not contain subnet auth keys")
Functions ¶
func CopySubnetChainConfigsToNetwork ¶
func CopySubnetChainConfigsToNetwork(app *application.Lux, networkDir string) error
CopySubnetChainConfigsToNetwork copies chain configs from ~/.lux/subnets/<name>/ to each node's chainConfigs/<blockchainID>/ directory. This is necessary because evm requires genesis.json in the chain config directory for initialization. The canonical source is always ~/.lux/subnets/<name>/ and this function ensures the running network nodes have access to these configs.
func DefaultEVMConfig ¶
func DefaultEVMConfig() map[string]interface{}
DefaultEVMConfig returns the default EVM chain configuration with admin API enabled. This applies to all EVM chains including C-chain and deployed chains.
func EnsureNetworkRunDir ¶
EnsureNetworkRunDir ensures a network run directory exists. If "current" symlink exists, reuses it. Otherwise creates a new timestamped run. Use `lux network clean` to wipe and start fresh.
func GetCurrentSupply ¶
func GetDefaultSubnetAirdropKeyInfo ¶
func GetDefaultSubnetAirdropKeyInfo(app *application.Lux, blockchainName string) (string, string, string, error)
GetDefaultSubnetAirdropKeyInfo returns the default airdrop key information for a subnet
func GetFirstEndpoint ¶
func GetFirstEndpoint(clusterInfo *rpcpb.ClusterInfo, chain string) string
GetFirstEndpoint get a human readable endpoint for the given chain
func GetLocallyDeployedNetIDs ¶
func GetLocallyDeployedNetIDs(app *application.Lux) ([]string, error)
GetLocallyDeployedNetIDs returns a list of net IDs for locally deployed nets This is used for auto-tracking nets when starting the local network
func GetLocallyDeployedSubnetIDs ¶
func GetLocallyDeployedSubnetIDs(app *application.Lux) ([]string, error)
GetLocallyDeployedSubnetIDs returns a list of subnet IDs for locally deployed subnets This is used for auto-tracking subnets when starting the local network Deprecated: Use GetLocallyDeployedNetIDs instead
func GetLocallyDeployedSubnets ¶
Returns an error if the server cannot be contacted. You may want to ignore this error.
func GetLocallyDeployedSubnetsFromFile ¶
func GetLocallyDeployedSubnetsFromFile(app *application.Lux) ([]string, error)
func GetPublicSubnetValidators ¶
func GetPublicSubnetValidators(subnetID ids.ID, network models.Network) ([]platformvm.ClientPermissionlessValidator, error)
func GetSubnetValidators ¶
func GetSubnetValidators(subnetID ids.ID) ([]platformvm.ClientPermissionlessValidator, error)
func HasEndpoints ¶
func HasEndpoints(clusterInfo *rpcpb.ClusterInfo) bool
HasEndpoints returns true if cluster info contains custom blockchains
func IsSubnetValidator ¶
func IssueTransformSubnetTx ¶
func PrepareCanonicalChainConfigs ¶
func PrepareCanonicalChainConfigs(app *application.Lux) (string, error)
PrepareCanonicalChainConfigs creates a canonical chain-configs directory at ~/.lux/chain-configs/ with subdirectories for each locally deployed subnet's blockchain ID. This directory can be passed to nodes via --chain-config-dir flag so all nodes share the same chain configs from a single source. Returns the canonical chain configs directory path.
func SetDefaultSnapshot ¶
Initialize default snapshot with bootstrap snapshot archive If force flag is set to true, overwrite the default snapshot if it exists
func ValidateSubnetNameAndGetChains ¶
ValidateSubnetNameAndGetChains validates a subnet name and returns chain information
func WaitForChainHealthyWithTimeout ¶ added in v1.21.40
func WaitForChainHealthyWithTimeout( cli client.Client, chainName string, timeout time.Duration, rootDir string, backendLogDir string, ) (*rpcpb.ClusterInfo, error)
WaitForChainHealthyWithTimeout waits for a chain to become healthy with a specific timeout. Returns an error with helpful diagnostics if the chain fails to become healthy.
func WaitForHealthy ¶
WaitForHealthy polls continuously until the network is ready to be used
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents a chain configuration with overlay support
func NewConfig ¶
func NewConfig(app *application.Lux, chainID string) *Config
NewConfig creates a new chain config for the given chain ID
func NewConfigWithAlias ¶
func NewConfigWithAlias(app *application.Lux, chainID, alias string) *Config
NewConfigWithAlias creates a config with both chain ID and human-readable alias
func (*Config) EffectiveJSON ¶
EffectiveJSON returns the effective config as formatted JSON
func (*Config) EnableAdmin ¶
func (c *Config) EnableAdmin()
EnableAdmin ensures admin API is enabled in the config
func (*Config) LoadGlobal ¶
LoadGlobal loads the global config from ~/.lux/chain-configs/<chainID>/config.json
func (*Config) SaveGlobal ¶
SaveGlobal saves the effective config as the global config
func (*Config) SetCLIOverride ¶
SetCLIOverride sets a CLI override for specific keys
func (*Config) SetCLIOverrides ¶
SetCLIOverrides sets multiple CLI overrides
type LocalDeployer ¶
type LocalDeployer struct {
// contains filtered or unexported fields
}
func NewLocalDeployer ¶
func NewLocalDeployer(app *application.Lux, luxVersion string, vmBin string) *LocalDeployer
func (*LocalDeployer) BackendStartedHere ¶
func (d *LocalDeployer) BackendStartedHere() bool
BackendStartedHere returns true if the backend was started by this run, or false if it found it there already
func (*LocalDeployer) DeployBlockchain ¶
DeployBlockchain deploys a blockchain to the local network
func (*LocalDeployer) DeployToLocalNetwork ¶
func (d *LocalDeployer) DeployToLocalNetwork(chain string, chainGenesis []byte, genesisPath string) (ids.ID, ids.ID, error)
DeployToLocalNetwork deploys to an already running network. It does NOT start the network - use 'lux network start' first.
func (*LocalDeployer) SetupLocalEnv ¶
func (d *LocalDeployer) SetupLocalEnv() (string, error)
SetupLocalEnv also does some heavy lifting: * sets up default snapshot if not installed * checks if node is installed in the local binary path * if not, it downloads it and installs it (os - and archive dependent) * returns the location of the node path
func (*LocalDeployer) StartServer ¶
func (d *LocalDeployer) StartServer() error
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles chain configuration for a network run
func NewManager ¶
func NewManager(app *application.Lux) *Manager
NewManager creates a new chain config manager
func (*Manager) AddChainWithAlias ¶
AddChainWithAlias adds a chain with both ID and alias
func (*Manager) EnableAdminAll ¶
func (m *Manager) EnableAdminAll()
EnableAdminAll enables admin API on all chains
func (*Manager) LoadDeployedChains ¶
LoadDeployedChains discovers and loads configs for all deployed chains
func (*Manager) ToNetrunnerMap ¶
ToNetrunnerMap converts configs to the format expected by netrunner's WithChainConfigs
type PublicDeployer ¶
type PublicDeployer struct {
LocalDeployer
// contains filtered or unexported fields
}
func NewPublicDeployer ¶
func NewPublicDeployer(app *application.Lux, usingLedger bool, kc keychain.Keychain, network models.Network) *PublicDeployer
func (*PublicDeployer) AddValidator ¶
func (d *PublicDeployer) AddValidator( controlKeys []string, subnetAuthKeysStrs []string, subnetID ids.ID, nodeID ids.NodeID, weight uint64, startTime time.Time, duration time.Duration, ) (bool, *txs.Tx, []string, error)
adds a subnet validator to the given [subnetID]
- creates an add subnet validator tx
- sets the change output owner to be a wallet address (if not, it may go to any other subnet auth address)
- signs the tx with the wallet as the owner of fee outputs and a possible subnet auth key
- if partially signed, returns the tx so that it can later on be signed by the rest of the subnet auth keys
- if fully signed, issues it
func (*PublicDeployer) ConvertL1 ¶
func (d *PublicDeployer) ConvertL1( controlKeys []string, subnetAuthKeysStrs []string, subnetID ids.ID, blockchainID ids.ID, managerAddress ethcommon.Address, validators []interface{}, ) (bool, ids.ID, *txs.Tx, []string, error)
ConvertL1 converts a subnet to an L1 (LP99)
func (*PublicDeployer) CreateAssetTx ¶
func (*PublicDeployer) DeployBlockchain ¶
func (d *PublicDeployer) DeployBlockchain( controlKeys []string, subnetAuthKeysStrs []string, subnetID ids.ID, chain string, genesis []byte, ) (bool, ids.ID, *txs.Tx, []string, error)
creates a blockchain for the given [subnetID]
- creates a create blockchain tx
- sets the change output owner to be a wallet address (if not, it may go to any other subnet auth address)
- signs the tx with the wallet as the owner of fee outputs and a possible subnet auth key
- if partially signed, returns the tx so that it can later on be signed by the rest of the subnet auth keys
- if fully signed, issues it
func (*PublicDeployer) DeploySubnet ¶
- creates a subnet for chain using the given [controlKeys] and [threshold] as subnet authentication parameters
func (*PublicDeployer) ExportToPChainTx ¶
func (d *PublicDeployer) ExportToPChainTx( subnetID ids.ID, subnetAssetID ids.ID, owner *secp256k1fx.OutputOwners, assetAmount uint64, ) (ids.ID, error)
func (*PublicDeployer) ImportFromXChain ¶
func (d *PublicDeployer) ImportFromXChain( subnetID ids.ID, owner *secp256k1fx.OutputOwners, ) (ids.ID, error)
func (*PublicDeployer) IncreaseValidatorPChainBalance ¶
func (d *PublicDeployer) IncreaseValidatorPChainBalance( validationID ids.ID, balance uint64, ) error
IncreaseValidatorPChainBalance increases a validator's balance on P-chain
func (*PublicDeployer) RegisterL1Validator ¶
func (d *PublicDeployer) RegisterL1Validator( balance uint64, blsInfo signer.ProofOfPossession, message []byte, ) (ids.ID, ids.ID, error)
RegisterL1Validator registers a validator on the P-Chain for an L1 subnet
func (*PublicDeployer) RemoveValidator ¶
func (d *PublicDeployer) RemoveValidator( controlKeys []string, subnetAuthKeysStrs []string, subnetID ids.ID, nodeID ids.NodeID, ) (bool, *txs.Tx, []string, error)
removes a subnet validator from the given [subnet] - verifies that the wallet is one of the subnet auth keys (so as to sign the AddSubnetValidator tx) - if operation is multisig (len(subnetAuthKeysStrs) > 1):
- creates a remove subnet validator tx
- sets the change output owner to be a wallet address (if not, it may go to any other subnet auth address)
- signs the tx with the wallet as the owner of fee outputs and a possible subnet auth key
- if partially signed, returns the tx so that it can later on be signed by the rest of the subnet auth keys
- if fully signed, issues it
type Publisher ¶
type Publisher interface {
Publish(r *git.Repository, subnetName, vmName string, subnetYAML []byte, vmYAML []byte) error
GetRepo() (*git.Repository, error)
}
func NewPublisher ¶
type RunManager ¶
type RunManager struct {
// contains filtered or unexported fields
}
RunManager manages network run directories with stable symlinks
func NewRunManager ¶
func NewRunManager(app *application.Lux, profile string) *RunManager
NewRunManager creates a new run manager for the given profile
func (*RunManager) ChainConfigDir ¶
func (r *RunManager) ChainConfigDir(nodeNum int) (string, error)
ChainConfigDir returns the chain config directory for a node
func (*RunManager) CleanOldRuns ¶
func (r *RunManager) CleanOldRuns(keep int) error
CleanOldRuns removes old run directories, keeping the N most recent
func (*RunManager) CurrentLink ¶
func (r *RunManager) CurrentLink() string
CurrentLink returns the path to the "current" symlink
func (*RunManager) CurrentRunDir ¶
func (r *RunManager) CurrentRunDir() (string, error)
CurrentRunDir returns the actual run directory that "current" points to
func (*RunManager) EnsureRunDir ¶
func (r *RunManager) EnsureRunDir(fresh, newRun bool) (string, error)
EnsureRunDir ensures a run directory exists with the following behavior: - Default (fresh=false, newRun=false): Reuse current symlink target if it exists - fresh=true: Wipe current target and recreate empty - newRun=true: Create new timestamped directory and update current symlink
func (*RunManager) ListRuns ¶
func (r *RunManager) ListRuns() ([]string, error)
ListRuns returns all run directories for this profile
func (*RunManager) NodeDir ¶
func (r *RunManager) NodeDir(nodeNum int) (string, error)
NodeDir returns the directory for a specific node in the current run
func (*RunManager) ProfileDir ¶
func (r *RunManager) ProfileDir() string
ProfileDir returns the base directory for this profile
func (*RunManager) SetCurrent ¶
func (r *RunManager) SetCurrent(runDir string) error
SetCurrent updates the "current" symlink to point to the specified run
type WarpSpec ¶
type WarpSpec struct {
SkipWarpDeploy bool
SkipRelayerDeploy bool
WarpVersion string
RelayerVersion string
RelayerBinPath string
RelayerLogLevel string
MessengerContractAddressPath string
MessengerDeployerAddressPath string
MessengerDeployerTxPath string
FundedAddress string
RegistryBydecodePath string
}
WarpSpec contains configuration for Warp deployments