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

node

package
v1.22.78 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: BSD-3-Clause Imports: 89 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBLSSignerWrapper added in v1.16.16

func NewBLSSignerWrapper(key *bls.SecretKey) bls.Signer

func NewResourceManagerWrapper added in v1.16.16

func NewResourceManagerWrapper(manager resource.Manager) tracker.ResourceManager

NewResourceManagerWrapper creates a new resource manager wrapper

func NewRouterAdapter added in v1.16.16

func NewRouterAdapter(r Router) router.Router

NewRouterAdapter creates a new router adapter

Types

type APIConfig added in v1.1.11

type APIConfig struct {
	APIIndexerConfig `json:"indexerConfig"`

	// Enable/Disable APIs
	AdminAPIEnabled    bool `json:"adminAPIEnabled"`
	InfoAPIEnabled     bool `json:"infoAPIEnabled"`
	KeystoreAPIEnabled bool `json:"keystoreAPIEnabled"`
	MetricsAPIEnabled  bool `json:"metricsAPIEnabled"`
	HealthAPIEnabled   bool `json:"healthAPIEnabled"`
}

type APIIndexerConfig added in v1.1.11

type APIIndexerConfig struct {
	IndexAPIEnabled      bool `json:"indexAPIEnabled"`
	IndexAllowIncomplete bool `json:"indexAllowIncomplete"`
}

type BLSSignerWrapper added in v1.16.16

type BLSSignerWrapper struct {
	// contains filtered or unexported fields
}

BLSSignerWrapper wraps a SecretKey to implement the Signer interface with error returns

func (*BLSSignerWrapper) PublicKey added in v1.16.16

func (s *BLSSignerWrapper) PublicKey() *bls.PublicKey

func (*BLSSignerWrapper) Sign added in v1.16.16

func (s *BLSSignerWrapper) Sign(msg []byte) (*bls.Signature, error)

func (*BLSSignerWrapper) SignProofOfPossession added in v1.16.16

func (s *BLSSignerWrapper) SignProofOfPossession(msg []byte) (*bls.Signature, error)

type BootstrapConfig added in v1.1.11

type BootstrapConfig struct {
	// Timeout before emitting a warn log when connecting to bootstrapping beacons
	BootstrapBeaconConnectionTimeout time.Duration `json:"bootstrapBeaconConnectionTimeout"`

	// Max number of containers in an ancestors message sent by this node.
	BootstrapAncestorsMaxContainersSent int `json:"bootstrapAncestorsMaxContainersSent"`

	// This node will only consider the first [AncestorsMaxContainersReceived]
	// containers in an ancestors message it receives.
	BootstrapAncestorsMaxContainersReceived int `json:"bootstrapAncestorsMaxContainersReceived"`

	// Max time to spend fetching a container and its
	// ancestors while responding to a GetAncestors message
	BootstrapMaxTimeGetAncestors time.Duration `json:"bootstrapMaxTimeGetAncestors"`

	Bootstrappers []genesis.Bootstrapper `json:"bootstrappers"`

	// Skip bootstrapping and start processing immediately
	SkipBootstrap bool `json:"skipBootstrap"`

	// Enable automining in POA mode
	EnableAutomining bool `json:"enableAutomining"`
}

type Config

type Config struct {
	HTTPConfig       `json:"httpConfig"`
	IPConfig         `json:"ipConfig"`
	StakingConfig    `json:"stakingConfig"`
	fee.StaticConfig `json:"txFeeConfig"`
	StateSyncConfig  `json:"stateSyncConfig"`
	BootstrapConfig  `json:"bootstrapConfig"`
	DatabaseConfig   `json:"databaseConfig"`

	UpgradeConfig upgrade.Config `json:"upgradeConfig"`

	// Genesis information
	GenesisBytes []byte `json:"-"`
	LuxAssetID   ids.ID `json:"luxAssetID"`

	// ID of the network this node should connect to
	NetworkID uint32 `json:"networkID"`

	// Health
	HealthCheckFreq time.Duration `json:"healthCheckFreq"`

	// Network configuration
	NetworkConfig network.Config `json:"networkConfig"`

	AdaptiveTimeoutConfig timer.AdaptiveTimeoutConfig `json:"adaptiveTimeoutConfig"`

	BenchlistConfig benchlist.Config `json:"benchlistConfig"`

	ProfilerConfig profiler.Config `json:"profilerConfig"`

	PluginDir string `json:"pluginDir"`
	// DevMode enables local PoA + auto-mine mode (network-id=local, sybil-protection disabled)
	DevMode bool `json:"devMode"`

	// File Descriptor Limit
	FdLimit uint64 `json:"fdLimit"`

	// Metrics
	MeterVMEnabled bool `json:"meterVMEnabled"`
	// Delay between automatic block proposals when DevMode is set
	DevBlockDelay time.Duration `json:"devBlockDelay"`

	RouterHealthConfig       HealthConfig  `json:"routerHealthConfig"`
	ConsensusShutdownTimeout time.Duration `json:"consensusShutdownTimeout"`
	// Poll for new frontiers every [FrontierPollFrequency]
	FrontierPollFrequency time.Duration `json:"consensusGossipFreq"`
	// ConsensusAppConcurrency defines the maximum number of goroutines to
	// handle App messages per chain.
	ConsensusAppConcurrency int `json:"consensusAppConcurrency"`

	TrackedChains  set.Set[ids.ID] `json:"trackedChains"`
	TrackAllChains bool            `json:"trackAllChains"`

	NetConfigs map[ids.ID]nets.Config `json:"subnetConfigs"`

	ChainConfigs map[string]chains.ChainConfig `json:"-"`
	ChainAliases map[ids.ID][]string           `json:"chainAliases"`

	VMAliases map[ids.ID][]string `json:"vmAliases"`

	// Halflife to use for the processing requests tracker.
	// Larger halflife --> usage metrics change more slowly.
	SystemTrackerProcessingHalflife time.Duration `json:"systemTrackerProcessingHalflife"`

	// Frequency to check the real resource usage of tracked processes.
	// More frequent checks --> usage metrics are more accurate, but more
	// expensive to track
	SystemTrackerFrequency time.Duration `json:"systemTrackerFrequency"`

	// Halflife to use for the cpu tracker.
	// Larger halflife --> cpu usage metrics change more slowly.
	SystemTrackerCPUHalflife time.Duration `json:"systemTrackerCPUHalflife"`

	// Halflife to use for the disk tracker.
	// Larger halflife --> disk usage metrics change more slowly.
	SystemTrackerDiskHalflife time.Duration `json:"systemTrackerDiskHalflife"`

	CPUTargeterConfig TargeterConfig `json:"cpuTargeterConfig"`

	DiskTargeterConfig TargeterConfig `json:"diskTargeterConfig"`

	RequiredAvailableDiskSpace         uint64 `json:"requiredAvailableDiskSpace"`
	WarningThresholdAvailableDiskSpace uint64 `json:"warningThresholdAvailableDiskSpace"`

	TraceConfig trace.Config `json:"traceConfig"`

	// See comment on [UseCurrentHeight] in platformvm.Config
	UseCurrentHeight bool `json:"useCurrentHeight"`

	// ProvidedFlags contains all the flags set by the user
	ProvidedFlags map[string]interface{} `json:"-"`

	// ChainDataDir is the root path for per-chain directories where VMs can
	// write arbitrary data.
	ChainDataDir string `json:"chainDataDir"`

	// ImportChainData is the path to import blockchain data from another chain
	ImportChainData string `json:"importChainData"`

	// Path to write process context to (including PID, API URI, and
	// staking address).
	ProcessContextFilePath string `json:"processContextFilePath"`

	// POA Mode Configuration
	POAModeEnabled     bool          `json:"poaModeEnabled"`
	POASingleNodeMode  bool          `json:"poaSingleNodeMode"`
	POAMinBlockTime    time.Duration `json:"poaMinBlockTime"`
	POAAuthorizedNodes []string      `json:"poaAuthorizedNodes"`

	// Logging
	Log log.Logger `json:"-"`
}

Config contains all of the configurations of a Lux node.

type DatabaseConfig added in v1.1.11

