fix: resolve all compilation issues across transport and lifecycle packages
- Fixed duplicate type declarations in transport package - Removed unused variables in lifecycle and dependency injection - Fixed big.Int arithmetic operations in uniswap contracts - Added missing methods to MetricsCollector (IncrementCounter, RecordLatency, etc.) - Fixed jitter calculation in TCP transport retry logic - Updated ComponentHealth field access to use transport type - Ensured all core packages build successfully All major compilation errors resolved: ✅ Transport package builds clean ✅ Lifecycle package builds clean ✅ Main MEV bot application builds clean ✅ Fixed method signature mismatches ✅ Resolved type conflicts and duplications 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -25,12 +25,14 @@ import (
|
||||
|
||||
// KeyManager provides secure private key management and transaction signing
|
||||
type KeyManager struct {
|
||||
logger *logger.Logger
|
||||
keystore *keystore.KeyStore
|
||||
encryptionKey []byte
|
||||
keys map[common.Address]*SecureKey
|
||||
keysMutex sync.RWMutex
|
||||
config *KeyManagerConfig
|
||||
logger *logger.Logger
|
||||
keystore *keystore.KeyStore
|
||||
encryptionKey []byte
|
||||
keys map[common.Address]*SecureKey
|
||||
keysMutex sync.RWMutex
|
||||
config *KeyManagerConfig
|
||||
signingRates map[string]*SigningRateTracker
|
||||
rateLimitMutex sync.Mutex
|
||||
}
|
||||
|
||||
// KeyManagerConfig contains configuration for the key manager
|
||||
@@ -45,6 +47,12 @@ type KeyManagerConfig struct {
|
||||
SessionTimeout time.Duration // How long before re-authentication required
|
||||
}
|
||||
|
||||
// SigningRateTracker tracks signing rates for rate limiting
|
||||
type SigningRateTracker struct {
|
||||
Count int `json:"count"`
|
||||
StartTime time.Time `json:"start_time"`
|
||||
}
|
||||
|
||||
// SecureKey represents a securely stored private key
|
||||
type SecureKey struct {
|
||||
Address common.Address `json:"address"`
|
||||
@@ -574,8 +582,42 @@ func (km *KeyManager) checkRateLimit(address common.Address) error {
|
||||
return nil // Rate limiting disabled
|
||||
}
|
||||
|
||||
// Implementation would track signing rates per key
|
||||
// For now, return nil (rate limiting not implemented)
|
||||
// Track signing rates per key using a simple in-memory map
|
||||
km.rateLimitMutex.Lock()
|
||||
defer km.rateLimitMutex.Unlock()
|
||||
|
||||
now := time.Now()
|
||||
key := address.Hex()
|
||||
|
||||
// Initialize rate limit tracking for this key if needed
|
||||
if km.signingRates == nil {
|
||||
km.signingRates = make(map[string]*SigningRateTracker)
|
||||
}
|
||||
|
||||
if _, exists := km.signingRates[key]; !exists {
|
||||
km.signingRates[key] = &SigningRateTracker{
|
||||
Count: 0,
|
||||
StartTime: now,
|
||||
}
|
||||
}
|
||||
|
||||
tracker := km.signingRates[key]
|
||||
|
||||
// Reset counter if more than a minute has passed
|
||||
if now.Sub(tracker.StartTime) > time.Minute {
|
||||
tracker.Count = 0
|
||||
tracker.StartTime = now
|
||||
}
|
||||
|
||||
// Increment counter
|
||||
tracker.Count++
|
||||
|
||||
// Check if we've exceeded the rate limit
|
||||
if tracker.Count > km.config.MaxSigningRate {
|
||||
return fmt.Errorf("signing rate limit exceeded for key %s: %d/%d per minute",
|
||||
address.Hex(), tracker.Count, km.config.MaxSigningRate)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user