testnet

package
v3.1.0-arabica Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TxsimVersion = "8e573bb"
	MB           = 1000 * 1000
	GB           = 1000 * MB
	MiB          = 1024 * 1024
	GiB          = 1024 * MiB
)
View Source
const (
	DefaultSeed    int64 = 42
	DefaultChainID       = "test-chain-id"
)

Variables

View Source
var DefaultResources = Resources{
	MemoryRequest: resource.MustParse("400Mi"),
	MemoryLimit:   resource.MustParse("400Mi"),
	CPU:           resource.MustParse("300m"),
	Volume:        resource.MustParse("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(ctx context.Context, 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 Node

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

func NewNode

func NewNode(
	ctx context.Context,
	name string,
	version string,
	startHeight int64,
	selfDelegation int64,
	peers []string,
	signerKey crypto.PrivKey,
	networkKey crypto.PrivKey,
	upgradeHeightV2 int64,
	resources Resources,
	grafana *GrafanaInfo,
	kn *knuu.Knuu,
	disableBBR bool,
) (*Node, error)

func (Node) AddressP2P

func (n Node) AddressP2P(ctx context.Context, 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 proxy host that can be used to communicate with the node

func (Node) AddressTracing

func (n Node) AddressTracing() string

func (Node) Client

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

func (*Node) EnableNetShaper

func (n *Node) EnableNetShaper()

func (*Node) GenesisValidator

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

func (*Node) Init

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

func (Node) IsValidator

func (n Node) IsValidator() bool

func (*Node) PullBlockSummaryTraces

func (n *Node) PullBlockSummaryTraces(path string) ([]trace.Event[schema.BlockSummary], error)

PullBlockSummaryTraces retrieves the block summary traces from a node. It will save them to the provided path.

func (*Node) PullRoundStateTraces

func (n *Node) PullRoundStateTraces(path string) ([]trace.Event[schema.RoundState], error)

PullRoundStateTraces retrieves the round state traces from a node. It will save them to the provided path.

func (Node) RemoteAddressGRPC

func (n Node) RemoteAddressGRPC(ctx context.Context) (string, error)

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

func (Node) RemoteAddressRPC

func (n Node) RemoteAddressRPC(ctx context.Context) (string, error)

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

func (Node) RemoteAddressTracing

func (n Node) RemoteAddressTracing(ctx context.Context) (string, error)

func (*Node) SetLatencyAndJitter

func (n *Node) SetLatencyAndJitter(latency, jitter int64) error

func (*Node) Start

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

func (*Node) StartAsync

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

func (*Node) Upgrade

func (n *Node) Upgrade(ctx context.Context, version string) error

func (*Node) WaitUntilStartedAndCreateProxy

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

type Option

type Option func(*config.Config)

func WithBroadcastTxs

func WithBroadcastTxs(broadcast bool) Option

func WithLocalTracing

func WithLocalTracing(localTracingType string) Option

func WithMempool

func WithMempool(mempool string) Option

func WithMempoolMaxTxBytes

func WithMempoolMaxTxBytes(maxTxBytes int) Option

func WithMempoolMaxTxsBytes

func WithMempoolMaxTxsBytes(maxTxsBytes int64) 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

func WithTxIndexer

func WithTxIndexer(indexer string) Option

type Options

type Options struct {
	Seed             int64
	Grafana          *GrafanaInfo
	ChainID          string
	GenesisModifiers []genesis.Modifier
}

type Resources

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

Resources defines the resource requirements for a Node.

type Testnet

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

func New

func New(knuu *knuu.Knuu, opts Options) (*Testnet, error)

func (*Testnet) Cleanup

func (t *Testnet) Cleanup(ctx context.Context)

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(ctx context.Context, version string, selfDelegation, upgradeHeightV2 int64, resources Resources, disableBBR bool) error

func (*Testnet) CreateGenesisNodes

func (t *Testnet) CreateGenesisNodes(ctx context.Context, num int, version string, selfDelegation, upgradeHeightV2 int64, resources Resources, disableBBR bool) error

func (*Testnet) CreateNode

func (t *Testnet) CreateNode(ctx context.Context, version string, startHeight, upgradeHeight int64, resources Resources, disableBBR bool) error

func (*Testnet) CreateTxClient

func (t *Testnet) CreateTxClient(
	ctx context.Context,
	name string,
	version string,
	blobSequences int,
	blobRange string,
	blobPerSequence int,
	resources Resources,
	grpcEndpoint string,
	upgradeSchedule map[int64]uint64,
) error

CreateTxClient creates a txsim node and sets it up.

Parameters: ctx: Context for managing the lifecycle. name: Name of the txsim knuu instance. version: Version of the txsim Docker image to pull. blobSequences: Number of blob sequences to run by the txsim. blobRange: Range of blob sizes in bytes used by the txsim. blobPerSequence: Number of blobs per sequence. resources: Resources allocated to the txsim. grpcEndpoint: gRPC endpoint of the node for transaction submission. upgradeSchedule: Map from height to version for scheduled upgrades (v3 and onwards).

func (*Testnet) CreateTxClients

func (t *Testnet) CreateTxClients(ctx context.Context,
	version string,
	sequences int,
	blobRange string,
	blobPerSequence int,
	resources Resources,
	grpcEndpoints []string,
	upgradeSchedule map[int64]uint64,
) error

func (*Testnet) Genesis

func (t *Testnet) Genesis() *genesis.Genesis

func (*Testnet) GetGenesisValidators

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

func (*Testnet) NewPreloader

func (t *Testnet) NewPreloader() (*preloader.Preloader, error)

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(ctx context.Context) ([]string, error)

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

func (*Testnet) RemoteRPCEndpoints

func (t *Testnet) RemoteRPCEndpoints(ctx context.Context) ([]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(ctx context.Context, configOpts ...Option) error

func (*Testnet) Start

func (t *Testnet) Start(ctx context.Context) error

func (*Testnet) StartNodes

func (t *Testnet) StartNodes(ctx context.Context) error

StartNodes starts the testnet nodes and setup proxies. It does not wait for the nodes to produce blocks. For that, use WaitToSync.

func (*Testnet) StartTxClients

func (t *Testnet) StartTxClients(ctx context.Context) error

func (*Testnet) WaitToSync

func (t *Testnet) WaitToSync(ctx context.Context) error

WaitToSync waits for the started nodes to sync with the network and move past the genesis block.

type TxSim

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

func CreateTxClient

func CreateTxClient(
	ctx context.Context,
	name string,
	version string,
	endpoint string,
	seed int64,
	blobSequences int,
	blobRange string,
	blobsPerSeq int,
	pollTime int,
	resources Resources,
	volumePath string,
	knuu *knuu.Knuu,
	upgradeSchedule map[int64]uint64,
) (*TxSim, error)

CreateTxClient returns a new TxSim instance.

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