Files
mev-beta/scripts/dev.sh
Administrator 3505921207 feat: comprehensive audit infrastructure and Phase 1 refactoring
This commit includes:

## Audit & Testing Infrastructure
- scripts/audit.sh: 12-section comprehensive codebase audit
- scripts/test.sh: 7 test types (unit, integration, race, bench, coverage, contracts, pkg)
- scripts/check-compliance.sh: SPEC.md compliance validation
- scripts/check-docs.sh: Documentation coverage checker
- scripts/dev.sh: Unified development script with all commands

## Documentation
- SPEC.md: Authoritative technical specification
- docs/AUDIT_AND_TESTING.md: Complete testing guide (600+ lines)
- docs/SCRIPTS_REFERENCE.md: All scripts documented (700+ lines)
- docs/README.md: Documentation index and navigation
- docs/DEVELOPMENT_SETUP.md: Environment setup guide
- docs/REFACTORING_PLAN.md: Systematic refactoring plan

## Phase 1 Refactoring (Critical Fixes)
- pkg/validation/helpers.go: Validation functions for addresses/amounts
- pkg/sequencer/selector_registry.go: Thread-safe selector registry
- pkg/sequencer/reader.go: Fixed race conditions with atomic metrics
- pkg/sequencer/swap_filter.go: Fixed race conditions, added error logging
- pkg/sequencer/decoder.go: Added address validation

## Changes Summary
- Fixed race conditions on 13 metric counters (atomic operations)
- Added validation at all ingress points
- Eliminated silent error handling
- Created selector registry for future ABI migration
- Reduced SPEC.md violations from 7 to 5

Build Status:  All packages compile
Compliance:  No race conditions, no silent failures
Documentation:  1,700+ lines across 5 comprehensive guides

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 07:17:13 +01:00

195 lines
5.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Development environment helper script
# Ensures all development happens within containers
set -e
PROJECT_ROOT="/docker/mev-beta"
cd "$PROJECT_ROOT" || exit 1
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
info() { echo -e "${BLUE}${NC} $1"; }
success() { echo -e "${GREEN}${NC} $1"; }
warn() { echo -e "${YELLOW}${NC} $1"; }
error() { echo -e "${RED}${NC} $1"; }
# Show usage
usage() {
cat <<EOF
Usage: ./scripts/dev.sh <command>
Container Development Commands:
up Start all development containers
down Stop all development containers
restart Restart all development containers
go Enter Go development container
python Enter Python development container
foundry Enter Foundry container
build Build Go application in container
test [type] Run tests (all, unit, integration, race, bench, coverage)
audit Run comprehensive codebase audit
check-docs Check documentation coverage
check-compliance Check SPEC.md compliance
forge-build Build Solidity contracts in container
forge-test Run Foundry tests in container
bindings Generate Go bindings from ABIs in container
clean Clean all build artifacts
reset Stop containers and clean artifacts
logs [service] View logs for a service (go-dev, foundry, mev-bot-v2, etc.)
ps Show running containers
Examples:
./scripts/dev.sh up # Start dev environment
./scripts/dev.sh go # Enter Go container
./scripts/dev.sh build # Build bot in Go container
./scripts/dev.sh test all # Run all tests
./scripts/dev.sh test coverage # Generate coverage report
./scripts/dev.sh audit # Run security & quality audit
./scripts/dev.sh check-compliance # Check SPEC.md compliance
./scripts/dev.sh forge-build # Build contracts
./scripts/dev.sh bindings # Generate bindings in Go container
EOF
exit 0
}
# Check if command is provided
if [ $# -eq 0 ]; then
usage
fi
COMMAND=$1
shift
case "$COMMAND" in
up)
info "Starting development containers..."
podman-compose up -d go-dev python-dev foundry
success "Development environment ready"
info "Available containers:"
echo " - mev-go-dev : Go 1.21"
echo " - mev-python-dev : Python 3.11"
echo " - mev-foundry : Foundry tools"
;;
down)
info "Stopping development containers..."
podman-compose stop go-dev python-dev foundry 2>/dev/null || true
success "Development containers stopped"
;;
restart)
info "Restarting development containers..."
podman-compose restart go-dev python-dev foundry
success "Development containers restarted"
;;
go)
info "Entering Go development container..."
podman exec -it mev-go-dev sh
;;
python)
info "Entering Python development container..."
podman exec -it mev-python-dev bash
;;
foundry)
info "Entering Foundry container..."
podman exec -it mev-foundry sh
;;
build)
info "Building Go application in container..."
podman exec -it mev-go-dev sh -c "cd /workspace && go build -o bin/mev-bot ./cmd/mev-bot/main.go"
success "Build complete: bin/mev-bot"
;;
test)
info "Running test suite..."
./scripts/test.sh "$@"
;;
audit)
info "Running codebase audit..."
./scripts/audit.sh
;;
check-docs)
info "Checking documentation coverage..."
./scripts/check-docs.sh
;;
check-compliance)
info "Checking SPEC.md compliance..."
./scripts/check-compliance.sh
;;
forge-build)
info "Building Solidity contracts in Foundry container..."
podman exec -it mev-foundry sh -c "cd /workspace/contracts && forge build"
success "Contracts built: contracts/out/"
;;
forge-test)
info "Running Foundry tests in container..."
podman exec -it mev-foundry sh -c "cd /workspace/contracts && forge test -vv $*"
;;
bindings)
info "Generating Go bindings from contract ABIs..."
podman exec -it mev-go-dev sh -c "cd /workspace && ./scripts/generate-bindings-in-container.sh"
success "Bindings generated in bindings/"
;;
clean)
info "Cleaning build artifacts..."
rm -rf bin/mev-bot
rm -rf contracts/out
rm -rf contracts/cache
success "Build artifacts cleaned"
;;
reset)
warn "Stopping containers and cleaning artifacts..."
podman-compose stop go-dev python-dev foundry 2>/dev/null || true
rm -rf bin/mev-bot
rm -rf contracts/out
rm -rf contracts/cache
success "Environment reset"
;;
logs)
SERVICE="${1:-go-dev}"
info "Showing logs for $SERVICE..."
podman-compose logs -f "$SERVICE"
;;
ps)
info "Running containers:"
podman-compose ps
;;
help|--help|-h)
usage
;;
*)
error "Unknown command: $COMMAND"
echo ""
usage
;;
esac