testnet

package
v2.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const TxsimVersion = "a92de72"

Variables

View Source
var DefaultResources = Resources{
	MemoryRequest: "200Mi",
	MemoryLimit:   "200Mi",
	CPU:           "300m",
	Volume:        "1Gi",
}

Functions

func DockerImageName

func DockerImageName(version string) string

func GetLatestVersion

func GetLatestVersion() (string, error)

GetLatestVersion retrieves the latest git commit hash or semantic version of the main branch.

func MakeAppConfig

func MakeAppConfig(_ *Node) (*serverconfig.Config, error)

func MakeConfig

func MakeConfig(node *Node, opts ...Option) (*config.Config, error)

func NoError

func NoError(message string, err error)

func WriteAddressBook

func WriteAddressBook(peers []string, file string) error

Types

type GrafanaInfo

type GrafanaInfo struct {
	Endpoint string
	Username string
	Token    string
}

func GetGrafanaInfoFromEnvVar

func GetGrafanaInfoFromEnvVar() *GrafanaInfo

type JSONRPCError

type JSONRPCError struct {
	Code    int
	Message string
	Data    string
}

func (*JSONRPCError) Error

func (e *JSONRPCError) Error() string

type Node

type Node struct {
	Name           string
	Version        string
	StartHeight    int64
	InitialPeers   []string
	SignerKey      crypto.PrivKey
	NetworkKey     crypto.PrivKey
	SelfDelegation int64
	Instance       *knuu.Instance
	// contains filtered or unexported fields
}

func NewNode

func NewNode(
	name, version string,
	startHeight, selfDelegation int64,
	peers []string,
	signerKey, networkKey crypto.PrivKey,
	upgradeHeight int64,
	resources Resources,
	grafana *GrafanaInfo,
) (*Node, error)

func (Node) AddressGRPC

func (n Node) AddressGRPC() string

AddressGRPC returns a GRPC endpoint address for the node. This returns the local proxy port that can be used to communicate with the node

func (Node) AddressP2P

func (n Node) AddressP2P(withID bool) string

AddressP2P returns a P2P endpoint address for the node. This is used for populating the address book. This will look something like: 3314051954fc072a0678ec0cbac690ad8676ab98@61.108.66.220:26656

func (Node) AddressRPC

func (n Node) AddressRPC() string

AddressRPC returns an RPC endpoint address for the node. This returns the local proxy port that can be used to communicate with the node

func (Node) Client

func (n Node) Client() (*http.HTTP, error)

func (*Node) ForwardBitTwisterPort

func (n *Node) ForwardBitTwisterPort() error

func (*Node) GenesisValidator

func (n *Node) GenesisValidator() genesis.Validator

func (*Node) GetHeight

func (n *Node) GetHeight(executor *knuu.Executor) (int64, error)

func (*Node) Init

func (n *Node) Init(genesis *types.GenesisDoc, peers []string, configOptions ...Option) error

func (Node) IsValidator

func (n Node) IsValidator() bool

func (Node) RemoteAddressGRPC

func (n Node) RemoteAddressGRPC() (string, error)

RemoteAddressGRPC retrieves the gRPC endpoint address of a node within the cluster.

func (Node) RemoteAddressRPC

func (n Node) RemoteAddressRPC() (string, error)

RemoteAddressRPC retrieves the RPC endpoint address of a node within the cluster.

func (*Node) Start

func (n *Node) Start() error

func (*Node) Upgrade

func (n *Node) Upgrade(version string) error

type Option

type Option func(*config.Config)

func WithBroadcastTxs

func WithBroadcastTxs(broadcast bool) Option

func WithMempool

func WithMempool(mempool string) Option

func WithPerPeerBandwidth

func WithPerPeerBandwidth(bandwidth int64) Option

func WithPrometheus

func WithPrometheus(prometheus bool) Option

func WithTimeoutCommit

func WithTimeoutCommit(timeout time.Duration) Option

func WithTimeoutPropose

func WithTimeoutPropose(timeout time.Duration) Option

type Resources

type Resources struct {
	// MemoryRequest specifies the initial memory allocation for the Node.
	MemoryRequest string
	// MemoryLimit specifies the maximum memory allocation for the Node.
	MemoryLimit string
	// CPU specifies the CPU allocation for the Node.
	CPU string
	// Volume specifies the storage volume allocation for the Node.
	Volume string
}

Resources defines the resource requirements for a Node.

type Testnet

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

func New

func New(name string, seed int64, grafana *GrafanaInfo, chainID string,
	genesisModifiers ...genesis.Modifier) (
	*Testnet, error,
)

func (*Testnet) Cleanup

func (t *Testnet) Cleanup()

func (*Testnet) CreateAccount

