constants

package module
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: BSD-3-Clause Imports: 9 Imported by: 216

Documentation

Index

Constants

View Source
const (
	// PlatformName exports the name of the platform
	PlatformName = "lux"

	// AppName exports the name of the lux application
	AppName = "node"
)

Const variables to be exported

View Source
const (
	// DefaultEVMVersion is the default Lux EVM version
	DefaultEVMVersion = "v0.8.0"

	// DefaultEVMRPCVersion is the RPC version used by Lux EVM
	// This must match the node's EVM RPC protocol version
	DefaultEVMRPCVersion = 42
)

EVM constants

View Source
const (
	// Remote network API endpoints
	// Each network has: api.lux{-suffix}.network for HTTP, wss.lux{-suffix}.network for WebSocket
	MainnetAPIEndpoint = "https://api.lux.network"
	MainnetWSEndpoint  = "wss://wss.lux.network"
	TestnetAPIEndpoint = "https://api.lux-test.network"
	TestnetWSEndpoint  = "wss://wss.lux-test.network"
	DevnetAPIEndpoint  = "https://api.lux-dev.network"
	DevnetWSEndpoint   = "wss://wss.lux-dev.network"

	// Local network (single-node dev mode or 5-node localnet)
	LocalAPIEndpoint        = "http://127.0.0.1:9630"
	LocalWSEndpoint         = "ws://127.0.0.1:9630/ext/bc/C/ws"
	LocalNetworkID          = LocalID // 1337
	NetrunnerLocalNetworkID = LocalID // 1337
	LocalNetworkNumNodes    = 5

	// Staking constants
	MinStakeDuration     = 24 * 14 * time.Hour  // 2 weeks
	MaxStakeDuration     = 24 * 365 * time.Hour // 1 year
	MinStakeWeight       = uint64(1)
	StakingStartLeadTime = 1 * time.Minute
	TimeParseLayout      = "2006-01-02 15:04:05"

	// Version management
	LuxCompatibilityURL = "https://raw.githubusercontent.com/luxfi/cli/main/lux-compatibility.json"
	DefaultLuxdVersion  = "v1.21.0"
)

CLI and operational constants (extends paths.go)

