Documentation
¶
Index ¶
- func RetryWithBackoff(config RetryConfig, fn func() error) error
- type CircuitBreaker
- type FuzzClient
- type LoadPattern
- type MultiNodeConfig
- type Peer
- type Protocol
- type RetryConfig
- type SystemMetrics
- type TransactionRecord
- type TxFuzzConfig
- type TxFuzzer
- func (tf *TxFuzzer) Close() error
- func (tf *TxFuzzer) ExportFailedHashes(filename string) error
- func (tf *TxFuzzer) ExportRecordsJSON() ([]byte, error)
- func (tf *TxFuzzer) ExportSuccessHashes(filename string) error
- func (tf *TxFuzzer) GetCurrentTPS() int
- func (tf *TxFuzzer) GetEnhancedStats() *TxStats
- func (tf *TxFuzzer) GetFailedHashes() []string
- func (tf *TxFuzzer) GetHealthStatus() map[string]bool
- func (tf *TxFuzzer) GetStats() TxStats
- func (tf *TxFuzzer) GetSuccessHashes() []string
- func (tf *TxFuzzer) GetSystemMetrics() *SystemMetrics
- func (tf *TxFuzzer) GetTransactionRecords() map[common.Hash]*TransactionRecord
- func (tf *TxFuzzer) PrintRealTimeStats()
- func (tf *TxFuzzer) Start(cfg *TxFuzzConfig) error
- func (tf *TxFuzzer) StartWithContext(ctx context.Context, cfg *TxFuzzConfig) error
- func (tf *TxFuzzer) Stop()
- type TxStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RetryWithBackoff ¶
func RetryWithBackoff(config RetryConfig, fn func() error) error
RetryWithBackoff executes a function with exponential backoff retry
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker represents a circuit breaker for error handling
func NewCircuitBreaker ¶
func NewCircuitBreaker(maxFailures int, resetTimeout time.Duration) *CircuitBreaker
NewCircuitBreaker creates a new circuit breaker
func (*CircuitBreaker) Call ¶
func (cb *CircuitBreaker) Call(fn func() error) error
Call executes a function with circuit breaker protection
type FuzzClient ¶
type FuzzClient struct {
// contains filtered or unexported fields
}
FuzzClient represents a P2P client for fuzzing Ethereum nodes
func NewFuzzClient ¶
func NewFuzzClient(logger utils.Logger) (*FuzzClient, error)
NewFuzzClient creates a new P2P fuzzing client
func (*FuzzClient) IsTxFuzzingActive ¶
func (f *FuzzClient) IsTxFuzzingActive() bool
IsTxFuzzingActive returns true if transaction fuzzing is currently active
func (*FuzzClient) Start ¶
func (f *FuzzClient) Start()
func (*FuzzClient) StartTxFuzzing ¶
func (f *FuzzClient) StartTxFuzzing(cfg *TxFuzzConfig, accounts []config.Account) error
StartTxFuzzing starts transaction fuzzing with the given configuration
func (*FuzzClient) StopTxFuzzing ¶
func (f *FuzzClient) StopTxFuzzing()
StopTxFuzzing stops the transaction fuzzing process
type LoadPattern ¶
type LoadPattern struct {
Type string `json:"type"` // "constant", "ramp", "spike", "wave"
StartTPS int `json:"startTPS"` // Starting TPS
PeakTPS int `json:"peakTPS"` // Peak TPS
RampTime time.Duration `json:"rampTime"` // Time to reach peak
SustainTime time.Duration `json:"sustainTime"` // Time to sustain peak
StepSize int `json:"stepSize"` // TPS increment per step
}
LoadPattern defines different load testing patterns
type MultiNodeConfig ¶
type MultiNodeConfig struct {
RPCEndpoints []string `json:"rpcEndpoints"` // Multiple RPC endpoints
LoadDistribution map[string]float64 `json:"loadDistribution"` // Load distribution per endpoint
FailoverEnabled bool `json:"failoverEnabled"` // Enable failover
HealthCheckInterval time.Duration `json:"healthCheckInterval"` // Health check interval
MaxRetries int `json:"maxRetries"` // Max retries per endpoint
RetryDelay time.Duration `json:"retryDelay"` // Delay between retries
}
MultiNodeConfig holds multi-node configuration
type Peer ¶
type Peer struct {
Node *enode.Node
Conn *rlpx.Conn
RW p2p.MsgReadWriter
Protocols map[string]Protocol
Connected time.Time
// contains filtered or unexported fields
}
Peer represents a connected peer
type RetryConfig ¶
type RetryConfig struct {
MaxRetries int
InitialDelay time.Duration
MaxDelay time.Duration
BackoffFactor float64
}
RetryConfig represents retry configuration
type SystemMetrics ¶
type SystemMetrics struct {
CPUUsage float64 `json:"cpuUsage"`
MemoryUsage float64 `json:"memoryUsage"`
NetworkIO map[string]int64 `json:"networkIO"`
NodeLatency map[string]time.Duration `json:"nodeLatency"`
ErrorRates map[string]float64 `json:"errorRates"`
Timestamp time.Time `json:"timestamp"`
}
SystemMetrics holds system performance metrics
type TransactionRecord ¶
type TransactionRecord struct {
Hash common.Hash `json:"hash"`
From common.Address `json:"from"`
To *common.Address `json:"to"`
Value *big.Int `json:"value"`
Gas uint64 `json:"gas"`
GasPrice *big.Int `json:"gasPrice"`
GasFeeCap *big.Int `json:"gasFeeCap,omitempty"`
GasTipCap *big.Int `json:"gasTipCap,omitempty"`
Nonce uint64 `json:"nonce"`
Data []byte `json:"data"`
TxType uint8 `json:"txType"`
SentTime time.Time `json:"sentTime"`
MinedTime *time.Time `json:"minedTime,omitempty"`
ConfirmedTime *time.Time `json:"confirmedTime,omitempty"`
Status string `json:"status"` // pending, mined, failed, confirmed
GasUsed *uint64 `json:"gasUsed,omitempty"`
BlockNumber *uint64 `json:"blockNumber,omitempty"`
Error string `json:"error,omitempty"`
MutationUsed bool `json:"mutationUsed"`
MutationType string `json:"mutationType,omitempty"`
}
TransactionRecord records detailed information about each transaction
type TxFuzzConfig ¶
type TxFuzzConfig struct {
// Basic configuration
RPCEndpoint string
ChainID int64
MaxGasPrice *big.Int
MaxGasLimit uint64
TxPerSecond int
FuzzDuration time.Duration
Seed int64
UseMutation bool
MutationRatio float64 // 0.0-1.0, ratio of transactions using mutation vs random generation
EnableTracking bool
OutputFile string
ConfirmBlocks uint64 // Number of blocks to wait for confirmation
SuccessHashFile string // 成功交易哈希文件路径
FailedHashFile string // 失败交易哈希文件路径
// Enhanced configuration for stress testing
MultiNode *MultiNodeConfig `json:"multiNode,omitempty"` // Multi-node configuration
LoadPattern *LoadPattern `json:"loadPattern,omitempty"` // Load pattern configuration
EnableMetrics bool `json:"enableMetrics"` // Enable system metrics collection
MetricsInterval time.Duration `json:"metricsInterval"` // Metrics collection interval
}
TxFuzzConfig holds configuration for transaction fuzzing
type TxFuzzer ¶
type TxFuzzer struct {
// contains filtered or unexported fields
}
TxFuzzer represents a transaction fuzzer with enhanced stress testing capabilities
func NewTxFuzzer ¶
func NewTxFuzzer(cfg *TxFuzzConfig, accounts []config.Account, logger utils.Logger) (*TxFuzzer, error)
NewTxFuzzer creates a new transaction fuzzer with enhanced stress testing capabilities
func (*TxFuzzer) ExportFailedHashes ¶
ExportFailedHashes exports failed transaction hashes to a file
func (*TxFuzzer) ExportRecordsJSON ¶
ExportRecordsJSON exports transaction records as JSON
func (*TxFuzzer) ExportSuccessHashes ¶
ExportSuccessHashes exports successful transaction hashes to a file
func (*TxFuzzer) GetCurrentTPS ¶
GetCurrentTPS returns the current transactions per second
func (*TxFuzzer) GetEnhancedStats ¶
GetEnhancedStats returns comprehensive statistics including per-node metrics
func (*TxFuzzer) GetFailedHashes ¶
GetFailedHashes returns a copy of failed transaction hashes
func (*TxFuzzer) GetHealthStatus ¶
GetHealthStatus returns the health status of all nodes
func (*TxFuzzer) GetSuccessHashes ¶
GetSuccessHashes returns a copy of successful transaction hashes
func (*TxFuzzer) GetSystemMetrics ¶
func (tf *TxFuzzer) GetSystemMetrics() *SystemMetrics
GetSystemMetrics returns current system metrics
func (*TxFuzzer) GetTransactionRecords ¶
func (tf *TxFuzzer) GetTransactionRecords() map[common.Hash]*TransactionRecord
GetTransactionRecords returns all transaction records
func (*TxFuzzer) PrintRealTimeStats ¶
func (tf *TxFuzzer) PrintRealTimeStats()
PrintRealTimeStats prints real-time statistics to console
func (*TxFuzzer) Start ¶
func (tf *TxFuzzer) Start(cfg *TxFuzzConfig) error
Start begins the transaction fuzzing process with enhanced load patterns
func (*TxFuzzer) StartWithContext ¶
func (tf *TxFuzzer) StartWithContext(ctx context.Context, cfg *TxFuzzConfig) error
StartWithContext starts the fuzzing process with context support
type TxStats ¶
type TxStats struct {
TotalSent int64 `json:"totalSent"`
TotalMined int64 `json:"totalMined"`
TotalFailed int64 `json:"totalFailed"`
TotalPending int64 `json:"totalPending"`
MutationUsed int64 `json:"mutationUsed"`
RandomUsed int64 `json:"randomUsed"`
StartTime time.Time `json:"startTime"`
LastUpdateTime time.Time `json:"lastUpdateTime"`
// contains filtered or unexported fields
}
TxStats holds statistics about transaction fuzzing