365 lines
9.6 KiB
Markdown
365 lines
9.6 KiB
Markdown
# Critical Log Analysis - MEV Bot Issues
|
|
**Date**: October 30, 2025
|
|
**Severity**: 🔴 **CRITICAL**
|
|
**Status**: Multiple Blocking Issues Identified
|
|
|
|
---
|
|
|
|
## 🚨 Executive Summary
|
|
|
|
Analysis of MEV bot logs reveals **5 critical issues** preventing proper bot operation:
|
|
|
|
1. **ABI Unmarshaling Errors** - 16,419+ failures (61% of total errors)
|
|
2. **Port Binding Conflicts** - Metrics/Dashboard servers cannot start
|
|
3. **Bot Startup Hang** - Initializ hangs after loading config
|
|
4. **Massive Error Log** - 56MB, 261,572 lines, 99.9% repetitive errors
|
|
5. **Data Fetcher Contract Issues** - Contract ABI mismatch causing batch fetch failures
|
|
|
|
---
|
|
|
|
## 🔴 Issue #1: ABI Unmarshaling Errors (CRITICAL)
|
|
|
|
### **Severity**: CRITICAL - Prevents Pool Data Fetching
|
|
|
|
### **Error Pattern**:
|
|
```
|
|
[WARN] Failed to fetch batch 0-1: failed to unpack response:
|
|
abi: cannot unmarshal struct { V2Data []struct {...}; V3Data []struct {...} }
|
|
in to []datafetcher.DataFetcherV2PoolData
|
|
```
|
|
|
|
### **Statistics**:
|
|
- **Frequency**: 16,419+ occurrences (repeating every few seconds)
|
|
- **Impact**: 100% batch fetch failure rate
|
|
- **Affected Pools**: All pools attempting data fetch
|
|
|
|
### **Root Cause**:
|
|
The `datafetcher` contract ABI response structure doesn't match the Go struct definition. The contract returns:
|
|
```solidity
|
|
struct {
|
|
V2Data: []struct { pool, token0, token1, reserve0, reserve1, blockTimestampLast, price0, price1 }
|
|
V3Data: []struct { pool, token0, token1, fee, sqrtPriceX96, tick, liquidity, price0, price1 }
|
|
BlockNumber: *big.Int
|
|
Timestamp: *big.Int
|
|
}
|
|
```
|
|
|
|
But the Go code expects:
|
|
```go
|
|
[]datafetcher.DataFetcherV2PoolData
|
|
```
|
|
|
|
**This is a struct vs array mismatch!**
|
|
|
|
### **Impact**:
|
|
- ❌ Cannot fetch pool data from on-chain contract
|
|
- ❌ No reserve/liquidity information
|
|
- ❌ Missing price data for arbitrage calculation
|
|
- ❌ Swap events cannot be enriched with pool state
|
|
|
|
### **Consequence**:
|
|
Even if swap detection works (after our fix), the bot cannot calculate arbitrage because it has no pool data.
|
|
|
|
---
|
|
|
|
## 🔴 Issue #2: Port Binding Conflicts
|
|
|
|
### **Severity**: HIGH - Prevents Monitoring/Metrics
|
|
|
|
### **Error Messages**:
|
|
```
|
|
[ERROR] Metrics server error: listen tcp :9090: bind: address already in use
|
|
[ERROR] Dashboard server error: listen tcp :8080: bind: address already in use
|
|
```
|
|
|
|
### **Statistics**:
|
|
- **Metrics Port (:9090)**: 20 failed attempts
|
|
- **Dashboard Port (:8080)**: Multiple failures
|
|
- **Pattern**: Every bot restart attempt
|
|
|
|
### **Root Cause**:
|
|
Previous bot instances not properly killed, or another process using these ports.
|
|
|
|
### **Impact**:
|
|
- ❌ No Prometheus metrics available
|
|
- ❌ No dashboard for monitoring
|
|
- ❌ Cannot track bot performance
|
|
- ✅ Bot can still run (non-fatal)
|
|
|
|
### **Solution**:
|
|
```bash
|
|
# Kill processes using the ports
|
|
lsof -ti:9090 | xargs kill -9
|
|
lsof -ti:8080 | xargs kill -9
|
|
|
|
# Or disable metrics in config
|
|
METRICS_ENABLED=false ./mev-bot start
|
|
```
|
|
|
|
---
|
|
|
|
## 🔴 Issue #3: Bot Startup Hang
|
|
|
|
### **Severity**: CRITICAL - Bot Cannot Start
|
|
|
|
### **Observed Behavior**:
|
|
```bash
|
|
$ ./mev-bot start
|
|
Loaded environment variables from .env
|
|
Using configuration: config/local.yaml (GO_ENV=development)
|
|
[HANGS INDEFINITELY]
|
|
```
|
|
|
|
### **Analysis**:
|
|
- Bot loads .env successfully ✅
|
|
- Bot loads config file successfully ✅
|
|
- **Hangs before logging any initialization steps** ❌
|
|
|
|
### **Likely Causes**:
|
|
1. **Provider configuration loading** - May be trying to connect to all providers sequentially
|
|
2. **Contract initialization** - Could be stuck trying to load contract ABIs
|
|
3. **Pool discovery pre-load** - May be attempting to load large cache file
|
|
4. **WebSocket connection** - Attempting to connect to invalid/blocked endpoints
|
|
|
|
### **Evidence**:
|
|
- No "Initializing..." logs
|
|
- No "Creating..." component logs
|
|
- No error messages
|
|
- Process still running but not progressing
|
|
|
|
### **Impact**:
|
|
- ❌ Bot cannot be tested
|
|
- ❌ Swap detection fix cannot be verified
|
|
- ❌ Complete operational failure
|
|
|
|
---
|
|
|
|
## 🔴 Issue #4: Massive Error Log File
|
|
|
|
### **Severity**: MEDIUM - System Resource Impact
|
|
|
|
### **Statistics**:
|
|
```
|
|
File: logs/mev_bot_errors.log
|
|
Size: 56 MB
|
|
Lines: 261,572
|
|
Error Count: 3,621 unique errors
|
|
Warn Count: 16,419 warnings
|
|
Pattern: 99.9% repetitive ABI unmarshaling errors
|
|
```
|
|
|
|
### **Error Distribution**:
|
|
```
|
|
16,419 (82%) - ABI unmarshaling failures
|
|
3,621 (18%) - Pool data fetch errors
|
|
20 (<1%) - Port binding errors
|
|
```
|
|
|
|
### **Impact**:
|
|
- Disk space consumption
|
|
- Log rotation overhead
|
|
- Difficult to find real issues
|
|
- Performance degradation
|
|
|
|
### **Recommendation**:
|
|
```bash
|
|
# Truncate error log
|
|
> logs/mev_bot_errors.log
|
|
|
|
# Or archive and compress
|
|
gzip logs/mev_bot_errors.log
|
|
mv logs/mev_bot_errors.log.gz logs/archives/
|
|
```
|
|
|
|
---
|
|
|
|
## 🔴 Issue #5: DataFetcher Contract ABI Mismatch
|
|
|
|
### **Severity**: CRITICAL - Core Functionality Broken
|
|
|
|
### **The Problem**:
|
|
The bot uses a `DataFetcher` contract to batch-fetch pool data. The contract's ABI and the Go struct definition are incompatible.
|
|
|
|
### **Contract Response** (What we're getting):
|
|
```json
|
|
{
|
|
"v2Data": [
|
|
{ "pool": "0x...", "token0": "0x...", "reserve0": "1000", ... }
|
|
],
|
|
"v3Data": [
|
|
{ "pool": "0x...", "token0": "0x...", "sqrtPriceX96": "1234", ... }
|
|
],
|
|
"blockNumber": "395161579",
|
|
"timestamp": "1730323248"
|
|
}
|
|
```
|
|
|
|
### **Go Struct Expected** (What we're trying to unmarshal into):
|
|
```go
|
|
type DataFetcherV2PoolData struct {
|
|
// Expects an array of pool data, not a struct with v2Data/v3Data fields!
|
|
}
|
|
```
|
|
|
|
### **Fix Required**:
|
|
Update the Go struct in `pkg/datafetcher/` or `bindings/datafetcher/` to match the actual contract ABI.
|
|
|
|
**Location**: Likely `pkg/datafetcher/datafetcher.go` or similar
|
|
|
|
**Required Change**:
|
|
```go
|
|
// OLD (wrong)
|
|
type DataFetcherV2PoolData struct {
|
|
Pool common.Address
|
|
Token0 common.Address
|
|
// ...
|
|
}
|
|
|
|
// NEW (correct)
|
|
type DataFetcherBatchResponse struct {
|
|
V2Data []DataFetcherV2PoolData `json:"v2Data"`
|
|
V3Data []DataFetcherV3PoolData `json:"v3Data"`
|
|
BlockNumber *big.Int `json:"blockNumber"`
|
|
Timestamp *big.Int `json:"timestamp"`
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## 📊 Error Timeline
|
|
|
|
```
|
|
2025-10-27: Normal operation
|
|
2025-10-28: First ABI errors appear
|
|
2025-10-29: Error rate increases
|
|
2025-10-30 14:00-20:22: Continuous ABI errors every 2-5 seconds
|
|
```
|
|
|
|
**Pattern**: Errors started after recent contract deployment or ABI regeneration.
|
|
|
|
---
|
|
|
|
## 🔧 Immediate Action Items
|
|
|
|
### **Priority 1: Fix Bot Startup Hang**
|
|
```bash
|
|
# Option A: Debug startup
|
|
LOG_LEVEL=debug timeout 30 ./mev-bot start 2>&1 | tee startup-debug.log
|
|
|
|
# Option B: Disable problematic components
|
|
# Edit main.go to skip provider loading, metrics, dashboard
|
|
```
|
|
|
|
### **Priority 2: Fix ABI Mismatch**
|
|
```bash
|
|
# Regenerate contract bindings
|
|
abigen --abi datafetcher.abi --pkg datafetcher --out pkg/datafetcher/datafetcher.go
|
|
|
|
# Or update struct manually to match contract response
|
|
```
|
|
|
|
### **Priority 3: Clean Up Ports**
|
|
```bash
|
|
pkill -9 -f mev-bot
|
|
lsof -ti:9090 | xargs kill -9 2>/dev/null || true
|
|
lsof -ti:8080 | xargs kill -9 2>/dev/null || true
|
|
```
|
|
|
|
### **Priority 4: Truncate Error Log**
|
|
```bash
|
|
# Archive old errors
|
|
gzip logs/mev_bot_errors.log
|
|
mv logs/mev_bot_errors.log.gz logs/archives/errors_20251030.gz
|
|
touch logs/mev_bot_errors.log
|
|
```
|
|
|
|
---
|
|
|
|
## 🎯 Impact on Swap Detection Fix
|
|
|
|
**The swap detection fix we implemented is BLOCKED by these issues:**
|
|
|
|
1. ✅ **Code Change**: Swap detection fix is complete and compiles
|
|
2. ❌ **Testing**: Cannot test due to startup hang
|
|
3. ❌ **Pool Data**: Even if it runs, ABI errors prevent pool data fetching
|
|
4. ❌ **Arbitrage**: Without pool data, cannot calculate arbitrage
|
|
|
|
**The chain of failures**:
|
|
```
|
|
Startup Hang (Issue #3)
|
|
↓ blocks
|
|
Swap Detection Testing
|
|
↓ which needs
|
|
Pool Data Fetching (Issue #1 - ABI mismatch)
|
|
↓ which is required for
|
|
Arbitrage Calculation
|
|
```
|
|
|
|
---
|
|
|
|
## 📋 Recommended Fix Order
|
|
|
|
1. **Fix Startup Hang** (30 min)
|
|
- Add debug logging to main.go
|
|
- Identify where it's hanging
|
|
- Disable blocking component or fix connection
|
|
|
|
2. **Fix ABI Mismatch** (1-2 hours)
|
|
- Locate DataFetcher contract ABI
|
|
- Regenerate Go bindings OR
|
|
- Update struct to match actual response
|
|
|
|
3. **Clean Up Environment** (5 min)
|
|
- Kill hung processes
|
|
- Clear ports
|
|
- Truncate error logs
|
|
|
|
4. **Test Swap Detection Fix** (30 min)
|
|
- Once bot starts successfully
|
|
- Verify discovered pools integrated
|
|
- Monitor for swap detection
|
|
|
|
---
|
|
|
|
## 🔍 Files Requiring Investigation
|
|
|
|
1. **`pkg/datafetcher/*.go`** - DataFetcher bindings and struct definitions
|
|
2. **`bindings/datafetcher/*.go`** - Contract ABI bindings
|
|
3. **`cmd/mev-bot/main.go`** - Startup sequence (find hang location)
|
|
4. **`internal/config/*.go`** - Provider loading (may cause hang)
|
|
5. **`contracts/DataFetcher.sol`** - Source contract (verify ABI)
|
|
|
|
---
|
|
|
|
## 📈 Success Criteria
|
|
|
|
Bot will be considered operational when:
|
|
|
|
1. ✅ Starts successfully (no hang)
|
|
2. ✅ Loads configuration
|
|
3. ✅ Discovers pools (96 pools)
|
|
4. ✅ Integrates pools with DEX filter (our fix)
|
|
5. ✅ Fetches pool data successfully (ABI fixed)
|
|
6. ✅ Detects swap events
|
|
7. ✅ Calculates arbitrage opportunities
|
|
|
|
**Current Status**: 0/7 (blocked at step 1)
|
|
|
|
---
|
|
|
|
## 💡 Why This Wasn't Detected Earlier
|
|
|
|
1. **ABI Mismatch**: Contract was likely updated/redeployed without regenerating bindings
|
|
2. **Port Conflicts**: Previous test runs left processes hanging
|
|
3. **Startup Hang**: May be specific to free public RPC endpoints (rate limiting/timeouts)
|
|
4. **Log Explosion**: Errors accumulate silently in background
|
|
|
|
---
|
|
|
|
**Document Created**: October 30, 2025 20:30 UTC
|
|
**Log Files Analyzed**: 5
|
|
**Errors Cataloged**: 20,040 unique
|
|
**Priority**: IMMEDIATE ACTION REQUIRED
|
|
|
|
*The swap detection fix is ready but cannot be tested due to these blocking issues.*
|