View Source
const (
	ServerRunFile = "gRPCserver.run"

	SuffixSeparator            = "_"
	SidecarFileName            = "sidecar.json"
	GenesisFileName            = "genesis.json"
	ElasticChainConfigFileName = "elastic_chain_config.json"
	NodeConfigJSONFile         = "node-config.json"
	NodeConfigFileName         = "node-config.json"
	ClusterYAMLFileName        = "cluster.yaml"
	ClustersConfigFileName     = "clusters.json"
	LocalNetworkMetaFile       = "local_network_meta.json"
	LastFileName               = ".last_actions.json"
	CertSuffix                 = ".pem"
	AliasesFileName            = "aliases.json"
	YAMLSuffix                 = ".yml"
	SidecarSuffix              = SuffixSeparator + SidecarFileName
	GenesisSuffix              = SuffixSeparator + GenesisFileName
	NodeFileName               = "node.json"

	SidecarVersion             = "1.4.0"
	LatestPreReleaseVersionTag = "latest-prerelease"
	LatestReleaseVersionTag    = "latest"

	MaxLogFileSize   = 4
	MaxNumOfLogFiles = 5
	RetainOldFiles   = 0 // retain all old log files

	// RequestTimeout lives in paths.go; keep CLI-specific timeouts here.
	E2ERequestTimeout            = 30 * time.Second
	ANRRequestTimeout            = 15 * time.Second
	APIRequestLargeTimeout       = 30 * time.Second
	DefaultWalletCreationTimeout = 5 * time.Second
	DefaultConfirmTxTimeout      = 20 * time.Second

	SimulatePublicNetwork    = "SIMULATE_PUBLIC_NETWORK"
	GithubAPITokenEnvVarName = "LUX_CLI_GITHUB_TOKEN"

	// LPM / CLI dependency URLs
	DefaultLuxPackage      = "luxfi/plugins-core"
	CLIMinVersionURL       = "https://raw.githubusercontent.com/luxfi/cli/main/min-version.json"
	CLILatestDependencyURL = CLIMinVersionURL
	LuxdCompatibilityURL   = LuxCompatibilityURL

	// Default values for relayer and validators
	DefaultRelayerAmount  = float64(10)
	PayTxsFeesMsg         = "pay transaction fees"
	LatestEVMVersion      = "v0.8.13"
	DefaultStakeWeight    = 20
	DefaultConfigFileName = ".lux"
	DefaultConfigFileType = "json"

	// Metrics
	MetricsNetwork            = "network"
	MetricsAPITokenEnvVarName = "METRICS_API_TOKEN"

	// Cloud service constants
	GCPCloudService            = "gcp"
	AWSCloudService            = "aws"
	E2EDocker                  = "e2e-docker"
	E2EClusterName             = "e2e-test-cluster"
	E2ENetworkPrefix           = "10.0.0"
	E2EBaseDirName             = ".e2e-test"
	AnsibleInventoryDir        = "ansible/inventory"
	GCPNodeAnsiblePrefix       = "gcp_node"
	AWSNodeAnsiblePrefix       = "aws_node"
	E2EDockerLoopbackHost      = "127.0.0.1"
	GCPDefaultImageProvider    = "canonical"
	GCPImageFilter             = "ubuntu-os-cloud"
	CloudNodeCLIConfigBasePath = "/home/ubuntu/.lux"
	CodespaceNameEnvVar        = "CODESPACE_NAME"
	AnsibleSSHShellParams      = "-o StrictHostKeyChecking=no"
	RemoteSSHUser              = "ubuntu"
	StakerCertFileName         = "staker.crt"
	StakerKeyFileName          = "staker.key"
	BLSKeyFileName             = "bls.key"
	RingtailKeyFileName        = "ringtail.key"
	MLDSAKeyFileName           = "mldsa.key"
	ValidatorUptimeDeductible  = 5 * time.Minute

	// SSH constants
	SSHSleepBetweenChecks = 1 * time.Second
	SSHFileOpsTimeout     = 10 * time.Second
	SSHScriptTimeout      = 120 * time.Second
	SSHPOSTTimeout        = 30 * time.Second
	SSHDirOpsTimeout      = 30 * time.Second

	// Docker constants
	DockerNodeConfigPath   = "/data/.luxgo/configs"
	WriteReadUserOnlyPerms = 0o600

	// AWS constants
	AWSCloudServerRunningState = "running"

	// this depends on bootstrap snapshot
	DefaultTokenName = "TEST"

	DefaultNumberOfLocalMachineNodes = 5

	// Staking constants
	BootstrapValidatorBalanceNanoLUX = 1_000_000_000_000 // 1000 LUX
	BootstrapValidatorWeight         = 20                // Default validator weight
	PoSL1MinimumStakeDurationSeconds = 86400             // 24 hours
	StakingMinimumLeadTime           = 25 * time.Second

	// Logging
	DefaultAggregatorLogLevel = "INFO"

	// Git
	GitExtension       = ".git"
	GitRepoCommitName  = "Lux CLI"
	GitRepoCommitEmail = "[email protected]"

	// Ansible
	AnsibleHostInventoryFileName = "hosts"
	AnsibleSSHUseAgentParams     = "-o ForwardAgent=yes"

	// Cloud node
	CloudNodeConfigPath           = "/home/ubuntu/.luxgo/configs"
	CloudNodePrometheusConfigPath = "/home/ubuntu/.luxgo/configs/prometheus"
	CloudNodeStakingPath          = "/home/ubuntu/.luxgo/staking"
	UpgradeFileName               = "upgrade.json"
	UpgradeBytesFileName          = "upgrade.json"
	NodePrometheusConfigFileName  = "prometheus.yml"
	ServicesDir                   = "services"
	WarpRelayerInstallDir         = "warp-relayer"
	WarpRelayerConfigFilename     = "warp-relayer.yml"

	// Config keys
	ConfigSnapshotsAutoSaveKey    = "SnapshotsAutoSaveEnabled"
	ConfigUpdatesDisabledKey      = "UpdatesDisabled"
	ConfigMetricsUserIDKey        = "metrics-user-id"
	ConfigMetricsEnabledKey       = "metrics-enabled"
	ConfigAuthorizeCloudAccessKey = "authorize-cloud-access"

	// Build environment
	BuildEnvGolangVersion = "1.24.5"

	// Docker images and repos
	LuxdDockerImage = NodeDockerImage
	LuxdGitRepo     = NodeGitURL
	LuxdRepoName    = NodeRepoName

	// Install directories
	LuxInstallDir     = "lux"
	LuxNodeInstallDir = "luxd"
	LuxGoInstallDir   = "luxd" // Deprecated: use LuxNodeInstallDir
	EVMInstallDir     = "evm"
	WarpDir           = "warp"
	WarpBranch        = "main"
	WarpURL           = "https://github.com/luxfi/warp.git"
	VMDir             = "vms"

	// CLI-specific directories (not in shared constants)
	CurrentPluginDir = "current" // Active plugins symlinked here (under PluginDir)
	DashboardsDir    = "dashboards"
	ChainConfigDir   = "chains"

	// Unified chain config file names (used in ~/.lux/chains/<chainName>/)
	ChainConfigFile         = "config.json"  // Chain-specific config (eth-apis, etc.)
	UnifiedChainGenesisFile = "genesis.json" // Chain genesis
	UnifiedChainUpgradeFile = "upgrade.json" // Chain upgrades
	ChainChainConfigFile    = "chain.json"   // Chain/validator config for the chain

	// Network structure: ~/.lux/networks/<networkName>/runs/<runID>/
	// This keeps network state persistent across runs
	NetworkRunsDir = "runs"

	// CLI commands / toggles
	Enable         = "enable"
	Disable        = "disable"
	SkipUpdateFlag = "skip-update-check"

	// CLI install URL
	CliInstallationURL     = "https://raw.githubusercontent.com/luxfi/cli/main/scripts/install.sh"
	EVMRPCCompatibilityURL = "https://raw.githubusercontent.com/luxfi/evm/main/compatibility.json"

	// Default node RPC URL
	DefaultNodeRunURL = "http://127.0.0.1:9630"

	// Warp addresses
	DefaultWarpMessengerAddress      = "0x0000000000000000000000000000000000000005"
	MainnetCChainWarpRegistryAddress = "0x0000000000000000000000000000000000000006"

	// Devnet flags
	DevnetFlagsProposerVMUseCurrentHeight = true

	// Per-node chain config
	PerNodeChainConfigFileName = "per-node-chain.json"

	// Grafana
	CustomGrafanaDashboardJSON = "custom_dashboard.json"

	// Cloud node paths
	CloudNodeEVMBinaryPath = "/home/ubuntu/.cli/bin/evm"
)

CLI-specific constants shared across tooling.

View Source
const (
	APIRole         = "api"
	ValidatorRole   = "validator"
	MonitorRole     = "monitor"
	WarpRelayerRole = "warp-relayer"
)

CLI/infra roles.

View Source
const (
	SSHTCPPort         = 22
	LuxdAPIPort        = 9630
	LuxdP2PPort        = 9651
	LuxdMonitoringPort = 9090
	LuxdGrafanaPort    = 3000
	LuxdLokiPort       = 23101
)

Default ports used by tooling.

