Restructured project for V2 refactor: **Structure Changes:** - Moved all V1 code to orig/ folder (preserved with git mv) - Created docs/planning/ directory - Added orig/README_V1.md explaining V1 preservation **Planning Documents:** - 00_V2_MASTER_PLAN.md: Complete architecture overview - Executive summary of critical V1 issues - High-level component architecture diagrams - 5-phase implementation roadmap - Success metrics and risk mitigation - 07_TASK_BREAKDOWN.md: Atomic task breakdown - 99+ hours of detailed tasks - Every task < 2 hours (atomic) - Clear dependencies and success criteria - Organized by implementation phase **V2 Key Improvements:** - Per-exchange parsers (factory pattern) - Multi-layer strict validation - Multi-index pool cache - Background validation pipeline - Comprehensive observability **Critical Issues Addressed:** - Zero address tokens (strict validation + cache enrichment) - Parsing accuracy (protocol-specific parsers) - No audit trail (background validation channel) - Inefficient lookups (multi-index cache) - Stats disconnection (event-driven metrics) Next Steps: 1. Review planning documents 2. Begin Phase 1: Foundation (P1-001 through P1-010) 3. Implement parsers in Phase 2 4. Build cache system in Phase 3 5. Add validation pipeline in Phase 4 6. Migrate and test in Phase 5 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
150 lines
4.6 KiB
Bash
Executable File
150 lines
4.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Setup Auto-Update System for MEV Bot
|
|
# This script installs git hooks and optionally systemd timers for automatic updates
|
|
|
|
set -e
|
|
|
|
PROJECT_DIR=$(cd "$(dirname "$0")/.." && pwd)
|
|
|
|
# Color codes
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${BLUE}========================================="
|
|
echo "MEV Bot Auto-Update Setup"
|
|
echo "=========================================${NC}"
|
|
echo ""
|
|
|
|
# Check if running as root
|
|
IS_ROOT=false
|
|
if [ "$EUID" -eq 0 ]; then
|
|
IS_ROOT=true
|
|
echo -e "${YELLOW}Running as root - will setup systemd timer${NC}"
|
|
else
|
|
echo -e "${YELLOW}Not running as root - will skip systemd timer${NC}"
|
|
echo -e "${YELLOW}Run with sudo to enable automatic periodic updates${NC}"
|
|
fi
|
|
echo ""
|
|
|
|
# Step 1: Install git hooks
|
|
echo -e "${BLUE}Step 1: Installing Git Hooks${NC}"
|
|
echo "-------------------------------------------"
|
|
cd "$PROJECT_DIR"
|
|
|
|
if [ -f "$PROJECT_DIR/scripts/install-git-hooks.sh" ]; then
|
|
"$PROJECT_DIR/scripts/install-git-hooks.sh"
|
|
echo -e "${GREEN}✓ Git hooks installed${NC}"
|
|
else
|
|
echo -e "${RED}✗ Git hooks installation script not found${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# Step 2: Setup systemd timer (if root)
|
|
if [ "$IS_ROOT" = true ]; then
|
|
echo -e "${BLUE}Step 2: Setting up Systemd Timer${NC}"
|
|
echo "-------------------------------------------"
|
|
|
|
# Update WorkingDirectory in service files
|
|
sed "s|WorkingDirectory=/docker/mev-beta|WorkingDirectory=$PROJECT_DIR|g" \
|
|
"$PROJECT_DIR/scripts/mev-bot-auto-update.service" > /tmp/mev-bot-auto-update.service
|
|
|
|
sed "s|/docker/mev-beta|$PROJECT_DIR|g" \
|
|
/tmp/mev-bot-auto-update.service > /tmp/mev-bot-auto-update.service.tmp
|
|
mv /tmp/mev-bot-auto-update.service.tmp /tmp/mev-bot-auto-update.service
|
|
|
|
# Copy service and timer files
|
|
cp /tmp/mev-bot-auto-update.service /etc/systemd/system/
|
|
cp "$PROJECT_DIR/scripts/mev-bot-auto-update.timer" /etc/systemd/system/
|
|
|
|
# Reload systemd
|
|
systemctl daemon-reload
|
|
|
|
# Enable and start the timer
|
|
systemctl enable mev-bot-auto-update.timer
|
|
systemctl start mev-bot-auto-update.timer
|
|
|
|
echo -e "${GREEN}✓ Systemd timer enabled and started${NC}"
|
|
echo ""
|
|
|
|
# Show timer status
|
|
echo -e "${YELLOW}Timer status:${NC}"
|
|
systemctl status mev-bot-auto-update.timer --no-pager | head -10
|
|
echo ""
|
|
|
|
# Show next scheduled run
|
|
echo -e "${YELLOW}Next scheduled update check:${NC}"
|
|
systemctl list-timers mev-bot-auto-update.timer --no-pager
|
|
echo ""
|
|
else
|
|
echo -e "${BLUE}Step 2: Systemd Timer (Skipped)${NC}"
|
|
echo "-------------------------------------------"
|
|
echo -e "${YELLOW}Run 'sudo ./scripts/setup-auto-update.sh' to enable automatic updates${NC}"
|
|
echo ""
|
|
fi
|
|
|
|
# Step 3: Create logs directory
|
|
echo -e "${BLUE}Step 3: Creating Logs Directory${NC}"
|
|
echo "-------------------------------------------"
|
|
mkdir -p "$PROJECT_DIR/logs"
|
|
echo -e "${GREEN}✓ Logs directory created${NC}"
|
|
echo ""
|
|
|
|
# Summary
|
|
echo -e "${GREEN}========================================="
|
|
echo "Auto-Update Setup Complete!"
|
|
echo "=========================================${NC}"
|
|
echo ""
|
|
|
|
echo "What's been configured:"
|
|
echo ""
|
|
echo "1. Git Hooks:"
|
|
echo " ✓ post-merge hook installed"
|
|
echo " → Triggers auto-rebuild after 'git pull'"
|
|
echo ""
|
|
|
|
if [ "$IS_ROOT" = true ]; then
|
|
echo "2. Systemd Timer:"
|
|
echo " ✓ Checks for updates every 5 minutes"
|
|
echo " ✓ Starts automatically on boot"
|
|
echo " ✓ Pulls and rebuilds when updates detected"
|
|
echo ""
|
|
echo "Manage the timer:"
|
|
echo " sudo systemctl status mev-bot-auto-update.timer"
|
|
echo " sudo systemctl stop mev-bot-auto-update.timer"
|
|
echo " sudo systemctl start mev-bot-auto-update.timer"
|
|
echo " sudo journalctl -u mev-bot-auto-update -f"
|
|
echo ""
|
|
else
|
|
echo "2. Manual Updates:"
|
|
echo " Run: ./scripts/auto-update.sh"
|
|
echo " Or: git pull (hooks will auto-rebuild)"
|
|
echo ""
|
|
fi
|
|
|
|
echo "3. Logs:"
|
|
echo " Auto-update log: tail -f logs/auto-update.log"
|
|
echo " Container log: docker compose logs -f mev-bot"
|
|
echo ""
|
|
|
|
echo -e "${BLUE}Optional: Webhook Receiver${NC}"
|
|
echo "-------------------------------------------"
|
|
echo "For immediate updates via GitHub/GitLab webhooks:"
|
|
echo ""
|
|
echo "1. Configure webhook in your Git provider:"
|
|
echo " URL: http://your-server:9000/webhook"
|
|
echo " Events: Push events (master branch)"
|
|
echo ""
|
|
echo "2. Start the webhook receiver:"
|
|
echo " ./scripts/webhook-receiver.sh"
|
|
echo ""
|
|
echo "Or run as systemd service (advanced setup needed)"
|
|
echo ""
|
|
|
|
echo -e "${GREEN}Your MEV bot will now auto-update! 🚀${NC}"
|
|
echo ""
|