Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultCommandRegistry() map[string]CommandHandler
- func DefaultTopologies() []string
- func DeserializeAccountPublicKey(hexPubKey string) (cryptotypes.PubKey, error)
- func DownloadGenesis(ctx context.Context, initCtx *run.InitContext) (json.RawMessage, error)
- func DownloadSync[T any](ctx context.Context, initCtx *run.InitContext, topic *sync.Topic, _ T, ...) ([]T, error)
- func EntryPoint(runenv *runtime.RunEnv, initCtx *run.InitContext) error
- func NodeID(globalSeq int64) string
- func PublishGenesis(ctx context.Context, initCtx *run.InitContext, gen *coretypes.GenesisDoc) error
- func PublishNodeConfigs(ctx context.Context, initCtx *run.InitContext, nodes []RoleConfig) error
- func SerializePublicKey(pubKey cryptotypes.PubKey) string
- func StandardAppConfig(_ *Params) *srvconfig.Config
- func StandardCometConfig(params *Params) *tmconfig.Config
- func TestgroundConsensusParams(params *Params) *tmproto.ConsensusParams
- type Command
- type CommandHandler
- type Configurator
- type ConsensusNode
- func (cn *ConsensusNode) Bootstrap(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) ([]PeerPacket, error)
- func (cn *ConsensusNode) Init(baseDir string, genesis json.RawMessage, mcfg RoleConfig) error
- func (cn *ConsensusNode) StartNode(ctx context.Context, baseDir string) error
- func (cn *ConsensusNode) Stop() error
- func (cn *ConsensusNode) UniversalTestingConfig() testnode.UniversalTestingConfig
- type Follower
- func (f *Follower) Execute(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) error
- func (f *Follower) ListenForCommands(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) error
- func (f *Follower) Plan(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) error
- func (f *Follower) Retro(ctx context.Context, runenv *runtime.RunEnv, _ *run.InitContext) error
- func (f *Follower) RunTxSim(ctx context.Context, c RunTxSimCommandArgs) error
- type GenesisWrapper
- type Leader
- func (l *Leader) Execute(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) error
- func (l *Leader) GenesisEvent(params *Params, packets []PeerPacket) (*coretypes.GenesisDoc, error)
- func (l *Leader) Plan(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) error
- func (l *Leader) Retro(ctx context.Context, runenv *runtime.RunEnv, _ *run.InitContext) error
- type Operator
- type Params
- type PeerPacket
- type Role
- type RoleConfig
- type RunTxSimCommandArgs
- type TracingParams
Constants ¶
const ( // CancelCommand is the name of the command to cancel a command if it is // still running. This is a special command because it is not executed // normally, instead the Operator executes it directly. CancelCommand = "cancel" // TestEndName is the name of the command to signal the end of a test. This // is a special command because it is not executed normally, instead the // Operator executes it directly. TestEndName = "test_end" )
const ( TopologyParam = "topology" ConnectAllTopology = "connect_all" ConnectRandomTopology = "connect_random" SeedTopology = "seed" SeedGroupID = "seeds" )
const ( UnboundedBlockSize = "unbounded" ConsistentFill = "consistent-fill" )
const ( RunTxSimCommandID = "run_txsim" RunSubmitRandomPFBs = "submit-random-pfbs" )
const ( TimeoutParam = "timeout" ChainIDParam = "chain_id" ValidatorsParam = "validators" FullNodesParam = "full_nodes" HaltHeightParam = "halt_height" PexParam = "pex" SeedNodeParam = "seed_node" BlobSequencesParam = "blob_sequences" BlobSizesParam = "blob_sizes" BlobsPerSeqParam = "blobs_per_sequence" TimeoutCommitParam = "timeout_commit" TimeoutProposeParam = "timeout_propose" InboundPeerCountParam = "inbound_peer_count" OutboundPeerCountParam = "outbound_peer_count" GovMaxSquareSizeParam = "gov_max_square_size" MaxBlockBytesParam = "max_block_bytes" MempoolParam = "mempool" BroadcastTxsParam = "broadcast_txs" TracingTokenParam = "tracing_token" TracingURLParam = "tracing_url" TracingNodesParam = "tracing_nodes" ExperimentParam = "experiment" )
const ( TxSimAccountName = "txsim" ValidatorGroupID = "validators" LeaderGlobalSequence = 1 )
const FailedState = "failed"
const (
FinishedConfigState = sync.State("finished-config")
)
Variables ¶
var ( // PeerPacketTopic is the topic that the peer packets are published to. This // is the first piece of information that is published. PeerPacketTopic = sync.NewTopic("peer_packet", PeerPacket{}) // GenesisTopic is the topic that the genesis is published to. GenesisTopic = sync.NewTopic("genesis", GenesisWrapper{}) // MetaConfigTopic is the topic where each node's app and tendermint configs // are puslished to. These are published before the any node starts. MetaConfigTopic = sync.NewTopic("meta_config", RoleConfig{}) // CommandTopic is the topic that commands are published to. These commands // are published by the leader and subscribed to by all followers. CommandTopic = sync.NewTopic("command", Command{}) )
Functions ¶
func DefaultCommandRegistry ¶
func DefaultCommandRegistry() map[string]CommandHandler
func DefaultTopologies ¶
func DefaultTopologies() []string
func DeserializeAccountPublicKey ¶
func DeserializeAccountPublicKey(hexPubKey string) (cryptotypes.PubKey, error)
func DownloadGenesis ¶
func DownloadGenesis(ctx context.Context, initCtx *run.InitContext) (json.RawMessage, error)
func DownloadSync ¶
func DownloadSync[T any](ctx context.Context, initCtx *run.InitContext, topic *sync.Topic, _ T, count int) ([]T, error)
DownloadSync downloads the given topic from the sync service. It will download the given number of messages from the topic. If the topic is closed before the expected number of messages are received, an error is returned.
func EntryPoint ¶
func EntryPoint(runenv *runtime.RunEnv, initCtx *run.InitContext) error
EntryPoint is the universal entry point for all role based tests.
func PublishGenesis ¶
func PublishGenesis(ctx context.Context, initCtx *run.InitContext, gen *coretypes.GenesisDoc) error
PublishGenesis publishes the genesis to the sync service. It splits the genesis into 10 parts and publishes each part separately. This gets around the 32Kb limit the underlying websocket has
func PublishNodeConfigs ¶
func PublishNodeConfigs(ctx context.Context, initCtx *run.InitContext, nodes []RoleConfig) error
func SerializePublicKey ¶
func SerializePublicKey(pubKey cryptotypes.PubKey) string
func StandardAppConfig ¶
func StandardCometConfig ¶
func TestgroundConsensusParams ¶
func TestgroundConsensusParams(params *Params) *tmproto.ConsensusParams
Types ¶
type Command ¶
type Command struct { ID string `json:"id"` Name string `json:"name"` Args json.RawMessage `json:"args"` Timeout time.Duration `json:"timeout"` TargetGroup string `json:"target_group"` }
Command is a struct to represent commands from the leader. Each command has an associated handler that describes the execution logic for the command.
func EndTestCommand ¶
func EndTestCommand() Command
func NewRunTxSimCommand ¶
func NewRunTxSimCommand(id string, timeout time.Duration, args RunTxSimCommandArgs) Command
type CommandHandler ¶
type CommandHandler func(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext, args json.RawMessage) error
CommandHandler type defines the signature for command handlers
type Configurator ¶
type Configurator func(nodes []RoleConfig) ([]RoleConfig, error)
Configurator is a function that arbitrarily modifies the provided node configurations. It is used to generate the topology (which nodes are connected to which) of the network, along with making other arbitrary changes to the configs.
func ConnectRandom ¶
func ConnectRandom(numPeers int) Configurator
func GetConfigurators ¶
func GetConfigurators(runenv *runtime.RunEnv) ([]Configurator, error)
GetConfigurators
func TracingConfigurator ¶
func TracingConfigurator(runenv *runtime.RunEnv, tparams TracingParams) Configurator
TracingConfigurator is a Configurator that configures tracing for the network. It will set the nodes to collect only the round state data, and will set the nodes specified in the TracingParams to collect all trace data.
type ConsensusNode ¶
type ConsensusNode struct { Name string CmtConfig *tmconfig.Config AppConfig *srvconfig.Config // AppOptions are the application options of the test node. AppOptions *testnode.KVAppOptions // AppCreator is used to create the application for the testnode. AppCreator srvtypes.AppCreator // SuppressLogs in testnode. This should be set to true when running // testground tests unless debugging. SuppressLogs bool // contains filtered or unexported fields }
ConsensusNode is the node type used by testground instances to run a celestia-app full node. It can optionally be configured to be a validator, and has methods to bootstrap a network, initialize itself, start, and stop.
func (*ConsensusNode) Bootstrap ¶
func (cn *ConsensusNode) Bootstrap(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) ([]PeerPacket, error)
Bootstrap is the first function called in a test by each node. It is responsible for initializing the node and creating a gentx if this node is a validator.
func (*ConsensusNode) Init ¶
func (cn *ConsensusNode) Init(baseDir string, genesis json.RawMessage, mcfg RoleConfig) error
Init creates the files required by tendermint and celestia-app using the data downloaded from the Leader node.
func (*ConsensusNode) StartNode ¶
func (cn *ConsensusNode) StartNode(ctx context.Context, baseDir string) error
StartNode uses the testnode package to start a tendermint node with celestia-app and the provided configuration.
func (*ConsensusNode) Stop ¶
func (cn *ConsensusNode) Stop() error
Stop stops the node and cleans up the data directory by calling the cleanup functions. It returns the last error that was not nil if any of the cleanup functions returned an error.
func (*ConsensusNode) UniversalTestingConfig ¶
func (cn *ConsensusNode) UniversalTestingConfig() testnode.UniversalTestingConfig
UniversalTestingConfig returns the configuration used by the testnode package.
type Follower ¶
type Follower struct { *ConsensusNode // contains filtered or unexported fields }
Follower is the role for all nodes in a test except for the leader. It is responsible for downloading the genesis block and any other configuration data from the leader node.
func (*Follower) ListenForCommands ¶
func (*Follower) Plan ¶
func (f *Follower) Plan(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) error
Plan is the method that downloads the genesis, configurations, and keys for all of the other nodes in the network.
type GenesisWrapper ¶
type GenesisWrapper struct { // Part is the index of the part of the genesis file. This is used to bypass // testground's 32Kb limit on messages. Part int `json:"part"` Genesis string `json:"genesis"` }
GenesisWrapper is a simple struct wrapper that makes it easier testground to properly serialize and distribute the genesis file.
type Leader ¶
type Leader struct { *ConsensusNode // contains filtered or unexported fields }
Leader is the role for the leader node in a test. It is responsible for creating the genesis block and distributing it to all nodes.
func (*Leader) GenesisEvent ¶
func (l *Leader) GenesisEvent(params *Params, packets []PeerPacket) (*coretypes.GenesisDoc, error)
type Operator ¶
type Operator struct {
// contains filtered or unexported fields
}
Operator is a struct to manage the execution of commands. This is used to orchestrate actions across a network. When a command is received, the Operator will spawn a new goroutine to execute the command. The Operator will also track the status of each job and cancel any jobs that are still running when the Operator is stopped.
func (*Operator) RegisterCommand ¶
func (o *Operator) RegisterCommand(name string, handler CommandHandler)
func (*Operator) Run ¶
func (o *Operator) Run(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext, cmds <-chan Command) error
Run starts the Operator and waits for commands to be received that target its group. The Operator will spawn a new goroutine for each command received. It will also cancel any running jobs when the context is canceled or an error is thrown.
type Params ¶
type Params struct { ChainID string Validators int FullNodes int HaltHeight int Timeout time.Duration Pex bool Configurators []Configurator GenesisModifiers []genesis.Modifier PerPeerBandwidth int BlobsPerSeq int BlobSequences int BlobSizes int InboundPeerCount int OutboundPeerCount int GovMaxSquareSize int MaxBlockBytes int TimeoutCommit time.Duration TimeoutPropose time.Duration Mempool string BroadcastTxs bool TracingParams Experiment string }
func (*Params) ValidateBasic ¶
type PeerPacket ¶
type PeerPacket struct { PeerID string `json:"peer_id"` GroupID string `json:"group_id"` GlobalSequence int64 `json:"global_sequence"` GenesisAccounts []string `json:"genesis_accounts"` GenesisPubKeys []string `json:"pub_keys"` GenTx json.RawMessage `json:"gen_tx"` }
PeerPacket is the message that is sent to other nodes upon network initialization. It contains the necessary info from this node to start the network.
func (*PeerPacket) GetPubKeys ¶
func (pp *PeerPacket) GetPubKeys() ([]cryptotypes.PubKey, error)
func (*PeerPacket) IsLeader ¶
func (pp *PeerPacket) IsLeader() bool
func (*PeerPacket) IsValidator ¶
func (pp *PeerPacket) IsValidator() bool
func (*PeerPacket) Name ¶
func (pp *PeerPacket) Name() string
type Role ¶
type Role interface { // Plan is the first function called in a test by each node. It is // responsible for creating the genesis block, configuring nodes, and // starting the network. Plan(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) error // Execute is the second function called in a test by each node. It is // responsible for running any experiments. This is phase where commands are // sent and received. Execute(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) error // Retro is the last function called in a test by each node. It is // responsible for collecting any data from the node and/or running any // retrospective tests or benchmarks. Retro(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) error }
Role is the interface between a testground test entrypoint and the actual test logic. Testground creates many instances and passes each instance a configuration from the plan and manifest toml files. From those configurations a Role is created for each node, and the three methods below are ran in order.
type RoleConfig ¶
type RoleConfig struct { PeerID string `json:"peer_id"` GroupID string `json:"group_id"` GlobalSequence int64 `json:"global_sequence"` CmtConfig *tmconfig.Config `json:"cmt_config"` AppConfig *srvconfig.Config `json:"app_config"` }
func ConnectAll ¶
func ConnectAll(nodes []RoleConfig) ([]RoleConfig, error)
ConnectAll is a Configurator that connects all nodes to each other via persistent peers.
func DownloadNodeConfigs ¶
func DownloadNodeConfigs(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) ([]RoleConfig, error)
func NewConfigSet ¶
func NewConfigSet(params *Params, pps []PeerPacket) []RoleConfig
type RunTxSimCommandArgs ¶
type RunTxSimCommandArgs struct { // BlobSequences is the number of blob sequences to run BlobSequences int `json:"blob_sequences"` BlobSize int `json:"blob_size"` BlobCount int `json:"blob_count"` }
func (*RunTxSimCommandArgs) Sequences ¶
func (c *RunTxSimCommandArgs) Sequences() []txsim.Sequence
type TracingParams ¶
func ParseTracingParams ¶
func ParseTracingParams(runenv *runtime.RunEnv) TracingParams