Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultJSONMarshal(v interface{}) ([]byte, error)
- func FindNextNetworkID(rootDir string) (uint32, string, error)
- func GetDefaultRootDir() (string, error)
- func NewPrivateKeys(keyCount int) ([]*secp256k1.PrivateKey, error)
- func NewTestGenesis(networkID uint32, nodes []*Node, keysToFund []*secp256k1.PrivateKey) (*genesis.UnparsedConfig, error)
- func StopNetwork(ctx context.Context, dir string) error
- func WaitForHealthy(ctx context.Context, node *Node) error
- type FlagsMap
- type Network
- func (n *Network) AddEphemeralNode(ctx context.Context, w io.Writer, flags FlagsMap) (*Node, error)
- func (n *Network) AddNode(ctx context.Context, w io.Writer, node *Node, isEphemeral bool) (*Node, error)
- func (n *Network) EnvFileContents() string
- func (n *Network) EnvFilePath() string
- func (n *Network) GetBootstrapIPsAndIDs() ([]string, []string, error)
- func (n *Network) GetCChainConfigPath() string
- func (n *Network) GetChainConfigDir() string
- func (n *Network) GetDefaultsPath() string
- func (n *Network) GetGenesisPath() string
- func (n *Network) GetURIs() []NodeURI
- func (n *Network) PopulateNetworkConfig(networkID uint32, nodeCount int, keyCount int) error
- func (n *Network) PopulateNodeConfig(node *Node, nodeParentDir string) error
- func (n *Network) ReadAll() error
- func (n *Network) ReadCChainConfig() error
- func (n *Network) ReadConfig() error
- func (n *Network) ReadDefaults() error
- func (n *Network) ReadGenesis() error
- func (n *Network) ReadNodes() error
- func (n *Network) Start(w io.Writer) error
- func (n *Network) Stop(ctx context.Context) error
- func (n *Network) WaitForHealthy(ctx context.Context, w io.Writer) error
- func (n *Network) WriteAll() error
- func (n *Network) WriteCChainConfig() error
- func (n *Network) WriteDefaults() error
- func (n *Network) WriteEnvFile() error
- func (n *Network) WriteGenesis() error
- func (n *Network) WriteNodes() 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) GetProofOfPossession() (*signer.ProofOfPossession, error)
- func (n *Node) InitiateStop() error
- func (n *Node) IsHealthy(ctx context.Context) (bool, error)
- func (n *Node) Read() 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 NodeProcess
- type NodeRuntime
- type NodeRuntimeConfig
- type NodeURI
- type XChainBalanceMap
Constants ¶
const ( // Constants defining the names of shell variables whose value can // configure temporary network orchestration. NetworkDirEnvName = "TMPNET_NETWORK_DIR" RootDirEnvName = "TMPNET_ROOT_DIR" 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 = time.Second )
const (
AvalancheGoPathEnvName = "AVALANCHEGO_PATH"
)
const (
DefaultNodeTickerInterval = 50 * time.Millisecond
)
Variables ¶
var ErrNotRunning = errors.New("not running")
Functions ¶
func DefaultJSONMarshal ¶
Marshal to json with default prefix and indent.
func FindNextNetworkID ¶
Find the next available network ID by attempting to create a directory numbered from 1000 until creation succeeds. Returns the network id and the full path of the created directory.
func GetDefaultRootDir ¶
Default root dir for storing networks and their configuration.
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 StopNetwork ¶ added in v1.10.18
Stop the nodes of the network configured in the provided directory.
Types ¶
type FlagsMap ¶
type FlagsMap map[string]interface{}
Defines a mapping of flag keys to values intended to be supplied to an invocation of an AvalancheGo node.
func DefaultFlags ¶ added in v1.10.18
func DefaultFlags() FlagsMap
A set of flags appropriate for testing.
func ReadFlagsMap ¶
Utility function simplifying construction of a FlagsMap from a file.
func (FlagsMap) GetStringVal ¶
GetStringVal simplifies retrieving a map value as a string.
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 Network ¶
type Network struct { NodeRuntimeConfig Genesis *genesis.UnparsedConfig CChainConfig FlagsMap DefaultFlags FlagsMap PreFundedKeys []*secp256k1.PrivateKey // Nodes comprising the network Nodes []*Node // Path where network configuration will be stored Dir string }
Defines the configuration required for a tempoary network
func ReadNetwork ¶ added in v1.10.18
Read a network from the provided directory.
func StartNetwork ¶
func StartNetwork( ctx context.Context, w io.Writer, rootDir string, network *Network, nodeCount int, keyCount int, ) (*Network, error)
Starts a new network stored under the provided root dir. Required configuration will be defaulted if not provided.
func (*Network) AddEphemeralNode ¶
Adds a backend-agnostic ephemeral node to the network
func (*Network) EnvFileContents ¶ added in v1.10.18
func (*Network) EnvFilePath ¶ added in v1.10.18
func (*Network) GetBootstrapIPsAndIDs ¶
func (*Network) GetCChainConfigPath ¶
func (*Network) GetChainConfigDir ¶ added in v1.11.10
func (*Network) GetDefaultsPath ¶
func (*Network) GetGenesisPath ¶
func (*Network) GetURIs ¶
Retrieve API URIs for all running primary validator nodes. URIs for ephemeral nodes are not returned.
func (*Network) PopulateNetworkConfig ¶
Ensure the network has the configuration it needs to start.
func (*Network) PopulateNodeConfig ¶
Ensure 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]. Requires that the network has valid genesis data.
func (*Network) ReadCChainConfig ¶
func (*Network) ReadConfig ¶
Read network configuration from disk.
func (*Network) ReadDefaults ¶
func (*Network) ReadGenesis ¶
func (*Network) WaitForHealthy ¶ added in v1.10.18
Wait until all nodes in the network are healthy.
func (*Network) WriteCChainConfig ¶
func (*Network) WriteDefaults ¶
func (*Network) WriteEnvFile ¶
Write an env file that sets the network dir env when sourced.
func (*Network) WriteGenesis ¶
func (*Network) WriteNodes ¶
type Node ¶
type Node struct { // 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 (*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) 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) InitiateStop ¶ added in v1.10.18
func (*Node) SetNetworkingConfig ¶ added in v1.10.18
Sets networking configuration for the node. Convenience method for setting networking flags.
func (*Node) WaitForStopped ¶ added in v1.10.18
type NodeProcess ¶ added in v1.10.18
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.10.18
func (p *NodeProcess) InitiateStop() error
Signals the node process to stop.
func (*NodeProcess) IsHealthy ¶ added in v1.10.18
func (p *NodeProcess) IsHealthy(ctx context.Context) (bool, error)
func (*NodeProcess) Start ¶ added in v1.10.18
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.10.18
func (p *NodeProcess) WaitForStopped(ctx context.Context) error
Waits for the node process to stop.
type NodeRuntime ¶ added in v1.10.18
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 ¶ added in v1.10.18
type NodeRuntimeConfig struct {
AvalancheGoPath string
}
Configuration required to configure a node runtime.
type XChainBalanceMap ¶
Helper type to simplify configuring X-Chain genesis balances