Documentation
¶
Overview ¶
Package config provides unified configuration management for the Lux blockchain stack. All components (cli, netrunner, node, evm) should import this package for consistent configuration handling.
Package config provides unified configuration and path management for all Lux tools. This is the single source of truth for directory structures across CLI, netrunner, and node.
Directory Structure:
~/.lux/ # Root data directory
├── chains/ # Unified chain configs (shared by all nodes)
│ └── <chainName>/
│ ├── genesis.json
│ ├── config.json
│ └── upgrade.json
├── networks/ # Network-specific data
│ └── <networkName>/ # mainnet, testnet, local
│ └── runs/
│ └── <runID>/ # run_20251222_102823
│ ├── node1/
│ ├── node2/
│ └── ...
├── plugins/ # VM plugins
│ └── current/ # Active plugins (symlinks)
│ └── <vmid> # e.g., ag3GReYPNuSR17rUP8acMdZipQBikdXNRKDyFszAysmy3vDXE
├── keys/ # Validator keys
│ └── <networkName>/
│ └── <nodeName>/
│ ├── staking.key
│ ├── staking.crt
│ └── signer.key
└── snapshots/ # Network snapshots for save/restore
└── <snapshotName>/
Index ¶
- Constants
- Variables
- func AddAllFlags(fs *pflag.FlagSet)
- func AddGlobalFlags(fs *pflag.FlagSet)
- func AddLogFlags(fs *pflag.FlagSet)
- func AddNetworkFlags(fs *pflag.FlagSet)
- func AddNodeFlags(fs *pflag.FlagSet)
- func CreateDevelopmentLogger(name string) (*zap.Logger, error)
- func CreateNopLogger() *zap.Logger
- func CreateProductionLogger(name string, logDir string) (*zap.Logger, error)
- func Exists(path string) bool
- func FormatError(err error, context string, args ...interface{}) string
- func GPUBackend() string
- func GetChainIDFromGenesis(genesis []byte) (uint64, error)
- func GetFlagDescription(key string) string
- func IsGPUEnabled() bool
- func IsSymlink(path string) bool
- func NewRunID() string
- func ResolvePluginBaseDir() string
- func ResolvePluginDir() string
- func SetGlobal(cfg *LuxConfig)
- func SetGlobalGPUConfig(cfg GPUConfig) error
- func VMID(vmName string) string
- func WellKnownVMIDs() map[string]string
- type AirdropConfig
- type ChainConfig
- type ChainManager
- func (cm *ChainManager) ChainExists(chainName string) bool
- func (cm *ChainManager) CopyChainConfigsToNode(chainName, chainID, nodeDir string) error
- func (cm *ChainManager) DeleteChain(chainName string) error
- func (cm *ChainManager) ListChains() ([]string, error)
- func (cm *ChainManager) LoadChain(chainName string) (*ChainConfig, error)
- func (cm *ChainManager) LoadGenesis(chainName string) ([]byte, error)
- func (cm *ChainManager) SaveChain(cc *ChainConfig) error
- func (cm *ChainManager) SaveGenesis(chainName string, genesis []byte) error
- type ChainStakeRequirement
- type DefaultPluginManager
- func (pm *DefaultPluginManager) EnsureDir() error
- func (pm *DefaultPluginManager) Exists(vmID string) bool
- func (pm *DefaultPluginManager) Get(ctx context.Context, vmID string) (*PluginInfo, error)
- func (pm *DefaultPluginManager) GetPath(vmID string) string
- func (pm *DefaultPluginManager) GetPluginDir() string
- func (pm *DefaultPluginManager) GetTarget(vmID string) (string, error)
- func (pm *DefaultPluginManager) Install(ctx context.Context, source string, vmID string) error
- func (pm *DefaultPluginManager) IsSymlink(vmID string) bool
- func (pm *DefaultPluginManager) Link(vmID, binaryPath string) error
- func (pm *DefaultPluginManager) LinkByName(vmName, binaryPath string) error
- func (pm *DefaultPluginManager) List(ctx context.Context) ([]PluginInfo, error)
- func (pm *DefaultPluginManager) Uninstall(ctx context.Context, vmID string) error
- func (pm *DefaultPluginManager) Verify(vmID string) error
- type GPUConfig
- type Loader
- type LoaderOption
- type LogConfig
- type LogFactory
- type LogFormat
- type LogLevel
- type LoggerAdapter
- type LuxConfig
- func (c *LuxConfig) GetChainsConfigPath() string
- func (c *LuxConfig) GetConfigsPath() string
- func (c *LuxConfig) GetDBPath() string
- func (c *LuxConfig) GetLogPath(name string) string
- func (c *LuxConfig) GetNetsConfigPath() string
- func (c *LuxConfig) GetPluginPath(vmID string) string
- func (c *LuxConfig) GetStakingPath() string
- func (c *LuxConfig) GetVMsConfigPath() string
- func (c *LuxConfig) Validate() error
- type NFTTier
- type NetworkConfig
- type NodeConfig
- type Paths
- func (p *Paths) ChainConfig(chainName string) string
- func (p *Paths) ChainDir(chainName string) string
- func (p *Paths) ChainGenesis(chainName string) string
- func (p *Paths) ChainUpgrade(chainName string) string
- func (p *Paths) ChainsBaseDir() string
- func (p *Paths) CurrentPluginsDir() string
- func (p *Paths) EnsureChainDir(chainName string) error
- func (p *Paths) EnsureCurrentPluginsDir() error
- func (p *Paths) EnsureDir(path string) error
- func (p *Paths) EnsureNetworkRunsDir(networkName string) error
- func (p *Paths) EnsureNodeKeysDir(networkName, nodeName string) error
- func (p *Paths) FindLatestRun(networkName string) (string, error)
- func (p *Paths) GetOrCreateRun(networkName string) (string, error)
- func (p *Paths) KeysBaseDir() string
- func (p *Paths) NetworkDir(networkName string) string
- func (p *Paths) NetworkKeysDir(networkName string) string
- func (p *Paths) NetworkRunDir(networkName, runID string) string
- func (p *Paths) NetworkRunsDir(networkName string) string
- func (p *Paths) NetworksBaseDir() string
- func (p *Paths) NodeDir(networkName, runID, nodeName string) string
- func (p *Paths) NodeKeysDir(networkName, nodeName string) string
- func (p *Paths) NodeSignerKey(networkName, nodeName string) string
- func (p *Paths) NodeStakingCert(networkName, nodeName string) string
- func (p *Paths) NodeStakingKey(networkName, nodeName string) string
- func (p *Paths) PluginPath(vmID string) string
- func (p *Paths) PluginsBaseDir() string
- func (p *Paths) SnapshotDir(snapshotName string) string
- func (p *Paths) SnapshotsBaseDir() string
- type PluginInfo
- type PluginManager
- type PluginManifest
- type PluginPackageManager
- func (pm *PluginPackageManager) Activate(ctx context.Context, org, name, version string) error
- func (pm *PluginPackageManager) ActivePath(vmid string) string
- func (pm *PluginPackageManager) GetActiveDir() string
- func (pm *PluginPackageManager) GetManifest(org, name, version string) (*PluginManifest, error)
- func (pm *PluginPackageManager) Install(ctx context.Context, manifest *PluginManifest, binaryPath string) error
- func (pm *PluginPackageManager) Link(ctx context.Context, manifest *PluginManifest, binaryPath string) error
- func (pm *PluginPackageManager) List(ctx context.Context) ([]PluginManifest, error)
- func (pm *PluginPackageManager) ListActive(ctx context.Context) (map[string]PluginManifest, error)
- func (pm *PluginPackageManager) MigrateFromLegacy(ctx context.Context, legacyDir string) error
- func (pm *PluginPackageManager) PackagePath(org, name, version string) string
- func (pm *PluginPackageManager) Uninstall(ctx context.Context, org, name, version string) error
- type PluginRegistry
- type StakingConfig
- type TokenomicsConfig
Constants ¶
const ( // Core directories DataDirKey = "data-dir" PluginDirKey = "plugin-dir" // Logging LogLevelKey = "log-level" LogFormatKey = "log-format" LogDirKey = "log-dir" LogMaxSizeKey = "log-max-size" LogMaxFilesKey = "log-max-files" LogMaxAgeKey = "log-max-age" LogCompressKey = "log-compress" LogShowCallerKey = "log-show-caller" LogShowColorsKey = "log-show-colors" // Network NetworkIDKey = "network-id" NetworkNameKey = "network-name" NetworkAPIEndpointKey = "api-endpoint" // Node HTTPPortKey = "http-port" StakingPortKey = "staking-port" DBTypeKey = "db-type" // Config file ConfigFileKey = "config-file" )
Flag keys used across all components
const ( // EnvPrefix is the prefix for environment variables EnvPrefix = "LUX" // ConfigFileName is the default config file name (without extension) ConfigFileName = "config" // DefaultDataDir is the default data directory DefaultDataDir = "~/.lux" )
const ( HTTPHostKey = "http-host" BootstrapNodesKey = "bootstrap-nodes" BootstrapIPsKey = "bootstrap-ips" BootstrapIDsKey = "bootstrap-ids" DBPathKey = "db-dir" LogsDirKey = "log-dir" TrackChainsKey = "track-chains" ChainConfigDirKey = "chain-config-dir" NetConfigDirKey = "net-config-dir" GenesisFileKey = "genesis-file" StakingTLSKeyPathKey = "staking-tls-key-file" StakingCertPathKey = "staking-tls-cert-file" StakingSignerKeyPathKey = "staking-signer-key-file" SybilProtectionEnabledKey = "sybil-protection-enabled" IndexEnabledKey = "index-enabled" IndexAllowIncompleteKey = "index-allow-incomplete" NetworkAllowPrivateIPsKey = "network-allow-private-ips" PartialSyncPrimaryNetworkKey = "partial-sync-primary-network" )
Luxd config keys referenced by netrunner/cli.
const ( // Root directory name LuxDir = ".lux" // Top-level directories under ~/.lux/ ChainsDir = "chains" NetworksDir = "networks" PluginsDir = "plugins" KeysDir = "keys" SnapshotsDir = "snapshots" // Subdirectories RunsDir = "runs" CurrentPluginsDir = "current" // File names for chain configs GenesisFile = "genesis.json" ConfigFile = "config.json" UpgradeFile = "upgrade.json" // File names for node keys StakingKeyFile = "staking.key" StakingCertFile = "staking.crt" SignerKeyFile = "signer.key" // Network names NetworkMainnet = "mainnet" NetworkTestnet = "testnet" NetworkLocal = "local" // Run directory prefix RunPrefix = "run" )
Directory names - single source of truth
const ( // Well-known VM names VMNameLuxEVM = "Lux EVM" VMNameCoreVM = "Core VM" VMNameXVM = "XVM" )
const (
LuxNodeDataDirVar = "LUXD_DATA_DIR"
)
Luxd environment variables referenced by cli helpers.
Variables ¶
var FlagDescriptions = map[string]string{ DataDirKey: "Base directory for all Lux data including plugins, logs, database, and configuration files", PluginDirKey: "Directory containing VM plugin binaries. Defaults to $DATA_DIR/plugins if not specified", LogLevelKey: "Minimum log level to output. Available levels: verbo, debug, trace, info, warn, error, fatal, off", LogFormatKey: "Output format for logs. 'terminal' for colored output, 'json' for structured logs, 'plain' for uncolored text", LogDirKey: "Directory where log files are written. Defaults to $DATA_DIR/logs if not specified", LogMaxSizeKey: "Maximum size of a single log file in megabytes before rotation", LogMaxFilesKey: "Maximum number of old log files to retain after rotation", LogMaxAgeKey: "Maximum age in days for old log files. Files older than this are deleted. 0 means no age limit", LogCompressKey: "Whether to compress rotated log files using gzip", LogShowCallerKey: "Include file name and line number in log entries", LogShowColorsKey: "Use ANSI colors in terminal output", NetworkIDKey: "Network ID for the blockchain network", NetworkNameKey: "Human-readable network name (mainnet, testnet, local, or custom)", NetworkAPIEndpointKey: "HTTP endpoint for the node's API", HTTPPortKey: "Port for HTTP API server", StakingPortKey: "Port for staking and P2P connections", DBTypeKey: "Database backend type. Options: badgerdb (default), leveldb, pebbledb, memdb", ConfigFileKey: "Path to configuration file. Supports JSON, YAML, and TOML formats", }
FlagDescription provides descriptions for flags
Functions ¶
func AddGlobalFlags ¶
AddGlobalFlags adds common flags used by all Lux components This should be called by root command of each component
func AddNetworkFlags ¶
AddNetworkFlags adds network-related flags
func CreateDevelopmentLogger ¶
CreateDevelopmentLogger creates a logger suitable for development
func CreateNopLogger ¶
CreateNopLogger creates a no-op logger that discards all output
func CreateProductionLogger ¶
CreateProductionLogger creates a logger suitable for production
func FormatError ¶
FormatError provides consistent error formatting This fixes issues like "last checked %s" format bugs
func GetChainIDFromGenesis ¶
GetChainIDFromGenesis extracts chainID from an EVM genesis file
func GetFlagDescription ¶
GetFlagDescription returns the description for a flag
func IsGPUEnabled ¶
func IsGPUEnabled() bool
IsGPUEnabled returns whether GPU acceleration is enabled globally.
func NewRunID ¶
func NewRunID() string
NewRunID generates a new timestamped run ID Returns: run_20251222_102823
func ResolvePluginBaseDir ¶
func ResolvePluginBaseDir() string
ResolvePluginBaseDir returns the base plugin directory This contains packages/, current/, and registry.json
func ResolvePluginDir ¶
func ResolvePluginDir() string
ResolvePluginDir resolves the plugin directory using the configuration stack This returns the "current" directory where VMID symlinks live for node compatibility Structure:
~/.lux/plugins/ ├── packages/luxfi/evm/v1.0.0/ # Actual packages ├── current/ag3GReY.../ # VMID symlinks (what node uses) └── registry.json
func SetGlobal ¶
func SetGlobal(cfg *LuxConfig)
SetGlobal sets the global configuration instance This should be called early in application startup
func SetGlobalGPUConfig ¶
SetGlobalGPUConfig sets the global GPU configuration. This should be called once during node initialization before any GPU accelerators are created.
func VMID ¶
VMID computes the VM ID from a VM name. This is the standard way to compute VMID: base58check(sha256(pad32(vmName))) Example: "Lux EVM" -> "ag3GReYPNuSR17rUP8acMdZipQBikdXNRKDyFszAysmy3vDXE"
func WellKnownVMIDs ¶
WellKnownVMIDs returns a map of well-known VM names to their IDs
Types ¶
type AirdropConfig ¶
type AirdropConfig struct {
Enabled bool
SnapshotDate string
ConversionRatio float64 // Legacy token to LUX conversion ratio
VestingPeriod uint64 // in seconds
ClaimPeriod uint64 // in seconds
}
AirdropConfig defines airdrop parameters
type ChainConfig ¶
type ChainConfig struct {
Name string // Chain name (e.g., "zoo", "mychain")
Genesis json.RawMessage // Genesis JSON
Config json.RawMessage // Chain config JSON (eth APIs, etc.)
Upgrade json.RawMessage // Upgrade config JSON
}
ChainConfig represents the chain configuration files
type ChainManager ¶
type ChainManager struct {
// contains filtered or unexported fields
}
ChainManager handles unified chain configuration across all nodes
func DefaultChainManager ¶
func DefaultChainManager() (*ChainManager, error)
DefaultChainManager creates a chain manager with default paths
func NewChainManager ¶
func NewChainManager(paths *Paths) *ChainManager
NewChainManager creates a new chain manager
func (*ChainManager) ChainExists ¶
func (cm *ChainManager) ChainExists(chainName string) bool
ChainExists checks if a chain configuration exists
func (*ChainManager) CopyChainConfigsToNode ¶
func (cm *ChainManager) CopyChainConfigsToNode(chainName, chainID, nodeDir string) error
CopyChainConfigsToNode copies chain configs to a node's chain directory This is used when starting nodes to provide chain-specific configuration Destination: <nodeDir>/configs/chains/<chainID>/
func (*ChainManager) DeleteChain ¶
func (cm *ChainManager) DeleteChain(chainName string) error
DeleteChain removes all configuration for a chain
func (*ChainManager) ListChains ¶
func (cm *ChainManager) ListChains() ([]string, error)
ListChains returns all configured chains
func (*ChainManager) LoadChain ¶
func (cm *ChainManager) LoadChain(chainName string) (*ChainConfig, error)
LoadChain loads all configuration for a chain
func (*ChainManager) LoadGenesis ¶
func (cm *ChainManager) LoadGenesis(chainName string) ([]byte, error)
LoadGenesis loads just the genesis file for a chain
func (*ChainManager) SaveChain ¶
func (cm *ChainManager) SaveChain(cc *ChainConfig) error
SaveChain saves chain configuration
func (*ChainManager) SaveGenesis ¶
func (cm *ChainManager) SaveGenesis(chainName string, genesis []byte) error
SaveGenesis saves just the genesis file for a chain
type ChainStakeRequirement ¶
type ChainStakeRequirement struct {
ChainID string
MinimumStake uint64
RequiresSpecialAccess bool // e.g., B-chain bridge validators
AccessRequirements string // Description of special requirements
}
ChainStakeRequirement defines chain-specific staking requirements
type DefaultPluginManager ¶
type DefaultPluginManager struct {
// contains filtered or unexported fields
}
DefaultPluginManager implements PluginManager
func (*DefaultPluginManager) EnsureDir ¶
func (pm *DefaultPluginManager) EnsureDir() error
EnsureDir ensures the plugin directory exists
func (*DefaultPluginManager) Exists ¶
func (pm *DefaultPluginManager) Exists(vmID string) bool
Exists checks if a plugin is installed
func (*DefaultPluginManager) Get ¶
func (pm *DefaultPluginManager) Get(ctx context.Context, vmID string) (*PluginInfo, error)
Get returns info about a specific plugin
func (*DefaultPluginManager) GetPath ¶
func (pm *DefaultPluginManager) GetPath(vmID string) string
GetPath returns the full path for a plugin binary
func (*DefaultPluginManager) GetPluginDir ¶
func (pm *DefaultPluginManager) GetPluginDir() string
GetPluginDir returns the plugin directory
func (*DefaultPluginManager) GetTarget ¶
func (pm *DefaultPluginManager) GetTarget(vmID string) (string, error)
GetTarget returns the target of a plugin symlink
func (*DefaultPluginManager) IsSymlink ¶
func (pm *DefaultPluginManager) IsSymlink(vmID string) bool
IsSymlink checks if a plugin path is a symlink
func (*DefaultPluginManager) Link ¶
func (pm *DefaultPluginManager) Link(vmID, binaryPath string) error
Link creates a symlink from the plugin directory to a VM binary. This is the preferred way to "install" a VM for development.
func (*DefaultPluginManager) LinkByName ¶
func (pm *DefaultPluginManager) LinkByName(vmName, binaryPath string) error
LinkByName creates a symlink using the VM name to compute VMID
func (*DefaultPluginManager) List ¶
func (pm *DefaultPluginManager) List(ctx context.Context) ([]PluginInfo, error)
List returns all installed plugins
func (*DefaultPluginManager) Uninstall ¶
func (pm *DefaultPluginManager) Uninstall(ctx context.Context, vmID string) error
Uninstall removes a plugin
func (*DefaultPluginManager) Verify ¶
func (pm *DefaultPluginManager) Verify(vmID string) error
Verify checks if a plugin is properly installed and executable
type GPUConfig ¶
type GPUConfig struct {
// Enabled controls whether GPU acceleration is used
Enabled bool
// Backend specifies which GPU backend to use: "auto", "metal", "cuda", "cpu"
Backend string
// DeviceIndex specifies which GPU device to use when multiple are available
DeviceIndex int
// LogLevel sets the GPU subsystem log level: "debug", "info", "warn", "error"
LogLevel string
}
GPUConfig holds GPU acceleration configuration.
func DefaultGPUConfig ¶
func DefaultGPUConfig() GPUConfig
DefaultGPUConfig returns the default GPU configuration.
func GetGlobalGPUConfig ¶
func GetGlobalGPUConfig() GPUConfig
GetGlobalGPUConfig returns the global GPU configuration. If not set, returns the default configuration.
func (GPUConfig) ResolveBackend ¶
ResolveBackend returns the actual backend to use based on configuration. If Backend is "auto", it detects the best available backend.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles configuration loading from all sources
func NewLoader ¶
func NewLoader(opts ...LoaderOption) *Loader
NewLoader creates a new configuration loader
func (*Loader) GetConfigFilePath ¶
GetConfigFilePath returns the path of the config file that was loaded
type LoaderOption ¶
type LoaderOption func(*Loader)
LoaderOption is a functional option for the Loader
func WithConfigFile ¶
func WithConfigFile(path string) LoaderOption
WithConfigFile sets an explicit config file path
func WithConfigPaths ¶
func WithConfigPaths(paths ...string) LoaderOption
WithConfigPaths sets custom config search paths
type LogConfig ¶
type LogConfig struct {
// Level is the minimum log level to output
Level string `json:"level" yaml:"level" mapstructure:"level"`
// Format is the log output format (terminal, json, plain)
Format string `json:"format" yaml:"format" mapstructure:"format"`
// Directory is where log files are written
Directory string `json:"directory" yaml:"directory" mapstructure:"directory"`
// MaxSize is the maximum size in megabytes before log rotation
MaxSize int `json:"max-size" yaml:"max-size" mapstructure:"max-size"`
// MaxFiles is the maximum number of old log files to retain
MaxFiles int `json:"max-files" yaml:"max-files" mapstructure:"max-files"`
// MaxAge is the maximum number of days to retain old log files
MaxAge int `json:"max-age" yaml:"max-age" mapstructure:"max-age"`
// Compress enables compression of rotated log files
Compress bool `json:"compress" yaml:"compress" mapstructure:"compress"`
// ShowCaller shows caller information in log entries
ShowCaller bool `json:"show-caller" yaml:"show-caller" mapstructure:"show-caller"`
// ShowColors enables colored output for terminal format
ShowColors bool `json:"show-colors" yaml:"show-colors" mapstructure:"show-colors"`
}
LogConfig defines unified logging settings
type LogFactory ¶
type LogFactory struct {
// contains filtered or unexported fields
}
LogFactory creates configured loggers
func NewLogFactory ¶
func NewLogFactory(cfg LogConfig) *LogFactory
NewLogFactory creates a new log factory from configuration
func NewLogFactoryFromGlobal ¶
func NewLogFactoryFromGlobal() *LogFactory
NewLogFactoryFromGlobal creates a log factory from global config
func (*LogFactory) CreateLogger ¶
func (f *LogFactory) CreateLogger(name string) (*zap.Logger, error)
CreateLogger creates a new logger with the given name
type LoggerAdapter ¶
LoggerAdapter wraps zap.Logger to provide additional functionality
func NewLoggerAdapter ¶
func NewLoggerAdapter(logger *zap.Logger) *LoggerAdapter
NewLoggerAdapter creates a new logger adapter
func (*LoggerAdapter) Sugared ¶
func (l *LoggerAdapter) Sugared() *zap.SugaredLogger
Sugared returns the sugared logger for printf-style logging
func (*LoggerAdapter) WithContext ¶
func (l *LoggerAdapter) WithContext(ctx map[string]interface{}) *LoggerAdapter
WithContext adds common context fields
type LuxConfig ¶
type LuxConfig struct {
// DataDir is the base directory for all Lux data
DataDir string `json:"data-dir" yaml:"data-dir" mapstructure:"data-dir"`
// PluginDir is the directory for VM plugins
PluginDir string `json:"plugin-dir" yaml:"plugin-dir" mapstructure:"plugin-dir"`
// Log contains logging configuration
Log LogConfig `json:"log" yaml:"log" mapstructure:"log"`
// Network contains network-related configuration
Network NetworkConfig `json:"network" yaml:"network" mapstructure:"network"`
// Node contains node-specific configuration
Node NodeConfig `json:"node" yaml:"node" mapstructure:"node"`
}
LuxConfig is the unified configuration for all Lux components
func DefaultConfig ¶
func DefaultConfig() *LuxConfig
DefaultConfig returns the default configuration
func Global ¶
func Global() *LuxConfig
Global returns the global configuration instance (singleton) This lazily loads configuration on first call
func MustLoad ¶
func MustLoad(opts ...LoaderOption) *LuxConfig
MustLoad loads configuration and panics on error
func (*LuxConfig) GetChainsConfigPath ¶
GetChainsConfigPath returns the chains config directory path
func (*LuxConfig) GetConfigsPath ¶
GetConfigsPath returns the configs directory path
func (*LuxConfig) GetLogPath ¶
GetLogPath returns the full path for a named log file
func (*LuxConfig) GetNetsConfigPath ¶
GetNetsConfigPath returns the nets config directory path
func (*LuxConfig) GetPluginPath ¶
GetPluginPath returns the full path for a plugin binary
func (*LuxConfig) GetStakingPath ¶
GetStakingPath returns the staking keys path
func (*LuxConfig) GetVMsConfigPath ¶
GetVMsConfigPath returns the VMs config directory path
type NFTTier ¶
type NFTTier struct {
Name string
RequiredLUX uint64 // Base LUX requirement with NFT
StakingMultiplier uint32 // Reward multiplier percentage
MaxValidators uint32 // Max validators in this tier
}
NFTTier represents different validator NFT tiers
type NetworkConfig ¶
type NetworkConfig struct {
// ID is the network ID
ID uint32 `json:"id" yaml:"id" mapstructure:"id"`
// Name is the network name (mainnet, testnet, local)
Name string `json:"name" yaml:"name" mapstructure:"name"`
// APIEndpoint is the primary API endpoint
APIEndpoint string `json:"api-endpoint" yaml:"api-endpoint" mapstructure:"api-endpoint"`
}
NetworkConfig defines network-related settings
type NodeConfig ¶
type NodeConfig struct {
// HTTPPort is the HTTP API port
HTTPPort int `json:"http-port" yaml:"http-port" mapstructure:"http-port"`
// StakingPort is the staking/P2P port
StakingPort int `json:"staking-port" yaml:"staking-port" mapstructure:"staking-port"`
// DBType is the database backend type
DBType string `json:"db-type" yaml:"db-type" mapstructure:"db-type"`
}
NodeConfig defines node-specific settings
type Paths ¶
type Paths struct {
// BaseDir is the root data directory (default: ~/.lux)
BaseDir string
}
Paths provides unified path management for Lux tools. Create one instance and use it throughout your application.
func DefaultPaths ¶
DefaultPaths returns a Paths instance using the default base directory (~/.lux)
func (*Paths) ChainConfig ¶
ChainConfig returns the config file path for a chain Returns: ~/.lux/chains/<chainName>/config.json
func (*Paths) ChainDir ¶
ChainDir returns the config directory for a specific chain Returns: ~/.lux/chains/<chainName>/
func (*Paths) ChainGenesis ¶
ChainGenesis returns the genesis file path for a chain Returns: ~/.lux/chains/<chainName>/genesis.json
func (*Paths) ChainUpgrade ¶
ChainUpgrade returns the upgrade file path for a chain Returns: ~/.lux/chains/<chainName>/upgrade.json
func (*Paths) ChainsBaseDir ¶
ChainsBaseDir returns the base directory for all chain configs Returns: ~/.lux/chains/
func (*Paths) CurrentPluginsDir ¶
CurrentPluginsDir returns the directory for active plugin symlinks Returns: ~/.lux/plugins/current/
func (*Paths) EnsureChainDir ¶
EnsureChainDir creates the chain config directory
func (*Paths) EnsureCurrentPluginsDir ¶
EnsureCurrentPluginsDir creates the current plugins directory
func (*Paths) EnsureNetworkRunsDir ¶
EnsureNetworkRunsDir creates the runs directory for a network
func (*Paths) EnsureNodeKeysDir ¶
EnsureNodeKeysDir creates the keys directory for a node
func (*Paths) FindLatestRun ¶
FindLatestRun finds the most recent run directory with node data Returns the run ID (not full path) or empty string if none found
func (*Paths) GetOrCreateRun ¶
GetOrCreateRun finds existing run or creates new one Returns the full path to the run directory
func (*Paths) KeysBaseDir ¶
KeysBaseDir returns the base directory for all keys Returns: ~/.lux/keys/
func (*Paths) NetworkDir ¶
NetworkDir returns the directory for a specific network Returns: ~/.lux/networks/<networkName>/
func (*Paths) NetworkKeysDir ¶
NetworkKeysDir returns the keys directory for a specific network Returns: ~/.lux/keys/<networkName>/
func (*Paths) NetworkRunDir ¶
NetworkRunDir returns a specific run directory Returns: ~/.lux/networks/<networkName>/runs/<runID>/
func (*Paths) NetworkRunsDir ¶
NetworkRunsDir returns the runs directory for a network Returns: ~/.lux/networks/<networkName>/runs/
func (*Paths) NetworksBaseDir ¶
NetworksBaseDir returns the base directory for all networks Returns: ~/.lux/networks/
func (*Paths) NodeDir ¶
NodeDir returns the directory for a specific node within a run Returns: ~/.lux/networks/<networkName>/runs/<runID>/<nodeName>/
func (*Paths) NodeKeysDir ¶
NodeKeysDir returns the keys directory for a specific node Returns: ~/.lux/keys/<networkName>/<nodeName>/
func (*Paths) NodeSignerKey ¶
NodeSignerKey returns the signer key path for a node Returns: ~/.lux/keys/<networkName>/<nodeName>/signer.key
func (*Paths) NodeStakingCert ¶
NodeStakingCert returns the staking cert path for a node Returns: ~/.lux/keys/<networkName>/<nodeName>/staking.crt
func (*Paths) NodeStakingKey ¶
NodeStakingKey returns the staking key path for a node Returns: ~/.lux/keys/<networkName>/<nodeName>/staking.key
func (*Paths) PluginPath ¶
PluginPath returns the path for a specific VM plugin Returns: ~/.lux/plugins/current/<vmID>
func (*Paths) PluginsBaseDir ¶
PluginsBaseDir returns the base directory for all plugins Returns: ~/.lux/plugins/
func (*Paths) SnapshotDir ¶
SnapshotDir returns the directory for a specific snapshot Returns: ~/.lux/snapshots/<snapshotName>/
func (*Paths) SnapshotsBaseDir ¶
SnapshotsBaseDir returns the base directory for all snapshots Returns: ~/.lux/snapshots/
type PluginInfo ¶
type PluginInfo struct {
// VMID is the VM identifier (hash)
VMID string `json:"vm_id"`
// Name is the human-readable name
Name string `json:"name"`
// Version is the plugin version
Version string `json:"version"`
// Path is the full path to the plugin binary
Path string `json:"path"`
// Description is an optional description
Description string `json:"description"`
// Installed indicates if the plugin is installed
Installed bool `json:"installed"`
// Size is the file size in bytes
Size int64 `json:"size"`
// ModTime is the last modification time
ModTime time.Time `json:"mod_time"`
}
PluginInfo describes an installed plugin
type PluginManager ¶
type PluginManager interface {
// GetPluginDir returns the resolved plugin directory
GetPluginDir() string
// List returns all installed plugins
List(ctx context.Context) ([]PluginInfo, error)
// Get returns info about a specific plugin
Get(ctx context.Context, vmID string) (*PluginInfo, error)
// Install installs a plugin from a source path
Install(ctx context.Context, source string, vmID string) error
// Uninstall removes a plugin
Uninstall(ctx context.Context, vmID string) error
// GetPath returns the full path for a plugin binary
GetPath(vmID string) string
// Exists checks if a plugin is installed
Exists(vmID string) bool
// EnsureDir ensures the plugin directory exists
EnsureDir() error
}
PluginManager handles plugin discovery, installation, and loading
func NewPluginManager ¶
func NewPluginManager(cfg *LuxConfig) PluginManager
NewPluginManager creates a new plugin manager
func NewPluginManagerWithDir ¶
func NewPluginManagerWithDir(pluginDir string) PluginManager
NewPluginManagerWithDir creates a plugin manager with a specific directory
type PluginManifest ¶
type PluginManifest struct {
// Name is the package name (e.g., "evm")
Name string `json:"name"`
// Org is the organization/username (e.g., "luxfi")
Org string `json:"org"`
// Version is the semantic version (e.g., "v1.0.0")
Version string `json:"version"`
// VMID is the computed VM identifier hash
VMID string `json:"vmid"`
// VMName is the canonical VM name used to compute VMID
VMName string `json:"vm_name,omitempty"`
// Aliases are alternative names for this VM
Aliases []string `json:"aliases,omitempty"`
// Binary is the executable filename
Binary string `json:"binary"`
// Description is a human-readable description
Description string `json:"description,omitempty"`
// Repository is the source repository URL
Repository string `json:"repository,omitempty"`
// InstalledAt is when the plugin was installed
InstalledAt time.Time `json:"installed_at"`
// Size is the binary size in bytes
Size int64 `json:"size,omitempty"`
}
PluginManifest contains metadata about an installed plugin
type PluginPackageManager ¶
type PluginPackageManager struct {
// contains filtered or unexported fields
}
PluginPackageManager provides proper package manager functionality
func NewPluginPackageManager ¶
func NewPluginPackageManager(baseDir string) (*PluginPackageManager, error)
NewPluginPackageManager creates a new package manager
func (*PluginPackageManager) Activate ¶
func (pm *PluginPackageManager) Activate(ctx context.Context, org, name, version string) error
Activate creates the VMID symlink for a specific version
func (*PluginPackageManager) ActivePath ¶
func (pm *PluginPackageManager) ActivePath(vmid string) string
ActivePath returns the path for VMID symlinks (node compatibility)
func (*PluginPackageManager) GetActiveDir ¶
func (pm *PluginPackageManager) GetActiveDir() string
GetActiveDir returns the directory containing VMID symlinks (for node compatibility)
func (*PluginPackageManager) GetManifest ¶
func (pm *PluginPackageManager) GetManifest(org, name, version string) (*PluginManifest, error)
GetManifest loads the manifest for a specific package version
func (*PluginPackageManager) Install ¶
func (pm *PluginPackageManager) Install(ctx context.Context, manifest *PluginManifest, binaryPath string) error
Install installs a plugin from a binary path
func (*PluginPackageManager) Link ¶
func (pm *PluginPackageManager) Link(ctx context.Context, manifest *PluginManifest, binaryPath string) error
Link creates a symlink-based installation (for development) Unlike Install which copies the binary, Link creates a symlink to the source
func (*PluginPackageManager) List ¶
func (pm *PluginPackageManager) List(ctx context.Context) ([]PluginManifest, error)
List returns all installed packages
func (*PluginPackageManager) ListActive ¶
func (pm *PluginPackageManager) ListActive(ctx context.Context) (map[string]PluginManifest, error)
ListActive returns all active plugins (those with VMID symlinks)
func (*PluginPackageManager) MigrateFromLegacy ¶
func (pm *PluginPackageManager) MigrateFromLegacy(ctx context.Context, legacyDir string) error
MigrateFromLegacy migrates plugins from the old VMID-based structure
func (*PluginPackageManager) PackagePath ¶
func (pm *PluginPackageManager) PackagePath(org, name, version string) string
PackagePath returns the path for a specific package version
type PluginRegistry ¶
type PluginRegistry struct {
// Plugins maps "org/name" to list of installed versions
Plugins map[string][]string `json:"plugins"`
// Active maps VMID to active package reference
Active map[string]string `json:"active"`
// UpdatedAt is when the registry was last modified
UpdatedAt time.Time `json:"updated_at"`
}
PluginRegistry tracks all installed plugins
type StakingConfig ¶
type StakingConfig struct {
// Minimum stake: 1M LUX for validators
MinimumValidatorStake uint64
// NFT staking tiers
NFTStakingEnabled bool
NFTTiers []NFTTier
// Delegation parameters
MinimumDelegatorStake uint64
MaxDelegationRatio uint32
// Chain-specific validator requirements
ChainValidatorRequirements map[string]ChainStakeRequirement
// Combined staking (NFT + delegation + staked) to reach minimum
AllowCombinedStaking bool
}
StakingConfig defines staking parameters
type TokenomicsConfig ¶
type TokenomicsConfig struct {
// Total supply: 2T tokens
TotalSupply uint64
// Airdrop configuration for legacy token holders
AirdropConfig AirdropConfig
// Staking requirements
StakingConfig StakingConfig
// Chain-specific allocations
ChainAllocations map[string]uint64
}
TokenomicsConfig defines the token economics for the Lux Network
func DefaultTokenomicsConfig ¶
func DefaultTokenomicsConfig() *TokenomicsConfig
DefaultTokenomicsConfig returns the default tokenomics configuration
func (*TokenomicsConfig) GetMinimumStake ¶
func (c *TokenomicsConfig) GetMinimumStake(hasNFT bool, nftTier string) uint64
GetMinimumStake returns the minimum stake based on NFT ownership
func (*TokenomicsConfig) GetStakingMultiplier ¶
func (c *TokenomicsConfig) GetStakingMultiplier(nftTier string) uint32
GetStakingMultiplier returns the reward multiplier for a given NFT tier