Help us shape the future of Go! Take the 2026 Go Developer Survey

node

package
v1.36.178 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: BSD-3-Clause Imports: 87 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CoreVMs = map[ids.ID]CoreVM{
	constants.PlatformVMID: {Name: "platformvm (P-Chain)", RegisteredInNodeGo: true},
	constants.XVMID:        {Name: "xvm (X-Chain)", RegisteredInNodeGo: true},
	constants.QuantumVMID:  {Name: "quantumvm (Q-Chain)", Factory: &quantumvm.Factory{Config: quantumvmconfig.DefaultConfig()}},
	constants.ZKVMID:       {Name: "zkvm (Z-Chain)", Factory: &zkvm.Factory{}},
}

CoreVMs is the authoritative set of in-process VMs. Q and Z carry their concrete factory (registerCoreVMs installs them); P and X are registered in node.go with runtime dependencies (RegisteredInNodeGo=true, Factory nil).

This map is the single source for "what is core". The anti-shadow guards iterate its keys; tests assert all four are present and that none also appears in OptionalVMs.

View Source
var OptionalVMs = map[ids.ID]PluginSpec{
	constants.DexVMID:      {Name: "dexvm"},
	constants.BridgeVMID:   {Name: "bridgevm"},
	constants.EVMID:        {Name: "evm"},
	constants.AIVMID:       {Name: "aivm"},
	constants.GraphVMID:    {Name: "graphvm"},
	constants.IdentityVMID: {Name: "identityvm"},
	constants.KeyVMID:      {Name: "keyvm"},
	constants.OracleVMID:   {Name: "oraclevm"},
	constants.RelayVMID:    {Name: "relayvm"},
	constants.MPCVMID:      {Name: "mpcvm"},

	constants.FHEVMID: {Name: "fhevm"},
}

OptionalVMs is the authoritative set of plugin-only VMs and their activation rules. It is the single source for both (a) which VMs MUST NOT be linked in-process, and (b) which chains are restricted to entitled nodes.

D (dexvm) carries the operator opt-in ALONE for now: dex-validator, which defaults false, so no node runs the DEX unless its operator asks for it.

The NFT entitlement is not merely unsatisfied, it is unsatisfiable: the gate reads the M-Chain by asserting an interface on the in-process VM, and this very registry requires M to load only as a plugin, so nothing can implement Entitlement(node) where the assertion would see it. Nothing in the tree does. A check that refuses unconditionally is not a policy, it is a refusal wearing a policy's name, and it kept the DEX off every node on every network.

Restore Restricted here the moment the M-Chain can answer the question — the claim/attestation encoding and its verifier already exist and are KAT-tested in luxfi/chains/ownership; what is missing is somewhere to read an attestation from and a group key sourced from consensus rather than from the operator.

B (bridgevm) is NOT restricted, and the reason is the security argument rather than a relaxation of it. B is a primary-network chain, and a primary-network validator validates every primary-network chain; the set that secures the bridge is already the set that secures P, X and C. Admitting only the subset of that set holding a particular token would run the bridge — the surface that custodies value crossing between networks — on FEWER nodes than the consensus underwriting it, which is the concentration the entitlement exists to prevent, pointed the wrong way. A chain every validator must validate cannot be gated on a credential only some validators hold.

C (evm) and the remaining app VMs are plugin-loaded but open.

Declaring a VM here is a statement of intent, not a guarantee that a binary exists: the registry scan simply finds nothing and the chain cannot start. fhevm (F-Chain) is exactly that case today — see its entry below.

Functions

func NewResourceManagerWrapper added in v1.16.16

func NewResourceManagerWrapper(manager resource.Manager) tracker.ResourceManager

NewResourceManagerWrapper creates a new resource manager wrapper

Types

type CoreVM added in v1.30.16

type CoreVM struct {
	Name               string
	Factory            vms.Factory
	RegisteredInNodeGo bool
}

CoreVM describes a VM that runs in-process (linked into luxd), never loaded from PluginDir and never restricted.

Factory is the concrete in-process factory for VMs whose construction needs no node runtime state (Q, Z) — registerCoreVMs installs these. It is nil for P and X, whose factories must be built with live node dependencies (chainManager, validators, security profile, classical-compat registry) and are therefore registered explicitly in node.go; RegisteredInNodeGo records that ownership so the nil Factory is self-documenting, not a footgun.

type HealthConfig added in v1.16.16

