feat: create v2-prep branch with comprehensive planning
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>
This commit is contained in:
144
scripts/auto-update.sh
Executable file
144
scripts/auto-update.sh
Executable file
@@ -0,0 +1,144 @@
|
||||
#!/bin/bash
|
||||
# MEV Bot Auto-Update Script
|
||||
# Checks for updates on master branch and automatically pulls, rebuilds, and restarts
|
||||
|
||||
set -e
|
||||
|
||||
# Configuration
|
||||
BRANCH="${GIT_BRANCH:-master}"
|
||||
REMOTE="${GIT_REMOTE:-origin}"
|
||||
PROJECT_DIR="${PROJECT_DIR:-$(cd "$(dirname "$0")/.." && pwd)}"
|
||||
LOG_FILE="${PROJECT_DIR}/logs/auto-update.log"
|
||||
|
||||
# Color codes
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Ensure log directory exists
|
||||
mkdir -p "${PROJECT_DIR}/logs"
|
||||
|
||||
# Logging function
|
||||
log() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
log_color() {
|
||||
echo -e "$1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
# Change to project directory
|
||||
cd "$PROJECT_DIR"
|
||||
|
||||
log_color "${BLUE}========================================="
|
||||
log "MEV Bot Auto-Update Check"
|
||||
log_color "${BLUE}=========================================${NC}"
|
||||
log "Project: $PROJECT_DIR"
|
||||
log "Branch: $BRANCH"
|
||||
log "Remote: $REMOTE"
|
||||
log ""
|
||||
|
||||
# Fetch latest changes from remote
|
||||
log_color "${YELLOW}Fetching latest changes from $REMOTE...${NC}"
|
||||
if git fetch "$REMOTE" >> "$LOG_FILE" 2>&1; then
|
||||
log_color "${GREEN}✓ Fetch successful${NC}"
|
||||
else
|
||||
log_color "${RED}✗ Fetch failed${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get current and remote commit hashes
|
||||
LOCAL_COMMIT=$(git rev-parse HEAD)
|
||||
REMOTE_COMMIT=$(git rev-parse "$REMOTE/$BRANCH")
|
||||
|
||||
log "Local commit: $LOCAL_COMMIT"
|
||||
log "Remote commit: $REMOTE_COMMIT"
|
||||
|
||||
# Check if update is available
|
||||
if [ "$LOCAL_COMMIT" = "$REMOTE_COMMIT" ]; then
|
||||
log_color "${GREEN}✓ Already up to date${NC}"
|
||||
log ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Update available
|
||||
log_color "${YELLOW}⚠ Update available!${NC}"
|
||||
log ""
|
||||
|
||||
# Show what's new
|
||||
log_color "${BLUE}New commits:${NC}"
|
||||
git log --oneline "$LOCAL_COMMIT..$REMOTE_COMMIT" | tee -a "$LOG_FILE"
|
||||
log ""
|
||||
|
||||
# Check if we're on the correct branch
|
||||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
if [ "$CURRENT_BRANCH" != "$BRANCH" ]; then
|
||||
log_color "${RED}✗ Not on $BRANCH branch (currently on $CURRENT_BRANCH)${NC}"
|
||||
log "Skipping auto-update. Please switch to $BRANCH manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for uncommitted changes
|
||||
if ! git diff-index --quiet HEAD --; then
|
||||
log_color "${RED}✗ Uncommitted changes detected${NC}"
|
||||
log "Skipping auto-update. Please commit or stash changes first."
|
||||
git status --short | tee -a "$LOG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Pull the changes
|
||||
log_color "${YELLOW}Pulling changes from $REMOTE/$BRANCH...${NC}"
|
||||
if git pull "$REMOTE" "$BRANCH" >> "$LOG_FILE" 2>&1; then
|
||||
log_color "${GREEN}✓ Pull successful${NC}"
|
||||
else
|
||||
log_color "${RED}✗ Pull failed${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# The post-merge hook will handle rebuild and restart
|
||||
log ""
|
||||
log_color "${YELLOW}Post-merge hook will handle rebuild and restart...${NC}"
|
||||
log ""
|
||||
|
||||
# Wait for post-merge hook to complete
|
||||
sleep 2
|
||||
|
||||
# Verify container is running
|
||||
log_color "${YELLOW}Verifying container status...${NC}"
|
||||
if docker compose ps | grep -q "mev-bot.*running"; then
|
||||
log_color "${GREEN}✓ Container is running${NC}"
|
||||
else
|
||||
log_color "${RED}✗ Container is not running${NC}"
|
||||
docker compose ps | tee -a "$LOG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Show container status
|
||||
log ""
|
||||
log_color "${GREEN}========================================="
|
||||
log "Update Complete!"
|
||||
log_color "${GREEN}=========================================${NC}"
|
||||
log "Updated from: $(echo $LOCAL_COMMIT | cut -c1-7)"
|
||||
log "Updated to: $(echo $REMOTE_COMMIT | cut -c1-7)"
|
||||
log ""
|
||||
|
||||
# Send notification if configured
|
||||
if command -v curl &> /dev/null && [ -n "$WEBHOOK_URL" ]; then
|
||||
NEW_COMMITS=$(git log --oneline "$LOCAL_COMMIT..$REMOTE_COMMIT" | wc -l)
|
||||
MESSAGE="MEV Bot auto-updated: $NEW_COMMITS new commit(s) on $BRANCH"
|
||||
|
||||
curl -X POST "$WEBHOOK_URL" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"text\":\"$MESSAGE\"}" \
|
||||
>> "$LOG_FILE" 2>&1 || true
|
||||
|
||||
log "Notification sent to webhook"
|
||||
fi
|
||||
|
||||
log "View logs: tail -f $LOG_FILE"
|
||||
log "View container logs: docker compose logs -f mev-bot"
|
||||
log ""
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user