View Source
const (
	SSHLongRunningScriptTimeout      = 10 * time.Minute
	CloudOperationTimeout            = 5 * time.Minute
	CloudServerStorageSize           = 100 // GB
	MonitoringCloudServerStorageSize = 200 // GB
	GCPStaticIPPrefix                = "lux-"
	IPAddressSuffix                  = "-ip"
	ErrReleasingGCPStaticIP          = "error releasing GCP static IP"
)

Cloud/infra timeouts and limits.

View Source
const (
	// LuxServerCmd is the base command name for the gRPC backend server.
	// Network-specific variants: lux-mainnet-grpc, lux-testnet-grpc, etc.
	LuxServerCmd = "lux-server"
	// BackendCmd is deprecated, use LuxServerCmd instead.
	BackendCmd = LuxServerCmd

	LuxMainnetGRPCCmd = "lux-mainnet-grpc"
	LuxTestnetGRPCCmd = "lux-testnet-grpc"
	LuxDevnetGRPCCmd  = "lux-devnet-grpc"
	LuxCustomGRPCCmd  = "lux-custom-grpc"
)

gRPC backend server command names.

View Source
const (
	// Network IDs (P-Chain) - these identify the PRIMARY NETWORK
	// mainnet, testnet, devnet: proper public networks (can run locally with validators)
	// Network IDs (P-Chain) — identify the primary network
	MainnetID  uint32 = 1    // Production
	TestnetID  uint32 = 2    // Staging
	DevnetID   uint32 = 3    // Development
	LocalID    uint32 = 1337 // Local single/multi-node dev
	UnitTestID uint32 = 369

	// Backward compat aliases
	LuxMainnetID = MainnetID
	LuxTestnetID = TestnetID
	CustomID     = LocalID // deprecated: use LocalID

	// Chain IDs (C-Chain EVM) — for wallets/dApps
	MainnetChainID uint32 = 96369
	TestnetChainID uint32 = 96368
	DevnetChainID  uint32 = 96370
	LocalChainID   uint32 = 1337
	CustomChainID         = LocalChainID // deprecated: use LocalChainID

	// Q-Chain Network IDs
	QChainMainnetID uint32 = 36963
	QChainTestnetID uint32 = 36962

	// Network name strings
	MainnetName  = "mainnet"
	TestnetName  = "testnet"
	DevnetName   = "devnet"
	LocalName    = "local"
	CustomName   = LocalName // deprecated: use LocalName
	UnitTestName = "testing"

	// HRP (Human Readable Part) for bech32 addresses
	// Determines address prefix: P-lux1..., X-test1..., P-local1...
	MainnetHRP  = "lux"    // P-lux1..., X-lux1...
	TestnetHRP  = "test"   // P-test1..., X-test1...
	DevnetHRP   = "dev"    // P-dev1..., X-dev1...
	LocalHRP    = "local"  // P-local1..., X-local1... (network 1337)
	CustomHRP   = "custom" // P-custom1..., X-custom1... (any other network ID)
	UnitTestHRP = "testing"
)

Const variables to be exported

View Source
const (
	// The network must be "tcp", "tcp4", "tcp6", "unix" or "unixpacket".
	NetworkType = "tcp"

	DefaultMaxMessageSize  = 2 * MiB
	DefaultPingPongTimeout = 30 * time.Second
	DefaultPingFrequency   = 3 * DefaultPingPongTimeout / 4
	DefaultByteSliceCap    = 128

	MaxContainersLen = int(4 * DefaultMaxMessageSize / 5)

	DefaultNetworkPeerListNumValidatorIPs        = 15
	DefaultNetworkPeerListValidatorGossipSize    = 20
	DefaultNetworkPeerListNonValidatorGossipSize = 0
	DefaultNetworkPeerListPeersGossipSize        = 10
	DefaultNetworkPeerListGossipFreq             = time.Minute
	DefaultNetworkPeerListPullGossipFreq         = 2 * time.Second
	DefaultNetworkPeerListBloomResetFreq         = time.Minute

	// Inbound Connection Throttling
	DefaultInboundConnUpgradeThrottlerCooldown = 10 * time.Second
	DefaultInboundThrottlerMaxConnsPerSec      = 256

	// Outbound Connection Throttling
	DefaultOutboundConnectionThrottlingRps = 50
	DefaultOutboundConnectionTimeout       = 30 * time.Second

	// Timeouts
	DefaultNetworkInitialTimeout                   = 5 * time.Second
	DefaultNetworkMinimumTimeout                   = 2 * time.Second
	DefaultNetworkMaximumTimeout                   = 10 * time.Second
	DefaultNetworkMaximumInboundTimeout            = 10 * time.Second
	DefaultNetworkTimeoutHalflife                  = 5 * time.Minute
	DefaultNetworkTimeoutCoefficient               = 2
	DefaultNetworkReadHandshakeTimeout             = 15 * time.Second
	DefaultNoIngressValidatorConnectionGracePeriod = 10 * time.Minute

	DefaultNetworkCompressionType           = CompressionTypeZstd
	DefaultNetworkMaxClockDifference        = time.Minute
	DefaultNetworkRequireValidatorToConnect = false
	DefaultNetworkPeerReadBufferSize        = 8 * KiB
	DefaultNetworkPeerWriteBufferSize       = 8 * KiB

	DefaultNetworkTCPProxyEnabled = false

	// The PROXY protocol specification recommends setting this value to be at
	// least 3 seconds to cover a TCP retransmit.
	// Ref: https://www.haproxy.org/download/2.3/doc/proxy-protocol.txt
	// Specifying a timeout of 0 will actually result in a timeout of 200ms, but
	// a timeout of 0 should generally not be provided.
	DefaultNetworkTCPProxyReadTimeout = 3 * time.Second

	// Benchlist
	DefaultBenchlistFailThreshold      = 10
	DefaultBenchlistDuration           = 15 * time.Minute
	DefaultBenchlistMinFailingDuration = 2*time.Minute + 30*time.Second

	// Router
	DefaultConsensusAppConcurrency  = 2
	DefaultConsensusShutdownTimeout = time.Minute
	DefaultFrontierPollFrequency    = 100 * time.Millisecond

	// Inbound Throttling
	DefaultInboundThrottlerAtLargeAllocSize         = 6 * MiB
	DefaultInboundThrottlerVdrAllocSize             = 32 * MiB
	DefaultInboundThrottlerNodeMaxAtLargeBytes      = DefaultMaxMessageSize
	DefaultInboundThrottlerMaxProcessingMsgsPerNode = 1024
	DefaultInboundThrottlerBandwidthRefillRate      = 512 * KiB
	DefaultInboundThrottlerBandwidthMaxBurstSize    = DefaultMaxMessageSize
	DefaultInboundThrottlerCPUMaxRecheckDelay       = 5 * time.Second
	DefaultInboundThrottlerDiskMaxRecheckDelay      = 5 * time.Second
	MinInboundThrottlerMaxRecheckDelay              = time.Millisecond

	// Outbound Throttling
	DefaultOutboundThrottlerAtLargeAllocSize    = 32 * MiB
	DefaultOutboundThrottlerVdrAllocSize        = 32 * MiB
	DefaultOutboundThrottlerNodeMaxAtLargeBytes = DefaultMaxMessageSize

	// Network Health
	DefaultHealthCheckAveragerHalflife = 10 * time.Second

	DefaultNetworkHealthMaxTimeSinceMsgSent     = time.Minute
	DefaultNetworkHealthMaxTimeSinceMsgReceived = time.Minute
	DefaultNetworkHealthMaxPortionSendQueueFill = 0.9
	DefaultNetworkHealthMinPeers                = 1
	DefaultNetworkHealthMaxSendFailRate         = .9

	// Metrics
	DefaultUptimeMetricFreq = 30 * time.Second

	// Delays
	DefaultNetworkInitialReconnectDelay = time.Second
	DefaultNetworkMaxReconnectDelay     = time.Minute
)
View Source
const (
	// NodeBinaryName is the name of the node binary executable
	NodeBinaryName = "luxd"

	// NodeInstallDir is the subdirectory for node binary under ~/.lux/bin/
	NodeInstallDir = "node"
)

