mirror of
https://github.com/luxfi/constants.git
synced 2026-10-30 16:59:17 +00:00
Under LP-0130's roster, M-Chain is MPCVMID and F-Chain is FHEVMID.
The legacy shared "threshold" substrate is retired. Callers migrated
to the split IDs in one atomic sweep across node/vms.go, node/genesis/
builder/{registry,builder,registry_test}.go and genesis/builder/
builder.go — no backwards-compat aliases remain.
Co-authored-by: Hanzo Dev <[email protected]>
134 lines
5.6 KiB
Go
134 lines
5.6 KiB
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package constants
|
|
|
|
import (
|
|
"encoding/binary"
|
|
|
|
"github.com/luxfi/crypto/hash"
|
|
"github.com/luxfi/ids"
|
|
)
|
|
|
|
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
|
|
MPCVMName = "mpcvm" // M-Chain: MPC threshold signing / bridge custody (LP-7100)
|
|
FHEVMName = "fhevm" // F-Chain: FHE confidential compute / encrypted state (LP-8200)
|
|
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
|
|
)
|
|
|
|
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'}
|
|
MPCVMID = ids.ID{'m', 'p', 'c', 'v', 'm'} // M-Chain: MPC threshold signing / bridge custody
|
|
FHEVMID = ids.ID{'f', 'h', 'e', 'v', 'm'} // F-Chain: FHE confidential compute
|
|
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
|
|
|
|
// UTXO_ASSET_ID is the MAINNET (networkID=1) materialization of the
|
|
// primary UTXO asset ID. Kept as a stable literal for tooling/docs;
|
|
// runtime code MUST use UTXOAssetIDFor(networkID) to get the correct
|
|
// per-network ID and avoid cross-network UTXO collapse (mainnet+testnet
|
|
// would otherwise share an asset ID, breaking any wallet/indexer that
|
|
// keys balance by AssetID alone).
|
|
UTXO_ASSET_ID = ids.ID{'l', 'u', 'x', ' ', 'a', 's', 's', 'e', 't', ' ', 'i', 'd'}
|
|
)
|
|
|
|
// UTXOAssetIDFor returns the network-scoped primary UTXO asset ID used by
|
|
// P-Chain and X-Chain. Domain-separates by networkID so the same address
|
|
// bytes on two networks own UTXOs with distinct asset IDs (prevents
|
|
// cross-network UTXO accounting collapse for naive indexers/wallets that
|
|
// key balance on AssetID alone).
|
|
//
|
|
// Mainnet (networkID=1) returns the legacy literal UTXO_ASSET_ID so existing
|
|
// mainnet state remains valid; all other networks get a hash-derived ID.
|
|
//
|
|
// Layout of the preimage: 12-byte ASCII "lux asset id" || 4-byte big-endian
|
|
// networkID. Hashed with SHA-256 (luxfi/crypto/hash) for a uniform 32-byte ID.
|
|
//
|
|
// The name uses "UTXO" (the technical category) not "LUX" (the brand) so
|
|
// the API stays consistent with UTXO_ASSET_ID and stays brand-neutral —
|
|
// downstream chains (e.g. Hanzo, Zoo, regulated EVM L1s) using this primitive
|
|
// keep their own brand identity.
|
|
func UTXOAssetIDFor(networkID uint32) ids.ID {
|
|
if networkID == 1 {
|
|
// Preserve mainnet's existing on-chain state and tooling references.
|
|
return UTXO_ASSET_ID
|
|
}
|
|
var preimage [16]byte
|
|
copy(preimage[:12], "lux asset id")
|
|
binary.BigEndian.PutUint32(preimage[12:], networkID)
|
|
return hash.ComputeHash256Array(preimage[:])
|
|
}
|
|
|
|
// 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 VMName(vmID ids.ID) string {
|
|
switch vmID {
|
|
case PlatformVMID:
|
|
return PlatformVMName
|
|
case XVMID:
|
|
return XVMName
|
|
case EVMID:
|
|
return EVMName
|
|
case XSVMID:
|
|
return XSVMName
|
|
case QuantumVMID:
|
|
return QuantumVMName
|
|
case AIVMID:
|
|
return AIVMName
|
|
case BridgeVMID:
|
|
return BridgeVMName
|
|
case MPCVMID:
|
|
return MPCVMName
|
|
case FHEVMID:
|
|
return FHEVMName
|
|
case KeyVMID:
|
|
return KeyVMName
|
|
case ZKVMID:
|
|
return ZKVMName
|
|
case GraphVMID:
|
|
return GraphVMName
|
|
case DexVMID:
|
|
return DexVMName
|
|
case OracleVMID:
|
|
return OracleVMName
|
|
case RelayVMID:
|
|
return RelayVMName
|
|
case IdentityVMID:
|
|
return IdentityVMName
|
|
default:
|
|
return vmID.String()
|
|
}
|
|
}
|