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>
This commit is contained in:
@@ -43,8 +43,8 @@
|
||||
**Required Environment Variables:**
|
||||
```bash
|
||||
# Core RPC Configuration
|
||||
export ARBITRUM_RPC_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/f69d14406bc00700da9b936504e1a870"
|
||||
export ARBITRUM_WS_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/f69d14406bc00700da9b936504e1a870"
|
||||
export ARBITRUM_RPC_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57"
|
||||
export ARBITRUM_WS_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57"
|
||||
|
||||
# Security
|
||||
export MEV_BOT_ENCRYPTION_KEY="<your-encryption-key>"
|
||||
|
||||
@@ -26,6 +26,20 @@ cd mev-beta
|
||||
go build -o mev-bot ./cmd/mev-bot/main.go
|
||||
```
|
||||
|
||||
#### Profitability Monitoring & Simulation
|
||||
|
||||
- **Key Prometheus metrics** exposed at `/metrics/prometheus`:
|
||||
- `mev_bot_net_profit_eth`, `mev_bot_total_profit_eth`, `mev_bot_gas_spent_eth`
|
||||
- `mev_bot_trade_error_rate`, `mev_bot_processing_latency_ms`, `mev_bot_successful_trades`
|
||||
- Track these in Grafana to watch hit rate, latency, and cumulative P&L during deployments.
|
||||
- **Historical replay harness**:
|
||||
- Run `make simulate-profit` (or `./scripts/run_profit_simulation.sh <report-dir>`) to analyse bundled vectors under `tools/simulation/vectors/`.
|
||||
- The CLI produces JSON and Markdown reports in `reports/simulation/latest/` summarising hit rate, gas burn, and per-exchange profitability.
|
||||
- **Runbook checklist**:
|
||||
1. Execute the profitability simulation ahead of staging/production releases and attach the Markdown summary to change records.
|
||||
2. During rollout, alert if `mev_bot_trade_error_rate` exceeds 0.25 for more than 10 minutes or if `mev_bot_net_profit_eth` trends negative across a 15-minute window.
|
||||
3. Archive both math audit (`reports/math/latest/`) and simulation (`reports/simulation/latest/`) artifacts with deployment notes.
|
||||
|
||||
### 2. Environment Setup
|
||||
```bash
|
||||
# Create environment file
|
||||
@@ -43,12 +57,21 @@ BOT_POLLING_INTERVAL=0.25
|
||||
METRICS_ENABLED=true
|
||||
METRICS_PORT=9090
|
||||
|
||||
# Key storage locations
|
||||
MEV_BOT_KEYSTORE_PATH=keystore/production
|
||||
MEV_BOT_AUDIT_LOG=logs/production_audit.log
|
||||
MEV_BOT_BACKUP_PATH=backups/production
|
||||
|
||||
# Alerting
|
||||
SLACK_WEBHOOK="https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK"
|
||||
DISCORD_WEBHOOK="https://discord.com/api/webhooks/YOUR/DISCORD/WEBHOOK"
|
||||
EOF
|
||||
```
|
||||
|
||||
> Tip: For a ready-to-use smoke test profile, source `env/smoke.env`. The sample file seeds a compliant encryption key, keystore paths, and metrics defaults so `./mev-bot start` can boot locally without exposing production secrets. Replace the placeholder RPC endpoints before connecting to real infrastructure.
|
||||
|
||||
Ensure the paths in `MEV_BOT_KEYSTORE_PATH`, `MEV_BOT_AUDIT_LOG`, and `MEV_BOT_BACKUP_PATH` exist on the host; the helper scripts (`scripts/run.sh`, `env/smoke.env`) create sane defaults under `keystore/`, `logs/`, and `backups/` if they are missing.
|
||||
|
||||
### 3. Production Configuration
|
||||
```bash
|
||||
# Copy production config
|
||||
@@ -188,6 +211,32 @@ scrape_configs:
|
||||
metrics_path: '/metrics/prometheus'
|
||||
```
|
||||
|
||||
Prometheus loads alert rules from `monitoring/alerts.yml` to enforce profitability guardrails:
|
||||
|
||||
```yaml
|
||||
# monitoring/alerts.yml
|
||||
groups:
|
||||
- name: mev-bot-alerts
|
||||
rules:
|
||||
- alert: MEVBotHighErrorRate
|
||||
expr: mev_bot_trade_error_rate > 0.25
|
||||
for: 10m
|
||||
labels: { severity: critical }
|
||||
annotations:
|
||||
summary: MEV bot trade error rate is above 25%
|
||||
description: Error rate exceeded SLO for 10 minutes; check RPC health and contract execution.
|
||||
|
||||
- alert: MEVBotDegradedProfitFactor
|
||||
expr: mev_bot_profit_factor < 1
|
||||
for: 15m
|
||||
labels: { severity: warning }
|
||||
annotations:
|
||||
summary: MEV bot profit factor dropped below 1
|
||||
description: Profit factor stayed below breakeven (1.0) for 15 minutes; review gas strategy.
|
||||
```
|
||||
|
||||
Reload Prometheus after updating both `prometheus.yml` and `alerts.yml` so the new rules take effect.
|
||||
|
||||
#### Grafana Dashboard
|
||||
```json
|
||||
{
|
||||
@@ -226,6 +275,20 @@ scrape_configs:
|
||||
}
|
||||
```
|
||||
|
||||
#### Profitability Monitoring & Simulation
|
||||
|
||||
- **Key Prometheus metrics** exposed at `/metrics/prometheus`:
|
||||
- `mev_bot_net_profit_eth`, `mev_bot_total_profit_eth`, `mev_bot_gas_spent_eth`
|
||||
- `mev_bot_trade_error_rate`, `mev_bot_processing_latency_ms`, `mev_bot_successful_trades`
|
||||
- Track these in Grafana to monitor hit rate, latency, and cumulative P&L during deployments.
|
||||
- **Historical replay harness**:
|
||||
- Run `make simulate-profit` (or `./scripts/run_profit_simulation.sh <report-dir>`) to analyse bundled vectors under `tools/simulation/vectors/`.
|
||||
- The CLI produces JSON and Markdown reports in `reports/simulation/latest/` summarising hit rate, gas burn, and per-exchange profitability.
|
||||
- **Runbook checklist**:
|
||||
1. Execute the profitability simulation ahead of staging/production releases and attach the Markdown summary to change records.
|
||||
2. During rollout, alert if `mev_bot_trade_error_rate` exceeds 0.25 for more than 10 minutes or if `mev_bot_net_profit_eth` trends negative across a 15-minute window.
|
||||
3. Archive both math audit (`reports/math/latest/`) and simulation (`reports/simulation/latest/`) artifacts with deployment notes.
|
||||
|
||||
## Performance Optimization
|
||||
|
||||
### L2 Message Processing Tuning
|
||||
@@ -506,4 +569,4 @@ tail -f logs/mev-bot.log
|
||||
pkill -SIGTERM mev-bot
|
||||
```
|
||||
|
||||
**Your MEV bot is now ready for production deployment with full L2 message processing capabilities!** 🚀
|
||||
**Your MEV bot is now ready for production deployment with full L2 message processing capabilities!** 🚀
|
||||
|
||||
Reference in New Issue
Block a user