Files
zeekay 7cf87b230b node-unified is the node
The module already called itself github.com/luxfi/node while containing no node
in Go: cmd/luxd was twenty-one lines that printed the size of a few types, and
the Go column of the matrix measured a VM plugin. A repo that fetches the thing
it claims to be has not replaced it, so the Go sources move in — 1515 files,
the daemon and everything under it — and the build reaches outside this module
for nothing.

Rust and C++ sit beside it unchanged and are still measured against it by the
differential. That is the point of one repo: the reference implementation and
the two ports are the same checkout, so parity is a thing you can run rather
than a thing you assert.

Verified: builds, and the closure carries no lux-private — checked at build time
rather than believed. The daemon starts twelve chains on a local network
(P X C Q Z A B G K M F, plus D through its plugin) and reports healthy.
2026-09-07 16:15:25 -07:00

75 lines
2.6 KiB
Go

// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
// Package security is the network security model for Lux L1/L2 networks
// (LP-018 §"Network security modes"). It is one small, orthogonal definition
// — pure values, no wire or state dependencies — composed by the three
// consumers that need it: the P-Chain tx wire, the executor, and state.
package security
import "errors"
// Admission governs how a network's own validator set admits members.
type Admission uint8
const (
// NoOwnSet: the network runs no validator set of its own; its security is
// entirely restaked from its parent.
NoOwnSet Admission = iota
// Open: permissionless. Any staker meeting Threshold joins the set.
Open
// Gated: membership is admitted by the Manager (PoA / permissioned).
Gated
)
// Manager is the authority that governs a network's own validator set.
type Manager uint8
const (
// PChain: the set is managed by P-Chain txs, authorised by the network Owner.
PChain Manager = iota
// Contract: the set is managed by an EVM staking contract on some chain.
Contract
)
// Mode is a network's complete security configuration.
//
// The two axes are orthogonal:
// - RestakeParent — the network leans on its parent's validator set.
// - own set — whether it runs its OWN set, described by (Admission, Manager).
//
// Their product spans every operating mode: a restaked L2
// (RestakeParent, NoOwnSet), a sovereign L1 (¬RestakeParent, Open|Gated), and
// a hybrid L2 that restakes its parent AND runs an additive own set
// (RestakeParent, Open|Gated).
type Mode struct {
RestakeParent bool
Admission Admission
Threshold uint64 // minimum stake for Open admission; 0 otherwise
Manager Manager
}
// Sovereign reports whether the network runs its own validator set.
func (m Mode) Sovereign() bool { return m.Admission != NoOwnSet }
var (
ErrUnknownAdmission = errors.New("security: unknown admission")
ErrUnknownManager = errors.New("security: unknown manager")
ErrNoSecurity = errors.New("security: network must restake parent or run its own set")
)
// Valid checks the enum ranges and the cross-axis invariant. It deliberately
// does NOT reach into tx-level data (genesis validators, manager address) —
// those consistency checks belong to the tx that carries the Mode.
func (m Mode) Valid() error {
switch {
case m.Admission > Gated:
return ErrUnknownAdmission
case m.Manager > Contract:
return ErrUnknownManager
case !m.RestakeParent && m.Admission == NoOwnSet:
return ErrNoSecurity
}
return nil
}