Binary configuration

View Source
const (
	// SnapshotPrefix is the prefix for network snapshot directories
	// Full path: ~/.lux/snapshots/lux-snapshot-{name}/
	SnapshotPrefix = "lux-snapshot-"

	// DefaultSnapshotName is the default snapshot name
	DefaultSnapshotName = "default-20251225"

	// Network-specific snapshot names
	MainnetSnapshotName = "mainnet-20251225"
	TestnetSnapshotName = "testnet-20251225"
	DevnetSnapshotName  = "devnet-20251225"
	CustomSnapshotName  = "custom-20251225"
)

Snapshot configuration

View Source
const (
	// BinDir is the subdirectory for binaries
	BinDir = "bin"

	// NetDir is the subdirectory for network data
	NetDir = "net"

	// LuxCliBinDir is an alias for BinDir (backward compatibility with CLI)
	LuxCliBinDir = BinDir

	// SnapshotsDir is the subdirectory for network snapshots
	SnapshotsDir = "snapshots"

	// SnapshotsDirName is an alias for SnapshotsDir
	SnapshotsDirName = SnapshotsDir

	// RunsDir is the subdirectory for runtime data
	RunsDir = "runs"

	// RunDir is an alias for RunsDir (backward compatibility with CLI)
	RunDir = RunsDir

	// PluginsDir is the subdirectory for VM plugins
	PluginsDir = "plugins"

	// PluginDir is an alias for PluginsDir
	PluginDir = PluginsDir

	// LogDir is the subdirectory for logs
	LogDir = "logs"

	// ConfigDir is the subdirectory for configuration
	ConfigDir = "config"

	// KeyDir is the subdirectory for keys
	KeyDir = "keys"

	// ChainsDir is the subdirectory for chain definitions
	ChainsDir = "chains"

	// NetworksDir is the subdirectory for network state
	NetworksDir = "networks"

	// CustomVMDir is the subdirectory for custom VMs
	CustomVMDir = "customvms"

	// ReposDir is the subdirectory for repositories
	ReposDir = "repos"

	// LPMDir is the subdirectory for LPM
	LPMDir = ".lpm"

	// LPMPluginDir is the subdirectory for LPM plugins
	LPMPluginDir = "lpm-plugins"

	// DevDir is the subdirectory for dev mode data
	// Used by 'lux dev start' for single-node development
	DevDir = "dev"
)

Directory structure

View Source
const (
	DefaultPerms755            = 0o755
	WriteReadReadPerms         = 0o644
	WriteReadOnlyPerms         = 0o600
	UserOnlyWriteReadExecPerms = 0o700 // User read/write/execute only
)

File permissions

View Source
const (
	// ElasticNetConfigFileName is the filename for elastic network config
	ElasticNetConfigFileName = "elastic.json"

	// LPMLogName is the filename for LPM logs
	LPMLogName = "lpm.log"

	// UpgradeBytesLockExtension is the lock file extension for upgrade bytes
	UpgradeBytesLockExtension = ".lock"
)

File names and extensions

View Source
const (
	// DefaultHTTPPort is the default HTTP API port
	DefaultHTTPPort = 9630

	// DefaultStakingPort is the default staking/P2P port
	DefaultStakingPort = 9631
)

Default ports

View Source
const (
	RequestTimeout    = 3 * time.Minute
	APIRequestTimeout = 30 * time.Second
)

Timeouts

