Documentation
¶
Index ¶
- func GetRandomAddress(randSrc *rand.Rand) *common.Address
- func LightSummary(results []Sample, startTime, endTime time.Time, rl *rate.Limiter)
- func NewHexwordReader(randSrc *rand.Rand) io.Reader
- func OutputRawBytes(rawTx []byte) error
- func OutputRawTransaction(tx *ethtypes.Transaction) error
- func Run(ctx context.Context, cfg *config.Config) error
- func SummarizeResults(ctx context.Context, c *ethclient.Client, rpc *ethrpc.Client, ...) error
- type Account
- type AccountPool
- func (ap *AccountPool) AccountCount() int
- func (ap *AccountPool) ActiveAccountCount() int
- func (ap *AccountPool) Add(ctx context.Context, privateKey *ecdsa.PrivateKey, startNonce *uint64) error
- func (ap *AccountPool) AddN(ctx context.Context, privateKeys ...*ecdsa.PrivateKey) error
- func (ap *AccountPool) AddRandom(ctx context.Context) error
- func (ap *AccountPool) AddRandomN(ctx context.Context, n uint64) error
- func (ap *AccountPool) AddReusableNonce(ctx context.Context, address common.Address, nonce uint64) error
- func (ap *AccountPool) AllAccountsReady() (bool, int, int)
- func (ap *AccountPool) FastForwardNonce(ctx context.Context, address common.Address, nextNonce uint64) (bool, error)
- func (ap *AccountPool) FetchNoncesInParallel(ctx context.Context) error
- func (ap *AccountPool) FundAccounts(ctx context.Context) error
- func (ap *AccountPool) GetPrivateKeys() []*ecdsa.PrivateKey
- func (ap *AccountPool) Next(ctx context.Context) (Account, error)
- func (ap *AccountPool) Nonces(ctx context.Context, onlyUsed bool) *sync.Map
- func (ap *AccountPool) NoncesOf(address common.Address) (startNonce, nonce uint64)
- func (ap *AccountPool) NumberOfPendingTxs(ctx context.Context) (uint64, error)
- func (ap *AccountPool) PrepareReverseNonces(txsPerAccount uint64) error
- func (ap *AccountPool) RefreshNonce(ctx context.Context, address common.Address) error
- func (ap *AccountPool) ReturnFunds(ctx context.Context) error
- func (ap *AccountPool) SetFundingAmount(amount *big.Int)
- func (ap *AccountPool) StopAccount(address common.Address) error
- type AccountPoolConfig
- type BlobCommitment
- type BlockSummary
- type Latency
- type Percentiles
- type PreconfStats
- type PreconfSummary
- type PreconfTracker
- type PreconfTxResult
- type Runner
- func (r *Runner) Close()
- func (r *Runner) GetAccountPool() *AccountPool
- func (r *Runner) GetClient() *ethclient.Client
- func (r *Runner) GetConfig() *config.Config
- func (r *Runner) GetDependencies() *mode.Dependencies
- func (r *Runner) GetResults() []Sample
- func (r *Runner) Init(ctx context.Context) error
- func (r *Runner) RecordSample(goRoutineID, requestID int64, err error, start, end time.Time, nonce uint64)
- func (r *Runner) Run(ctx context.Context) error
- func (r *Runner) SetModes(m []mode.Runner)
- type Sample
- type Summary
- type SummaryOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRandomAddress ¶
GetRandomAddress generates a random Ethereum address.
func LightSummary ¶
LightSummary prints a quick summary of load test results.
func NewHexwordReader ¶
NewHexwordReader creates a new hexword reader with the given random source.
func OutputRawBytes ¶
OutputRawBytes outputs raw bytes as a 0x-prefixed hex string.
func OutputRawTransaction ¶
func OutputRawTransaction(tx *ethtypes.Transaction) error
OutputRawTransaction outputs a raw signed transaction as hex.
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
Account represents a single account used by the load test.
func (*Account) PrivateKey ¶
func (a *Account) PrivateKey() *ecdsa.PrivateKey
PrivateKey returns the private key of the account.
type AccountPool ¶
type AccountPool struct {
// contains filtered or unexported fields
}
AccountPool manages a pool of accounts used for sending transactions.
func NewAccountPool ¶
func NewAccountPool(ctx context.Context, client *ethclient.Client, cfg *AccountPoolConfig) (*AccountPool, error)
NewAccountPool creates a new account pool with the given configuration.
func (*AccountPool) AccountCount ¶ added in v0.1.121
func (ap *AccountPool) AccountCount() int
AccountCount returns the total number of accounts in the pool.
func (*AccountPool) ActiveAccountCount ¶ added in v0.1.111
func (ap *AccountPool) ActiveAccountCount() int
ActiveAccountCount returns the number of accounts that are not stopped.
func (*AccountPool) Add ¶
func (ap *AccountPool) Add(ctx context.Context, privateKey *ecdsa.PrivateKey, startNonce *uint64) error
Add adds an account to the pool with the given private key.
func (*AccountPool) AddN ¶
func (ap *AccountPool) AddN(ctx context.Context, privateKeys ...*ecdsa.PrivateKey) error
AddN adds multiple accounts to the pool with the given private keys.
func (*AccountPool) AddRandom ¶
func (ap *AccountPool) AddRandom(ctx context.Context) error
AddRandom adds a random account to the pool.
func (*AccountPool) AddRandomN ¶
func (ap *AccountPool) AddRandomN(ctx context.Context, n uint64) error
AddRandomN adds N random accounts to the pool.
func (*AccountPool) AddReusableNonce ¶
func (ap *AccountPool) AddReusableNonce(ctx context.Context, address common.Address, nonce uint64) error
AddReusableNonce adds a reusable nonce to the account with the given address.
func (*AccountPool) AllAccountsReady ¶
func (ap *AccountPool) AllAccountsReady() (bool, int, int)
AllAccountsReady returns whether all accounts are ready for use.
func (*AccountPool) FastForwardNonce ¶ added in v0.1.121
func (ap *AccountPool) FastForwardNonce(ctx context.Context, address common.Address, nextNonce uint64) (bool, error)
FastForwardNonce sets the nonce of the account with the given address to nextNonce when it is higher than the current value, and drops any reusable nonces below nextNonce since the network already considers them used. It never rewinds the nonce, so a stale error message can't undo progress made by concurrent in-flight transactions. It returns whether the nonce was updated.
func (*AccountPool) FetchNoncesInParallel ¶ added in v0.1.111
func (ap *AccountPool) FetchNoncesInParallel(ctx context.Context) error
FetchNoncesInParallel fetches nonces for all accounts that aren't ready yet. Fetches run concurrently but no more than Concurrency requests are in flight at once, so a large --sending-accounts-file doesn't hit the endpoint with one request per account simultaneously. This is the default behavior unless SequentialNonceFetch is enabled.
func (*AccountPool) FundAccounts ¶
func (ap *AccountPool) FundAccounts(ctx context.Context) error
FundAccounts funds all accounts in the pool.
func (*AccountPool) GetPrivateKeys ¶ added in v0.1.104
func (ap *AccountPool) GetPrivateKeys() []*ecdsa.PrivateKey
GetPrivateKeys returns the private keys of all accounts in the pool.
func (*AccountPool) Next ¶
func (ap *AccountPool) Next(ctx context.Context) (Account, error)
Next returns the next account in the pool. Skips stopped accounts. Returns an error if no active accounts are available.
func (*AccountPool) NoncesOf ¶
func (ap *AccountPool) NoncesOf(address common.Address) (startNonce, nonce uint64)
NoncesOf returns the start nonce and current nonce for a given address.
func (*AccountPool) NumberOfPendingTxs ¶
func (ap *AccountPool) NumberOfPendingTxs(ctx context.Context) (uint64, error)
NumberOfPendingTxs returns the difference between the internal nonce and the network pending nonce for all accounts in the pool.
func (*AccountPool) PrepareReverseNonces ¶ added in v0.1.121
func (ap *AccountPool) PrepareReverseNonces(txsPerAccount uint64) error
PrepareReverseNonces prepares all accounts for reverse nonce order sending. For each account, the current nonce becomes the floor (startNonce) and the nonce counter is moved to the top of the account's planned range (startNonce + txsPerAccount - 1). Next() then walks the range downward. Must be called after all account nonces have been fetched and after any setup transactions (contract deployments) have been accounted for, and before the first call to Next().
func (*AccountPool) RefreshNonce ¶
RefreshNonce refreshes the nonce for the given address.
func (*AccountPool) ReturnFunds ¶
func (ap *AccountPool) ReturnFunds(ctx context.Context) error
ReturnFunds returns funds from all accounts back to the funding account.
func (*AccountPool) SetFundingAmount ¶
func (ap *AccountPool) SetFundingAmount(amount *big.Int)
SetFundingAmount updates the funding amount for the pool.
func (*AccountPool) StopAccount ¶ added in v0.1.111
func (ap *AccountPool) StopAccount(address common.Address) error
StopAccount marks an account as stopped so it won't be used for further transactions.
type AccountPoolConfig ¶
type AccountPoolConfig struct {
FundingPrivateKey *ecdsa.PrivateKey
FundingAmount *big.Int
RateLimit float64
EthCallOnly bool
RefundRemainingFunds bool
CheckBalanceBeforeFunding bool
LegacyTxMode bool
AccountsPerFundingTx uint64
SequentialNonceFetch bool
StopOnInsufficientFunds bool
// Concurrency bounds the number of in-flight requests the parallel nonce
// sweep issues. Values <= 0 fall back to a single request at a time.
Concurrency int64
// Gas override settings
ForceGasPrice uint64
ForcePriorityGasPrice uint64
GasPriceMultiplier *big.Float
ChainSupportBaseFee bool
// ReverseNonceOrder makes Next() hand out each account's nonces in
// descending order, from a precomputed highest nonce down to the account's
// starting nonce (see PrepareReverseNonces). Used to stress queued vs
// pending txpool dynamics. Requires fire-and-forget.
ReverseNonceOrder bool
// DuplicateNonceRate controls how often Next() returns the same nonce twice
// in a row for the same account. The probability of duplication is
// rate / (rate + 1): 0 = disabled, 1 = 50%, 4 = 80%. Used to induce nonce
// contention during reorgs / split networks. Requires fire-and-forget.
DuplicateNonceRate float64
// Seed seeds the duplicate-nonce RNG so runs are reproducible.
Seed int64
}
AccountPoolConfig holds configuration for the account pool.
type BlobCommitment ¶
type BlobCommitment struct {
Blob [131072]byte // kzg4844.Blob size
Commitment [48]byte // kzg4844.Commitment size
Proof [48]byte // kzg4844.Proof size
VersionedHash common.Hash
}
BlobCommitment holds blob transaction commitment data.
type BlockSummary ¶
type BlockSummary struct {
Block *rpctypes.RawBlockResponse
Receipts map[common.Hash]rpctypes.RawTxReceipt
Latencies map[uint64]time.Duration
}
BlockSummary holds data about a single block's transactions.
type Percentiles ¶ added in v0.1.104
Percentiles holds p50, p75, p90, p95, p99 values.
type PreconfStats ¶ added in v0.1.104
type PreconfStats struct {
Summary PreconfSummary `json:"summary"`
Transactions []PreconfTxResult `json:"transactions"`
}
PreconfStats is the JSON output structure containing summary and per-tx data.
type PreconfSummary ¶ added in v0.1.104
type PreconfSummary struct {
TotalTasks uint64 `json:"total_tasks"`
PreconfSuccess uint64 `json:"preconf_success"`
PreconfFail uint64 `json:"preconf_fail"`
BothFailed uint64 `json:"both_failed"`
IneffectivePreconf uint64 `json:"ineffective_preconf"`
FalsePositives uint64 `json:"false_positives"`
Confidence uint64 `json:"confidence"`
ReceiptSuccess uint64 `json:"receipt_success"`
ReceiptFail uint64 `json:"receipt_fail"`
TotalGasUsed uint64 `json:"total_gas_used"`
// Preconf duration percentiles (milliseconds)
PreconfP50 float64 `json:"preconf_p50,omitempty"`
PreconfP75 float64 `json:"preconf_p75,omitempty"`
PreconfP90 float64 `json:"preconf_p90,omitempty"`
PreconfP95 float64 `json:"preconf_p95,omitempty"`
PreconfP99 float64 `json:"preconf_p99,omitempty"`
// Receipt duration percentiles (milliseconds)
ReceiptP50 float64 `json:"receipt_p50,omitempty"`
ReceiptP75 float64 `json:"receipt_p75,omitempty"`
ReceiptP90 float64 `json:"receipt_p90,omitempty"`
ReceiptP95 float64 `json:"receipt_p95,omitempty"`
ReceiptP99 float64 `json:"receipt_p99,omitempty"`
}
PreconfSummary holds aggregate stats from the preconf tracker.
type PreconfTracker ¶ added in v0.1.104
type PreconfTracker struct {
// contains filtered or unexported fields
}
func NewPreconfTracker ¶ added in v0.1.104
func NewPreconfTracker(client *ethclient.Client, statsFilePath string) *PreconfTracker
func (*PreconfTracker) Start ¶ added in v0.1.104
func (pt *PreconfTracker) Start(ctx context.Context)
Start begins periodic stats file writing every 2 seconds until context is cancelled.
func (*PreconfTracker) Stats ¶ added in v0.1.104
func (pt *PreconfTracker) Stats()
Stats logs the final summary and writes the stats file.
func (*PreconfTracker) Track ¶ added in v0.1.104
func (pt *PreconfTracker) Track(txHash common.Hash)
type PreconfTxResult ¶ added in v0.1.104
type PreconfTxResult struct {
TxHash string `json:"tx_hash"`
PreconfDurationMs int64 `json:"preconf_duration_ms,omitempty"`
ReceiptDurationMs int64 `json:"receipt_duration_ms,omitempty"`
BlockDiff uint64 `json:"block_diff,omitempty"`
GasUsed uint64 `json:"gas_used,omitempty"`
Status uint64 `json:"status,omitempty"` // 1 = success, 0 = fail
}
PreconfTxResult holds per-transaction preconf and receipt data.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner handles the execution of a load test.
func (*Runner) GetAccountPool ¶
func (r *Runner) GetAccountPool() *AccountPool
GetAccountPool returns the account pool.
func (*Runner) GetDependencies ¶
func (r *Runner) GetDependencies() *mode.Dependencies
GetDependencies returns the mode dependencies.
func (*Runner) GetResults ¶
GetResults returns all recorded samples.
type Sample ¶
type Sample struct {
GoRoutineID int64
RequestID int64
RequestTime time.Time
WaitTime time.Duration
Receipt string
IsError bool
Nonce uint64
}
Sample represents a single load test request/response.