Documentation
¶
Index ¶
- Constants
- Variables
- func BootstrapNewNetwork(ctx context.Context, w io.Writer, network *Network, rootNetworkDir string, ...) error
- func CheckLogsExist(ctx context.Context, log log.Logger, networkUUID string) error
- func CheckMetricsExist(ctx context.Context, log log.Logger, networkUUID string) error
- func CheckNodeHealth(ctx context.Context, uri string) (*health.APIReply, error)
- func DefaultChainConfigs() map[string]FlagsMap
- func DefaultJSONMarshal(v interface{}) ([]byte, error)
- func DefaultPodFlags(networkName string, dataDir string) map[string]string
- func EnvVarName(prefix, key string) string
- func GetClientConfig(log log.Logger, path string, context string) (*restclient.Config, error)
- func GetClientset(log log.Logger, path string, context string) (*kubernetes.Clientset, error)
- func GetEnvWithDefault(key, defaultValue string) string
- func GetEthAddress(key *secp256k1.PrivateKey) common.Address
- func GetGitHubLabels() map[string]string
- func GetNodeWebsocketURIs(nodes []*Node, blockchainID ids.ID) ([]string, error)
- func GetPrometheusServiceDiscoveryDir() (string, error)
- func GetReusableNetworkPathForOwner(owner string) (string, error)
- func IsRunningInCluster() bool
- func MetricsLinkForNetwork(networkUUID, startTime, endTime string) string
- func NewNodeStatefulSet(name string, generateName bool, imageName string, containerName string, ...) *appsv1.StatefulSet
- func NewPrivateKeys(keyCount int) ([]*secp256k1.PrivateKey, error)
- func NewTestGenesis(networkID uint32, xChainBalances XChainBalanceMap, ...) (*genesis.UnparsedConfig, error)
- func NewTestGenesisWithFunds(networkID uint32, nodes []*Node, keysToFund []*secp256k1.PrivateKey) (*genesis.UnparsedConfig, error)
- func NodesToIDs(nodes ...*Node) []ids.NodeID
- func RestartNetwork(ctx context.Context, w io.Writer, dir string) error
- func StartPrometheus(ctx context.Context, log log.Logger) error
- func StartPromtail(ctx context.Context, log log.Logger) error
- func StopLogsCollector(ctx context.Context, log log.Logger) error
- func StopMetricsCollector(ctx context.Context, log log.Logger) error
- func StopNetwork(ctx context.Context, dir string) error
- func WaitForHealthy(ctx context.Context, node *Node) error
- func WaitForNodeHealthy(ctx context.Context, log log.Logger, kubeconfig *restclient.Config, ...) (ids.NodeID, error)
- func WaitForPodCondition(ctx context.Context, clientset *kubernetes.Clientset, namespace string, ...) error
- func WaitForPodStatus(ctx context.Context, clientset *kubernetes.Clientset, namespace string, ...) error
- func WaitForPromtailReadiness(ctx context.Context, log log.Logger) error
- func WritePrometheusSDConfig(name string, sdConfig SDConfig, withGitHubLabels bool) (string, error)
- type Chain
- type FlagsMap
- type KubeRuntime
- func (p *KubeRuntime) GetAccessibleStakingAddress(ctx context.Context) (netip.AddrPort, func(), error)
- func (p *KubeRuntime) GetAccessibleURI() string
- func (p *KubeRuntime) InitiateStop(ctx context.Context) error
- func (p *KubeRuntime) IsHealthy(ctx context.Context) (bool, error)
- func (p *KubeRuntime) Restart(ctx context.Context) error
- func (p *KubeRuntime) Start(ctx context.Context) error
- func (p *KubeRuntime) WaitForStopped(ctx context.Context) error
- type KubeRuntimeConfig
- type Net
- type Network
- func (n *Network) Bootstrap(ctx context.Context, w io.Writer) error
- func (n *Network) Create(rootDir string) error
- func (n *Network) CreateNets(ctx context.Context, w io.Writer, apiURI string, restartRequired bool) error
- func (n *Network) EnsureDefaultConfig(w io.Writer, luxNodePath string, pluginDir string) error
- func (n *Network) EnsureNodeConfig(node *Node) error
- func (n *Network) EnvFileContents() string
- func (n *Network) EnvFilePath() string
- func (n *Network) GetMonitoringLabels() map[string]string
- func (n *Network) GetNodeURIs() []NodeURI
- func (n *Network) GetSubnet(name string) *Net
- func (n *Network) GetURIForNodeID(nodeID ids.NodeID) (string, error)
- func (n *Network) Read() error
- func (n *Network) Restart(ctx context.Context, w io.Writer) error
- func (n *Network) RestartNode(ctx context.Context, w io.Writer, node *Node) error
- func (n *Network) StartNode(ctx context.Context, w io.Writer, node *Node) error
- func (n *Network) StartNodes(ctx context.Context, w io.Writer, nodesToStart ...*Node) error
- func (n *Network) Stop(ctx context.Context) error
- func (n *Network) TrackedSubnetsForNode(nodeID ids.NodeID) string
- func (n *Network) Write() error
- type NetworkConfig
- type Node
- func (n *Node) EnsureBLSSigningKey() error
- func (n *Node) EnsureKeys() error
- func (n *Node) EnsureNodeID() error
- func (n *Node) EnsureStakingKeypair() error
- func (n *Node) GetDataDir() string
- func (n *Node) GetProofOfPossession() (*signer.ProofOfPossession, error)
- func (n *Node) InitiateStop(ctx context.Context) error
- func (n *Node) IsHealthy(ctx context.Context) (bool, error)
- func (n *Node) Read() error
- func (n *Node) SaveAPIPort() error
- func (n *Node) SaveMetricsSnapshot(ctx context.Context) error
- func (n *Node) SetNetworkingConfig(bootstrapIDs []string, bootstrapIPs []string)
- func (n *Node) Start(w io.Writer) error
- func (n *Node) Stop(ctx context.Context) error
- func (n *Node) WaitForStopped(ctx context.Context) error
- func (n *Node) Write() error
- type NodeConfig
- type NodeProcess
- type NodeRuntime
- type NodeRuntimeConfig
- type NodeURI
- type ProcessRuntime
- func (p *ProcessRuntime) GetAccessibleStakingAddress(_ context.Context) (netip.AddrPort, func(), error)
- func (p *ProcessRuntime) GetAccessibleURI() string
- func (p *ProcessRuntime) InitiateStop(_ context.Context) error
- func (p *ProcessRuntime) IsHealthy(ctx context.Context) (bool, error)
- func (p *ProcessRuntime) Restart(ctx context.Context) error
- func (p *ProcessRuntime) Start(ctx context.Context) error
- func (p *ProcessRuntime) WaitForStopped(ctx context.Context) error
- type ProcessRuntimeConfig
- type SDConfig
- type Subnet
- func (s *Subnet) AddValidators(ctx context.Context, w io.Writer, apiURI string, nodes ...*Node) error
- func (s *Subnet) Create(ctx context.Context, uri string) error
- func (s *Subnet) CreateChains(ctx context.Context, w io.Writer, uri string) error
- func (s *Subnet) GetWallet(ctx context.Context, uri string) (primary.Wallet, error)
- func (s *Subnet) HasChainConfig() bool
- func (s *Subnet) Write(subnetDir string, chainDir string) error
- type XChainBalanceMap
Constants ¶
const ( DefaultNodeCount = 2 // Minimum required to ensure connectivity-based health checks will pass DefaultFundedKeyCount = 50 DefaultGasLimit = uint64(100_000_000) // Gas limit is arbitrary // Arbitrarily large amount of LUX to fund keys on the X-Chain for testing DefaultFundedKeyXChainAmount = 30 * units.MegaLux // A short min stake duration enables testing of staking logic. DefaultMinStakeDuration = time.Second // RootNetworkDirEnvName is the environment variable for the root network directory RootNetworkDirEnvName = "TMPNET_ROOT_DIR" )
const ( // Interval appropriate for network operations that should be // retried periodically but not too often. DefaultPollingInterval = 500 * time.Millisecond // Validator start time must be a minimum of SyncBound from the // current time for validator addition to succeed, and adding 20 // seconds provides a buffer in case of any delay in processing. DefaultValidatorStartTimeDiff = executor.SyncBound + 20*time.Second DefaultNetworkTimeout = 2 * time.Minute // Arbitrary number of pre-funded keys to create by default DefaultPreFundedKeyCount = 50 )
const ( // Constants defining the names of shell variables whose value can // configure network orchestration. NetworkDirEnvName = "TMPNET_NETWORK_DIR" RootDirEnvName = "TMPNET_ROOT_DIR" // eth address: 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC HardHatKeyStr = "56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027" )
const (
AvalancheGoPathEnvName = "LUXD_PATH"
)
const (
DefaultNodeTickerInterval = 50 * time.Millisecond
)
const (
LuxNodePathEnvName = "LUXD_PATH"
)
const ( // 2GB is the minimum size of a PersistentVolumeClaim used for a node's data directory: // - A value greater than 1GB must be used // - A node will report unhealthy if it detects less than 1GiB available // - EBS volume sizes are in GB // - The minimum number greater than 1GB is 2GB MinimumVolumeSizeGB = 2 )
const ( // Use a delay slightly longer than the scrape interval to ensure a final scrape before shutdown NetworkShutdownDelay = prometheusScrapeInterval + 2*time.Second )
Variables ¶
var ( ErrNotRunning = errors.New("not running") // MetricsAvailableMessage is the message logged when metrics are available MetricsAvailableMessage = "Metrics available" )
var (
AvalancheGoPluginDirEnvName = config.EnvVarName(config.EnvPrefix, config.PluginDirKey)
)
var ( // Arbitrarily large amount of LUX (10^12) to fund keys on the C-Chain for testing DefaultFundedKeyCChainAmount = new(big.Int).Exp(big.NewInt(10), big.NewInt(30), nil) )
var DefaultKubeRuntimeConfig = &KubeRuntimeConfig{
Namespace: "default",
VolumeSizeGB: 10,
Image: "luxfi/luxd:latest",
}
var ( // Key expected to be funded for net-evm hardhat testing // TODO(marun) Remove when net-evm configures the genesis with this key. HardhatKey *secp256k1.PrivateKey )
Functions ¶
func BootstrapNewNetwork ¶
func CheckLogsExist ¶
CheckLogsExist checks if logs exist for the given network. If no network UUID is provided, an attempt will be made to derive selectors from env vars (GH_*) identifying a github actions run.
func CheckMetricsExist ¶
CheckMetricsExist checks if metrics exist for the given network. Github labels are also used as filters if provided as env vars (GH_*).
func CheckNodeHealth ¶
CheckNodeHealth checks if a node is healthy
func DefaultChainConfigs ¶
A set of chain configurations appropriate for testing.
func DefaultJSONMarshal ¶
Marshal to json with default prefix and indent.
func DefaultPodFlags ¶
DefaultPodFlags defines common flags for luxd nodes running in a pod.
func EnvVarName ¶ added in v1.11.14
EnvVarName returns the environment variable name for a given prefix and key
func GetClientConfig ¶
GetClientConfig replicates the behavior of clientcmd.BuildConfigFromFlags with zap logging and support for an optional config context. If path is not provided, use of in-cluster config will be attempted.
func GetClientset ¶
GetClientset returns a kubernetes clientset for the provided kubeconfig path and context.
func GetEnvWithDefault ¶
GetEnvWithDefault gets an environment variable with a default value
func GetEthAddress ¶ added in v1.1.11
func GetEthAddress(key *secp256k1.PrivateKey) common.Address
GetEthAddress converts a secp256k1 private key to an Ethereum address (exported version)
func GetGitHubLabels ¶
func GetNodeWebsocketURIs ¶
GetNodeWebsocketURIs returns websocket URIs for nodes (stub)
func GetPrometheusServiceDiscoveryDir ¶
GetPrometheusServiceDiscoveryDir returns the path for prometheus file-based service discovery configuration.
func GetReusableNetworkPathForOwner ¶
Retrieves the path to a reusable network path for the given owner.
func IsRunningInCluster ¶
func IsRunningInCluster() bool
IsRunningInCluster detects if this code is running inside a Kubernetes cluster by checking for the presence of the service account token that's automatically mounted in every pod.
func MetricsLinkForNetwork ¶
MetricsLinkForNetwork returns a metrics link for the given network UUID and time range
func NewNodeStatefulSet ¶
func NewNodeStatefulSet( name string, generateName bool, imageName string, containerName string, volumeName string, volumeSize string, volumeMountPath string, flags FlagsMap, labels map[string]string, ) *appsv1.StatefulSet
NewNodeStatefulSet returns a statefulset for an luxd node.
func NewPrivateKeys ¶
func NewPrivateKeys(keyCount int) ([]*secp256k1.PrivateKey, error)
Helper simplifying creation of a set of private keys
func NewTestGenesis ¶
func NewTestGenesis( networkID uint32, xChainBalances XChainBalanceMap, cChainBalances core.GenesisAlloc, validatorIDs []ids.NodeID, ) (*genesis.UnparsedConfig, error)
Create a genesis struct valid for bootstrapping a test network. Note that many of the genesis fields (e.g. reward addresses) are randomly generated or hard-coded.
func NewTestGenesisWithFunds ¶ added in v1.1.11
func NewTestGenesisWithFunds( networkID uint32, nodes []*Node, keysToFund []*secp256k1.PrivateKey, ) (*genesis.UnparsedConfig, error)
Create a genesis struct valid for bootstrapping a test network. Note that many of the genesis fields (e.g. reward addresses) are randomly generated or hard-coded.
func NodesToIDs ¶
func RestartNetwork ¶
Restarts the nodes of the network configured in the provided directory.
func StartPrometheus ¶
StartPrometheus ensures prometheus is running to collect metrics from local nodes.
func StartPromtail ¶
StartPromtail ensures promtail is running to collect logs from local nodes.
func StopLogsCollector ¶
StopLogsCollector ensures promtail is not running.
func StopMetricsCollector ¶
StopMetricsCollector ensures prometheus is not running.
func StopNetwork ¶
Stops the nodes of the network configured in the provided directory.
func WaitForHealthy ¶ added in v1.1.11
WaitForHealthy blocks until Node.IsHealthy returns true or an error (including context timeout) is observed.
func WaitForNodeHealthy ¶
func WaitForNodeHealthy( ctx context.Context, log log.Logger, kubeconfig *restclient.Config, namespace string, podName string, healthCheckInterval time.Duration, out io.Writer, outErr io.Writer, ) (ids.NodeID, error)
WaitForNodeHealthy waits for the node running in the specified pod to report healthy.
func WaitForPodCondition ¶
func WaitForPodCondition(ctx context.Context, clientset *kubernetes.Clientset, namespace string, podName string, conditionType corev1.PodConditionType) error
WaitForPodCondition watches the specified pod until the status includes the specified condition.
func WaitForPodStatus ¶
func WaitForPodStatus( ctx context.Context, clientset *kubernetes.Clientset, namespace string, name string, acceptable func(*corev1.PodStatus) bool, ) error
WaitForPodStatus watches the specified pod until the status is deemed acceptable by the provided test function.
func WaitForPromtailReadiness ¶
WaitForPromtailReadiness waits until prometheus is ready. It can only succeed after one or more nodes have written their service discovery configuration.
func WritePrometheusSDConfig ¶
WritePrometheusSDConfig writes the SDConfig with the provided name to the location expected by the prometheus instance start by tmpnet.
If withGitHubLabels is true, checks env vars for GitHub-specific labels and adds them as labels if present before writing the SDConfig.
Returns the path to the written configuration file.
Types ¶
type Chain ¶
type Chain struct {
// Set statically
VMID ids.ID
Config string
Genesis []byte
// Set at runtime
ChainID ids.ID
PreFundedKey *secp256k1.PrivateKey
}
func (*Chain) WriteConfig ¶ added in v1.1.11
Write the chain configuration to the specified directory.
type FlagsMap ¶
Defines a mapping of flag keys to values intended to be supplied to an invocation of an AvalancheGo node.
func DefaultTestFlags ¶ added in v1.1.11
func DefaultTestFlags() FlagsMap
Flags appropriate for networks used for all types of testing.
func ReadFlagsMap ¶
Utility function simplifying construction of a FlagsMap from a file.
func (FlagsMap) GetStringVal ¶ added in v1.1.11
GetStringVal simplifies retrieving a map value as a string.
func (FlagsMap) SetDefault ¶
SetDefault ensures the effectiveness of a flag override by only setting a value supplied whose key is not already explicitly set.
func (FlagsMap) SetDefaults ¶
SetDefaults ensures the effectiveness of flag overrides by only setting values supplied in the defaults map that are not already explicitly set.
type KubeRuntime ¶
type KubeRuntime struct {
// contains filtered or unexported fields
}
func (*KubeRuntime) GetAccessibleStakingAddress ¶ added in v1.11.14
func (p *KubeRuntime) GetAccessibleStakingAddress(ctx context.Context) (netip.AddrPort, func(), error)
GetAccessibleStakingAddress retrieves a StakingAddress for the node intended to be accessible from this process until the provided cancel function is called.
func (*KubeRuntime) GetAccessibleURI ¶ added in v1.11.14
func (p *KubeRuntime) GetAccessibleURI() string
GetAccessibleURI retrieves a URI for the node accessible from where this process is running. If the process is running inside a kube cluster, the node and the process will be assumed to be running in the same kube cluster and the node's URI be used. If the process is running outside of a kube cluster, a URI accessible from outside of the cluster will be used.
func (*KubeRuntime) InitiateStop ¶
func (p *KubeRuntime) InitiateStop(ctx context.Context) error
Stop the Pod by setting the replicas to zero on the StatefulSet.
func (*KubeRuntime) IsHealthy ¶
func (p *KubeRuntime) IsHealthy(ctx context.Context) (bool, error)
IsHealthy checks if the node is running and healthy.
func (*KubeRuntime) Restart ¶
func (p *KubeRuntime) Restart(ctx context.Context) error
Restarts the node. Does not wait for readiness or health.
func (*KubeRuntime) Start ¶
func (p *KubeRuntime) Start(ctx context.Context) error
Start the node as a Kubernetes StatefulSet.
func (*KubeRuntime) WaitForStopped ¶
func (p *KubeRuntime) WaitForStopped(ctx context.Context) error
Waits for the node process to stop. TODO(marun) Consider using a watch instead
type KubeRuntimeConfig ¶
type KubeRuntimeConfig struct {
// Path to the kubeconfig file identifying the target cluster
ConfigPath string `json:"configPath,omitempty"`
// The context of the kubeconfig file to use
ConfigContext string `json:"configContext,omitempty"`
// Namespace in the target cluster in which resources will be
// created. For simplicity all nodes are assumed to be deployed to
// the same namespace to ensure network connectivity.
Namespace string `json:"namespace,omitempty"`
// The docker image to run for the node
Image string `json:"image,omitempty"`
// Size in gigabytes of the PersistentVolumeClaim to allocate for the node
VolumeSizeGB uint `json:"volumeSizeGB,omitempty"`
// Whether to schedule each Luxd node to a dedicated Kubernetes node
UseExclusiveScheduling bool `json:"useExclusiveScheduling,omitempty"`
// Label key to use for exclusive scheduling for node selection and toleration
SchedulingLabelKey string `json:"schedulingLabelKey,omitempty"`
// Label value to use for exclusive scheduling for node selection and toleration
SchedulingLabelValue string `json:"schedulingLabelValue,omitempty"`
// Host for ingress rules (e.g., "localhost:30791" for kind, "tmpnet.example.com" for EKS)
IngressHost string `json:"ingressHost,omitempty"`
// TLS secret name for ingress (empty for HTTP, populated for HTTPS)
IngressSecret string `json:"ingressSecret,omitempty"`
}
type Net ¶ added in v1.17.2
type Net struct {
// A unique string that can be used to refer to the net across different temporary
// networks (since the NetID will be different every time the net is created)
Name string
Config FlagsMap
// The ID of the transaction that created the subnet
NetID ids.ID
// The private key that owns the subnet
OwningKey *secp256k1.PrivateKey
// IDs of the nodes responsible for validating the subnet
ValidatorIDs []ids.NodeID
Chains []*Chain
}
type Network ¶
type Network struct {
// Uniquely identifies the temporary network for metrics
// collection. Distinct from node's concept of network ID
// since the utility of special network ID values (e.g. to trigger
// specific fork behavior in a given network) precludes requiring
// unique network ID values across all temporary networks.
UUID string
// A string identifying the entity that started or maintains this
// network. Useful for differentiating between networks when a
// given CI job uses multiple networks.
Owner string
// Path where network configuration and data is stored
Dir string
// Id of the network. If zero, must be set in Genesis.
NetworkID uint32
// Genesis for the network. If nil, NetworkID must be non-zero
Genesis *genesis.UnparsedConfig
// Configuration for primary network chains (P, X, C)
// TODO(marun) Rename to PrimaryChainConfigs
ChainConfigs map[string]FlagsMap
// Default configuration to use when creating new nodes
DefaultFlags FlagsMap
DefaultRuntimeConfig NodeRuntimeConfig
// Keys pre-funded in the genesis on both the X-Chain and the C-Chain
PreFundedKeys []*secp256k1.PrivateKey
// Nodes that constitute the network
Nodes []*Node
// Subnets that have been enabled on the network
Subnets []*Subnet
}
Collects the configuration for running a temporary node network
func LocalNetworkOrPanic ¶
func LocalNetworkOrPanic() *Network
func NewDefaultNetwork ¶
func ReadNetwork ¶
Reads a network from the provided directory.
func (*Network) Create ¶
Creates the network on disk, generating its genesis and configuring its nodes in the process.
func (*Network) CreateNets ¶ added in v1.17.2
func (n *Network) CreateNets(ctx context.Context, w io.Writer, apiURI string, restartRequired bool) error
Ensure that each net on the network is created. If restartRequired is false, node restart to pick up configuration changes becomes the responsibility of the caller.
func (*Network) EnsureDefaultConfig ¶
Initializes a new network with default configuration.
func (*Network) EnsureNodeConfig ¶
Ensures the provided node has the configuration it needs to start. If the data dir is not set, it will be defaulted to [nodeParentDir]/[node ID]. For a not-yet-created network, no action will be taken. TODO(marun) Reword or refactor to account for the differing behavior pre- vs post-start
func (*Network) EnvFileContents ¶
func (*Network) EnvFilePath ¶
func (*Network) GetMonitoringLabels ¶
GetMonitoringLabels returns monitoring labels for the network (stub)
func (*Network) GetNodeURIs ¶
func (*Network) GetURIForNodeID ¶ added in v1.1.11
func (*Network) RestartNode ¶ added in v1.1.11
Restart a single node.
func (*Network) StartNodes ¶
Starts the specified nodes
func (*Network) TrackedSubnetsForNode ¶
TrackedSubnetsForNode returns the net IDs for the given node
type NetworkConfig ¶ added in v1.1.11
type NetworkConfig struct {
Genesis *genesis.UnparsedConfig
CChainConfig FlagsMap
DefaultFlags FlagsMap
FundedKeys []*secp256k1.PrivateKey
}
NetworkConfig defines configuration shared or common to all nodes in a given network.
func (*NetworkConfig) EnsureGenesis ¶ added in v1.1.11
func (c *NetworkConfig) EnsureGenesis(networkID uint32, validatorIDs []ids.NodeID) error
Ensure genesis is generated if not already present.
type Node ¶
type Node struct {
// Uniquely identifies the network the node is part of to enable monitoring.
NetworkUUID string
// Identify the entity associated with this network. This is
// intended to be used to label metrics to enable filtering
// results for a test run between the primary/shared network used
// by the majority of tests and private networks used by
// individual tests.
NetworkOwner string
// Set by EnsureNodeID which is also called when the node is read.
NodeID ids.NodeID
// Flags that will be supplied to the node at startup
Flags FlagsMap
// An ephemeral node is not expected to be a persistent member of the network and
// should therefore not be used as for bootstrapping purposes.
IsEphemeral bool
// The configuration used to initialize the node runtime.
RuntimeConfig *NodeRuntimeConfig
// Runtime state, intended to be set by NodeRuntime
URI string
StakingAddress string
// contains filtered or unexported fields
}
Node supports configuring and running a node participating in a temporary network.
func NewEphemeralNode ¶
Initializes an ephemeral node using the provided config flags
func NewNodesOrPanic ¶
Initializes the specified number of nodes.
func (*Node) EnsureBLSSigningKey ¶
Ensures a BLS signing key is generated if not already present.
func (*Node) EnsureKeys ¶
Ensures staking and signing keys are generated if not already present and that the node ID (derived from the staking keypair) is set.
func (*Node) EnsureNodeID ¶
Derives the node ID. Requires that a tls keypair is present.
func (*Node) EnsureStakingKeypair ¶
Ensures a staking keypair is generated if not already present.
func (*Node) GetDataDir ¶ added in v1.1.11
func (*Node) GetProofOfPossession ¶
func (n *Node) GetProofOfPossession() (*signer.ProofOfPossession, error)
Derives the nodes proof-of-possession. Requires the node to have a BLS signing key.
func (*Node) SaveAPIPort ¶ added in v1.1.11
Saves the currently allocated API port to the node's configuration for use across restarts. Reusing the port ensures consistent labeling of metrics.
func (*Node) SaveMetricsSnapshot ¶
Writes the current state of the metrics endpoint to disk
func (*Node) SetNetworkingConfig ¶ added in v1.1.11
Sets networking configuration for the node. Convenience method for setting networking flags.
type NodeConfig ¶ added in v1.1.11
NodeConfig defines configuration for an luxd node.
func NewNodeConfig ¶ added in v1.1.11
func NewNodeConfig() *NodeConfig
func (*NodeConfig) EnsureBLSSigningKey ¶ added in v1.1.11
func (nc *NodeConfig) EnsureBLSSigningKey() error
Ensures a BLS signing key is generated if not already present.
func (*NodeConfig) EnsureKeys ¶ added in v1.1.11
func (nc *NodeConfig) EnsureKeys() error
Ensures staking and signing keys are generated if not already present and that the node ID (derived from the staking keypair) is set.
func (*NodeConfig) EnsureNodeID ¶ added in v1.1.11
func (nc *NodeConfig) EnsureNodeID() error
Attempt to derive the node ID from the node configuration.
func (*NodeConfig) EnsureStakingKeypair ¶ added in v1.1.11
func (nc *NodeConfig) EnsureStakingKeypair() error
Ensures a staking keypair is generated if not already present.
func (*NodeConfig) SetNetworkingConfigDefaults ¶ added in v1.1.11
func (nc *NodeConfig) SetNetworkingConfigDefaults( httpPort uint16, stakingPort uint16, bootstrapIDs []string, bootstrapIPs []string, )
Convenience method for setting networking flags.
type NodeProcess ¶ added in v1.1.11
type NodeProcess struct {
// contains filtered or unexported fields
}
Defines local-specific node configuration. Supports setting default and node-specific values.
func (*NodeProcess) InitiateStop ¶ added in v1.1.11
func (p *NodeProcess) InitiateStop() error
Signals the node process to stop.
func (*NodeProcess) IsHealthy ¶ added in v1.1.11
func (p *NodeProcess) IsHealthy(ctx context.Context) (bool, error)
func (*NodeProcess) Start ¶ added in v1.1.11
func (p *NodeProcess) Start(w io.Writer) error
Start waits for the process context to be written which indicates that the node will be accepting connections on its staking port. The network will start faster with this synchronization due to the avoidance of exponential backoff if a node tries to connect to a beacon that is not ready.
func (*NodeProcess) WaitForStopped ¶ added in v1.1.11
func (p *NodeProcess) WaitForStopped(ctx context.Context) error
Waits for the node process to stop.
type NodeRuntime ¶
type NodeRuntime interface {
Start(w io.Writer) error
InitiateStop() error
WaitForStopped(ctx context.Context) error
IsHealthy(ctx context.Context) (bool, error)
// contains filtered or unexported methods
}
NodeRuntime defines the methods required to support running a node.
type NodeRuntimeConfig ¶
type NodeRuntimeConfig struct {
LuxNodePath string
Process *ProcessRuntimeConfig `json:"process,omitempty"`
Kube *KubeRuntimeConfig `json:"kube,omitempty"`
}
Configuration required to configure a node runtime.
type ProcessRuntime ¶
type ProcessRuntime struct {
// contains filtered or unexported fields
}
Defines local-specific node configuration. Supports setting default and node-specific values.
func (*ProcessRuntime) GetAccessibleStakingAddress ¶ added in v1.18.2
func (*ProcessRuntime) GetAccessibleURI ¶ added in v1.18.2
func (p *ProcessRuntime) GetAccessibleURI() string
GetAccessibleURI returns the URI that can be used to access the node's API.
func (*ProcessRuntime) InitiateStop ¶
func (p *ProcessRuntime) InitiateStop(_ context.Context) error
Signals the node process to stop.
func (*ProcessRuntime) IsHealthy ¶
func (p *ProcessRuntime) IsHealthy(ctx context.Context) (bool, error)
func (*ProcessRuntime) Restart ¶
func (p *ProcessRuntime) Restart(ctx context.Context) error
Restarts the node
func (*ProcessRuntime) Start ¶
func (p *ProcessRuntime) Start(ctx context.Context) error
Start waits for the process context to be written which indicates that the node will be accepting connections on its staking port. The network will start faster with this synchronization due to the avoidance of exponential backoff if a node tries to connect to a beacon that is not ready.
func (*ProcessRuntime) WaitForStopped ¶
func (p *ProcessRuntime) WaitForStopped(ctx context.Context) error
Waits for the node process to stop.
type ProcessRuntimeConfig ¶
type SDConfig ¶
SDConfig represents a Prometheus service discovery config entry.
file_sd_config docs: https://metrics.io/docs/prometheus/latest/configuration/configuration/#file_sd_config
type Subnet ¶
type Subnet = Net
Subnet is an alias for Net to maintain backward compatibility
func (*Subnet) AddValidators ¶
func (s *Subnet) AddValidators(ctx context.Context, w io.Writer, apiURI string, nodes ...*Node) error
Add validators to the subnet
func (*Subnet) Create ¶
Issues the net creation transaction and retains the result. The URI of a node is required to issue the transaction.
func (*Subnet) CreateChains ¶
func (*Subnet) HasChainConfig ¶
HasChainConfig indicates whether at least one of the subnet's chains have explicit configuration. This can be used to determine whether validator restart is required after chain creation to ensure that chains are configured correctly.
type XChainBalanceMap ¶
Helper type to simplify configuring X-Chain genesis balances