Documentation ¶
Index ¶
- Constants
- Variables
- func Run(ctx context.Context, rpcEndpoints, grpcEndpoints []string, ...) error
- type Account
- type AccountAllocator
- type AccountManager
- type BlobSequence
- func (s *BlobSequence) Clone(n int) []Sequence
- func (s *BlobSequence) Init(_ context.Context, _ grpc.ClientConn, allocateAccounts AccountAllocator, ...)
- func (s *BlobSequence) Next(_ context.Context, _ grpc.ClientConn, rand *rand.Rand) (Operation, error)
- func (s *BlobSequence) WithNamespace(namespace ns.Namespace) *BlobSequence
- type Operation
- type QueryClient
- type Range
- type SendSequence
- type Sequence
- type StakeSequence
- type TxClient
- func (tc *TxClient) Broadcast(ctx context.Context, txBuilder sdkclient.TxBuilder, blobs []*blob.Blob) (*coretypes.ResultTx, error)
- func (tc *TxClient) ChainID() string
- func (tc *TxClient) Client() *http.HTTP
- func (tc *TxClient) Height() int64
- func (tc *TxClient) LastUpdated() time.Time
- func (tc *TxClient) Tx() sdkclient.TxBuilder
- func (tc *TxClient) WaitForHeight(ctx context.Context, height int64) error
- func (tc *TxClient) WaitForNBlocks(ctx context.Context, blocks int64) error
- func (tc *TxClient) WaitForTx(ctx context.Context, txID []byte) (*coretypes.ResultTx, error)
Constants ¶
const ( SendGasLimit = 100000 FeegrantGasLimit = 800000 )
const ( // Set the default gas limit to cover the costs of most transactions. // At 0.1 utia per gas, this equates to 20_000utia per transaction. DefaultGasLimit = 200_000 )
const ( // how often to poll the network for the latest height DefaultPollTime = 3 * time.Second )
Variables ¶
var ErrEndOfSequence = errors.New("end of sequence")
ErrEndOfSequence is a special error which indicates that the sequence has been terminated
Functions ¶
func Run ¶
func Run( ctx context.Context, rpcEndpoints, grpcEndpoints []string, keys keyring.Keyring, masterAccName string, seed int64, pollTime time.Duration, useFeegrant bool, sequences ...Sequence, ) error
Run is the entrypoint function for starting the txsim client. The lifecycle of the client is managed through the context. At least one grpc and rpc endpoint must be provided. The client relies on a single funded master account present in the keyring. The client allocates subaccounts for sequences at runtime. A seed can be provided for deterministic randomness. The pollTime dictates the frequency that the client should check for updates from state and that transactions have been committed.
This should be used for testing purposes only.
All sequences can be scaled up using the `Clone` method. This allows for a single sequence that repeatedly sends random PFBs to be scaled up to 1000 accounts sending PFBs.
Types ¶
type Account ¶
type Account struct { Address types.AccAddress PubKey cryptotypes.PubKey Sequence uint64 AccountNumber uint64 Balance int64 }
type AccountAllocator ¶
type AccountAllocator func(n, balance int) []types.AccAddress
AccountAllocator reserves and funds a series of accounts to be used exclusively by the Sequence.
type AccountManager ¶
type AccountManager struct {
// contains filtered or unexported fields
}
func NewAccountManager ¶
func NewAccountManager( ctx context.Context, keys keyring.Keyring, masterAccName string, txClient *TxClient, queryClient *QueryClient, useFeegrant bool, ) (*AccountManager, error)
func (*AccountManager) AllocateAccounts ¶
func (am *AccountManager) AllocateAccounts(n, balance int) []types.AccAddress
AllocateAccounts is used by sequences to specify the number of accounts and the balance of each of those accounts. Not concurrently safe.
func (*AccountManager) GenerateAccounts ¶
func (am *AccountManager) GenerateAccounts(ctx context.Context) error
Generate the pending accounts by sending the adequate funds. This operation is not concurrently safe.
type BlobSequence ¶
type BlobSequence struct {
// contains filtered or unexported fields
}
BlobSequence defines a pattern whereby a single user repeatedly sends a pay for blob message roughly every height. The PFB may consist of several blobs
func NewBlobSequence ¶
func NewBlobSequence(sizes, blobsPerPFB Range) *BlobSequence
func (*BlobSequence) Clone ¶
func (s *BlobSequence) Clone(n int) []Sequence
func (*BlobSequence) Init ¶
func (s *BlobSequence) Init(_ context.Context, _ grpc.ClientConn, allocateAccounts AccountAllocator, _ *rand.Rand, useFeegrant bool)
func (*BlobSequence) Next ¶
func (s *BlobSequence) Next(_ context.Context, _ grpc.ClientConn, rand *rand.Rand) (Operation, error)
func (*BlobSequence) WithNamespace ¶
func (s *BlobSequence) WithNamespace(namespace ns.Namespace) *BlobSequence
WithNamespace provides the option of fixing a predefined namespace for all blobs.
type Operation ¶
type Operation struct { Msgs []types.Msg Blobs []*blob.Blob Delay int64 GasLimit uint64 GasPrice float64 }
An operation represents a series of messages and blobs that are to be bundled in a single transaction. A delay (in heights) may also be set before the transaction is sent. The gas limit and price can also be set. If left at 0, the DefaultGasLimit will be used.
type QueryClient ¶
type QueryClient struct {
// contains filtered or unexported fields
}
QueryClient multiplexes requests across multiple running gRPC connections. It does this in a round-robin fashion.
func NewQueryClient ¶
func NewQueryClient(grpcEndpoints []string) (*QueryClient, error)
func (*QueryClient) Auth ¶
func (qc *QueryClient) Auth() auth.QueryClient
func (*QueryClient) Bank ¶
func (qc *QueryClient) Bank() bank.QueryClient
func (*QueryClient) Close ¶
func (qc *QueryClient) Close() error
func (*QueryClient) Conn ¶
func (qc *QueryClient) Conn() protogrpc.ClientConn
type SendSequence ¶
type SendSequence struct {
// contains filtered or unexported fields
}
SendSequence sets up an endless sequence of send transactions, moving tokens between a set of accounts
func NewSendSequence ¶
func NewSendSequence(numAccounts, sendAmount, numIterations int) *SendSequence
func (*SendSequence) Clone ¶
func (s *SendSequence) Clone(n int) []Sequence
func (*SendSequence) Init ¶
func (s *SendSequence) Init(_ context.Context, _ grpc.ClientConn, allocateAccounts AccountAllocator, _ *rand.Rand, _ bool)
Init sets up the accounts involved in the sequence. It calculates the necessary balance as the fees per transaction multiplied by the number of expected iterations plus the amount to be sent from one account to another
type Sequence ¶
type Sequence interface { // Clone replicates n instances of the sequence for scaling up the load // on a network. This is called before `Init` Clone(n int) []Sequence // Init allows the sequence to initialize itself. It may read the current state of // the chain and provision accounts for usage throughout the sequence. // For any randomness, use the rand source provided. Init(ctx context.Context, querier grpc.ClientConn, accountAllocator AccountAllocator, rand *rand.Rand, useFeegrant bool) // Next returns the next operation in the sequence. It returns EndOfSequence // when the sequence has been exhausted. The sequence may make use of the // grpc connection to query the state of the network as well as the deterministic // random number generator. Any error will abort the rest of the sequence. Next(ctx context.Context, querier grpc.ClientConn, rand *rand.Rand) (Operation, error) }
Sequence is the basic unit for programmatic transaction generation. It embodies a pattern of transactions which are executed among a group of accounts in isolation from the rest of the state machine.
type StakeSequence ¶
type StakeSequence struct {
// contains filtered or unexported fields
}
StakeSequence sets up an endless sequence whereby an account delegates to a validator, continuously claims the reward, and occasionally redelegates to another validator at random. The account only ever delegates to a single validator at a time. TODO: Allow for multiple delegations
func NewStakeSequence ¶
func NewStakeSequence(initialStake int) *StakeSequence
func (*StakeSequence) Clone ¶
func (s *StakeSequence) Clone(n int) []Sequence
func (*StakeSequence) Init ¶
func (s *StakeSequence) Init(_ context.Context, _ grpc.ClientConn, allocateAccounts AccountAllocator, _ *rand.Rand, useFeegrant bool)
type TxClient ¶
type TxClient struct {
// contains filtered or unexported fields
}
TxClient is a client for submitting transactions to one of several nodes. It uses a round-robin algorithm for multiplexing requests across multiple clients.
func NewTxClient ¶
func (*TxClient) Broadcast ¶
func (tc *TxClient) Broadcast(ctx context.Context, txBuilder sdkclient.TxBuilder, blobs []*blob.Blob) (*coretypes.ResultTx, error)
Broadcast encodes and broadcasts a transaction to the network. If CheckTx fails, the error will be returned. The method does not wait for the transaction to be included in a block.
func (*TxClient) LastUpdated ¶
func (*TxClient) WaitForHeight ¶
WaitForHeight continually polls the network for the latest height. It is concurrently safe.
func (*TxClient) WaitForNBlocks ¶
WaitForNBlocks uses WaitForHeight to wait for the given number of blocks to be produced.