Documentation
¶
Index ¶
- Variables
- func ProcessBasicPlaceholders(str string, txIdx uint64, stepIdx int, stripPrefix bool) (string, error)
- func ProcessContractPlaceholders(str string, registry *ContractRegistry, stripPrefix bool) (string, error)
- func ValidateConfigString(configStr string) error
- type BaseTask
- type CallTask
- type ContractRegistry
- func (r *ContractRegistry) Clone() *ContractRegistry
- func (r *ContractRegistry) Get(name string) (common.Address, bool)
- func (r *ContractRegistry) Has(name string) bool
- func (r *ContractRegistry) ListAllContracts() map[string]common.Address
- func (r *ContractRegistry) ListContracts() map[string]common.Address
- func (r *ContractRegistry) ResolveReference(ref string) (common.Address, error)
- func (r *ContractRegistry) Set(name string, address common.Address)
- type DeployTask
- type RawTasksConfig
- type Scenario
- type ScenarioOptions
- type Task
- type TaskConfig
- type TaskExecutionContext
- type TaskFactory
- type TasksConfig
Constants ¶
This section is empty.
Variables ¶
var ScenarioDefaultOptions = ScenarioOptions{ TotalCount: 0, Throughput: 10, MaxPending: 0, MaxWallets: 0, Rebroadcast: 1, BaseFee: 20, TipFee: 2, TasksConfig: "", TasksFile: "", AwaitTxs: false, Timeout: "", ClientGroup: "", LogTxs: false, }
var ScenarioDescriptor = scenario.Descriptor{ Name: ScenarioName, Description: "Execute configurable task sequences with initialization and recurring execution phases", DefaultOptions: ScenarioDefaultOptions, NewScenario: newScenario, }
var ScenarioName = "taskrunner"
Functions ¶
func ProcessBasicPlaceholders ¶ added in v1.1.7
func ProcessBasicPlaceholders(str string, txIdx uint64, stepIdx int, stripPrefix bool) (string, error)
ProcessBasicPlaceholders processes {txid}, {stepid}, {random}, {random:N}, {randomaddr} placeholders If stripPrefix is true, removes 0x prefix from addresses (for use in bytecode/calldata)
func ProcessContractPlaceholders ¶ added in v1.1.7
func ProcessContractPlaceholders(str string, registry *ContractRegistry, stripPrefix bool) (string, error)
ProcessContractPlaceholders processes {contract:name} and {contract:name:nonce} placeholders If stripPrefix is true, removes the 0x prefix from addresses (for use in bytecode/calldata)
func ValidateConfigString ¶
ValidateConfigString validates a configuration string without full parsing
Types ¶
type CallTask ¶
type CallTask struct {
BaseTask
Target string `yaml:"target" json:"target"` // Contract address or {contract:name}
CallData string `yaml:"call_data" json:"call_data"` // Raw hex calldata
CallABI string `yaml:"call_abi" json:"call_abi"` // JSON ABI string
CallABIFile string `yaml:"call_abi_file" json:"call_abi_file"` // Path to ABI file or URL (http/https)
CallFnName string `yaml:"call_fn_name" json:"call_fn_name"` // Function name
CallArgs []interface{} `yaml:"call_args" json:"call_args"` // Function arguments
GasLimit uint64 `yaml:"gas_limit" json:"gas_limit"` // Gas limit
Amount uint64 `yaml:"amount" json:"amount"` // ETH amount to send (in gwei)
}
CallTask represents a contract function call task
func (*CallTask) BuildTransaction ¶
func (t *CallTask) BuildTransaction(ctx context.Context, wallet *spamoor.Wallet, registry *ContractRegistry, execCtx *TaskExecutionContext) (*types.Transaction, error)
BuildTransaction creates a contract call transaction
type ContractRegistry ¶
type ContractRegistry struct {
// contains filtered or unexported fields
}
ContractRegistry manages deployed contract addresses for task references
func NewContractRegistry ¶
func NewContractRegistry() *ContractRegistry
NewContractRegistry creates a new empty contract registry
func (*ContractRegistry) Clone ¶
func (r *ContractRegistry) Clone() *ContractRegistry
Clone creates a new registry that inherits from this one This is used to create execution-scoped registries that can see init contracts
func (*ContractRegistry) Get ¶
func (r *ContractRegistry) Get(name string) (common.Address, bool)
Get retrieves a contract address by name It first checks the local registry, then the parent registry
func (*ContractRegistry) Has ¶
func (r *ContractRegistry) Has(name string) bool
Has checks if a contract with the given name exists
func (*ContractRegistry) ListAllContracts ¶
func (r *ContractRegistry) ListAllContracts() map[string]common.Address
ListAllContracts returns all contracts including from parent registries
func (*ContractRegistry) ListContracts ¶
func (r *ContractRegistry) ListContracts() map[string]common.Address
ListContracts returns all contract names and addresses in this registry (excluding parent registry)
func (*ContractRegistry) ResolveReference ¶
func (r *ContractRegistry) ResolveReference(ref string) (common.Address, error)
ResolveReference resolves a contract reference string to an address Supports both direct addresses and contract references like {contract:name}
type DeployTask ¶
type DeployTask struct {
BaseTask
ContractCode string `yaml:"contract_code" json:"contract_code"` // Hex-encoded bytecode
ContractFile string `yaml:"contract_file" json:"contract_file"` // Path to bytecode file or URL (http/https)
ContractArgs string `yaml:"contract_args" json:"contract_args"` // Constructor arguments (hex)
GasLimit uint64 `yaml:"gas_limit" json:"gas_limit"` // Gas limit for deployment
Amount uint64 `yaml:"amount" json:"amount"` // ETH amount to send (in gwei)
}
DeployTask represents a contract deployment task
func (*DeployTask) BuildTransaction ¶
func (t *DeployTask) BuildTransaction(ctx context.Context, wallet *spamoor.Wallet, registry *ContractRegistry, execCtx *TaskExecutionContext) (*types.Transaction, error)
BuildTransaction creates a contract deployment transaction
func (*DeployTask) Validate ¶
func (t *DeployTask) Validate() error
Validate checks if the deploy task configuration is valid
type RawTasksConfig ¶
type RawTasksConfig struct {
InitTasks []*TaskConfig `yaml:"init" json:"init"`
ExecutionTasks []*TaskConfig `yaml:"execution" json:"execution"`
}
RawTasksConfig represents the raw configuration before parsing tasks
type ScenarioOptions ¶
type ScenarioOptions struct {
TotalCount uint64 `yaml:"total_count"`
Throughput uint64 `yaml:"throughput"`
MaxPending uint64 `yaml:"max_pending"`
MaxWallets uint64 `yaml:"max_wallets"`
Rebroadcast uint64 `yaml:"rebroadcast"`
BaseFee float64 `yaml:"base_fee"`
TipFee float64 `yaml:"tip_fee"`
BaseFeeWei string `yaml:"base_fee_wei"`
TipFeeWei string `yaml:"tip_fee_wei"`
TasksConfig string `yaml:"tasks_config"` // Inline YAML/JSON task configuration
TasksFile string `yaml:"tasks_file"` // Path to task configuration file or URL
AwaitTxs bool `yaml:"await_txs"` // Send and await each transaction individually
Timeout string `yaml:"timeout"`
ClientGroup string `yaml:"client_group"`
LogTxs bool `yaml:"log_txs"`
}
type Task ¶
type Task interface {
// GetType returns the task type identifier
GetType() string
// GetName returns the task name (optional, for registry)
GetName() string
// Validate checks if the task configuration is valid
Validate() error
// BuildTransaction creates a transaction for this task
BuildTransaction(ctx context.Context, wallet *spamoor.Wallet, registry *ContractRegistry, execCtx *TaskExecutionContext) (*types.Transaction, error)
}
Task represents a single executable task in the TaskRunner scenario
func CreateTask ¶
func CreateTask(config *TaskConfig) (Task, error)
CreateTask creates a task instance from configuration
func NewCallTask ¶
NewCallTask creates a new call task from configuration
type TaskConfig ¶
type TaskConfig struct {
Type string `yaml:"type" json:"type"`
Name string `yaml:"name" json:"name"`
Data map[string]interface{} `yaml:"data" json:"data"`
}
TaskConfig represents the generic configuration for any task
type TaskExecutionContext ¶
type TaskExecutionContext struct {
BaseFee float64 // Max fee per gas in gwei
TipFee float64 // Max tip per gas in gwei
BaseFeeWei string // Max fee per gas in wei (overrides BaseFee for L2 sub-gwei fees)
TipFeeWei string // Max tip per gas in wei (overrides TipFee for L2 sub-gwei fees)
TxPool *spamoor.TxPool // For fee calculation
WalletPool *spamoor.WalletPool // For gas estimation helpers (EstimateDeployGas, etc.)
Client *spamoor.Client // Live client for RPC-based gas estimation
}
TaskExecutionContext contains context information for task execution
type TaskFactory ¶
TaskFactory is a function that creates a task from configuration
type TasksConfig ¶
type TasksConfig struct {
InitTasks []Task `yaml:"init" json:"init"`
ExecutionTasks []Task `yaml:"execution" json:"execution"`
}
TasksConfig represents the complete task configuration
func ParseTasksConfig ¶
func ParseTasksConfig(data []byte) (*TasksConfig, error)
ParseTasksConfig parses task configuration from YAML or JSON data