node

package
v1.18.1-qos Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: BSD-3-Clause Imports: 82 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBLSSignerWrapper added in v1.17.2

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

func NewResourceManagerWrapper added in v1.17.2

func NewResourceManagerWrapper(manager resource.Manager) tracker.ResourceManager

NewResourceManagerWrapper creates a new resource manager wrapper

func NewRouterAdapter added in v1.17.2

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

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

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

func (*BLSSignerWrapper) Sign added in v1.17.2

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

func (*BLSSignerWrapper) SignProofOfPossession added in v1.17.2

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 ChainRouter added in v1.17.2

type ChainRouter = Router

Type aliases for router types

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

	// 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"`

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

	// Metrics
	MeterVMEnabled bool `json:"meterVMEnabled"`

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

	TrackedSubnets set.Set[ids.ID] `json:"trackedSubnets"`

	SubnetConfigs map[ids.ID]subnets.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 an 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.17.2

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
	MetricsRegisterer metric.Registerer

	// 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  consensus.AcceptorGroup
	TxAcceptorGroup     consensus.AcceptorGroup
	VertexAcceptorGroup consensus.AcceptorGroup

	// Net runs the networking stack
	Net network.Network

	// Handles HTTP API calls
	APIServer server.Server

	// This node's configuration
	Config *Config

	// Incremented only once on initialization.
	// Decremented when node is done shutting down.
	DoneShuttingDown sync.WaitGroup

	// 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 an Lux node.

func New added in v0.1.1

func New(
	config *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

type NodeProcessContext added in v1.1.11

type NodeProcessContext struct {
	// The process id of the node
	PID int `json:"pid"`
	// URI to access the node API
	// Format: [https|http]://[host]:[port]
	URI string `json:"uri"`
	// Address other nodes can use to communicate with this node
	// Format: [host]:[port]
	StakingAddress string `json:"stakingAddress"`
}

type Router added in v1.17.2

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, 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 NewSimpleRouter added in v1.17.2

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

NewSimpleRouter creates a new router

func Trace added in v1.17.2

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

Trace wraps a router with tracing capabilities

type SimpleRouter added in v1.17.2

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

SimpleRouter implements Router interface

func (*SimpleRouter) AddChain added in v1.17.2

func (r *SimpleRouter) AddChain(ctx context.Context, h handler.Handler)

func (*SimpleRouter) Benched added in v1.17.2

func (r *SimpleRouter) Benched(chainID ids.ID, nodeID ids.NodeID)

func (*SimpleRouter) Connected added in v1.17.2

func (r *SimpleRouter) Connected(nodeID ids.NodeID, nodeVersion *version.Application, netID ids.ID)

func (*SimpleRouter) Deprecated added in v1.17.2

func (r *SimpleRouter) Deprecated()

Deprecated implements the Router interface

func (*SimpleRouter) Disconnected added in v1.17.2

func (r *SimpleRouter) Disconnected(nodeID ids.NodeID)

func (*SimpleRouter) HandleInbound added in v1.17.2

func (r *SimpleRouter) HandleInbound(ctx context.Context, msg message.InboundMessage)

func (*SimpleRouter) HealthCheck added in v1.17.2

func (r *SimpleRouter) HealthCheck(ctx context.Context) (interface{}, error)

func (*SimpleRouter) Initialize added in v1.17.2

func (r *SimpleRouter) 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 (*SimpleRouter) RegisterRequest added in v1.17.2

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

func (*SimpleRouter) Shutdown added in v1.17.2

func (r *SimpleRouter) Shutdown(ctx context.Context)

func (*SimpleRouter) Unbenched added in v1.17.2

func (r *SimpleRouter) Unbenched(chainID ids.ID, nodeID ids.NodeID)

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

type Targeter = tracker.Targeter

Type aliases for router types

type TargeterConfig added in v1.17.2

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"`
}

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