type HealthConfig struct {
	Enabled                       bool          `json:"enabled"`
	PollingInterval               time.Duration `json:"pollingInterval"`
	MaxOutstandingRequestDuration time.Duration `json:"maxOutstandingRequestDuration"`
	MaxTimeSinceMsgReceived       time.Duration `json:"maxTimeSinceMsgReceived"`
	MaxTimeSinceMsgSent           time.Duration `json:"maxTimeSinceMsgSent"`
	MaxPortionSentQueueBytesFull  float64       `json:"maxPortionSentQueueBytesFull"`
	MaxPortionSendQueueFull       float64       `json:"maxPortionSendQueueFull"`
	MaxSendFailRate               float64       `json:"maxSendFailRate"`
	MinConnectedPeers             int           `json:"minConnectedPeers"`
	ReadTimeout                   time.Duration `json:"readTimeout"`
	WriteTimeout                  time.Duration `json:"writeTimeout"`
}

HealthConfig for router health monitoring

type Node

type Node struct {
	Log          log.Logger
	VMFactoryLog log.Logger
	LogFactory   log.Factory

	// This node's unique ID used when communicating with other nodes
	// (in consensus, for example)
	ID ids.NodeID

	StakingTLSSigner crypto.Signer
	StakingTLSCert   *staking.Certificate

	// Storage for this node
	DB database.Database

	// dispatcher for events as they happen in consensus
	BlockAcceptorGroup  nodeconsensus.AcceptorGroup
	TxAcceptorGroup     nodeconsensus.AcceptorGroup
	VertexAcceptorGroup nodeconsensus.AcceptorGroup

	// Net runs the networking stack
	Net network.Network

	// Handles HTTP API calls
	APIServer server.Server

	// This node's configuration
	Config *node.Config

	// Metrics Registerer
	MetricsGatherer        metric.MultiGatherer
	MeterDBMetricsGatherer metric.MultiGatherer

	VMAliaser ids.Aliaser
	VMManager vms.Manager

	// VM endpoint registry
	VMRegistry registry.VMRegistry
	// contains filtered or unexported fields
}

Node is an instance of a Lux node.

func New added in v0.1.1

func New(
	config *node.Config,
	logFactory log.Factory,
	logger log.Logger,
) (*Node, error)

New returns an instance of Node

func (*Node) Dispatch

func (n *Node) Dispatch() error

Dispatch starts the node's servers. Returns when the node exits.

func (*Node) ExitCode added in v0.1.1

func (n *Node) ExitCode() int

func (*Node) SecurityProfile added in v1.26.11

func (n *Node) SecurityProfile() *consensusconfig.ChainSecurityProfile

SecurityProfile returns the chain-wide ChainSecurityProfile this node is operating under, or nil when the genesis carries no pin. The returned pointer is the post-Validate+ComputeHash result already stamped with ProfileHash; callers MUST NOT mutate it.

Downstream consumers (signer factory, peer handshake gate, mempool admittance, validator registry, bridge oracle co-signer) take this as a dependency at construction time. The single load happens at node bootstrap (initSecurityProfile); there is no per-request re-resolution.

Closes red-team finding F102 at the consumer API boundary.

func (*Node) Shutdown

func (n *Node) Shutdown(exitCode int)

Shutdown this node May be called multiple times All calls to shutdownOnce.Do block until the first call returns

type PluginSpec added in v1.30.16

type PluginSpec struct {
	// Name is the chain VM's package/plugin name (e.g. "dexvm"). For the nine
	// luxfi/chains VMs the plugin main is github.com/luxfi/chains/<Name>/cmd/
	// plugin and the built artifact is placed at <plugin-dir>/<VMID-CB58> by the
	// Dockerfile Chain VM Plugin Stage. The C-Chain EVM ("evm") is also
	// plugin-loaded but its plugin main lives in the EVM repo, not chains.
	Name string
	// Restricted means a node may activate this VM's chain only when the M-Chain
	// holds an ownership attestation naming it. False means plugin-loaded but open
	// to any node that tracks the chain.
	//
	// WHICH collection confers the entitlement is deliberately not stated here. It
	// is asserted once, by whoever reads that collection and asks the M-Chain to
	// sign; a second copy of that pin in the node would be a second source of
	// truth, able to drift from the first.
	Restricted bool
}

PluginSpec describes a VM that is loaded ONLY from PluginDir (never linked in-process), and whether its chain is restricted to entitled nodes.

type Router added in v1.16.16