View Source
const (
	// LuxOrg is the GitHub organization
	LuxOrg = "luxfi"

	// Repository names
	NodeRepoName      = "node"
	EVMRepoName       = "evm"
	NetrunnerRepoName = "netrunner"
	CLIRepoName       = "cli"
	CliRepoName       = CLIRepoName
	ConstantsRepoName = "constants"
	SDKRepoName       = "sdk"
	WalletRepoName    = "wallet"

	// Aliases for backward compatibility
	LuxRepoName = NodeRepoName // deprecated: use NodeRepoName
)

Organization and repository names

View Source
const (

	// NetrunnerBinaryName is the name of the netrunner executable
	NetrunnerBinaryName = "netrunner"

	// EVMBinaryName is the name of the EVM plugin
	EVMBinaryName = "evm"
	// EVMBin is a compatibility alias for EVMBinaryName.
	EVMBin = EVMBinaryName

	// CLIBinaryName is the name of the CLI executable
	CLIBinaryName = "lux"
)

Binary names

View Source
const (
	NodeDockerImage = "luxfi/luxd"
	EVMDockerImage  = "luxfi/evm"
)

Docker images

View Source
const (
	NodeGitURL      = "https://github.com/luxfi/node"
	EVMGitURL       = "https://github.com/luxfi/evm"
	NetrunnerGitURL = "https://github.com/luxfi/netrunner"
	CLIGitURL       = "https://github.com/luxfi/cli"
)

Git URLs

View Source
const (
	EnvNodePath      = "LUX_NODE_PATH"
	EnvNetrunnerPath = "LUX_NETRUNNER_PATH"
	EnvEVMPath       = "LUX_EVM_PATH"
	EnvPluginsDir    = "LUX_PLUGINS_DIR"
)

Environment variables for binary paths

View Source
const (
	ConfigNodePath      = "node-path"
	ConfigNetrunnerPath = "netrunner-path"
	ConfigEVMPath       = "evm-path"
	ConfigPluginsDir    = "plugins-dir"
)

Config keys for binary paths (viper/config file keys)

View Source
const (
	// gRPC server ports (lux-server) - aligned with chain ID pattern
	GRPCPortTestnet = 8368 // testnet gRPC server (chain ID 96368)
	GRPCPortMainnet = 8369 // mainnet gRPC server (chain ID 96369)
	GRPCPortDevnet  = 8370 // devnet gRPC server (chain ID 96370)
	GRPCPortCustom  = 8371 // custom network gRPC server (chainID 1337)
	GRPCPortDev     = 8546 // dev mode gRPC server (Anvil-compatible, HTTP on 8545)

	// Aliases for backward compatibility
	// "custom" is deprecated, use "local" instead
	GRPCPortLocal        = GRPCPortCustom        // canonical; GRPCPortCustom is the deprecated alias
	GRPCGatewayPortLocal = GRPCGatewayPortCustom // canonical; GRPCGatewayPortCustom is the deprecated alias

	// Gateway ports - offset by 10 from gRPC
	GRPCGatewayPortTestnet = 8378 // testnet gateway
	GRPCGatewayPortMainnet = 8379 // mainnet gateway
	GRPCGatewayPortDevnet  = 8380 // devnet gateway
	GRPCGatewayPortCustom  = 8381 // custom gateway
	GRPCGatewayPortDev     = 8556 // dev mode gateway

	// Node API base ports
	NodePortMainnet = 9630 // mainnet first node API port
	NodePortTestnet = 9640 // testnet first node API port
	NodePortDevnet  = 9650 // devnet first node API port
	NodePortCustom  = 9660 // custom network first node API port (chainID 1337)
	NodePortDev     = 8545 // dev mode single-node (Anvil-compatible)

	// gRPC client configuration
	GRPCClientLogLevel = "error"
	GRPCDialTimeout    = 5 * time.Second // Reduced for faster local development
)

lux-server gRPC ports for multi-network support Each network type has dedicated ports to allow simultaneous operation All 4 networks (mainnet, testnet, devnet, custom) can run in parallel - mainnet, testnet, devnet: proper public networks (can run locally with validators) - local: for local development with chainID 1337 ("custom" is deprecated alias) Port scheme: aligned with chain IDs (8368-8371 for gRPC, 8378-8381 for gateway)

View Source
const (
	KiB = 1024       // 1 kibibyte
	MiB = 1024 * KiB // 1 mebibyte
	GiB = 1024 * MiB // 1 gibibyte
)

Byte size units

View Source
const (
	MicroLux uint64 = 1               // Base unit (6 decimals) - 0.000001 LUX
	MilliLux uint64 = 1000 * MicroLux // 0.001 LUX
	Lux      uint64 = 1000 * MilliLux // 1 LUX = 10^6 microLUX
	KiloLux  uint64 = 1000 * Lux      // 1,000 LUX
	MegaLux  uint64 = 1000 * KiloLux  // 1,000,000 LUX
	GigaLux  uint64 = 1000 * MegaLux  // 1,000,000,000 LUX (1 billion)
	TeraLux  uint64 = 1000 * GigaLux  // 1,000,000,000,000 LUX (1 trillion)

	// Schmeckle preserved for compatibility (≈49.463 milliLUX)
	Schmeckle uint64 = 49*MilliLux + 463*MicroLux

	// NanoLux deprecated - use MicroLux as base unit.
	// Kept for backward compatibility but represents the same as MicroLux.
	NanoLux uint64 = MicroLux
)

Denominations of value LUX uses 6 decimals (like USDC), allowing max supply of ~18.4 trillion LUX in uint64.

View Source
const (
	PlatformVMName  = "platformvm"  // P-Chain: Platform/Validators
	XVMName         = "xvm"         // X-Chain: UTXO Exchange
	EVMName         = "evm"         // C-Chain: EVM Smart Contracts
	XSVMName        = "xsvm"        // Cross-Chain VM
	QuantumVMName   = "quantumvm"   // Q-Chain: Quantum-resistant security
	AIVMName        = "aivm"        // A-Chain: AI Virtual Machine
	BridgeVMName    = "bridgevm"    // B-Chain: Bridge/Cross-chain
	ThresholdVMName = "thresholdvm" // T-Chain: Threshold signatures
	KeyVMName       = "keyvm"       // K-Chain: Key Management
	ZKVMName        = "zkvm"        // Z-Chain: Zero-Knowledge proofs
	GraphVMName     = "graphvm"     // G-Chain: GraphQL/DGraph unified data layer
	DexVMName       = "dexvm"       // D-Chain: Decentralized Exchange
	OracleVMName    = "oraclevm"    // O-Chain: Oracle/Off-chain Data
	RelayVMName     = "relayvm"     // R-Chain: Cross-chain Relay/Messages
	IdentityVMName  = "identityvm"  // I-Chain: Decentralized Identity
)
View Source
const (
	// BaseDirName is the default directory name for Lux data
	// Located at ~/.lux on all platforms
	BaseDirName = ".lux"
)

Base directory configuration - consistent across node, netrunner, cli

View Source
const ChainAliasPrefix string = "bc"

ChainAliasPrefix denotes a prefix for an alias that belongs to a blockchain ID.

View Source
const (
	KeySuffix = ".pk"
)

Key file suffixes.

View Source
const PointerOverhead = 8

PointerOverhead is used to approximate the memory footprint from allocating a pointer.

View Source
const VMAliasPrefix string = "vm"

VMAliasPrefix denotes a prefix for an alias that belongs to a VM ID.

Variables

View Source
var (
	ErrNoBlockchainID                 = errors.New("\n\nNo blockchainID found. To resolve this:\n- Use 'lux blockchain deploy' to deploy the blockchain and generate a blockchainID.\n- Or use 'lux blockchain import' to import an existing configuration.\n") //nolint:staticcheck // ST1005: intentional formatting for user-friendly error messages
	ErrNoChainID                      = errors.New("\n\nNo chainID found. To resolve this:\n- Use 'lux blockchain deploy' to create the chain and generate a chainID.\n- Or use 'lux blockchain import' to import an existing configuration.\n")                //nolint:staticcheck // ST1005: intentional formatting for user-friendly error messages
	ErrInvalidValidatorManagerAddress = errors.New("invalid validator manager address")
	ErrKeyNotFoundOnMap               = errors.New("key not found on map")
)
View Source
var (
	// ActivatedACPs is the set of ACPs that are activated.
	//
	// See: https://github.com/orgs/luxfi/projects/1
	ActivatedACPs = set.Of[uint32](

		23,
		24,
		25,
		30,
		31,
		41,
		62,

		77,
		103,
		118,
		125,
		131,
		151,
	)

	// CurrentACPs is the set of ACPs that are currently, at the time of
	// release, marked as implementable and not activated.
	//
	// See: https://github.com/orgs/luxfi/projects/1
	CurrentACPs = set.Of[uint32](
		176,
	)

	// ScheduledACPs are the ACPs included into the next upgrade.
	ScheduledACPs = set.Of[uint32](
		176,
	)

	// CurrentLPs is the set of supported Lux Protocols
	CurrentLPs = set.Of[uint32](176)

	// ScheduledLPs are the LPs included in the next upgrade
	ScheduledLPs = set.Of[uint32](176)

	// ActivatedLPs is the set of activated LPs
	ActivatedLPs = set.Of[uint32](176)
)
View Source
var (
	PrimaryNetworkID = ids.Empty
	PlatformChainID  = ids.PChainID // P-Chain: 11111111111111111111111111111111P

	// Chain IDs - these identify specific chains WITHIN a network
	// NOT to be confused with Network IDs
	// Native chains have a recognizable pattern: all zeros except last byte which is the chain letter
	// These are provided by the ids package for consistent display across the ecosystem
	CChainID = ids.CChainID // C-Chain: 11111111111111111111111111111111C
	XChainID = ids.XChainID // X-Chain: 11111111111111111111111111111111X
	QChainID = ids.QChainID // Q-Chain: 11111111111111111111111111111111Q
	AChainID = ids.AChainID // A-Chain: 11111111111111111111111111111111A
	BChainID = ids.BChainID // B-Chain: 11111111111111111111111111111111B
	TChainID = ids.TChainID // T-Chain: 11111111111111111111111111111111T
	ZChainID = ids.ZChainID // Z-Chain: 11111111111111111111111111111111Z (Zero-knowledge)
	GChainID = ids.GChainID // G-Chain: 11111111111111111111111111111111G (Graph/dgraph)
	KChainID = ids.KChainID // K-Chain: 11111111111111111111111111111111K (KMS)
	DChainID = ids.DChainID // D-Chain: 11111111111111111111111111111111D (DEX)

	// NetworkIDToNetworkName maps network IDs to human-readable names
	NetworkIDToNetworkName = map[uint32]string{
		MainnetID:      MainnetName,
		TestnetID:      TestnetName,
		DevnetID:       DevnetName,
		LocalID:        LocalName,
		UnitTestID:     UnitTestName,
		MainnetChainID: MainnetName,
		TestnetChainID: TestnetName,
		DevnetChainID:  DevnetName,
	}

	// NetworkNameToNetworkID maps names to network IDs
	NetworkNameToNetworkID = map[string]uint32{
		MainnetName:  MainnetID,
		TestnetName:  TestnetID,
		DevnetName:   DevnetID,
		LocalName:    LocalID,
		"custom":     LocalID,
		UnitTestName: UnitTestID,
	}

	// NetworkIDToHRP maps network IDs to bech32 address prefix
	// 1 → P-lux1..., 2 → P-test1..., 3 → P-dev1..., 1337 → P-local1...
	// Unknown network IDs fall back to "custom" HRP
	NetworkIDToHRP = map[uint32]string{
		MainnetID:      MainnetHRP,
		TestnetID:      TestnetHRP,
		DevnetID:       DevnetHRP,
		LocalID:        LocalHRP,
		UnitTestID:     UnitTestHRP,
		MainnetChainID: MainnetHRP,
		TestnetChainID: TestnetHRP,
		DevnetChainID:  DevnetHRP,
	}

	// NetworkHRPToNetworkID maps HRP back to network ID
	NetworkHRPToNetworkID = map[string]uint32{
		MainnetHRP:  MainnetID,
		TestnetHRP:  TestnetID,
		DevnetHRP:   DevnetID,
		LocalHRP:    LocalID,
		"custom":    LocalID,
		UnitTestHRP: UnitTestID,
	}

	// ProductionNetworkIDs are networks that should use production-grade settings
	ProductionNetworkIDs = set.Of(MainnetID, TestnetID, MainnetChainID, TestnetChainID)

	ValidNetworkPrefix = "network-"

	ErrParseNetworkName = errors.New("failed to parse network name")
	ErrNetworkNotFound  = errors.New("network not found in registry")
	ErrUnknownChain     = errors.New("unknown chain name")
)

Variables to be exported

View Source
var (
	PlatformVMID    = ids.ID{'p', 'l', 'a', 't', 'f', 'o', 'r', 'm', 'v', 'm'}
	ExchangeVMID    = ids.ID{'a', 'v', 'm'} // X-Chain: UTXO Exchange
	XVMID           = ExchangeVMID          // Alias for ExchangeVMID
	ContractVMID    = ids.ID{'e', 'v', 'm'} // C-Chain: EVM Smart Contracts
	EVMID           = ContractVMID          // Alias for ContractVMID
	XSVMID          = ids.ID{'x', 's', 'v', 'm'}
	QuantumVMID     = ids.ID{'q', 'u', 'a', 'n', 't', 'u', 'm', 'v', 'm'}
	QVMID           = QuantumVMID                // Alias for QuantumVMID
	AttestationVMID = ids.ID{'a', 'i', 'v', 'm'} // A-Chain: Attestation/AI VM
	AIVMID          = AttestationVMID            // Alias for AttestationVMID
	BridgeVMID      = ids.ID{'b', 'r', 'i', 'd', 'g', 'e', 'v', 'm'}
	ThresholdVMID   = ids.ID{'t', 'h', 'r', 'e', 's', 'h', 'o', 'l', 'd', 'v', 'm'}
	KeyVMID         = ids.ID{'k', 'e', 'y', 'v', 'm'} // K-Chain: Key Management
	KVMID           = KeyVMID                         // Alias for KeyVMID
	ZKVMID          = ids.ID{'z', 'k', 'v', 'm'}
	GraphVMID       = ids.ID{'g', 'r', 'a', 'p', 'h', 'v', 'm'}
	DexVMID         = ids.ID{'d', 'e', 'x', 'v', 'm'}                          // D-Chain: Decentralized Exchange
	OracleVMID      = ids.ID{'o', 'r', 'a', 'c', 'l', 'e', 'v', 'm'}           // O-Chain: Oracle
	OVMID           = OracleVMID                                               // Alias for OracleVMID
	RelayVMID       = ids.ID{'r', 'e', 'l', 'a', 'y', 'v', 'm'}                // R-Chain: Relay
	RVMID           = RelayVMID                                                // Alias for RelayVMID
	IdentityVMID    = ids.ID{'i', 'd', 'e', 'n', 't', 'i', 't', 'y', 'v', 'm'} // I-Chain: Identity
	IVMID           = IdentityVMID                                             // Alias for IdentityVMID
)
View Source
var BlackholeAddr = common.Address{
	1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}

BlackholeAddr is the address where assets are burned.

View Source
var DefaultRegistry = NewChainRegistry()

DefaultRegistry is the global chain registry with default configurations.

View Source
var EtnaActivationTime = map[uint32]time.Time{
	TestnetID:      time.Date(2024, time.November, 25, 16, 0, 0, 0, time.UTC),
	MainnetID:      time.Date(2024, time.December, 16, 17, 0, 0, 0, time.UTC),
	LocalNetworkID: time.Unix(0, 0),
}

EtnaActivationTime provides network activation times for Etna.

Functions

func GetHRP

func GetHRP(networkID uint32) string

GetHRP returns the Human-Readable-Part of bech32 addresses for a networkID

func GetNetworkCChainID

func GetNetworkCChainID(networkID uint32) ids.ID

GetNetworkCChainID returns the C-chain ID for the given network.

func GetNetworkPChainID

func GetNetworkPChainID(networkID uint32) ids.ID

GetNetworkPChainID returns the P-chain ID for the given network.

func GetNetworkQChainID

func GetNetworkQChainID(networkID uint32) ids.ID

GetNetworkQChainID returns the Q-chain ID for the given network.

func GetNetworkStateFile

func GetNetworkStateFile(networkType string) string

GetNetworkStateFile returns the state file name for a network type Each network has its own state file to allow parallel operation

func GetNetworkXChainID

func GetNetworkXChainID(networkID uint32) ids.ID

GetNetworkXChainID returns the X-chain ID for the given network.

func GetServerCmdForNetwork

func GetServerCmdForNetwork(networkType string) string

GetServerCmdForNetwork returns the network-specific gRPC server command name.

func IsValidNetworkType

func IsValidNetworkType(networkType string) bool

IsValidNetworkType checks if the network type is valid

func NetworkID

func NetworkID(networkName string) (uint32, error)

NetworkID returns the ID of the network with name [networkName]

func NetworkName

func NetworkName(networkID uint32) string

NetworkName returns a human readable name for the network with ID [networkID]

func VMName

func VMName(vmID ids.ID) string

