tmpnet

package
v1.22.61 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultNetworkTimeout = 2 * time.Minute
)

Variables

This section is empty.

Functions

func GenerateNodeID added in v1.16.56

func GenerateNodeID() (ids.NodeID, error)

GenerateNodeID generates a random NodeID for testing purposes

func GetDefaultNetworkID added in v1.16.56

func GetDefaultNetworkID() uint32

GetDefaultNetworkID returns the default network ID for testing

func NewTestGenesisWithFunds added in v1.1.11

func NewTestGenesisWithFunds(
	networkID uint32,
	nodes []*Node,
	fundedKeys []*secp256k1.PrivateKey,
) ([]byte, error)

NewTestGenesisWithFunds creates a test genesis configuration with funded accounts

func ValidateGenesis added in v1.16.56

func ValidateGenesis(genesisBytes []byte) error

ValidateGenesis validates a genesis configuration

Types

type Allocation added in v1.16.56

type Allocation struct {
	ETHAddr        string         `json:"ethAddr"`
	LUXAddr        string         `json:"luxAddr"`
	InitialAmount  uint64         `json:"initialAmount"`
	UnlockSchedule []UnlockPeriod `json:"unlockSchedule,omitempty"`
}

Allocation represents an initial fund allocation

type Chain

type Chain struct {
	ChainID   ids.ID
	VMID      ids.ID
	ChainName string
	Genesis   []byte
}

Chain represents a blockchain in a subnet

type Flags added in v1.16.56

type Flags map[string]interface{}

Flags is a map of node flags with helper methods

func (Flags) GetStringVal added in v1.16.56

func (f Flags) GetStringVal(key string) string

GetStringVal returns the string value for a flag, or empty string if not found or not a string

type GenesisConfig added in v1.16.56

type GenesisConfig struct {
	NetworkID                  uint32       `json:"networkID"`
	Allocations                []Allocation `json:"allocations"`
	StartTime                  uint64       `json:"startTime"`
	InitialStakeDuration       uint64       `json:"initialStakeDuration"`
	InitialStakeDurationOffset uint64       `json:"initialStakeDurationOffset"`
	InitialStakedFunds         []string     `json:"initialStakedFunds"`
	InitialStakers             []Staker     `json:"initialStakers"`
	CChainGenesis              string       `json:"cChainGenesis"`
	Message                    string       `json:"message"`
}

GenesisConfig represents genesis configuration

type Network

type Network struct {
	UUID                 string
	NetworkID            uint32
	Owner                string
	Dir                  string
	Nodes                []*Node
	DefaultRuntimeConfig NodeRuntimeConfig
	Genesis              interface{} // Can be []byte or *genesis.UnparsedConfig
	DefaultFlags         Flags

	// Track subnets/chains
	Subnets []*Subnet
}

Network represents a local test network

func ReadNetwork

func ReadNetwork(ctx context.Context, log log.Logger, networkDir string) (*Network, error)

ReadNetwork reads a network from its directory

func (*Network) EnsureDefaultConfig

func (n *Network) EnsureDefaultConfig(log log.Logger) error

EnsureDefaultConfig ensures the network has default configuration

func (*Network) EnsureNodeConfig

func (n *Network) EnsureNodeConfig(node *Node) error

EnsureNodeConfig ensures a node has proper configuration for this network

func (*Network) GetBootstrapIPsAndIDs

func (n *Network) GetBootstrapIPsAndIDs() ([]string, []string)

GetBootstrapIPsAndIDs returns the bootstrap IPs and IDs for the network

func (*Network) Start added in v1.16.56

func (n *Network) Start(ctx context.Context, log log.Logger) error

Start starts all nodes in the network

func (*Network) Stop

func (n *Network) Stop(ctx context.Context) error

Stop stops all nodes in the network

func (*Network) Write

func (n *Network) Write() error

Write writes the network configuration to disk

type Node

type Node struct {
	NodeID         ids.NodeID
	URI            string
	StakingPort    uint64
	HTTPPort       uint64
	StakingAddress netip.AddrPort
	DataDir        string
	RuntimeConfig  *NodeRuntimeConfig
	Flags          Flags

	// BLS signing key
	SigningKey *bls.SecretKey

	// Staking credentials
	StakingKey  []byte
	StakingCert []byte
	// contains filtered or unexported fields
}

Node represents a node in a local test network

func NewNode

func NewNode() *Node

NewNode creates a new node with default configuration

func ReadNode added in v1.1.11

func ReadNode(nodeDir string) (*Node, error)

ReadNode reads a node configuration from its directory

func (*Node) EnsureBLSSigningKey

func (n *Node) EnsureBLSSigningKey() error

EnsureBLSSigningKey ensures the node has a BLS signing key

func (*Node) EnsureKeys

func (n *Node) EnsureKeys() error

EnsureKeys ensures the node has staking credentials and derives NodeID from them

func (*Node) GetURI added in v1.16.56

func (n *Node) GetURI() string

GetURI returns the node's HTTP URI

func (*Node) InitiateStop

func (n *Node) InitiateStop() error

InitiateStop sends SIGTERM to the node process without waiting

func (*Node) IsRunning

func (n *Node) IsRunning() bool

IsRunning returns true if the node process is running

func (*Node) Start

func (n *Node) Start(ctx context.Context, log log.Logger) error

Start starts the node process

func (*Node) Stop

func (n *Node) Stop(ctx context.Context) error

Stop stops the node process

func (*Node) WaitForStopped

func (n *Node) WaitForStopped(ctx context.Context) error

WaitForStopped waits for the node process to exit

func (*Node) Write

func (n *Node) Write() error

Write writes the node configuration to disk

type NodeConfig added in v1.1.11

type NodeConfig struct {
	NodeID      string                 `json:"nodeID"`
	URI         string                 `json:"uri"`
	StakingPort uint64                 `json:"stakingPort"`
	HTTPPort    uint64                 `json:"httpPort"`
	DataDir     string                 `json:"dataDir"`
	Flags       map[string]interface{} `json:"flags"`
}

NodeConfig is the serialized node configuration

type NodeRuntimeConfig

type NodeRuntimeConfig struct {
	Process *ProcessRuntimeConfig
}

NodeRuntimeConfig configures how nodes are run

type ProcessRuntimeConfig

type ProcessRuntimeConfig struct {
	LuxdPath    string
	LuxNodePath string // Alias for LuxdPath for CLI compatibility
	PluginDir   string
}

ProcessRuntimeConfig configures process execution

type Staker added in v1.16.56

type Staker struct {
	NodeID        string `json:"nodeID"`
	RewardAddress string `json:"rewardAddress"`
	DelegationFee uint32 `json:"delegationFee"`
}

Staker represents an initial staker

type Subnet

type Subnet struct {
	SubnetID     ids.ID
	Chains       []*Chain
	ValidatorIDs []ids.NodeID
}

Subnet represents a subnet in the network

type UnlockPeriod added in v1.16.56

type UnlockPeriod struct {
	Amount   uint64 `json:"amount"`
	Locktime uint64 `json:"locktime"`
}

UnlockPeriod represents a vesting unlock period

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL