chore: remove local replace directives

This commit is contained in:
2026-01-08 23:43:50 -08:00
parent 182bc3f6be
commit 81372fca2f
8 changed files with 370 additions and 9 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ const (
DBTypeKey = "db-type"
// Config file
ConfigFileKey = "config"
ConfigFileKey = "config-file"
)
// AddGlobalFlags adds common flags used by all Lux components
+1 -1
View File
@@ -1,6 +1,6 @@
module github.com/luxfi/config
go 1.24.0
go 1.24.9
require (
github.com/btcsuite/btcutil v1.0.2
+14
View File
@@ -11,7 +11,9 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
@@ -19,21 +21,29 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4=
github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI=
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
@@ -49,6 +59,7 @@ github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSW
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc=
go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
@@ -63,10 +74,13 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
+129
View File
@@ -0,0 +1,129 @@
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package config
import (
"fmt"
"runtime"
"sync"
)
// GPUConfig holds GPU acceleration configuration.
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
}
// DefaultGPUConfig returns the default GPU configuration.
func DefaultGPUConfig() GPUConfig {
return GPUConfig{
Enabled: true,
Backend: "auto",
DeviceIndex: 0,
LogLevel: "warn",
}
}
// Validate checks that the GPU configuration is valid.
func (c GPUConfig) Validate() error {
switch c.Backend {
case "auto", "metal", "cuda", "cpu":
// Valid backends
default:
return fmt.Errorf("invalid GPU backend %q: must be auto, metal, cuda, or cpu", c.Backend)
}
// Validate backend is supported on current platform
if c.Backend == "metal" && runtime.GOOS != "darwin" {
return fmt.Errorf("metal backend is only supported on macOS")
}
if c.Backend == "cuda" && runtime.GOOS == "darwin" {
return fmt.Errorf("cuda backend is not supported on macOS")
}
if c.DeviceIndex < 0 {
return fmt.Errorf("GPU device index must be non-negative")
}
switch c.LogLevel {
case "debug", "info", "warn", "error":
// Valid log levels
default:
return fmt.Errorf("invalid GPU log level %q: must be debug, info, warn, or error", c.LogLevel)
}
return nil
}
// ResolveBackend returns the actual backend to use based on configuration.
// If Backend is "auto", it detects the best available backend.
func (c GPUConfig) ResolveBackend() string {
if !c.Enabled {
return "cpu"
}
if c.Backend != "auto" {
return c.Backend
}
// Auto-detect based on platform
switch runtime.GOOS {
case "darwin":
return "metal"
case "linux":
return "cuda"
default:
return "cpu"
}
}
// Global GPU configuration (set during node initialization)
var (
globalGPUConfig GPUConfig
globalGPUConfigOnce sync.Once
globalGPUConfigSet bool
)
// SetGlobalGPUConfig sets the global GPU configuration.
// This should be called once during node initialization before any GPU accelerators are created.
func SetGlobalGPUConfig(cfg GPUConfig) error {
var setErr error
globalGPUConfigOnce.Do(func() {
if err := cfg.Validate(); err != nil {
setErr = err
return
}
globalGPUConfig = cfg
globalGPUConfigSet = true
})
return setErr
}
// GetGlobalGPUConfig returns the global GPU configuration.
// If not set, returns the default configuration.
func GetGlobalGPUConfig() GPUConfig {
if !globalGPUConfigSet {
return DefaultGPUConfig()
}
return globalGPUConfig
}
// IsGPUEnabled returns whether GPU acceleration is enabled globally.
func IsGPUEnabled() bool {
return GetGlobalGPUConfig().Enabled
}
// GPUBackend returns the configured GPU backend.
func GPUBackend() string {
return GetGlobalGPUConfig().ResolveBackend()
}
+30
View File
@@ -0,0 +1,30 @@
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package config
// Luxd config keys referenced by netrunner/cli.
const (
HTTPHostKey = "http-host"
BootstrapIPsKey = "bootstrap-ips"
BootstrapIDsKey = "bootstrap-ids"
DBPathKey = "db-dir"
LogsDirKey = "log-dir"
TrackChainsKey = "track-chains"
ChainConfigDirKey = "chain-config-dir"
NetConfigDirKey = "subnet-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 environment variables referenced by cli helpers.
const (
LuxNodeDataDirVar = "LUXD_DATA_DIR"
)
+3 -3
View File
@@ -61,9 +61,9 @@ const (
UpgradeFile = "upgrade.json"
// File names for node keys
StakingKeyFile = "staking.key"
StakingCertFile = "staking.crt"
SignerKeyFile = "signer.key"
StakingKeyFile = "staking.key"
StakingCertFile = "staking.crt"
SignerKeyFile = "signer.key"
// Network names
NetworkMainnet = "mainnet"
+5 -4
View File
@@ -427,10 +427,11 @@ func ResolvePluginBaseDir() 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
//
// ~/.lux/plugins/
// ├── packages/luxfi/evm/v1.0.0/ # Actual packages
// ├── current/ag3GReY.../ # VMID symlinks (what node uses)
// └── registry.json
func ResolvePluginDir() string {
baseDir := ResolvePluginBaseDir()
+187
View File
@@ -0,0 +1,187 @@
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package config
// TokenomicsConfig defines the token economics for the Lux Network
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
}
// AirdropConfig defines airdrop parameters
type AirdropConfig struct {
Enabled bool
SnapshotDate string
ConversionRatio float64 // Legacy token to LUX conversion ratio
VestingPeriod uint64 // in seconds
ClaimPeriod uint64 // in seconds
}
// StakingConfig defines staking parameters
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
}
// NFTTier represents different validator NFT tiers
type NFTTier struct {
Name string
RequiredLUX uint64 // Base LUX requirement with NFT
StakingMultiplier uint32 // Reward multiplier percentage
MaxValidators uint32 // Max validators in this tier
}
// ChainStakeRequirement defines chain-specific staking requirements
type ChainStakeRequirement struct {
ChainID string
MinimumStake uint64
RequiresSpecialAccess bool // e.g., B-chain bridge validators
AccessRequirements string // Description of special requirements
}
// DefaultTokenomicsConfig returns the default tokenomics configuration
func DefaultTokenomicsConfig() *TokenomicsConfig {
return &TokenomicsConfig{
// 10 Billion total supply (with 9 decimals = 10^19 units)
TotalSupply: 10_000_000_000_000_000_000, // 10B tokens with 9 decimals
AirdropConfig: AirdropConfig{
Enabled: true,
SnapshotDate: "2025-01-01T00:00:00Z",
ConversionRatio: 1000.0, // 1 legacy token = 1000 LUX
VestingPeriod: 365 * 24 * 60 * 60, // 1 year
ClaimPeriod: 90 * 24 * 60 * 60, // 90 days to claim
},
StakingConfig: StakingConfig{
// 1M LUX minimum for validators (can be combined)
MinimumValidatorStake: 1_000_000_000_000_000, // 1M tokens with 9 decimals
NFTStakingEnabled: true,
NFTTiers: []NFTTier{
{
Name: "Genesis",
RequiredLUX: 500_000_000_000_000, // 500K LUX with Genesis NFT
StakingMultiplier: 200, // 2x rewards
MaxValidators: 100,
},
{
Name: "Pioneer",
RequiredLUX: 750_000_000_000_000, // 750K LUX with Pioneer NFT
StakingMultiplier: 150, // 1.5x rewards
MaxValidators: 500,
},
{
Name: "Standard",
RequiredLUX: 1_000_000_000_000_000, // 1M LUX standard
StakingMultiplier: 100, // 1x rewards
MaxValidators: 0, // Unlimited
},
},
// Delegation minimum: 25K LUX
MinimumDelegatorStake: 25_000 * 1e9,
MaxDelegationRatio: 10, // 10x validator stake
// Allow combined staking (NFT value + delegated + staked = 1M+)
AllowCombinedStaking: true,
// Chain-specific requirements
ChainValidatorRequirements: map[string]ChainStakeRequirement{
"P": {
ChainID: "P",
MinimumStake: 1_000_000 * 1e9, // 1M LUX standard
},
"C": {
ChainID: "C",
MinimumStake: 1_000_000 * 1e9, // 1M LUX standard
},
"X": {
ChainID: "X",
MinimumStake: 1_000_000 * 1e9, // 1M LUX standard
},
"A": {
ChainID: "A",
MinimumStake: 1_000_000 * 1e9, // 1M LUX for AI chain
},
"B": {
ChainID: "B",
MinimumStake: 100_000_000 * 1e9, // 100M LUX for bridge validators
RequiresSpecialAccess: true,
AccessRequirements: "Bridge validator requires 100M LUX stake and KYC verification",
},
"Z": {
ChainID: "Z",
MinimumStake: 1_000_000 * 1e9, // 1M LUX standard
},
},
},
// Chain allocations (percentage of total supply)
ChainAllocations: map[string]uint64{
"P-Chain": 1_500_000_000_000_000_000, // 1.5B for staking/governance (15%)
"X-Chain": 2_000_000_000_000_000_000, // 2B for exchanges/liquidity (20%)
"C-Chain": 3_000_000_000_000_000_000, // 3B for smart contracts/DeFi (30%)
"A-Chain": 1_500_000_000_000_000_000, // 1.5B for attestation operations (15%)
"B-Chain": 1_000_000_000_000_000_000, // 1B for bridge liquidity (10%)
"Z-Chain": 1_000_000_000_000_000_000, // 1B for privacy/ZK operations (10%)
},
}
}
// GetMinimumStake returns the minimum stake based on NFT ownership
func (c *TokenomicsConfig) GetMinimumStake(hasNFT bool, nftTier string) uint64 {
if !hasNFT || !c.StakingConfig.NFTStakingEnabled {
return c.StakingConfig.MinimumValidatorStake
}
for _, tier := range c.StakingConfig.NFTTiers {
if tier.Name == nftTier {
return tier.RequiredLUX
}
}
return c.StakingConfig.MinimumValidatorStake
}
// GetStakingMultiplier returns the reward multiplier for a given NFT tier
func (c *TokenomicsConfig) GetStakingMultiplier(nftTier string) uint32 {
if !c.StakingConfig.NFTStakingEnabled {
return 100 // Default 1x multiplier
}
for _, tier := range c.StakingConfig.NFTTiers {
if tier.Name == nftTier {
return tier.StakingMultiplier
}
}
return 100 // Default 1x multiplier
}