func (t *Testnet) CreateAccount(name string, tokens int64, txsimKeyringDir string) (keyring.Keyring, error)

CreateAccount creates an account and adds it to the testnet genesis. The account is created with the given name and tokens and is persisted in the given txsimKeyringDir. If txsimKeyringDir is an empty string, an in-memory keyring is created.

func (*Testnet) CreateGenesisNode

func (t *Testnet) CreateGenesisNode(version string, selfDelegation, upgradeHeight int64, resources Resources) error

func (*Testnet) CreateGenesisNodes

func (t *Testnet) CreateGenesisNodes(num int, version string, selfDelegation, upgradeHeight int64, resources Resources) error

func (*Testnet) CreateNode

func (t *Testnet) CreateNode(version string, startHeight, upgradeHeight int64, resources Resources) error

func (*Testnet) CreateTxClient

func (t *Testnet) CreateTxClient(name,
	version string,
	sequences int,
	blobRange string,
	resources Resources,
	grpcEndpoint string,
) error

CreateTxClient creates a txsim node and sets it up name: name of the txsim knuu instance version: version of the txsim docker image to be pulled from the registry specified by txsimDockerSrcURL seed: seed for the txsim sequences: number of sequences to be run by the txsim blobRange: range of blob sizes to be used by the txsim in bytes pollTime: time in seconds between each sequence resources: resources to be allocated to the txsim grpcEndpoint: grpc endpoint of the node to which the txsim will connect and send transactions

func (*Testnet) CreateTxClients

func (t *Testnet) CreateTxClients(version string,
	sequences int,
	blobRange string,
	resources Resources,
	grpcEndpoints []string,
) error

func (*Testnet) GRPCEndpoints

func (t *Testnet) GRPCEndpoints() []string

func (*Testnet) GetExecutor

func (t *Testnet) GetExecutor() (*knuu.Executor, error)

func (*Testnet) GetGenesisValidators

func (t *Testnet) GetGenesisValidators() []genesis.Validator

func (*Testnet) Node

func (t *Testnet) Node(i int) *Node

func (*Testnet) Nodes

func (t *Testnet) Nodes() []*Node

func (*Testnet) RPCEndpoints

func (t *Testnet) RPCEndpoints() []string

func (*Testnet) RemoteGRPCEndpoints

func (t *Testnet) RemoteGRPCEndpoints() ([]string, error)

RemoteGRPCEndpoints retrieves the gRPC endpoint addresses of the testnet's validator nodes.

func (*Testnet) RemoteRPCEndpoints

func (t *Testnet) RemoteRPCEndpoints() ([]string, error)

RemoteRPCEndpoints retrieves the RPC endpoint addresses of the testnet's validator nodes.

func (*Testnet) SetConsensusMaxBlockSize

func (t *Testnet) SetConsensusMaxBlockSize(size int64)

func (*Testnet) SetConsensusParams

func (t *Testnet) SetConsensusParams(params *tmproto.ConsensusParams)

func (*Testnet) Setup

func (t *Testnet) Setup(configOpts ...Option) error

func (*Testnet) Start

func (t *Testnet) Start() error

func (*Testnet) StartTxClients

func (t *Testnet) StartTxClients() error

type TxSim

type TxSim struct {
	Name     string
	Instance *knuu.Instance
}

func CreateTxClient

func CreateTxClient(
	name, version string,
	endpoint string,
	seed int64,
	sequences int,
	blobRange string,
	pollTime int,
	resources Resources,
	volumePath string,
) (*TxSim, error)

type Version

type Version struct {
	Major uint64
	Minor uint64
	Patch uint64
	IsRC  bool
	RC    uint64
}

func ParseVersion

func ParseVersion(version string) (Version, bool)

ParseVersion takes a string and returns a Version. If the string is not a valid version, the second return value is false. Must be of the format v1.0.0 or v1.0.0-rc1 (i.e. following SemVer)

func (Version) IsGreater

func (v Version) IsGreater(v2 Version) bool

func (Version) String

func (v Version) String() string

type VersionSet

type VersionSet []Version

func ParseVersions

func ParseVersions(versionStr string) VersionSet

ParseVersions takes a string of space-separated versions and returns a VersionSet. Invalid versions are ignored.

func (VersionSet) FilterMajor

func (v VersionSet) FilterMajor(majorVersion uint64) VersionSet

func (VersionSet) FilterOutReleaseCandidates

func (v VersionSet) FilterOutReleaseCandidates() VersionSet

func (VersionSet) GetLatest

func (v VersionSet) GetLatest() Version

func (VersionSet) Order

func (v VersionSet) Order()

func (VersionSet) Random

func (v VersionSet) Random(r *rand.Rand) Version

func (VersionSet) String

func (v VersionSet) String() string

Jump to

Keyboard shortcuts

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