mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
* feat(platformvm): CreateSovereignL1Tx — single-tx sovereign L1 launch
Adds a new platformvm tx type that atomically registers a sovereign L1
in one P-chain commit. Replaces what is today the four-step flow:
CreateNetworkTx + AddChainValidatorTx ×N + CreateChainTx ×K + ConvertNetworkToL1Tx
with one signed tx. After commit, the primary network has a permanent
record of the L1's network ID + initial validator set + chain manifest
+ on-chain validator-manager contract — but it does NOT track-chains
or validate the L1's blocks. The L1 runs its own consensus from
genesis. L2/L3/L4 follow the same pattern recursively.
Type shape:
type CreateSovereignL1Tx struct {
BaseTx
Owner fx.Owner // CreateNetworkTx parity
Validators []*ConvertNetworkToL1Validator // genesis validator set
Chains []*SovereignL1Chain // VM ID + genesis blob per chain
ManagerChainIdx uint32 // index into Chains[]
ManagerAddress types.JSONByteSlice // validator-manager contract
}
type SovereignL1Chain struct {
BlockchainName string
VMID ids.ID
FxIDs []ids.ID
GenesisData []byte
}
SyntacticVerify enforces:
- at least one validator (sorted, unique)
- at least one chain, ≤ MaxSovereignL1Chains (16)
- ManagerChainIdx is in range of Chains[]
- ManagerAddress ≤ MaxChainAddressLength
- per-chain name + VMID + FxIDs + genesis bounds
- BaseTx + Owner + each Validator each verify
Wired into:
- Visitor interface
- codec (registered as the next tx type after ConvertNetworkToL1Tx)
- signer + complexity + metrics + executor stubs across all visitor
implementations
Executor body is stubbed with a TODO. The atomic state transition
(mint new networkID from tx hash, seed validator-manager state,
register each Chain, charge fee) lands in a follow-up PR. This PR is
the type definition + interface plumbing so downstream tools (wallet,
CLI, fee calc, metrics) can target the tx type while the executor is
implemented.
* chore(node): kill subnet — chain/network vocabulary across node
Zero remaining `subnet|Subnet|SUBNET` in node Go source. Per canonical
no-subnet rule.
## Wire types (Go fields only; byte-level wire encoding unchanged)
message/wire/types.go TrackedSubnets → TrackedChains
message/wire/zap.go same on Read/Write
proto/p2p/p2p_zap.go SubnetUptime alias → ChainUptime
(consumes luxfi/proto rename in companion PR)
## Comment scrub
message/wire/types.go "(chain, subnet) pair" → "(chain, network) pair"
network/peer/handshake.go "primary-network or subnet" → "primary-network or per-chain"
node/node.go "per-subnet" → "per-chain"
"P→subnet warp" → "P→chain warp"
genesis/builder/builder.go "their own subnets" → "their own chains"
vms/platformvm/client.go dropped "subnet jargon" reference
vms/platformvm/service.go dropped "net / subnet jargon" reference
vms/platformvm/config/internal.go "subnet-spawned blockchain" → "per-chain blockchain"
## ICPSubnet (Internet Computer adapter)
ICPSubnet → ICPNet (type rename — unrelated to platform subnet,
but still a subnet word; killed for consistency)
map field `subnets` → `nets`
## Examples
wallet/network/primary/examples/bootstrap-hanzo/main.go:
--subnet-id → --network-id (CLI flag)
existingSubnetID local var → existingNetID
"subnet ID" log lines → "network ID"
"SUBNET_ID=" output → "NETWORK_ID="
"subnet-evm VM ID" → "EVM VM ID"
All comments rephrased.
wallet/network/primary/examples/heartbeat-tx/main.go: one comment
rephrase.
go.work workspace cleanup:
- Removed ./operator/go entry (placeholder; lux/operator polyglot
layout pending the cross-repo migration)
- Removed ./operator entry (mid-migration; nothing to build)
Build clean. Zero `grep -rIn "subnet|Subnet" --include="*.go"` matches.
136 lines
4.7 KiB
Go
136 lines
4.7 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package config
|
|
|
|
import (
|
|
"time"
|
|
|
|
consensusconfig "github.com/luxfi/consensus/config"
|
|
validators "github.com/luxfi/validators"
|
|
"github.com/luxfi/validators/uptime"
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/math/set"
|
|
"github.com/luxfi/node/chains"
|
|
"github.com/luxfi/node/upgrade"
|
|
"github.com/luxfi/node/vms/components/gas"
|
|
"github.com/luxfi/node/vms/platformvm/reward"
|
|
"github.com/luxfi/node/vms/platformvm/txs"
|
|
"github.com/luxfi/node/vms/platformvm/validators/fee"
|
|
"github.com/luxfi/node/vms/txs/auth"
|
|
)
|
|
|
|
// Internal contains all of the parameters for the PlatformVM that are
|
|
// internally set by the node.
|
|
type Internal struct {
|
|
// The node's chain manager
|
|
Chains chains.Manager
|
|
|
|
// Node's validator set maps netID -> validators of the net
|
|
//
|
|
// Invariant: The primary network's validator set should have been added to
|
|
// the manager before calling VM.Initialize.
|
|
// Invariant: The primary network's validator set should be empty before
|
|
// calling VM.Initialize.
|
|
Validators validators.Manager
|
|
|
|
DynamicFeeConfig gas.Config
|
|
|
|
ValidatorFeeConfig fee.Config
|
|
|
|
// Provides access to the uptime manager as a thread safe data structure
|
|
UptimeLockedCalculator uptime.LockedCalculator
|
|
|
|
// True if the node is being run with staking enabled
|
|
SybilProtectionEnabled bool
|
|
|
|
// If true, only the P-chain will be instantiated on the primary network.
|
|
PartialSyncPrimaryNetwork bool
|
|
|
|
// Set of chains that this node is validating
|
|
TrackedChains set.Set[ids.ID]
|
|
|
|
// If true, track all chains automatically (useful for dev/test networks)
|
|
TrackAllChains bool
|
|
|
|
// The minimum amount of tokens one must bond to be a validator
|
|
MinValidatorStake uint64
|
|
|
|
// The maximum amount of tokens that can be bonded on a validator
|
|
MaxValidatorStake uint64
|
|
|
|
// Minimum stake, in nLUX, that can be delegated on the primary network
|
|
MinDelegatorStake uint64
|
|
|
|
// Minimum fee that can be charged for delegation
|
|
MinDelegationFee uint32
|
|
|
|
// UptimePercentage is the minimum uptime required to be rewarded for staking
|
|
UptimePercentage float64
|
|
|
|
// Minimum amount of time to allow a staker to stake
|
|
MinStakeDuration time.Duration
|
|
|
|
// Maximum amount of time to allow a staker to stake
|
|
MaxStakeDuration time.Duration
|
|
|
|
// Config for the minting function
|
|
RewardConfig reward.Config
|
|
|
|
// All network upgrade timestamps
|
|
UpgradeConfig upgrade.Config
|
|
|
|
// UseCurrentHeight forces [GetMinimumHeight] to return the current height
|
|
// of the P-Chain instead of the oldest block in the [recentlyAccepted]
|
|
// window.
|
|
//
|
|
// This config is particularly useful for triggering proposervm activation
|
|
// on recently created chains (without this, users need to wait for
|
|
// [recentlyAcceptedWindowTTL] to pass for activation to occur).
|
|
UseCurrentHeight bool
|
|
|
|
// SecurityProfile pins the chain-wide credential-admission policy
|
|
// resolved at node bootstrap from the genesis SecurityProfile block
|
|
// (F102). The platformvm threads this into its mempool builder via
|
|
// SetAuthPolicy so strict-PQ chains refuse classical secp256k1
|
|
// credentials at gossip time. Nil for legacy (classical-compat)
|
|
// networks that pre-date the locked-profile pin.
|
|
SecurityProfile *consensusconfig.ChainSecurityProfile
|
|
|
|
// ClassicalCompatRegistry names the allow-list of legacy operators
|
|
// that may still post classical secp256k1 credentials under a
|
|
// classical-compat fork profile. Nil for strict-PQ (the empty
|
|
// registry refuses everything classical) and for legacy networks
|
|
// (the mempool gate is bypassed entirely).
|
|
ClassicalCompatRegistry auth.ClassicalCompatRegistry
|
|
}
|
|
|
|
// Create the blockchain described in [tx], but only if this node is a member of
|
|
// the chain that validates the blockchain.
|
|
//
|
|
// P-only primary network: P-Chain is the sole mandatory chain (created out
|
|
// of band by the chain manager at startup). EVERY other chain — X-Chain
|
|
// (XVM), C-Chain (EVM), Q-Chain (Quantum), D-Chain (DEX), and any
|
|
// per-chain blockchain — opt-in via --track-chains / --track-all
|
|
// or by being present in platform genesis. Operators bring up exactly what
|
|
// their workload needs, nothing more.
|
|
func (c *Internal) CreateChain(blockchainID ids.ID, tx *txs.CreateChainTx) {
|
|
if c.SybilProtectionEnabled &&
|
|
!c.TrackAllChains && // Not tracking all chains automatically
|
|
!c.TrackedChains.Contains(tx.ChainID) && // Check if chain ID is tracked
|
|
!c.TrackedChains.Contains(blockchainID) { // Check if blockchain ID is tracked
|
|
return
|
|
}
|
|
|
|
chainParams := chains.ChainParameters{
|
|
ID: blockchainID,
|
|
ChainID: tx.ChainID,
|
|
GenesisData: tx.GenesisData,
|
|
VMID: tx.VMID,
|
|
FxIDs: tx.FxIDs,
|
|
Name: tx.BlockchainName,
|
|
}
|
|
|
|
c.Chains.QueueChainCreation(chainParams)
|
|
}
|