Files
node/vms/platformvm/txs/executor/warp_verifier.go
T
Hanzo DevandGitHub 09a4d1343d chore(node): kill subnet — chain/network vocabulary across node (#116)
* 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.
2026-05-29 21:17:44 -07:00

165 lines
3.4 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package executor
import (
"context"
validators "github.com/luxfi/validators"
"github.com/luxfi/node/vms/platformvm/txs"
"github.com/luxfi/node/vms/platformvm/warp"
)
const (
WarpQuorumNumerator = 67
WarpQuorumDenominator = 100
)
var _ txs.Visitor = (*warpVerifier)(nil)
// VerifyWarpMessages verifies all warp messages in the tx. If any of the warp
// messages are invalid, an error is returned.
func VerifyWarpMessages(
ctx context.Context,
networkID uint32,
validatorState validators.State,
pChainHeight uint64,
tx txs.UnsignedTx,
) error {
return tx.Visit(&warpVerifier{
context: ctx,
networkID: networkID,
validatorState: validatorState,
pChainHeight: pChainHeight,
})
}
type warpVerifier struct {
context context.Context
networkID uint32
validatorState validators.State
pChainHeight uint64
}
func (*warpVerifier) AddValidatorTx(*txs.AddValidatorTx) error {
return nil
}
func (*warpVerifier) AddChainValidatorTx(*txs.AddChainValidatorTx) error {
return nil
}
func (*warpVerifier) AddDelegatorTx(*txs.AddDelegatorTx) error {
return nil
}
func (*warpVerifier) CreateChainTx(*txs.CreateChainTx) error {
return nil
}
func (*warpVerifier) CreateNetworkTx(*txs.CreateNetworkTx) error {
return nil
}
func (*warpVerifier) ImportTx(*txs.ImportTx) error {
return nil
}
func (*warpVerifier) ExportTx(*txs.ExportTx) error {
return nil
}
func (*warpVerifier) AdvanceTimeTx(*txs.AdvanceTimeTx) error {
return nil
}
func (*warpVerifier) RewardValidatorTx(*txs.RewardValidatorTx) error {
return nil
}
func (*warpVerifier) RemoveChainValidatorTx(*txs.RemoveChainValidatorTx) error {
return nil
}
func (*warpVerifier) TransformChainTx(*txs.TransformChainTx) error {
return nil
}
func (*warpVerifier) AddPermissionlessValidatorTx(*txs.AddPermissionlessValidatorTx) error {
return nil
}
func (*warpVerifier) AddPermissionlessDelegatorTx(*txs.AddPermissionlessDelegatorTx) error {
return nil
}
func (*warpVerifier) TransferChainOwnershipTx(*txs.TransferChainOwnershipTx) error {
return nil
}
func (*warpVerifier) BaseTx(*txs.BaseTx) error {
return nil
}
func (*warpVerifier) ConvertNetworkToL1Tx(*txs.ConvertNetworkToL1Tx) error {
return nil
}
func (*warpVerifier) CreateSovereignL1Tx(*txs.CreateSovereignL1Tx) error {
return nil
}
func (*warpVerifier) IncreaseL1ValidatorBalanceTx(*txs.IncreaseL1ValidatorBalanceTx) error {
return nil
}
func (*warpVerifier) DisableL1ValidatorTx(*txs.DisableL1ValidatorTx) error {
return nil
}
func (*warpVerifier) SlashValidatorTx(*txs.SlashValidatorTx) error {
return nil
}
func (*warpVerifier) CreateAssetTx(*txs.CreateAssetTx) error {
return nil
}
func (*warpVerifier) OperationTx(*txs.OperationTx) error {
return nil
}
func (w *warpVerifier) RegisterL1ValidatorTx(tx *txs.RegisterL1ValidatorTx) error {
return w.verify(tx.Message)
}
func (w *warpVerifier) SetL1ValidatorWeightTx(tx *txs.SetL1ValidatorWeightTx) error {
return w.verify(tx.Message)
}
func (w *warpVerifier) verify(message []byte) error {
msg, err := warp.ParseMessage(message)
if err != nil {
return err
}
validators, err := warp.GetCanonicalValidatorSetFromChainID(
w.context,
w.validatorState,
w.pChainHeight,
msg.SourceChainID,
)
if err != nil {
return err
}
return msg.Signature.Verify(
&msg.UnsignedMessage,
w.networkID,
validators,
WarpQuorumNumerator,
WarpQuorumDenominator,
)
}