Files
mev-beta/tools/gas-audit/main.go
Krypto Kajun 850223a953 fix(multicall): resolve critical multicall parsing corruption issues
- Added comprehensive bounds checking to prevent buffer overruns in multicall parsing
- Implemented graduated validation system (Strict/Moderate/Permissive) to reduce false positives
- Added LRU caching system for address validation with 10-minute TTL
- Enhanced ABI decoder with missing Universal Router and Arbitrum-specific DEX signatures
- Fixed duplicate function declarations and import conflicts across multiple files
- Added error recovery mechanisms with multiple fallback strategies
- Updated tests to handle new validation behavior for suspicious addresses
- Fixed parser test expectations for improved validation system
- Applied gofmt formatting fixes to ensure code style compliance
- Fixed mutex copying issues in monitoring package by introducing MetricsSnapshot
- Resolved critical security vulnerabilities in heuristic address extraction
- Progress: Updated TODO audit from 10% to 35% complete

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 00:12:55 -05:00

68 lines
1.9 KiB
Go

package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"time"
"github.com/fraktal/mev-beta/tools/gas-audit/internal"
)
func main() {
var (
network = flag.String("network", "arbitrum", "Network to audit (arbitrum, ethereum)")
gasPrice = flag.String("gas-price", "auto", "Gas price in gwei (auto for dynamic)")
scenarios = flag.String("scenarios", "default", "Gas estimation scenarios")
outputDir = flag.String("output", "reports/gas", "Output directory")
verbose = flag.Bool("verbose", false, "Enable verbose output")
realtime = flag.Bool("realtime", false, "Monitor real-time gas costs")
duration = flag.Duration("duration", 5*time.Minute, "Duration for real-time monitoring")
tolerance = flag.Float64("tolerance", 15.0, "Gas estimation tolerance percentage")
)
flag.Parse()
// Create output directory
if err := os.MkdirAll(*outputDir, 0755); err != nil {
log.Fatalf("Failed to create output directory: %v", err)
}
// Initialize gas auditor
auditor, err := internal.NewGasAuditor(&internal.GasAuditConfig{
Network: *network,
GasPrice: *gasPrice,
ScenariosFile: *scenarios,
OutputDir: *outputDir,
Verbose: *verbose,
Tolerance: *tolerance,
})
if err != nil {
log.Fatalf("Failed to initialize gas auditor: %v", err)
}
ctx := context.Background()
if *realtime {
fmt.Printf("Starting real-time gas cost monitoring for %v...\n", *duration)
ctx, cancel := context.WithTimeout(ctx, *duration)
defer cancel()
if err := auditor.MonitorRealTimeGas(ctx); err != nil {
log.Fatalf("Real-time gas monitoring failed: %v", err)
}
} else {
fmt.Printf("Running gas cost audit for %s network...\n", *network)
if err := auditor.AuditGasCosts(ctx); err != nil {
log.Fatalf("Gas audit failed: %v", err)
}
if err := auditor.GenerateReport(); err != nil {
log.Fatalf("Report generation failed: %v", err)
}
}
fmt.Printf("Gas audit complete. Reports saved to: %s\n", *outputDir)
}