spamoor

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2025 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BatcherTxLimit  = 50
	BatcherBaseGas  = 50000
	BatcherGasPerTx = 35000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockInfo added in v1.1.3

type BlockInfo struct {
	Number     uint64
	Hash       common.Hash
	ParentHash common.Hash
	Timestamp  uint64
}

BlockInfo represents information about a processed block

type Client added in v1.1.3

type Client struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewClient added in v1.1.3

func NewClient(rpchost string) (*Client, error)

func (*Client) GetBalanceAt added in v1.1.3

func (client *Client) GetBalanceAt(ctx context.Context, wallet common.Address) (*big.Int, error)

func (*Client) GetBlockHeight added in v1.1.3

func (client *Client) GetBlockHeight(ctx context.Context) (uint64, error)

func (*Client) GetChainId added in v1.1.3

func (client *Client) GetChainId(ctx context.Context) (*big.Int, error)

func (*Client) GetClientGroup added in v1.1.3

func (client *Client) GetClientGroup() string

func (*Client) GetClientVersion added in v1.1.3

func (client *Client) GetClientVersion(ctx context.Context) (string, error)

func (*Client) GetEthClient added in v1.1.3

func (client *Client) GetEthClient() *ethclient.Client

func (*Client) GetLastBlockHeight added in v1.1.3

func (client *Client) GetLastBlockHeight() (uint64, time.Time)

func (*Client) GetName added in v1.1.3

func (client *Client) GetName() string

func (*Client) GetNonceAt added in v1.1.3

func (client *Client) GetNonceAt(ctx context.Context, wallet common.Address, blockNumber *big.Int) (uint64, error)

func (*Client) GetPendingNonceAt added in v1.1.3

func (client *Client) GetPendingNonceAt(ctx context.Context, wallet common.Address) (uint64, error)

func (*Client) GetRPCHost added in v1.1.3

func (client *Client) GetRPCHost() string

func (*Client) GetSuggestedFee added in v1.1.3

func (client *Client) GetSuggestedFee(ctx context.Context) (*big.Int, *big.Int, error)

func (*Client) GetTransactionReceiptCtx added in v1.1.3

func (client *Client) GetTransactionReceiptCtx(ctx context.Context, txHash common.Hash) (*types.Receipt, error)

func (*Client) SendRawTransactionCtx added in v1.1.3

func (client *Client) SendRawTransactionCtx(ctx context.Context, tx []byte) error

func (*Client) SendTransaction2 added in v1.1.3

func (client *Client) SendTransaction2(ctx context.Context, tx *types.Transaction) error

func (*Client) SendTransactionCtx added in v1.1.3

func (client *Client) SendTransactionCtx(ctx context.Context, tx *types.Transaction) error

func (*Client) UpdateWallet added in v1.1.3

func (client *Client) UpdateWallet(ctx context.Context, wallet *Wallet) error

type ClientPool

type ClientPool struct {
	// contains filtered or unexported fields
}

func NewClientPool

func NewClientPool(ctx context.Context, rpcHosts []string, logger logrus.FieldLogger) *ClientPool

func (*ClientPool) GetAllClients

func (pool *ClientPool) GetAllClients() []*Client

func (*ClientPool) GetAllGoodClients

func (pool *ClientPool) GetAllGoodClients() []*Client

func (*ClientPool) GetClient

func (pool *ClientPool) GetClient(mode ClientSelectionMode, input int, group string) *Client

func (*ClientPool) PrepareClients

func (pool *ClientPool) PrepareClients() error

type ClientSelectionMode

type ClientSelectionMode uint8
var (
	SelectClientByIndex    ClientSelectionMode = 0
	SelectClientRandom     ClientSelectionMode = 1
	SelectClientRoundRobin ClientSelectionMode = 2
)

type FundingRequest added in v1.1.3

type FundingRequest struct {
	Wallet *Wallet
	Amount *uint256.Int
}

type RootWallet added in v1.1.3

type RootWallet struct {
	// contains filtered or unexported fields
}

func InitRootWallet

func InitRootWallet(ctx context.Context, privkey string, client *Client, logger logrus.FieldLogger) (*RootWallet, error)

func (*RootWallet) GetTxBatcher added in v1.1.3

func (wallet *RootWallet) GetTxBatcher() *TxBatcher

func (*RootWallet) GetWallet added in v1.1.3

func (wallet *RootWallet) GetWallet() *Wallet

func (*RootWallet) InitTxBatcher added in v1.1.3

func (wallet *RootWallet) InitTxBatcher(ctx context.Context, txpool *TxPool)

func (*RootWallet) WithWalletLock added in v1.1.3

func (wallet *RootWallet) WithWalletLock(ctx context.Context, txCount int, lockedLogFn func(), lockedFn func() error) error

type SendTransactionOptions added in v1.1.3

