fix: rename custom → localnet, EVM chainId 31337

- custom/ → localnet/ (1337 is localnet, not custom)
- LocalnetID=1337 (P-Chain networkID)
- LocalnetChainID=31337 (C-Chain EVM chainId, matches Anvil convention)
- CustomID deprecated → use LocalID from luxfi/constants
- anything not mainnet/testnet/devnet/localnet is custom (--genesis-file)
This commit is contained in:
Hanzo AI
2026-04-08 13:33:11 -07:00
parent 7a09480b25
commit 0ef529faab
7 changed files with 26 additions and 25 deletions
+2 -2
View File
@@ -659,7 +659,7 @@ func FromFlag(networkID uint32, genesisContent string, stakingCfg *StakingConfig
// FromDatabase returns genesis data for database replay mode
func FromDatabase(networkID uint32, dbPath string, dbType string, stakingCfg *StakingConfig) ([]byte, ids.ID, error) {
config := genesiscfg.GetConfig(constants.CustomID)
config := genesiscfg.GetConfig(constants.LocalID)
config.NetworkID = networkID
config.Message = "DATABASE_REPLAY_MODE"
return FromConfig(config)
@@ -880,7 +880,7 @@ func ForDevMode(cfg DevModeConfig, stakingCfg *StakingConfig) ([]byte, ids.ID, e
// Build the genesis config
config := &genesiscfg.Config{
NetworkID: constants.CustomID,
NetworkID: constants.LocalID,
Allocations: []genesiscfg.Allocation{allocation},
StartTime: startTime,
InitialStakeDuration: hundredYears,
+16 -15
View File
@@ -25,22 +25,23 @@ import (
)
// Network ID constants (P-Chain)
// mainnet, testnet, devnet: proper public networks (can run locally with validators)
// custom: for custom local development with chainID 1337
// mainnet, testnet, devnet: proper public networks
// localnet: local development with LIGHT mnemonic (networkID=1337, EVM chainID=31337)
// anything else is custom (override via --genesis-file)
const (
MainnetID = 1
TestnetID = 2
DevnetID = 3
CustomID = 1337 // custom local development network
MainnetID = 1
TestnetID = 2
DevnetID = 3
LocalnetID = 1337
// Chain ID constants (C-Chain EVM) - can be used as network ID aliases
MainnetChainID = 96369
TestnetChainID = 96368
DevnetChainID = 96370
CustomChainID = 1337
// Chain ID constants (C-Chain EVM)
MainnetChainID = 96369
TestnetChainID = 96368
DevnetChainID = 96370
LocalnetChainID = 31337
)
//go:embed mainnet testnet devnet custom
//go:embed mainnet testnet devnet localnet
var embeddedGenesis embed.FS
// GetGenesis returns the genesis JSON bytes for a network ID.
@@ -228,8 +229,8 @@ func networkNameFromID(networkID uint32) string {
return "testnet"
case DevnetID, DevnetChainID:
return "devnet"
case CustomID: // CustomChainID == CustomID (both 1337)
return "custom"
case LocalnetID: // LocalnetChainID == LocalnetID (both 1337)
return "localnet"
default:
return ""
}
@@ -320,7 +321,7 @@ func buildCanonicalGenesisFromSplitFiles(networkName string) ([]byte, error) {
func loadGenesisFromFS(networkID uint32) ([]byte, error) {
networkName := networkNameFromID(networkID)
if networkName == "" {
networkName = "custom"
networkName = "localnet"
}
home, _ := os.UserHomeDir()
@@ -1,6 +1,6 @@
{
"config": {
"chainId": 1337,
"chainId": 31337,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
@@ -100,7 +100,7 @@
},
"8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": {
"balance": "0x0",
"comment": "EWOQ key disabled use mnemonic-derived keys only"
"comment": "EWOQ key disabled \u2014 use mnemonic-derived keys only"
}
},
"nonce": "0x0",
@@ -113,4 +113,4 @@
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
}
@@ -85,7 +85,7 @@
"unlockSchedule": []
}
],
"cChainGenesis": "{\"config\":{\"chainId\":1337,\"homesteadBlock\":0,\"eip150Block\":0,\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0,\"berlinBlock\":0,\"londonBlock\":0,\"arrowGlacierBlock\":0,\"grayGlacierBlock\":0,\"mergeNetsplitBlock\":0,\"shanghaiTime\":0,\"cancunTime\":0,\"terminalTotalDifficulty\":0,\"chainEVMTimestamp\":0,\"durangoTimestamp\":0,\"etnaTimestamp\":0,\"fortunaTimestamp\":0,\"graniteTimestamp\":0,\"blobSchedule\":{\"cancun\":{\"target\":3,\"max\":6,\"baseFeeUpdateFraction\":3338477}},\"feeConfig\":{\"gasLimit\":15000000,\"targetBlockRate\":1,\"minBaseFee\":1000000000,\"targetGas\":60000000,\"baseFeeChangeDenominator\":36,\"minBlockGasCost\":0,\"maxBlockGasCost\":1000000,\"blockGasCostStep\":200000},\"warpConfig\":{\"blockTimestamp\":0,\"quorumNumerator\":67,\"requirePrimaryNetworkSigners\":false}},\"nonce\":\"0x0\",\"timestamp\":\"0x0\",\"extraData\":\"0x\",\"gasLimit\":\"0xe4e1c0\",\"difficulty\":\"0x0\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"coinbase\":\"0x0000000000000000000000000000000000000000\",\"alloc\":{\"0200000000000000000000000000000000000005\":{\"balance\":\"0x0\",\"code\":\"0x01\",\"nonce\":\"0x1\"},\"9011E888251AB053B7bD1cdB598Db4f9DEd94714\":{\"balance\":\"0x193e5939a08ce9dbd480000000\"},\"35D64Ff3f618f7a17DF34DCb21be375A4686a8de\":{\"balance\":\"0x19d971e4fe8401e74000000\"},\"f39Fd6e51aad88F6F4ce6aB8827279cffFb92266\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"70997970C51812dc3A010C7d01b50e0d17dc79C8\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"3C44CdDdB6a900fa2b585dd299e03d12FA4293BC\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"90F79bf6EB2c4f870365E785982E1f101E93b906\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"15d34AAf54267DB7D7c367839AAf71A00a2C6A65\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"9965507D1a55bcC2695C58ba16FB37d819B0A4dc\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"976EA74026E726554dB657fA54763abd0C3a0aa9\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"14dC79964da2C08b23698B3D3cc7Ca32193d9955\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"a0Ee7A142d267C1f36714E4a8F75612F20a79720\":{\"balance\":\"0x21e19e0c9bab2400000\"}},\"number\":\"0x0\",\"gasUsed\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"baseFeePerGas\":\"0x3b9aca00\"}",
"cChainGenesis": "{\"config\":{\"chainId\":31337,\"homesteadBlock\":0,\"eip150Block\":0,\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0,\"berlinBlock\":0,\"londonBlock\":0,\"arrowGlacierBlock\":0,\"grayGlacierBlock\":0,\"mergeNetsplitBlock\":0,\"shanghaiTime\":0,\"cancunTime\":0,\"terminalTotalDifficulty\":0,\"chainEVMTimestamp\":0,\"durangoTimestamp\":0,\"etnaTimestamp\":0,\"fortunaTimestamp\":0,\"graniteTimestamp\":0,\"blobSchedule\":{\"cancun\":{\"target\":3,\"max\":6,\"baseFeeUpdateFraction\":3338477}},\"feeConfig\":{\"gasLimit\":15000000,\"targetBlockRate\":1,\"minBaseFee\":1000000000,\"targetGas\":60000000,\"baseFeeChangeDenominator\":36,\"minBlockGasCost\":0,\"maxBlockGasCost\":1000000,\"blockGasCostStep\":200000},\"warpConfig\":{\"blockTimestamp\":0,\"quorumNumerator\":67,\"requirePrimaryNetworkSigners\":false}},\"nonce\":\"0x0\",\"timestamp\":\"0x0\",\"extraData\":\"0x\",\"gasLimit\":\"0xe4e1c0\",\"difficulty\":\"0x0\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"coinbase\":\"0x0000000000000000000000000000000000000000\",\"alloc\":{\"0200000000000000000000000000000000000005\":{\"balance\":\"0x0\",\"code\":\"0x01\",\"nonce\":\"0x1\"},\"9011E888251AB053B7bD1cdB598Db4f9DEd94714\":{\"balance\":\"0x193e5939a08ce9dbd480000000\"},\"35D64Ff3f618f7a17DF34DCb21be375A4686a8de\":{\"balance\":\"0x19d971e4fe8401e74000000\"},\"f39Fd6e51aad88F6F4ce6aB8827279cffFb92266\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"70997970C51812dc3A010C7d01b50e0d17dc79C8\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"3C44CdDdB6a900fa2b585dd299e03d12FA4293BC\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"90F79bf6EB2c4f870365E785982E1f101E93b906\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"15d34AAf54267DB7D7c367839AAf71A00a2C6A65\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"9965507D1a55bcC2695C58ba16FB37d819B0A4dc\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"976EA74026E726554dB657fA54763abd0C3a0aa9\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"14dC79964da2C08b23698B3D3cc7Ca32193d9955\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f\":{\"balance\":\"0x21e19e0c9bab2400000\"},\"a0Ee7A142d267C1f36714E4a8F75612F20a79720\":{\"balance\":\"0x21e19e0c9bab2400000\"}},\"number\":\"0x0\",\"gasUsed\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"baseFeePerGas\":\"0x3b9aca00\"}",
"initialStakeDuration": 31536000,
"initialStakeDurationOffset": 5400,
"initialStakedFunds": [
@@ -158,4 +158,4 @@
"zChainGenesis": "{\"version\":1,\"message\":\"Lux Chain Genesis\"}",
"gChainGenesis": "{\"version\":1,\"message\":\"Lux Chain Genesis\"}",
"kChainGenesis": "{\"version\":1,\"message\":\"Lux Chain Genesis\"}"
}
}
+3 -3
View File
@@ -25,9 +25,9 @@ func GetConfig(networkID uint32) *Config {
case constants.DevnetID, constants.DevnetChainID:
networkName = "devnet"
case constants.LocalID:
networkName = "custom"
networkName = "localnet"
default:
networkName = "custom"
networkName = "localnet"
}
// Try standard genesis locations (user overrides checked first)
@@ -180,7 +180,7 @@ func GetConfigFromDir(dir string) (*Config, error) {
// - LUX_GENESIS_DIR: directory containing genesis files
// - LUX_KEYS_DIR: directory containing node keys (default: ~/.lux/keys)
func GetConfigFromEnv() (*Config, error) {
networkID := uint32(constants.CustomID)
networkID := uint32(constants.LocalID)
if envID := os.Getenv("LUX_NETWORK_ID"); envID != "" {
var id uint32
if _, err := fmt.Sscanf(envID, "%d", &id); err == nil {