type DatabaseConfig struct {
	// If true, all writes are to memory and are discarded at node shutdown.
	ReadOnly bool `json:"readOnly"`

	// Path to database
	Path string `json:"path"`

	// Name of the database type to use
	Name string `json:"name"`

	// Path to config file
	Config []byte `json:"-"`
}

type HTTPConfig added in v1.1.11

type HTTPConfig struct {
	server.HTTPConfig
	APIConfig `json:"apiConfig"`
	HTTPHost  string `json:"httpHost"`
	HTTPPort  uint16 `json:"httpPort"`

	HTTPSEnabled bool   `json:"httpsEnabled"`
	HTTPSKey     []byte `json:"-"`
	HTTPSCert    []byte `json:"-"`

	HTTPAllowedOrigins []string `json:"httpAllowedOrigins"`
	HTTPAllowedHosts   []string `json:"httpAllowedHosts"`

	ShutdownTimeout time.Duration `json:"shutdownTimeout"`
	ShutdownWait    time.Duration `json:"shutdownWait"`
}

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 IPConfig added in v1.1.11

type IPConfig struct {
	PublicIP                  string        `json:"publicIP"`
	PublicIPResolutionService string        `json:"publicIPResolutionService"`
	PublicIPResolutionFreq    time.Duration `json:"publicIPResolutionFreq"`
	// The host portion of the address to listen on. The port to
	// listen on will be sourced from IPPort.
	//
	// - If empty, listen on all interfaces (both ipv4 and ipv6).
	// - If populated, listen only on the specified address.
	ListenHost string `json:"listenHost"`
	ListenPort uint16 `json:"listenPort"`
}

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) 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 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

	RegisterRequest(
		ctx context.Context,
		nodeID ids.NodeID,
		chainID ids.ID,
		requestID uint32,
		op message.Op,
		failedMsg message.InboundMessage,
		engineType p2p.EngineType,
	)

	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)
	Deprecated() // Required for router.Router compatibility
}

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 StakingConfig added in v1.1.11

type StakingConfig struct {
	genesis.StakingConfig
	SybilProtectionEnabled        bool            `json:"sybilProtectionEnabled"`
	PartialSyncPrimaryNetwork     bool            `json:"partialSyncPrimaryNetwork"`
	StakingTLSCert                tls.Certificate `json:"-"`
	StakingSigningKey             *bls.SecretKey  `json:"-"`
	SybilProtectionDisabledWeight uint64          `json:"sybilProtectionDisabledWeight"`
	StakingKeyPath                string          `json:"stakingKeyPath"`
	StakingCertPath               string          `json:"stakingCertPath"`
	StakingSignerPath             string          `json:"stakingSignerPath"`
}

type StateSyncConfig added in v1.1.11

type StateSyncConfig struct {
	StateSyncIDs []ids.NodeID     `json:"stateSyncIDs"`
	StateSyncIPs []netip.AddrPort `json:"stateSyncIPs"`
}

type Targeter added in v1.16.16

type Targeter = tracker.Targeter

Type aliases

type TargeterConfig added in v1.16.16

type TargeterConfig struct {
	// VdrAlloc is the percentage of resource usage that is attributed to validators
	// The range is [0, 1], defaults to 1 (100%)
	VdrAlloc float64 `json:"vdrAlloc"`
	// MaxNonVdrUsage is the maximum amount of resources that non-validators can use
	// The range is [0, 1], defaults to 0
	MaxNonVdrUsage float64 `json:"maxNonVdrUsage"`
	// MaxNonVdrNodeUsage is the maximum amount of resources that a non-validator node can use
	// The range is [0, 1], defaults to 0
	MaxNonVdrNodeUsage float64 `json:"maxNonVdrNodeUsage"`
}

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) Deprecated added in v1.22.22

func (v *ValidatorManager) Deprecated()

Router interface methods - forward to underlying router

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) RegisterRequest added in v1.22.22

func (v *ValidatorManager) RegisterRequest(
	ctx context.Context,
	nodeID ids.NodeID,
	chainID ids.ID,
	requestID uint32,
	op message.Op,
	failedMsg message.InboundMessage,
	engineType p2p.EngineType,
)

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
	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