type SendTransactionOptions struct {
	Client             *Client
	ClientGroup        string
	ClientsStartOffset int

	OnConfirm     TxConfirmFn
	LogFn         TxLogFn
	OnRebroadcast TxRebroadcastFn

	MaxRebroadcasts     int
	RebroadcastInterval time.Duration
	TransactionBytes    []byte
}

type TxBatcher added in v1.1.3

type TxBatcher struct {
	// contains filtered or unexported fields
}

func NewTxBatcher added in v1.1.3

func NewTxBatcher(txpool *TxPool) *TxBatcher

func (*TxBatcher) Deploy added in v1.1.3

func (b *TxBatcher) Deploy(ctx context.Context, wallet *Wallet, client *Client) error

func (*TxBatcher) GetAddress added in v1.1.3

func (b *TxBatcher) GetAddress() common.Address

func (*TxBatcher) GetRequestCalldata added in v1.1.3

func (b *TxBatcher) GetRequestCalldata(requests []*FundingRequest) ([]byte, error)

type TxConfirmFn added in v1.1.3

type TxConfirmFn func(tx *types.Transaction, receipt *types.Receipt, err error)

type TxInfo added in v1.1.3

type TxInfo struct {
	TxHash     common.Hash
	From       common.Address
	To         *common.Address
	Tx         *types.Transaction
	FromWallet *Wallet
	ToWallet   *Wallet
	Options    *SendTransactionOptions
}

TxInfo represents information about a confirmed transaction

type TxLogFn added in v1.1.3

type TxLogFn func(client *Client, retry int, rebroadcast int, err error)

type TxPool added in v1.1.3

type TxPool struct {
	// contains filtered or unexported fields
}

func NewTxPool added in v1.1.3

func NewTxPool(options *TxPoolOptions) *TxPool

func (*TxPool) AwaitTransaction added in v1.1.3

func (pool *TxPool) AwaitTransaction(ctx context.Context, wallet *Wallet, tx *types.Transaction) (*types.Receipt, error)

func (*TxPool) SendAndAwaitTxRange added in v1.1.3

func (pool *TxPool) SendAndAwaitTxRange(ctx context.Context, wallet *Wallet, txs []*types.Transaction, options *SendTransactionOptions) error

func (*TxPool) SendTransaction added in v1.1.3

func (pool *TxPool) SendTransaction(ctx context.Context, wallet *Wallet, tx *types.Transaction, options *SendTransactionOptions) error

type TxPoolOptions added in v1.1.3

type TxPoolOptions struct {
	Context              context.Context
	ClientPool           *ClientPool
	ReorgDepth           int // Number of blocks to keep in memory for reorg tracking
	GetActiveWalletPools func() []*WalletPool
}

type TxRebroadcastFn added in v1.1.3

type TxRebroadcastFn func(tx *types.Transaction, options *SendTransactionOptions, client *Client)

type Wallet added in v1.1.3

type Wallet struct {
	// contains filtered or unexported fields
}

func NewWallet added in v1.1.3

func NewWallet(privkey string) (*Wallet, error)

func (*Wallet) AddBalance added in v1.1.3

func (wallet *Wallet) AddBalance(amount *big.Int)

func (*Wallet) BuildBlobTx added in v1.1.3

func (wallet *Wallet) BuildBlobTx(txData *types.BlobTx) (*types.Transaction, error)

func (*Wallet) BuildBoundTx added in v1.1.3

func (wallet *Wallet) BuildBoundTx(ctx context.Context, txData *txbuilder.TxMetadata, buildFn func(transactOpts *bind.TransactOpts) (*types.Transaction, error)) (*types.Transaction, error)

func (*Wallet) BuildDynamicFeeTx added in v1.1.3

func (wallet *Wallet) BuildDynamicFeeTx(txData *types.DynamicFeeTx) (*types.Transaction, error)

func (*Wallet) BuildSetCodeTx added in v1.1.3

func (wallet *Wallet) BuildSetCodeTx(txData *types.SetCodeTx) (*types.Transaction, error)

func (*Wallet) GetAddress added in v1.1.3

func (wallet *Wallet) GetAddress() common.Address

func (*Wallet) GetBalance added in v1.1.3

func (wallet *Wallet) GetBalance() *big.Int

func (*Wallet) GetChainId added in v1.1.3

func (wallet *Wallet) GetChainId() *big.Int

func (*Wallet) GetConfirmedNonce added in v1.1.3

func (wallet *Wallet) GetConfirmedNonce() uint64

func (*Wallet) GetNextNonce added in v1.1.3

func (wallet *Wallet) GetNextNonce() uint64

func (*Wallet) GetNonce added in v1.1.3

func (wallet *Wallet) GetNonce() uint64

func (*Wallet) GetPrivateKey added in v1.1.3

func (wallet *Wallet) GetPrivateKey() *ecdsa.PrivateKey

func (*Wallet) ReplaceBlobTx added in v1.1.3

func (wallet *Wallet) ReplaceBlobTx(txData *types.BlobTx, nonce uint64) (*types.Transaction, error)

func (*Wallet) ReplaceDynamicFeeTx added in v1.1.3

func (wallet *Wallet) ReplaceDynamicFeeTx(txData *types.DynamicFeeTx, nonce uint64) (*types.Transaction, error)

func (*Wallet) ResetPendingNonce added in v1.1.3

func (wallet *Wallet) ResetPendingNonce(ctx context.Context, client *Client)

func (*Wallet) SetAddress added in v1.1.3

func (wallet *Wallet) SetAddress(address common.Address)

func (*Wallet) SetBalance added in v1.1.3

func (wallet *Wallet) SetBalance(balance *big.Int)

func (*Wallet) SetChainId added in v1.1.3

func (wallet *Wallet) SetChainId(chainid *big.Int)

func (*Wallet) SetNonce added in v1.1.3

func (wallet *Wallet) SetNonce(nonce uint64)

func (*Wallet) SubBalance added in v1.1.3

func (wallet *Wallet) SubBalance(amount *big.Int)

type WalletPool

type WalletPool struct {
	// contains filtered or unexported fields
}

func NewWalletPool

func NewWalletPool(ctx context.Context, logger logrus.FieldLogger, rootWallet *RootWallet, clientPool *ClientPool, txpool *TxPool) *WalletPool

func (*WalletPool) AddWellKnownWallet added in v1.1.1

func (pool *WalletPool) AddWellKnownWallet(config *WellKnownWalletConfig)

func (*WalletPool) CheckChildWalletBalance

func (pool *WalletPool) CheckChildWalletBalance(childWallet *Wallet) error

func (*WalletPool) GetAllWallets

func (pool *WalletPool) GetAllWallets() []*Wallet

func (*WalletPool) GetChainId added in v1.1.3

func (pool *WalletPool) GetChainId() *big.Int

func (*WalletPool) GetClient

func (pool *WalletPool) GetClient(mode ClientSelectionMode, input int, group string) *Client

func (*WalletPool) GetClientPool

func (pool *WalletPool) GetClientPool() *ClientPool

func (*WalletPool) GetConfiguredWalletCount added in v1.1.3

func (pool *WalletPool) GetConfiguredWalletCount() uint64

func (*WalletPool) GetContext

func (pool *WalletPool) GetContext() context.Context

func (*WalletPool) GetRootWallet

func (pool *WalletPool) GetRootWallet() *RootWallet

func (*WalletPool) GetTxPool

func (pool *WalletPool) GetTxPool() *TxPool

func (*WalletPool) GetWallet

func (pool *WalletPool) GetWallet(mode WalletSelectionMode, input int) *Wallet

func (*WalletPool) GetWalletCount

func (pool *WalletPool) GetWalletCount() uint64

func (*WalletPool) GetWalletName added in v1.1.1

func (pool *WalletPool) GetWalletName(address common.Address) string

func (*WalletPool) GetWellKnownWallet added in v1.1.1

func (pool *WalletPool) GetWellKnownWallet(name string) *Wallet

func (*WalletPool) LoadConfig

func (pool *WalletPool) LoadConfig(configYaml string) error

func (*WalletPool) MarshalConfig

func (pool *WalletPool) MarshalConfig() (string, error)

func (*WalletPool) PrepareWallets

func (pool *WalletPool) PrepareWallets(runFundings bool) error

func (*WalletPool) SetRefillAmount

func (pool *WalletPool) SetRefillAmount(amount *uint256.Int)

func (*WalletPool) SetRefillBalance

func (pool *WalletPool) SetRefillBalance(balance *uint256.Int)

func (*WalletPool) SetRefillInterval

func (pool *WalletPool) SetRefillInterval(interval uint64)

func (*WalletPool) SetWalletCount

func (pool *WalletPool) SetWalletCount(count uint64)

func (*WalletPool) SetWalletSeed

func (pool *WalletPool) SetWalletSeed(seed string)

type WalletPoolConfig

type WalletPoolConfig struct {
	WalletCount    uint64       `yaml:"wallet_count,omitempty"`
	RefillAmount   *uint256.Int `yaml:"refill_amount"`
	RefillBalance  *uint256.Int `yaml:"refill_balance"`
	RefillInterval uint64       `yaml:"refill_interval"`
	WalletSeed     string       `yaml:"seed"`
}

func GetDefaultWalletConfig added in v1.1.1

func GetDefaultWalletConfig(scenarioName string) *WalletPoolConfig

type WalletSelectionMode

type WalletSelectionMode uint8
var (
	SelectWalletByIndex    WalletSelectionMode = 0
	SelectWalletRandom     WalletSelectionMode = 1
	SelectWalletRoundRobin WalletSelectionMode = 2
)

type WellKnownWalletConfig added in v1.1.1

type WellKnownWalletConfig struct {
	Name          string
	RefillAmount  *uint256.Int
	RefillBalance *uint256.Int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL