Documentation
¶
Index ¶
- Constants
- Variables
- func BootstrapNewNetwork(ctx context.Context, log logging.Logger, network *Network, ...) error
- func CheckLogsExist(ctx context.Context, log logging.Logger, networkUUID string) error
- func CheckMetricsExist(ctx context.Context, log logging.Logger, networkUUID string) error
- func CheckNodeHealth(ctx context.Context, uri string) (*health.APIReply, error)
- func DefaultChainConfigs() map[string]ConfigMap
- func DefaultJSONMarshal(v interface{}) ([]byte, error)
- func DefaultPodFlags(networkName string, dataDir string) map[string]string
- func DeployKubeCollectors(ctx context.Context, log logging.Logger, configPath string, ...) error
- func GetClientConfig(log logging.Logger, path string, context string) (*restclient.Config, error)
- func GetClientset(log logging.Logger, path string, context string) (*kubernetes.Clientset, error)
- func GetEnvWithDefault(envVar, defaultVal string) string
- func GetNodeWebsocketURIs(ctx context.Context, nodes []*Node, blockchainID string, ...) ([]string, error)
- func GetPrometheusServiceDiscoveryDir() (string, error)
- func GetReusableNetworkPathForOwner(owner string) (string, error)
- func IsRunningInCluster() bool
- func MetricsLinkForNetwork(networkUUID string, startTime string, 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, nodes []*Node, keysToFund []*secp256k1.PrivateKey) (*genesis.UnparsedConfig, error)
- func NodesToIDs(nodes ...*Node) []ids.NodeID
- func RestartNetwork(ctx context.Context, log logging.Logger, dir string) error
- func StartKindCluster(ctx context.Context, log logging.Logger, configPath string, ...) error
- func StartPrometheus(ctx context.Context, log logging.Logger) error
- func StartPromtail(ctx context.Context, log logging.Logger) error
- func StopLogsCollector(ctx context.Context, log logging.Logger) error
- func StopMetricsCollector(ctx context.Context, log logging.Logger) error
- func StopNetwork(ctx context.Context, log logging.Logger, dir string) error
- func WaitForActiveValidators(ctx context.Context, log logging.Logger, pChainClient platformvm.Client, ...) error
- func WaitForHealthyNodes(ctx context.Context, log logging.Logger, nodes []*Node) error
- func WaitForNodeHealthy(ctx context.Context, log logging.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 logging.Logger) error
- type Chain
- type ConfigMap
- type FlagsMap
- type KubeRuntime
- func (p *KubeRuntime) GetLocalStakingAddress(ctx context.Context) (netip.AddrPort, func(), error)
- func (p *KubeRuntime) GetLocalURI(ctx context.Context) (string, func(), error)
- 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 Network
- func (n *Network) Bootstrap(ctx context.Context, log logging.Logger) error
- func (n *Network) Create(rootDir string) error
- func (n *Network) CreateSubnets(ctx context.Context, log logging.Logger, apiURI string, restartRequired bool) error
- func (n *Network) DefaultGenesis() (*genesis.UnparsedConfig, error)
- func (n *Network) EnsureDefaultConfig(log logging.Logger) error
- func (n *Network) EnsureNodeConfig(node *Node) error
- func (n *Network) EnvFileContents() string
- func (n *Network) EnvFilePath() string
- func (n *Network) GetAvailableNodeIDs() []string
- func (n *Network) GetBootstrapIPsAndIDs(skippedNode *Node) ([]string, []string)
- func (n *Network) GetChainConfigContent() (string, error)
- func (n *Network) GetGenesisFileContent() (string, error)
- func (n *Network) GetGenesisPath() string
- func (n *Network) GetMonitoringLabels() map[string]string
- func (n *Network) GetNetworkID() uint32
- func (n *Network) GetNode(nodeID ids.NodeID) (*Node, error)
- func (n *Network) GetNodeURIs(ctx context.Context, deferCleanupFunc func(func())) ([]NodeURI, error)
- func (n *Network) GetSubnet(name string) *Subnet
- func (n *Network) GetSubnetConfigContent() (string, error)
- func (n *Network) GetSubnetDir() string
- func (n *Network) Read(ctx context.Context) error
- func (n *Network) Restart(ctx context.Context) error
- func (n *Network) StartNode(ctx context.Context, node *Node) error
- func (n *Network) StartNodes(ctx context.Context, log logging.Logger, 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 Node
- func (n *Node) EnsureBLSSigningKey() error
- func (n *Node) EnsureKeys() error
- func (n *Node) EnsureNodeID() error
- func (n *Node) EnsureStakingKeypair() error
- func (n *Node) GetFlagsPath() string
- func (n *Node) GetLocalStakingAddress(ctx context.Context) (netip.AddrPort, func(), error)
- func (n *Node) GetLocalURI(ctx context.Context) (string, func(), error)
- func (n *Node) GetProofOfPossession() (*signer.ProofOfPossession, error)
- func (n *Node) GetUniqueID() string
- func (n *Node) InitiateStop(ctx context.Context) error
- func (n *Node) IsHealthy(ctx context.Context) (bool, error)
- func (n *Node) IsRunning() bool
- func (n *Node) Read(ctx context.Context, network *Network, dataDir string) error
- func (n *Node) Restart(ctx context.Context) error
- func (n *Node) SaveMetricsSnapshot(ctx context.Context) error
- func (n *Node) Start(ctx context.Context) error
- func (n *Node) Stop(ctx context.Context) error
- func (n *Node) WaitForHealthy(ctx context.Context) error
- func (n *Node) WaitForStopped(ctx context.Context) error
- func (n *Node) Write() error
- type NodeRuntime
- type NodeRuntimeConfig
- type NodeURI
- type ProcessRuntime
- func (p *ProcessRuntime) GetLocalStakingAddress(_ context.Context) (netip.AddrPort, func(), error)
- func (p *ProcessRuntime) GetLocalURI(_ context.Context) (string, func(), error)
- 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 RPCChainVMVersion
- type Subnet
- func (s *Subnet) AddValidators(ctx context.Context, log logging.Logger, apiURI string, nodes ...*Node) error
- func (s *Subnet) Create(ctx context.Context, uri string) error
- func (s *Subnet) CreateChains(ctx context.Context, log logging.Logger, 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) error
- type XChainBalanceMap
Constants ¶
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 // Minimum required to ensure connectivity-based health checks will pass DefaultNodeCount = 2 // Arbitrary number of pre-funded keys to create by default DefaultPreFundedKeyCount = 50 // A short minimum stake duration enables testing of staking logic. DefaultMinStakeDuration = "1s" )
const ( // Constants defining the names of shell variables whose value can // configure network orchestration. RootNetworkDirEnvName = "TMPNET_ROOT_NETWORK_DIR" NetworkDirEnvName = "TMPNET_NETWORK_DIR" // Message to log indicating where to look for metrics and logs for network MetricsAvailableMessage = "metrics and logs available via grafana (collectors must be running)" // eth address: 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC HardHatKeyStr = "56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027" )
const ( // TODO(marun) This should be configurable DefaultTmpnetNamespace = "tmpnet" KindKubeconfigContext = "kind-kind" )
const (
AvalancheGoPathEnvName = "AVALANCHEGO_PATH"
)
const (
DefaultNodeTickerInterval = 50 * time.Millisecond
)
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 (
AvalancheGoPluginDirEnvName = config.EnvVarName(config.EnvPrefix, config.PluginDirKey)
)
var ErrUnrecoverableNodeHealthCheck = errors.New("failed to query node health")
var ( // Key expected to be funded for subnet-evm hardhat testing // TODO(marun) Remove when subnet-evm configures the genesis with this key. HardhatKey *secp256k1.PrivateKey )
Functions ¶
func BootstrapNewNetwork ¶ added in v1.11.7
func CheckLogsExist ¶ added in v1.13.0
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 ¶ added in v1.13.0
CheckMetricsExist checks if metrics exist for the given network. Github labels are also used as filters if provided as env vars (GH_*).
func CheckNodeHealth ¶ added in v1.11.12
func DefaultChainConfigs ¶ added in v1.10.18
A set of chain configurations appropriate for testing.
func DefaultJSONMarshal ¶
Marshal to json with default prefix and indent.
func DefaultPodFlags ¶ added in v1.11.13
DefaultPodFlags defines common flags for avalanchego nodes running in a pod.
func DeployKubeCollectors ¶ added in v1.13.1
func DeployKubeCollectors( ctx context.Context, log logging.Logger, configPath string, configContext string, startMetricsCollector bool, startLogsCollector bool, ) error
DeployKubeCollectors deploys collectors of logs and metrics to a Kubernetes cluster.
func GetClientConfig ¶ added in v1.13.0
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 ¶ added in v1.13.0
GetClientset returns a kubernetes clientset for the provided kubeconfig path and context.
func GetEnvWithDefault ¶ added in v1.13.0
func GetNodeWebsocketURIs ¶ added in v1.13.2
func GetNodeWebsocketURIs( ctx context.Context, nodes []*Node, blockchainID string, deferCleanupFunc func(func()), ) ([]string, error)
GetNodeWebsocketURIs returns a list of websocket URIs for the given nodes and blockchain ID, in the form "ws://<node-uri>/ext/bc/<blockchain-id>/ws". Ephemeral and stopped nodes are ignored.
func GetPrometheusServiceDiscoveryDir ¶ added in v1.13.2
GetPrometheusServiceDiscoveryDir returns the path for prometheus file-based service discovery configuration.
func GetReusableNetworkPathForOwner ¶ added in v1.11.5
Retrieves the path to a reusable network path for the given owner.
func IsRunningInCluster ¶ added in v1.13.2
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 ¶ added in v1.11.12
MetricsLinkForNetwork returns a link to the default metrics dashboard for the network with the given UUID. The start and end times are accepted as strings to support the use of Grafana's time range syntax (e.g. `now`, `now-1h`).
func NewNodeStatefulSet ¶ added in v1.11.13
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 avalanchego node.
func NewPrivateKeys ¶ added in v1.10.18
func NewPrivateKeys(keyCount int) ([]*secp256k1.PrivateKey, error)
Helper simplifying creation of a set of private keys
func NewTestGenesis ¶
func NewTestGenesis( 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 ¶ added in v1.11.4
func RestartNetwork ¶ added in v1.10.18
Restarts the nodes of the network configured in the provided directory.
func StartKindCluster ¶ added in v1.13.0
func StartKindCluster( ctx context.Context, log logging.Logger, configPath string, startMetricsCollector bool, startLogsCollector bool, ) error
StartKindCluster starts a new kind cluster with integrated registry if one is not already running.
func StartPrometheus ¶ added in v1.13.1
StartPrometheus ensures prometheus is running to collect metrics from local nodes.
func StartPromtail ¶ added in v1.13.1
StartPromtail ensures promtail is running to collect logs from local nodes.
func StopLogsCollector ¶ added in v1.13.1
StopLogsCollector ensures promtail is not running.
func StopMetricsCollector ¶ added in v1.13.1
StopMetricsCollector ensures prometheus is not running.
func StopNetwork ¶ added in v1.10.18
Stops the nodes of the network configured in the provided directory.
func WaitForActiveValidators ¶ added in v1.11.10
func WaitForHealthyNodes ¶ added in v1.13.1
Waits for the provided nodes to become healthy.
func WaitForNodeHealthy ¶ added in v1.11.13
func WaitForNodeHealthy( ctx context.Context, log logging.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 ¶ added in v1.11.13
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 ¶ added in v1.11.13
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.
Types ¶
type Chain ¶ added in v1.10.18
type Chain struct { // Set statically VMID ids.ID Config string Genesis []byte // VersionArgs are the argument(s) to pass to the VM binary to receive // version details in json format (e.g. `--version-json`). This // supports checking that the rpcchainvm version of the VM binary // matches the version used by the configured avalanchego binary. If // empty, the version check will be skipped. VersionArgs []string // Set at runtime ChainID ids.ID PreFundedKey *secp256k1.PrivateKey }
type ConfigMap ¶ added in v1.13.1
ConfigMap enables defining configuration in a format appropriate for round-tripping through JSON back to golang structs.
type FlagsMap ¶
Defines a mapping of flag keys to values intended to be supplied to an invocation of an AvalancheGo node.
func DefaultE2EFlags ¶ added in v1.13.1
func DefaultE2EFlags() FlagsMap
Flags suggested for e2e testing
func DefaultTmpnetFlags ¶ added in v1.11.6
func DefaultTmpnetFlags() FlagsMap
Flags suggested for temporary networks. Applied by default.
func ReadFlagsMap ¶
Utility function simplifying construction of a FlagsMap from a file.
func (FlagsMap) SetDefault ¶ added in v1.13.1
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 ¶ added in v1.13.1
type KubeRuntime struct {
// contains filtered or unexported fields
}
func (*KubeRuntime) GetLocalStakingAddress ¶ added in v1.13.1
GetLocalStakingAddress retrieves a StakingAddress for the node intended to be accessible from this process until the provided cancel function is called.
func (*KubeRuntime) GetLocalURI ¶ added in v1.13.1
func (p *KubeRuntime) GetLocalURI(ctx context.Context) (string, func(), error)
GetLocalURI retrieves a URI for the node intended to be accessible from this process until the provided cancel function is called.
func (*KubeRuntime) InitiateStop ¶ added in v1.13.1
func (p *KubeRuntime) InitiateStop(ctx context.Context) error
Stop the Pod by setting the replicas to zero on the StatefulSet.
func (*KubeRuntime) IsHealthy ¶ added in v1.13.1
func (p *KubeRuntime) IsHealthy(ctx context.Context) (bool, error)
IsHealthy checks if the node is running and healthy.
TODO(marun) Add WaitForHealthy as a runtime method to minimize API calls required and enable reuse of forwarded connection when running external to the kubernetes cluster
func (*KubeRuntime) Restart ¶ added in v1.13.1
func (p *KubeRuntime) Restart(ctx context.Context) error
Restarts the node. Does not wait for readiness or health.
func (*KubeRuntime) Start ¶ added in v1.13.1
func (p *KubeRuntime) Start(ctx context.Context) error
Start the node as a Kubernetes StatefulSet.
func (*KubeRuntime) WaitForStopped ¶ added in v1.13.1
func (p *KubeRuntime) WaitForStopped(ctx context.Context) error
Waits for the node process to stop. TODO(marun) Consider using a watch instead
type KubeRuntimeConfig ¶ added in v1.13.1
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 AvalancheGo 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"` }
type Network ¶
type Network struct { // Uniquely identifies the temporary network for metrics // collection. Distinct from avalanchego'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. Consider // using the GetNetworkID method if needing to retrieve the ID of // a running network. NetworkID uint32 // Genesis for the network. If nil, NetworkID must be non-zero Genesis *genesis.UnparsedConfig // Configuration for primary subnets PrimarySubnetConfig ConfigMap // Configuration for primary network chains (P, X, C) PrimaryChainConfigs map[string]ConfigMap // 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 // contains filtered or unexported fields }
Collects the configuration for running a temporary avalanchego network
func LocalNetworkOrPanic ¶ added in v1.11.6
func LocalNetworkOrPanic() *Network
func NewDefaultNetwork ¶ added in v1.11.6
func ReadNetwork ¶ added in v1.10.18
Reads a network from the provided directory.
func (*Network) Create ¶ added in v1.10.18
Creates the network on disk, generating its genesis and configuring its nodes in the process.
func (*Network) CreateSubnets ¶ added in v1.10.18
func (n *Network) CreateSubnets(ctx context.Context, log logging.Logger, apiURI string, restartRequired bool) error
Ensure that each subnet on the network is created. If restartRequired is false, node restart to pick up configuration changes becomes the responsibility of the caller.
func (*Network) DefaultGenesis ¶ added in v1.11.11
func (n *Network) DefaultGenesis() (*genesis.UnparsedConfig, error)
func (*Network) EnsureDefaultConfig ¶ added in v1.10.18
Initializes a new network with default configuration.
func (*Network) EnsureNodeConfig ¶ added in v1.10.18
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].
func (*Network) EnvFileContents ¶ added in v1.10.18
func (*Network) EnvFilePath ¶ added in v1.10.18
func (*Network) GetAvailableNodeIDs ¶ added in v1.13.1
GetAvailableNodeIDs returns the node IDs of nodes in the network that are running and not ephemeral.
func (*Network) GetBootstrapIPsAndIDs ¶ added in v1.13.1
Retrieves bootstrap IPs and IDs for all non-ephemeral nodes except the skipped one (this supports collecting the bootstrap details for restarting a node).
For consumption outside of avalanchego. Needs to be kept exported.
func (*Network) GetChainConfigContent ¶ added in v1.13.1
GetChainConfigContent returns the base64-encoded and JSON-marshaled map of chain alias/ID to JSON-marshaled chain configuration for both primary and custom chains.
func (*Network) GetGenesisFileContent ¶ added in v1.13.1
GetGenesisFileContent returns the base64-encoded JSON-marshaled network genesis.
func (*Network) GetGenesisPath ¶ added in v1.13.1
For consumption outside of avalanchego. Needs to be kept exported.
func (*Network) GetMonitoringLabels ¶ added in v1.13.1
GetMonitoringLabels retrieves the map of labels and their values to be applied to metrics and logs collected from nodes and other collection targets for the network (including test workloads). Callers may need to set a unique value for the `instance` label to ensure a stable identity for the collection target.
func (*Network) GetNetworkID ¶ added in v1.11.11
GetNetworkID returns the effective ID of the network. If the network defines a genesis, the network ID in the genesis will be returned. If a genesis is not present (i.e. a network with a genesis included in the avalanchego binary - mainnet, testnet and local), the value of the NetworkID field will be returned
func (*Network) GetNodeURIs ¶ added in v1.10.18
func (n *Network) GetNodeURIs(ctx context.Context, deferCleanupFunc func(func())) ([]NodeURI, error)
GetNodeURIs returns the URIs of nodes in the network that are running and not ephemeral. The URIs returned are guaranteed be reachable by the caller until the cleanup function is called regardless of whether the nodes are running as local processes or in a kube cluster.
func (*Network) GetSubnetConfigContent ¶ added in v1.13.1
GetSubnetConfigContent returns the base64-encoded and JSON-marshaled map of subnetID to subnet configuration.
func (*Network) GetSubnetDir ¶ added in v1.11.10
func (*Network) StartNode ¶ added in v1.10.18
Starts the provided node after configuring it for the network.
func (*Network) StartNodes ¶ added in v1.11.7
Starts the specified nodes
func (*Network) TrackedSubnetsForNode ¶ added in v1.11.4
TrackedSubnetsForNode returns the subnet IDs for the given node
type Node ¶
type Node struct { // Set by EnsureNodeID which is also called when the node is read. NodeID ids.NodeID // The set of flags used to start whose values are intended to deviate from the // default set of flags configured for the network. 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 // Optional, the configuration used to initialize the node runtime. // If not set, the network default will be used. RuntimeConfig *NodeRuntimeConfig // Runtime state, intended to be set by NodeRuntime URI string StakingAddress netip.AddrPort // Defaults to [network dir]/[node id] if not set DataDir string // contains filtered or unexported fields }
Node supports configuring and running a node participating in a temporary network.
func FilterAvailableNodes ¶ added in v1.13.1
FilteredAvailableNodes filters the provided nodes by whether they are running and not ephemeral.
func NewEphemeralNode ¶ added in v1.11.4
Initializes an ephemeral node using the provided config flags
func NewNode ¶ added in v1.10.18
func NewNode() *Node
Initializes a new node with only the data dir set
func NewNodesOrPanic ¶ added in v1.11.6
Initializes the specified number of nodes.
func (*Node) EnsureBLSSigningKey ¶ added in v1.10.18
Ensures a BLS signing key is generated if not already present.
func (*Node) EnsureKeys ¶ added in v1.10.18
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 ¶ added in v1.10.18
Derives the node ID. Requires that a tls keypair is present.
func (*Node) EnsureStakingKeypair ¶ added in v1.10.18
Ensures a staking keypair is generated if not already present.
func (*Node) GetFlagsPath ¶ added in v1.13.1
For consumption outside of avalanchego. Needs to be kept exported.
func (*Node) GetLocalStakingAddress ¶ added in v1.13.0
func (*Node) GetLocalURI ¶ added in v1.13.0
func (*Node) GetProofOfPossession ¶ added in v1.10.18
func (n *Node) GetProofOfPossession() (*signer.ProofOfPossession, error)
Derives the nodes proof-of-possession. Requires the node to have a BLS signing key.
func (*Node) GetUniqueID ¶ added in v1.12.2
GetUniqueID returns a globally unique identifier for the node.
func (*Node) InitiateStop ¶ added in v1.10.18
func (*Node) SaveMetricsSnapshot ¶ added in v1.10.18
Writes the current state of the metrics endpoint to disk
func (*Node) WaitForHealthy ¶ added in v1.13.1
WaitForHealthy blocks until node health is true or an error (including context timeout) is observed.
func (*Node) WaitForStopped ¶ added in v1.10.18
type NodeRuntime ¶ added in v1.10.18
type NodeRuntime interface { GetLocalURI(ctx context.Context) (string, func(), error) GetLocalStakingAddress(ctx context.Context) (netip.AddrPort, func(), error) Start(ctx context.Context) error InitiateStop(ctx context.Context) error WaitForStopped(ctx context.Context) error Restart(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 ¶ added in v1.10.18
type NodeRuntimeConfig struct { Process *ProcessRuntimeConfig `json:"process,omitempty"` Kube *KubeRuntimeConfig `json:"kube,omitempty"` }
Configuration required to configure a node runtime. Only one of the fields should be set.
func (*NodeRuntimeConfig) GetNetworkStartTimeout ¶ added in v1.13.2
func (c *NodeRuntimeConfig) GetNetworkStartTimeout(nodeCount int) (time.Duration, error)
GetNetworkStartTimeout returns the timeout to use when starting a network.
type NodeURI ¶
NodeURI associates a node ID with its API URI.
func GetNodeURIs ¶ added in v1.10.18
func GetNodeURIs(ctx context.Context, nodes []*Node, deferCleanupFunc func(func())) ([]NodeURI, error)
GetNodeURIs returns the URIs of the provided nodes that are running and not ephemeral. The URIs returned are guaranteed be reachable by the caller until the cleanup function is called regardless of whether the nodes are running as local processes or in a kube cluster.
type ProcessRuntime ¶ added in v1.13.1
type ProcessRuntime struct {
// contains filtered or unexported fields
}
Defines local-specific node configuration. Supports setting default and node-specific values.
func (*ProcessRuntime) GetLocalStakingAddress ¶ added in v1.13.1
func (*ProcessRuntime) GetLocalURI ¶ added in v1.13.1
func (p *ProcessRuntime) GetLocalURI(_ context.Context) (string, func(), error)
func (*ProcessRuntime) InitiateStop ¶ added in v1.13.1
func (p *ProcessRuntime) InitiateStop(_ context.Context) error
Signals the node process to stop.
func (*ProcessRuntime) IsHealthy ¶ added in v1.13.1
func (p *ProcessRuntime) IsHealthy(ctx context.Context) (bool, error)
func (*ProcessRuntime) Restart ¶ added in v1.13.1
func (p *ProcessRuntime) Restart(ctx context.Context) error
Restarts the node
func (*ProcessRuntime) Start ¶ added in v1.13.1
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 ¶ added in v1.13.1
func (p *ProcessRuntime) WaitForStopped(ctx context.Context) error
Waits for the node process to stop.
type ProcessRuntimeConfig ¶ added in v1.13.1
type RPCChainVMVersion ¶ added in v1.11.11
type RPCChainVMVersion struct {
RPCChainVM uint64 `json:"rpcchainvm"`
}
type Subnet ¶ added in v1.10.18
type Subnet struct { // A unique string that can be used to refer to the subnet across different temporary // networks (since the SubnetID will be different every time the subnet is created) Name string Config ConfigMap // The ID of the transaction that created the subnet SubnetID 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 }
func (*Subnet) AddValidators ¶ added in v1.10.18
func (s *Subnet) AddValidators(ctx context.Context, log logging.Logger, apiURI string, nodes ...*Node) error
Add validators to the subnet
func (*Subnet) Create ¶ added in v1.10.18
Issues the subnet creation transaction and retains the result. The URI of a node is required to issue the transaction.
func (*Subnet) CreateChains ¶ added in v1.10.18
func (*Subnet) HasChainConfig ¶ added in v1.11.0
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