VMName returns the name of the VM with the provided ID. If a human readable name isn't known, then the formatted ID is returned.

func ValidNetworkTypes

func ValidNetworkTypes() []string

ValidNetworkTypes returns all valid network types mainnet, testnet, devnet: proper public networks (can also run locally) custom: for custom local development with chainID 1337 dev: single-node Anvil-compatible mode on port 8545

Types

type ChainConfig

type ChainConfig struct {
	NetworkID uint32

	PChainID ids.ID // Platform chain - staking, validation
	XChainID ids.ID // Exchange chain - UTXO asset exchange
	CChainID ids.ID // Contract chain - EVM smart contracts
	QChainID ids.ID // Quantum chain - post-quantum cryptography
	AChainID ids.ID // Attestation chain - oracles, compute attestation
	BChainID ids.ID // Bridge chain - cross-chain interop
	TChainID ids.ID // Threshold chain - FHE, threshold crypto
	ZChainID ids.ID // ZK chain - zero-knowledge proofs
	GChainID ids.ID // Graph chain - dgraph
	KChainID ids.ID // KMS chain - key management
	DChainID ids.ID // DEX chain - native DEX
}

ChainConfig holds the chain IDs for a specific network. This allows chain IDs to be dynamically configured per network, enabling migration to new chain IDs without code changes.

func GetChainConfig

func GetChainConfig(networkID uint32) *ChainConfig

GetChainConfig returns the chain configuration for a network.

type ChainRegistry

type ChainRegistry struct {
	// contains filtered or unexported fields
}

ChainRegistry provides dynamic lookup of chain IDs per network. It supports runtime configuration and migration of chain IDs.

func NewChainRegistry

func NewChainRegistry() *ChainRegistry

NewChainRegistry creates a new chain registry.

func (*ChainRegistry) GetAChainID

func (r *ChainRegistry) GetAChainID(networkID uint32) ids.ID

GetAChainID returns the A-chain ID for the given network.

func (*ChainRegistry) GetBChainID

func (r *ChainRegistry) GetBChainID(networkID uint32) ids.ID

GetBChainID returns the B-chain ID for the given network.

func (*ChainRegistry) GetCChainID

func (r *ChainRegistry) GetCChainID(networkID uint32) ids.ID

GetCChainID returns the C-chain ID for the given network.

func (*ChainRegistry) GetConfig

func (r *ChainRegistry) GetConfig(networkID uint32) *ChainConfig

GetConfig returns the chain configuration for a network. Returns nil if no configuration exists.

func (*ChainRegistry) GetDChainID

func (r *ChainRegistry) GetDChainID(networkID uint32) ids.ID

GetDChainID returns the D-chain ID for the given network.

func (*ChainRegistry) GetOrDefault

func (r *ChainRegistry) GetOrDefault(networkID uint32) *ChainConfig

GetOrDefault returns the chain configuration for a network, or the default (mainnet) configuration if not found.

func (*ChainRegistry) GetPChainID

func (r *ChainRegistry) GetPChainID(networkID uint32) ids.ID

GetPChainID returns the P-chain ID for the given network.

func (*ChainRegistry) GetQChainID

func (r *ChainRegistry) GetQChainID(networkID uint32) ids.ID

GetQChainID returns the Q-chain ID for the given network.

func (*ChainRegistry) GetTChainID

func (r *ChainRegistry) GetTChainID(networkID uint32) ids.ID

GetTChainID returns the T-chain ID for the given network.

func (*ChainRegistry) GetXChainID

func (r *ChainRegistry) GetXChainID(networkID uint32) ids.ID

GetXChainID returns the X-chain ID for the given network.

func (*ChainRegistry) GetZChainID

func (r *ChainRegistry) GetZChainID(networkID uint32) ids.ID

GetZChainID returns the Z-chain ID for the given network.

func (*ChainRegistry) MigrateChain

func (r *ChainRegistry) MigrateChain(networkID uint32, chainName string, newChainID ids.ID) error

MigrateChain updates a chain ID for a network. This triggers migration callbacks and is used for chain upgrades.

func (*ChainRegistry) OnMigrate

func (r *ChainRegistry) OnMigrate(callback func(networkID uint32, oldConfig, newConfig *ChainConfig))

OnMigrate registers a callback for chain migration events.

func (*ChainRegistry) RegisterConfig

func (r *ChainRegistry) RegisterConfig(config *ChainConfig)

RegisterConfig registers a chain configuration for a network.

type CompressionType

type CompressionType byte
const (
	CompressionTypeNone CompressionType = iota + 1
	CompressionTypeZstd
)

func CompressionTypeFromString

func CompressionTypeFromString(s string) (CompressionType, error)

func (CompressionType) MarshalJSON

func (t CompressionType) MarshalJSON() ([]byte, error)

func (CompressionType) String

func (t CompressionType) String() string

type HTTPAccess

type HTTPAccess string

HTTPAccess represents HTTP access configuration.

const (
	HTTPAccessPublic  HTTPAccess = "public"
	HTTPAccessPrivate HTTPAccess = "private"
)

type NetworkGRPCPorts

type NetworkGRPCPorts struct {
	Server  int
	Gateway int
}

NetworkGRPCPorts holds gRPC port configuration for a network type

func GetGRPCPorts

func GetGRPCPorts(networkType string) NetworkGRPCPorts

GetGRPCPorts returns the gRPC ports for a given network type

type NetworkPorts

type NetworkPorts struct {
	GRPC      int // lux-server gRPC port
	Gateway   int // lux-server gateway port
	NodeBase  int // First node API port (each node uses 2 ports)
	NetworkID uint32
}

NetworkPorts holds all port configuration for a network type

func GetNetworkPorts

func GetNetworkPorts(networkType string) NetworkPorts

GetNetworkPorts returns all port configuration for a network type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL