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:
Krypto Kajun
2025-09-19 17:23:14 -05:00
parent 0680ac458a
commit 3f69aeafcf
71 changed files with 26755 additions and 421 deletions

View File

@@ -39,6 +39,9 @@ type Logger struct {
performanceLogger *log.Logger // Performance metrics and RPC calls
transactionLogger *log.Logger // Detailed transaction analysis
// Security filtering
secureFilter *SecureFilter
levelName string
}
@@ -99,6 +102,18 @@ func New(level string, format string, file string) *Logger {
// Create loggers with no prefixes (we format ourselves)
logLevel := parseLogLevel(level)
// Determine security level based on environment and log level
var securityLevel SecurityLevel
env := os.Getenv("GO_ENV")
switch {
case env == "production":
securityLevel = SecurityLevelProduction
case logLevel >= WARN:
securityLevel = SecurityLevelInfo
default:
securityLevel = SecurityLevelDebug
}
return &Logger{
logger: log.New(mainFile, "", 0),
opportunityLogger: log.New(opportunityFile, "", 0),
@@ -106,6 +121,7 @@ func New(level string, format string, file string) *Logger {
performanceLogger: log.New(performanceFile, "", 0),
transactionLogger: log.New(transactionFile, "", 0),
level: logLevel,
secureFilter: NewSecureFilter(securityLevel),
levelName: level,
}
}
@@ -160,6 +176,9 @@ func (l *Logger) Error(v ...interface{}) {
func (l *Logger) Opportunity(txHash, from, to, method, protocol string, amountIn, amountOut, minOut, profitUSD float64, additionalData map[string]interface{}) {
timestamp := time.Now().Format("2006/01/02 15:04:05")
// Create sanitized additional data for production
sanitizedData := l.secureFilter.SanitizeForProduction(additionalData)
message := fmt.Sprintf(`%s [OPPORTUNITY] 🎯 ARBITRAGE OPPORTUNITY DETECTED
├── Transaction: %s
├── From: %s → To: %s
@@ -170,10 +189,13 @@ func (l *Logger) Opportunity(txHash, from, to, method, protocol string, amountIn
├── Estimated Profit: $%.2f USD
└── Additional Data: %v`,
timestamp, txHash, from, to, method, protocol,
amountIn, amountOut, minOut, profitUSD, additionalData)
amountIn, amountOut, minOut, profitUSD, sanitizedData)
l.logger.Println(message)
l.opportunityLogger.Println(message) // Dedicated opportunity log
// Apply security filtering to the entire message
filteredMessage := l.secureFilter.FilterMessage(message)
l.logger.Println(filteredMessage)
l.opportunityLogger.Println(filteredMessage) // Dedicated opportunity log
}
// OpportunitySimple logs a simple opportunity message (for backwards compatibility)
@@ -227,6 +249,9 @@ func (l *Logger) Transaction(txHash, from, to, method, protocol string, gasUsed,
status = "SUCCESS"
}
// Sanitize metadata for production
sanitizedMetadata := l.secureFilter.SanitizeForProduction(metadata)
message := fmt.Sprintf(`%s [TRANSACTION] 💳 %s
├── Hash: %s
├── From: %s → To: %s
@@ -236,9 +261,12 @@ func (l *Logger) Transaction(txHash, from, to, method, protocol string, gasUsed,
├── Status: %s
└── Metadata: %v`,
timestamp, status, txHash, from, to, method, protocol,
gasUsed, gasPrice, value, status, metadata)
gasUsed, gasPrice, value, status, sanitizedMetadata)
l.transactionLogger.Println(message) // Dedicated transaction log only
// Apply security filtering to the entire message
filteredMessage := l.secureFilter.FilterMessage(message)
l.transactionLogger.Println(filteredMessage) // Dedicated transaction log only
}
// BlockProcessing logs block processing metrics for sequencer monitoring
@@ -269,7 +297,10 @@ func (l *Logger) ArbitrageAnalysis(poolA, poolB, tokenPair string, priceA, price
timestamp, status, tokenPair, poolA, priceA, poolB, priceB,
priceDiff*100, estimatedProfit, status)
l.opportunityLogger.Println(message) // Arbitrage analysis goes to opportunity log
// Apply security filtering to protect sensitive pricing data
filteredMessage := l.secureFilter.FilterMessage(message)
l.opportunityLogger.Println(filteredMessage) // Arbitrage analysis goes to opportunity log
}
// RPC logs RPC call metrics for endpoint optimization
@@ -290,3 +321,25 @@ func (l *Logger) RPC(endpoint, method string, duration time.Duration, success bo
l.performanceLogger.Println(message) // RPC metrics go to performance log
}
// SwapAnalysis logs swap event analysis with security filtering
func (l *Logger) SwapAnalysis(tokenIn, tokenOut string, amountIn, amountOut float64, protocol, poolAddr string, metadata map[string]interface{}) {
timestamp := time.Now().Format("2006/01/02 15:04:05")
// Sanitize metadata for production
sanitizedMetadata := l.secureFilter.SanitizeForProduction(metadata)
message := fmt.Sprintf(`%s [SWAP_ANALYSIS] 🔄 %s → %s
├── Amount In: %.6f %s
├── Amount Out: %.6f %s
├── Protocol: %s
├── Pool: %s
└── Metadata: %v`,
timestamp, tokenIn, tokenOut, amountIn, tokenIn, amountOut, tokenOut,
protocol, poolAddr, sanitizedMetadata)
// Apply security filtering to the entire message
filteredMessage := l.secureFilter.FilterMessage(message)
l.transactionLogger.Println(filteredMessage) // Dedicated transaction log
}