Documentation ¶
Index ¶
- Constants
- Variables
- func Run(ctx context.Context, grpcEndpoint string, keys keyring.Keyring, ...) error
- 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 Options
- type Range
- type SendSequence
- type Sequence
- type StakeSequence
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 DefaultSeed = 900183116
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, grpcEndpoint string, keys keyring.Keyring, encCfg encoding.Config, opts *Options, 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 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 (*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 uint64 GasLimit uint64 GasPrice float64 }
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 Options ¶
type Options struct {
// contains filtered or unexported fields
}
func DefaultOptions ¶
func DefaultOptions() *Options
func (*Options) SpecifyMasterAccount ¶
func (*Options) SuppressLogs ¶
func (*Options) UseFeeGrant ¶
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)