Documentation
¶
Index ¶
- Constants
- func GetAll() map[string]Runner
- func GetRandomAddress(deps *Dependencies) *common.Address
- func LogReceiptTrace(txHash common.Hash, raw json.RawMessage, elapsed time.Duration, err error, ...)
- func NewHexwordReader(deps *Dependencies) io.Reader
- func OutputRawBytes(rawTx []byte) error
- func OutputRawTransaction(tx *types.Transaction) error
- func Register(mode Runner)
- func SendRawTransactionPrivate(ctx context.Context, rpcClient *ethrpc.Client, tx *types.Transaction) error
- func SendRawTransactionSync(ctx context.Context, deps *Dependencies, cfg *config.Config, ...) error
- func SendSignedTransaction(ctx context.Context, deps *Dependencies, cfg *config.Config, ...) error
- func SyncErrorCode(err error) (int, bool)
- func TransactOptsToCallMsg(cfg *config.Config, gasLimit uint64) ethereum.CallMsg
- func TxToCallMsg(cfg *config.Config, tx *types.Transaction) ethereum.CallMsg
- type Dependencies
- type HexwordReader
- type IndexedActivity
- type Runner
- type SyncReceipt
- type SyncTracker
- type SyncTxResult
Constants ¶
const ( // SyncErrTimeout means the transaction reached the mempool but no receipt // was produced before the timeout elapsed. The transaction may still be // mined afterwards. SyncErrTimeout = 4 // SyncErrQueued means the transaction was not added to the mempool because // it is not ready for execution. SyncErrQueued = 5 // SyncErrNonceGap means the transaction was not added to the mempool // because of a nonce gap. The error data carries the expected nonce. SyncErrNonceGap = 6 )
EIP-7966 error codes returned by eth_sendRawTransactionSync. These are method-specific codes, not the standard JSON-RPC ones, and each carries a data field: the transaction hash for timeout and queued, the expected nonce for a nonce gap.
const ( SyncErrBorNonceTooLow = -38010 SyncErrBorNonceTooHigh = -38011 SyncErrBorIntrinsicGas = -38013 SyncErrBorInsufficientFunds = -38014 SyncErrBorClientLimit = -38026 )
Codes bor returns from this method beyond the EIP-7966 set. Bor implements only code 4 from the EIP; a transaction it refuses to accept fails in SubmitTransaction first and comes back with one of these instead, so they are classified separately rather than lumped in with unknown errors.
Variables ¶
This section is empty.
Functions ¶
func GetRandomAddress ¶
func GetRandomAddress(deps *Dependencies) *common.Address
GetRandomAddress generates a random Ethereum address using the given random source.
func LogReceiptTrace ¶ added in v0.1.121
func LogReceiptTrace(txHash common.Hash, raw json.RawMessage, elapsed time.Duration, err error, okMsg, failMsg string)
LogReceiptTrace trace-logs a raw receipt (or the error that stood in for one) so the node's answers can be audited later, e.g. by diffing them against eth_getTransactionReceipt. It is shared by the synchronous send path and the runner's --wait-for-receipt polling, which differ only in message.
func NewHexwordReader ¶
func NewHexwordReader(deps *Dependencies) io.Reader
NewHexwordReader creates a new hexword reader with the given random source.
func OutputRawBytes ¶
OutputRawBytes outputs raw bytes as a 0x-prefixed hex string to stdout.
func OutputRawTransaction ¶
func OutputRawTransaction(tx *types.Transaction) error
OutputRawTransaction outputs a raw signed transaction as hex.
func SendRawTransactionPrivate ¶ added in v0.1.111
func SendRawTransactionPrivate(ctx context.Context, rpcClient *ethrpc.Client, tx *types.Transaction) error
SendRawTransactionPrivate sends a signed transaction using eth_sendRawTransactionPrivate.
func SendRawTransactionSync ¶ added in v0.1.121
func SendRawTransactionSync(ctx context.Context, deps *Dependencies, cfg *config.Config, tx *types.Transaction) error
SendRawTransactionSync submits a signed transaction with eth_sendRawTransactionSync (EIP-7966), which returns once the node has a receipt for it or the timeout elapses, and records the outcome on deps.SyncTracker when one is set.
The returned error is the RPC error verbatim, so the caller records the same failure the node reported. Note that a timeout is an error even though the transaction is in the mempool and may still be mined.
func SendSignedTransaction ¶ added in v0.1.121
func SendSignedTransaction(ctx context.Context, deps *Dependencies, cfg *config.Config, tx *types.Transaction) error
SendSignedTransaction broadcasts a signed transaction using whichever send path the configuration selects. Modes that build and sign their own transactions share this so a new send method only has to be wired in once.
func SyncErrorCode ¶ added in v0.1.121
SyncErrorCode returns the EIP-7966 error code carried by an eth_sendRawTransactionSync failure, and whether the error had one at all.
func TransactOptsToCallMsg ¶
TransactOptsToCallMsg converts bind.TransactOpts to an ethereum.CallMsg.
func TxToCallMsg ¶
TxToCallMsg converts a transaction to an ethereum.CallMsg.
Types ¶
type Dependencies ¶
type Dependencies struct {
// Ethereum clients
Client *ethclient.Client
RPCClient *ethrpc.Client
// SendClient/SendRPCClient are used only to broadcast signed
// transactions. They alias Client/RPCClient unless --send-rpc-url is set.
SendClient *ethclient.Client
SendRPCClient *ethrpc.Client
// Contract instances
LoadTesterContract *tester.LoadTester
LoadTesterAddress common.Address
ERC20Contract *tokens.ERC20
ERC20Address common.Address
ERC721Contract *tokens.ERC721
ERC721Address common.Address
// SyncTracker aggregates eth_sendRawTransactionSync outcomes when
// --sync-txs is set. Nil otherwise, which records nothing.
SyncTracker *SyncTracker
// Mode-specific data
RecallTransactions []rpctypes.PolyTransaction
IndexedActivity *IndexedActivity
// Random source for deterministic randomness
RandSource *rand.Rand
RandSourceMu sync.Mutex
// UniswapV3 configuration (populated when uniswapv3 mode is used)
UniswapV3Config *uniswap.UniswapV3Config
UniswapV3PoolConfig *uniswap.PoolConfig
UniswapV3Pool *uniswapv3.IUniswapV3Pool
}
Dependencies holds shared resources needed by mode implementations.
func (*Dependencies) RandIntn ¶
func (d *Dependencies) RandIntn(n int) int
RandIntn returns a deterministic random int while guarding concurrent access.
type HexwordReader ¶
type HexwordReader struct {
// contains filtered or unexported fields
}
HexwordReader provides a reader that generates hex-word patterns.
type IndexedActivity ¶
type IndexedActivity struct {
BlockNumbers []string
TransactionIDs []string
BlockIDs []string
Addresses []string
ERC20Addresses []string
ERC721Addresses []string
Contracts []string
BlockNumber uint64
Transactions []rpctypes.PolyTransaction
}
IndexedActivity holds indexed blockchain activity data for RPC testing.
type Runner ¶
type Runner interface {
// Name returns the canonical name of the mode.
Name() string
// Aliases returns alternative names/shortcuts for this mode.
Aliases() []string
// RequiresContract returns true if this mode needs the LoadTester contract.
RequiresContract() bool
// RequiresERC20 returns true if this mode needs an ERC20 contract.
RequiresERC20() bool
// RequiresERC721 returns true if this mode needs an ERC721 contract.
RequiresERC721() bool
// Init sets up any mode-specific state before execution.
Init(ctx context.Context, cfg *config.Config, deps *Dependencies) error
// Execute performs a single load test operation.
// Returns start time, end time, transaction hash, and any error.
Execute(ctx context.Context, cfg *config.Config, deps *Dependencies, opts *bind.TransactOpts) (start, end time.Time, txHash common.Hash, err error)
}
Runner defines the interface that all load test modes must implement.
type SyncReceipt ¶ added in v0.1.121
type SyncReceipt struct {
TransactionHash common.Hash `json:"transactionHash"`
Status *hexutil.Uint64 `json:"status"`
GasUsed *hexutil.Uint64 `json:"gasUsed"`
BlockNumber *hexutil.Big `json:"blockNumber"`
BlockHash *common.Hash `json:"blockHash"`
// Preconfirmation is bor's marker for a receipt produced by its
// preconfirmation pipeline rather than canonical block import. It is not
// part of EIP-7966, so nodes that do not preconfirm simply omit it.
Preconfirmation *bool `json:"preconfirmation"`
}
SyncReceipt is the receipt returned by eth_sendRawTransactionSync. EIP-7966 specifies "the transaction receipt object as defined by the eth_getTransactionReceipt method", but a node answering before canonical inclusion may leave the block fields empty, so every field is optional here rather than decoded into types.Receipt, which requires them.
func (*SyncReceipt) Speculative ¶ added in v0.1.121
func (r *SyncReceipt) Speculative() bool
Speculative reports whether the receipt is a preconfirmation rather than a canonical one.
Bor states this outright with a "preconfirmation" field, and that answer is taken when present. EIP-7966 itself defines no such marker, so for every other node this falls back to reading the block fields: bor's preconfirmation receipts carry no block hash, and a receipt with no block cannot be canonical on any implementation. A node that both omits the marker and fills in a speculative block number is indistinguishable from one answering canonically; pair with --wait-for-receipt to confirm canonical inclusion independently.
func (*SyncReceipt) Succeeded ¶ added in v0.1.121
func (r *SyncReceipt) Succeeded() bool
Succeeded reports whether the receipt carries a success status. A receipt with no status field at all is not treated as a success.
type SyncTracker ¶ added in v0.1.121
type SyncTracker struct {
// contains filtered or unexported fields
}
SyncTracker aggregates eth_sendRawTransactionSync outcomes across routines. A nil tracker records nothing, so callers never need to check for one.
func NewSyncTracker ¶ added in v0.1.121
func NewSyncTracker() *SyncTracker
NewSyncTracker creates a tracker for synchronous submission outcomes.
func (*SyncTracker) Record ¶ added in v0.1.121
func (t *SyncTracker) Record(txHash common.Hash, receipt *SyncReceipt, elapsed time.Duration, err error)
Record files the outcome of one submission.
func (*SyncTracker) Results ¶ added in v0.1.121
func (t *SyncTracker) Results() []SyncTxResult
Results returns a copy of the per-transaction outcomes.
func (*SyncTracker) Stats ¶ added in v0.1.121
func (t *SyncTracker) Stats()
Stats logs a summary of the synchronous submissions.
type SyncTxResult ¶ added in v0.1.121
type SyncTxResult struct {
TxHash string `json:"tx_hash"`
DurationMs int64 `json:"duration_ms"`
Speculative bool `json:"speculative,omitempty"`
BlockNumber uint64 `json:"block_number,omitempty"`
GasUsed uint64 `json:"gas_used,omitempty"`
Status uint64 `json:"status,omitempty"`
ErrorCode int `json:"error_code,omitempty"`
Error string `json:"error,omitempty"`
}
SyncTxResult holds the outcome of a single synchronous submission.