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:
Administrator
2025-11-10 10:14:26 +01:00
parent 1773daffe7
commit 803de231ba
411 changed files with 20390 additions and 8680 deletions

273
scripts/dev-env.sh Executable file
View File

@@ -0,0 +1,273 @@
#!/bin/bash
# MEV Bot Development Environment Manager
# Supports branch selection and podman-in-podman development
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
# Default values
DEFAULT_BRANCH="master-dev"
COMPOSE_FILE="docker-compose.dev.yml"
# Function to print colored messages
print_info() {
echo -e "${BLUE}${NC} $1"
}
print_success() {
echo -e "${GREEN}${NC} $1"
}
print_warning() {
echo -e "${YELLOW}${NC} $1"
}
print_error() {
echo -e "${RED}${NC} $1"
}
# Function to show usage
usage() {
cat << EOF
${BLUE}MEV Bot Development Environment Manager${NC}
Usage: $0 [COMMAND] [OPTIONS]
Commands:
start [BRANCH] Start development environment with specified branch (default: master-dev)
stop Stop development environment
restart [BRANCH] Restart development environment with specified branch
rebuild [BRANCH] Rebuild and restart with specified branch
logs [OPTIONS] Show logs (pass options like -f for follow)
shell Open shell in running container
status Show container status
clean Clean all containers and volumes
branches List available git branches
switch BRANCH Switch to a different branch and rebuild
Options:
-h, --help Show this help message
Examples:
$0 start master-dev # Start with master-dev branch
$0 start fix-critical-arbitrage-bugs # Start with feature branch
$0 rebuild master # Rebuild with master branch
$0 logs -f # Follow logs
$0 switch feat-new-feature # Switch to new feature branch
Environment Variables:
GIT_BRANCH Git branch to use (default: master-dev)
LOG_LEVEL Logging level (default: debug)
METRICS_ENABLED Enable metrics (default: true)
EOF
}
# Function to check dependencies
check_dependencies() {
if ! command -v podman-compose &> /dev/null; then
print_error "podman-compose is not installed"
print_info "Install with: pip3 install podman-compose"
exit 1
fi
}
# Function to list available branches
list_branches() {
print_info "Available branches:"
cd "$PROJECT_ROOT"
git branch -a | grep -v HEAD | sed 's/^..../ /'
}
# Function to start development environment
start_dev() {
local branch="${1:-$DEFAULT_BRANCH}"
print_info "Starting MEV Bot development environment on branch: $branch"
cd "$PROJECT_ROOT"
# Export branch for docker-compose
export GIT_BRANCH="$branch"
# Build and start
print_info "Building image for branch: $branch"
podman-compose -f "$COMPOSE_FILE" build --build-arg GIT_BRANCH="$branch"
print_info "Starting container..."
podman-compose -f "$COMPOSE_FILE" up -d
print_success "Development environment started on branch: $branch"
print_info "View logs with: $0 logs -f"
print_info "Access shell with: $0 shell"
}
# Function to stop development environment
stop_dev() {
print_info "Stopping development environment..."
cd "$PROJECT_ROOT"
podman-compose -f "$COMPOSE_FILE" down
print_success "Development environment stopped"
}
# Function to restart development environment
restart_dev() {
local branch="${1:-$DEFAULT_BRANCH}"
stop_dev
start_dev "$branch"
}
# Function to rebuild development environment
rebuild_dev() {
local branch="${1:-$DEFAULT_BRANCH}"
print_info "Rebuilding development environment on branch: $branch"
cd "$PROJECT_ROOT"
export GIT_BRANCH="$branch"
# Stop existing containers
podman-compose -f "$COMPOSE_FILE" down
# Rebuild with no cache
print_info "Building image (no cache) for branch: $branch"
podman-compose -f "$COMPOSE_FILE" build --no-cache --build-arg GIT_BRANCH="$branch"
# Start
print_info "Starting container..."
podman-compose -f "$COMPOSE_FILE" up -d
print_success "Development environment rebuilt and started on branch: $branch"
}
# Function to show logs
show_logs() {
cd "$PROJECT_ROOT"
podman-compose -f "$COMPOSE_FILE" logs "$@"
}
# Function to open shell
open_shell() {
cd "$PROJECT_ROOT"
local container=$(podman-compose -f "$COMPOSE_FILE" ps -q | head -1)
if [ -z "$container" ]; then
print_error "No running container found"
exit 1
fi
print_info "Opening shell in container..."
podman exec -it "$container" /bin/bash || podman exec -it "$container" /bin/sh
}
# Function to show status
show_status() {
cd "$PROJECT_ROOT"
print_info "Development environment status:"
podman-compose -f "$COMPOSE_FILE" ps
}
# Function to clean everything
clean_all() {
print_warning "This will remove all containers, images, and volumes. Continue? (y/N)"
read -r response
if [[ "$response" =~ ^[Yy]$ ]]; then
cd "$PROJECT_ROOT"
podman-compose -f "$COMPOSE_FILE" down -v
podman images | grep mev-bot | awk '{print $3}' | xargs -r podman rmi -f
print_success "Cleaned all containers, images, and volumes"
else
print_info "Cancelled"
fi
}
# Function to switch branches
switch_branch() {
local branch="$1"
if [ -z "$branch" ]; then
print_error "Please specify a branch"
usage
exit 1
fi
print_info "Switching to branch: $branch"
cd "$PROJECT_ROOT"
# Check if branch exists
if ! git rev-parse --verify "$branch" &> /dev/null; then
print_error "Branch '$branch' does not exist"
list_branches
exit 1
fi
# Stop current environment
stop_dev
# Checkout branch
print_info "Checking out branch: $branch"
git checkout "$branch"
# Rebuild and start
rebuild_dev "$branch"
}
# Main script logic
main() {
check_dependencies
case "${1:-}" in
start)
start_dev "${2:-$DEFAULT_BRANCH}"
;;
stop)
stop_dev
;;
restart)
restart_dev "${2:-$DEFAULT_BRANCH}"
;;
rebuild)
rebuild_dev "${2:-$DEFAULT_BRANCH}"
;;
logs)
shift
show_logs "$@"
;;
shell)
open_shell
;;
status)
show_status
;;
clean)
clean_all
;;
branches)
list_branches
;;
switch)
switch_branch "$2"
;;
-h|--help|help)
usage
;;
*)
print_error "Unknown command: ${1:-}"
echo ""
usage
exit 1
;;
esac
}
# Run main function
main "$@"