type Router interface {
	Initialize(
		nodeID ids.NodeID,
		logger log.Logger,
		timeoutManager timer.AdaptiveTimeoutManager,
		gossipFrequency uint64,
		harshQuittersTime uint64,
		harshQuittersSlashingFraction uint64,
		appGossipValidatorSize uint64,
		appGossipNonValidatorSize uint64,
		gossipAcceptedFrontierSize uint64,
		appSendQueueSize uint64,
		peerNotConnectedF uint64,
		connectedPeers ...ids.NodeID,
	) error

	HandleInbound(ctx context.Context, msg message.InboundMessage)
	Shutdown(ctx context.Context)
	AddChain(ctx context.Context, chainID ids.ID, handler handler.Handler)
	Connected(nodeID ids.NodeID, nodeVersion *version.Application, netID ids.ID)
	Disconnected(nodeID ids.NodeID)
	Benched(chainID ids.ID, nodeID ids.NodeID)
	Unbenched(chainID ids.ID, nodeID ids.NodeID)
	HealthCheck(ctx context.Context) (interface{}, error)
}

Router handles message routing between chains

func NewRouter added in v1.22.59

func NewRouter(logger log.Logger, timeoutManager timer.AdaptiveTimeoutManager) Router

NewRouter creates a new chain router

func NewSimpleRouter added in v1.16.16

func NewSimpleRouter(logger log.Logger, timeoutManager timer.AdaptiveTimeoutManager) Router

NewSimpleRouter is deprecated - use NewRouter instead

func Trace added in v1.16.16

func Trace(router Router, name string, tracer trace.Tracer) Router

Trace wraps a router with tracing capabilities

type Targeter added in v1.16.16

type Targeter = tracker.Targeter

Type aliases

type ValidatorManager added in v1.22.22

type ValidatorManager struct {
	Router
	// contains filtered or unexported fields
}

ValidatorManager wraps the consensus router and handles: - Validator connection tracking - Beacon connection management for bootstrap - Sybil protection weight management

func NewValidatorManager added in v1.22.22

func NewValidatorManager(cfg ValidatorManagerConfig) *ValidatorManager

NewValidatorManager creates a new validator manager

func (*ValidatorManager) AddChain added in v1.22.22

func (v *ValidatorManager) AddChain(ctx context.Context, chainID ids.ID, h handler.Handler)

func (*ValidatorManager) Benched added in v1.22.22

func (v *ValidatorManager) Benched(chainID ids.ID, nodeID ids.NodeID)

func (*ValidatorManager) Connected added in v1.22.22

func (v *ValidatorManager) Connected(nodeID ids.NodeID, nodeVersion *version.Application, netID ids.ID)

func (*ValidatorManager) Disconnected added in v1.22.22

func (v *ValidatorManager) Disconnected(nodeID ids.NodeID)

func (*ValidatorManager) HandleInbound added in v1.22.22

func (v *ValidatorManager) HandleInbound(ctx context.Context, msg message.InboundMessage)

func (*ValidatorManager) HealthCheck added in v1.22.22

func (v *ValidatorManager) HealthCheck(ctx context.Context) (interface{}, error)

func (*ValidatorManager) Initialize added in v1.22.22

func (v *ValidatorManager) Initialize(
	nodeID ids.NodeID,
	logger log.Logger,
	timeoutManager timer.AdaptiveTimeoutManager,
	gossipFrequency uint64,
	harshQuittersTime uint64,
	harshQuittersSlashingFraction uint64,
	appGossipValidatorSize uint64,
	appGossipNonValidatorSize uint64,
	gossipAcceptedFrontierSize uint64,
	appSendQueueSize uint64,
	peerNotConnectedF uint64,
	connectedPeers ...ids.NodeID,
) error

func (*ValidatorManager) Shutdown added in v1.22.22

func (v *ValidatorManager) Shutdown(ctx context.Context)

func (*ValidatorManager) Unbenched added in v1.22.22

func (v *ValidatorManager) Unbenched(chainID ids.ID, nodeID ids.NodeID)

type ValidatorManagerConfig added in v1.22.22

type ValidatorManagerConfig struct {
	Router                  Router
	Log                     log.Logger
	Validators              validators.Manager
	Beacons                 validators.Manager
	TrackedNetworks         []ids.ID
	SybilProtectionDisabled bool
	SybilProtectionWeight   uint64
	RequiredBeaconConns     int64
	OnSufficientlyConnected chan struct{}
}

ValidatorManagerConfig configures the validator manager

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL