feat(prod): complete production deployment with Podman containerization

- Migrate from Docker to Podman for enhanced security (rootless containers)
- Add production-ready Dockerfile with multi-stage builds
- Configure production environment with Arbitrum mainnet RPC endpoints
- Add comprehensive test coverage for core modules (exchanges, execution, profitability)
- Implement production audit and deployment documentation
- Update deployment scripts for production environment
- Add container runtime and health monitoring scripts
- Document RPC limitations and remediation strategies
- Implement token metadata caching and pool validation

This commit prepares the MEV bot for production deployment on Arbitrum
with full containerization, security hardening, and operational tooling.

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Krypto Kajun
2025-11-08 10:15:22 -06:00
parent 52d555ccdf
commit 8cba462024
55 changed files with 15523 additions and 4908 deletions

View File

@@ -1,9 +1,9 @@
#!/bin/bash
#!/usr/bin/env bash
# Critical Fixes Application Script
# Date: 2025-10-30
# Purpose: Apply all critical fixes identified in log analysis
set -e # Exit on error
set -euo pipefail # Exit on error, undefined vars, pipe failures
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
@@ -42,7 +42,7 @@ create_backup() {
mkdir -p "$backup_dir"
if [ -f "$file" ]; then
cp "$file" "$backup_dir/$(basename $file).backup"
cp "$file" "$backup_dir/$(basename "$file").backup"
log_info "Backed up: $file -> $backup_dir"
fi
}

View File

@@ -5,7 +5,7 @@ set -euo pipefail
# Can be used in any Go project by adjusting configuration
# Configuration variables
BINARY_NAME="${BINARY_NAME:-$(basename $(pwd))}"
BINARY_NAME="${BINARY_NAME:-$(basename "$PWD")}"
BINARY_DIR="${BINARY_DIR:-bin}"
MAIN_FILE="${MAIN_FILE:-cmd/mev-bot/main.go}"
BUILD_TAGS="${BUILD_TAGS:-}"
@@ -94,7 +94,9 @@ export GOOS="$GOOS"
export GOARCH="$GOARCH"
# Build the application
echo "go build -o $OUTPUT $BUILD_TAGS:+-tags $BUILD_TAGS $LDFLAGS:+-ldflags $LDFLAGS $MAIN_FILE"
echo "Building $BINARY_NAME..."
[ -n "$BUILD_TAGS" ] && echo " Build tags: $BUILD_TAGS"
[ -n "$LDFLAGS" ] && echo " LDFLAGS: $LDFLAGS"
go build -o "$OUTPUT" ${BUILD_TAGS:+-tags "$BUILD_TAGS"} ${LDFLAGS:+-ldflags "$LDFLAGS"} "$MAIN_FILE"
echo "Build completed successfully!"

View File

@@ -1,8 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash
# Check wallet balance on Arbitrum One
# Verifies wallet is ready for MEV bot execution
set -e
set -euo pipefail
PRIVATE_KEY_FILE="/tmp/wallet_key.txt"
ALCHEMY_RPC="https://arb-mainnet.g.alchemy.com/v2/d6VAHgzkOI3NgLGem6uBMiADT1E9rROB"
@@ -70,7 +70,12 @@ if [ -z "$BALANCE_HEX" ]; then
fi
# Convert hex to decimal (wei)
BALANCE_WEI=$(echo $((BALANCE_HEX)))
# Handle both with and without 0x prefix
if [[ "$BALANCE_HEX" == 0x* ]]; then
BALANCE_WEI=$((BALANCE_HEX))
else
BALANCE_WEI=$((0x$BALANCE_HEX))
fi
# Convert wei to ETH (1 ETH = 10^18 wei)
BALANCE_ETH=$(echo "scale=6; $BALANCE_WEI / 1000000000000000000" | bc)

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env bash
# Run CI pipeline inside a container (for isolation)
# Usage: ./scripts/ci-container.sh [quick|dev|full]
# Supports: Podman, Docker, and Podman-in-Podman
set -euo pipefail
@@ -16,40 +17,48 @@ case $MODE in
SKIP_FLAGS="-e HARNESS_SKIP_DOCKER=true"
;;
full)
echo "🐳 Running Full CI in Container (no Docker build)..."
echo "🐳 Running Full CI in Container (Podman/Docker compatible)..."
SKIP_FLAGS="-e HARNESS_SKIP_DOCKER=true"
;;
*)
echo "Usage: $0 [quick|dev|full]"
echo " quick - Fast validation (30-60s)"
echo " dev - Development pipeline (1-2min)"
echo " full - Complete validation except Docker (2-3min)"
echo " full - Complete validation with container support (2-3min)"
exit 1
;;
esac
# Check for container runtime
if command -v podman >/dev/null 2>&1; then
RUNTIME="podman"
elif command -v docker >/dev/null 2>&1; then
RUNTIME="docker"
else
echo "❌ Error: Neither podman nor docker found"
# Load container runtime detection
source "$(dirname "$0")/container-runtime.sh" init
if [[ -z "$CONTAINER_RUNTIME" ]]; then
echo "❌ Error: No container runtime found (podman or docker required)"
echo "Install with: sudo apt install podman"
exit 1
fi
echo "Using container runtime: $RUNTIME"
echo "Using container runtime: $CONTAINER_RUNTIME"
echo ""
# Create cache directories for performance
mkdir -p .gocache .gomodcache
# Get DinD mount flags if inside container
DIND_MOUNTS=""
if [[ "$INSIDE_CONTAINER" == "true" ]]; then
DIND_MOUNTS="$(source "$(dirname "$0")/container-runtime.sh" socket)"
if [[ -n "$DIND_MOUNTS" ]]; then
DIND_MOUNTS="-v $DIND_MOUNTS"
fi
fi
# Run pipeline in container
$RUNTIME run --rm \
$CONTAINER_RUNTIME run --rm \
-v "$(pwd)":/workspace \
-v "$(pwd)/.gocache":/root/.cache/go-build \
-v "$(pwd)/.gomodcache":/go/pkg/mod \
$DIND_MOUNTS \
-w /workspace \
$SKIP_FLAGS \
golang:1.25-alpine \

153
scripts/container-runtime.sh Executable file
View File

@@ -0,0 +1,153 @@
#!/usr/bin/env bash
# Container Runtime Detection & Configuration
# Detects and uses available container runtime: podman-in-podman > podman > docker-in-docker > docker
set -euo pipefail
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Export these for use in calling scripts
export CONTAINER_RUNTIME=""
export COMPOSE_CMD=""
export CONTAINER_SOCKET=""
export INSIDE_CONTAINER=""
# Detect if we're inside a container
detect_container_env() {
if [[ -f /.dockerenv ]] || [[ -f /run/.containerenv ]]; then
INSIDE_CONTAINER="true"
else
INSIDE_CONTAINER="false"
fi
}
# Find available container runtime
detect_runtime() {
local runtime_priority=(
"podman"
"docker"
)
for runtime in "${runtime_priority[@]}"; do
if command -v "$runtime" &>/dev/null; then
CONTAINER_RUNTIME="$runtime"
# Get compose command
if command -v "${runtime}-compose" &>/dev/null; then
COMPOSE_CMD="${runtime}-compose"
elif [[ "$runtime" == "docker" ]] && command -v docker-compose &>/dev/null; then
COMPOSE_CMD="docker-compose"
elif [[ "$runtime" == "podman" ]] && command -v podman-compose &>/dev/null; then
COMPOSE_CMD="podman-compose"
elif [[ "$runtime" == "podman" ]]; then
# Fallback: podman has built-in compose
COMPOSE_CMD="podman compose"
else
COMPOSE_CMD="$runtime compose"
fi
return 0
fi
done
return 1
}
# Setup DinD (Docker in Docker) socket
setup_dind_socket() {
local runtime="$1"
case "$runtime" in
podman)
# Podman socket location
if [[ -S "$XDG_RUNTIME_DIR/podman/podman.sock" ]]; then
CONTAINER_SOCKET="$XDG_RUNTIME_DIR/podman/podman.sock"
elif [[ -S "/run/podman/podman.sock" ]]; then
CONTAINER_SOCKET="/run/podman/podman.sock"
elif [[ -S "/run/user/$(id -u)/podman/podman.sock" ]]; then
CONTAINER_SOCKET="/run/user/$(id -u)/podman/podman.sock"
fi
;;
docker)
# Docker socket location
if [[ -S "/var/run/docker.sock" ]]; then
CONTAINER_SOCKET="/var/run/docker.sock"
elif [[ -S "/run/docker.sock" ]]; then
CONTAINER_SOCKET="/run/docker.sock"
fi
;;
esac
}
# Get mount flags for DinD
get_dind_mount_flags() {
local runtime="$1"
if [[ -z "$CONTAINER_SOCKET" ]]; then
return
fi
case "$runtime" in
podman)
echo "-v $CONTAINER_SOCKET:/run/podman/podman.sock"
;;
docker)
echo "-v $CONTAINER_SOCKET:/var/run/docker.sock"
;;
esac
}
# Initialize runtime
init_runtime() {
detect_container_env
if ! detect_runtime; then
echo -e "${RED}❌ Error: No container runtime found (podman or docker required)${NC}" >&2
return 1
fi
setup_dind_socket "$CONTAINER_RUNTIME"
# Export for subshells
export CONTAINER_RUNTIME
export COMPOSE_CMD
export CONTAINER_SOCKET
export INSIDE_CONTAINER
return 0
}
# Display status
show_status() {
echo -e "${BLUE}Container Runtime Detection:${NC}"
echo " Runtime: ${GREEN}$CONTAINER_RUNTIME${NC}"
echo " Compose: ${GREEN}$COMPOSE_CMD${NC}"
echo " Inside Container: ${GREEN}$INSIDE_CONTAINER${NC}"
if [[ -n "$CONTAINER_SOCKET" ]]; then
echo " Socket: ${GREEN}$CONTAINER_SOCKET${NC}"
fi
}
# Main execution
if [[ "${1:-}" == "init" ]]; then
init_runtime
elif [[ "${1:-}" == "status" ]]; then
init_runtime
show_status
elif [[ "${1:-}" == "runtime" ]]; then
init_runtime
echo "$CONTAINER_RUNTIME"
elif [[ "${1:-}" == "compose" ]]; then
init_runtime
echo "$COMPOSE_CMD"
elif [[ "${1:-}" == "socket" ]]; then
init_runtime
echo "$CONTAINER_SOCKET"
else
init_runtime
fi

View File

@@ -1,9 +1,9 @@
#!/bin/bash
#!/usr/bin/env bash
# MEV Bot Smart Contract Deployment Script
# Deploys ArbitrageExecutor and FlashLoanReceiver contracts to Arbitrum
set -e # Exit on error
set -euo pipefail # Exit on error, undefined vars, pipe failures
# Colors for output
RED='\033[0;31m'

View File

@@ -1,9 +1,10 @@
#!/bin/bash
#!/usr/bin/env bash
# Production Deployment Script for MEV Bot
# This script deploys the MEV bot to a production environment for live trading
# Supports: Podman (preferred) and Docker
set -e # Exit on any error
set -euo pipefail # Exit on any error, undefined vars, pipe failures
# Colors for output
RED='\033[0;31m'
@@ -93,34 +94,37 @@ else
exit 1
fi
# Check if Docker is available
if ! command -v docker &> /dev/null; then
echo -e "${RED}❌ Error: Docker is not installed or not in PATH${NC}"
# Load container runtime detection
source "$(dirname "$0")/container-runtime.sh" init
if [[ -z "$CONTAINER_RUNTIME" ]]; then
echo -e "${RED}❌ Error: No container runtime found (podman or docker required)${NC}"
exit 1
fi
if ! command -v docker-compose &> /dev/null; then
echo -e "${RED}❌ Error: docker-compose is not installed or not in PATH${NC}"
if [[ -z "$COMPOSE_CMD" ]]; then
echo -e "${RED}❌ Error: No compose command available${NC}"
exit 1
fi
echo -e "${GREEN}Docker and docker-compose are available${NC}"
echo -e "${GREEN}Container runtime available: $CONTAINER_RUNTIME${NC}"
echo -e "${GREEN}✅ Compose command: $COMPOSE_CMD${NC}"
# Stop any existing containers
echo -e "${BLUE}⏹️ Stopping any existing production containers...${NC}"
docker-compose -f docker-compose.production.yaml down --remove-orphans 2>/dev/null || true
$COMPOSE_CMD -f docker-compose.production.yaml down --remove-orphans 2>/dev/null || true
# Pull latest images
echo -e "${BLUE}⬇️ Pulling latest images...${NC}"
docker-compose -f docker-compose.production.yaml pull
$COMPOSE_CMD -f docker-compose.production.yaml pull
# Build images
echo -e "${BLUE}🔨 Building production images...${NC}"
docker-compose -f docker-compose.production.yaml build
$COMPOSE_CMD -f docker-compose.production.yaml build
# Start services
echo -e "${BLUE}🚀 Starting production services...${NC}"
docker-compose -f docker-compose.production.yaml up -d
$COMPOSE_CMD -f docker-compose.production.yaml up -d
# Wait for services to start
echo -e "${BLUE}⏳ Waiting for services to start...${NC}"
@@ -133,7 +137,7 @@ SERVICES_RUNNING=true
SERVICES=("mev-bot-arbitrum" "mev-bot-redis" "mev-bot-postgres" "mev-bot-prometheus" "mev-bot-grafana" "mev-bot-fluentd")
for service in "${SERVICES[@]}"; do
if docker ps | grep -q "$service"; then
if $CONTAINER_RUNTIME ps | grep -q "$service"; then
echo -e "${GREEN}$service is running${NC}"
else
echo -e "${RED}$service is not running${NC}"
@@ -151,15 +155,15 @@ if [ "$SERVICES_RUNNING" = true ]; then
echo -e " - Grafana: http://localhost:${GRAFANA_PORT:-3000}"
echo ""
echo -e "${BLUE}📝 Logs:${NC}"
echo -e " - MEV Bot: docker logs mev-bot-arbitrum"
echo -e " - Redis: docker logs mev-bot-redis"
echo -e " - PostgreSQL: docker logs mev-bot-postgres"
echo -e " - MEV Bot: $CONTAINER_RUNTIME logs mev-bot-arbitrum"
echo -e " - Redis: $CONTAINER_RUNTIME logs mev-bot-redis"
echo -e " - PostgreSQL: $CONTAINER_RUNTIME logs mev-bot-postgres"
echo ""
echo -e "${YELLOW}⚠️ Remember to monitor the production environment closely during initial deployment${NC}"
echo -e "${YELLOW}⚠️ Start with small position sizes to validate everything works correctly${NC}"
else
echo -e "${RED}❌ Some production services failed to start${NC}"
echo -e "${YELLOW}Check logs with: docker-compose -f docker-compose.production.yaml logs${NC}"
echo -e "${YELLOW}Check logs with: $COMPOSE_CMD -f docker-compose.production.yaml logs${NC}"
exit 1
fi

View File

@@ -1,8 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash
# Enable MEV Bot Execution Mode
# Updates configuration to allow live trading with flash loans
set -e
set -euo pipefail
CONFIG_FILE="config/bot_config.yaml"
KEYSTORE_DIR="keystore/production"

View File

@@ -34,7 +34,7 @@ cat > "$HOOKS_DIR/pre-commit" << 'EOF'
#!/usr/bin/env bash
# Pre-commit hook - Fast validation before commit
set -e
set -euo pipefail
echo "🔍 Running pre-commit validation..."
@@ -82,7 +82,7 @@ cat > "$HOOKS_DIR/pre-push" << 'EOF'
#!/usr/bin/env bash
# Pre-push hook - Comprehensive validation before push
set -e
set -euo pipefail
echo "🚀 Running pre-push validation..."
@@ -125,6 +125,8 @@ cat > "$HOOKS_DIR/post-commit" << 'EOF'
#!/usr/bin/env bash
# Post-commit hook - Optional post-commit actions
set -euo pipefail
# Get commit info
commit_hash=$(git rev-parse HEAD)
commit_msg=$(git log -1 --pretty=%B)
@@ -146,8 +148,10 @@ cat > "$HOOKS_DIR/prepare-commit-msg" << 'EOF'
#!/usr/bin/env bash
# Prepare commit message hook - Add conventional commit format help
set -euo pipefail
commit_file="$1"
commit_source="$2"
commit_source="${2:-}"
# Only add template for regular commits (not merges, amendments, etc.)
if [[ "$commit_source" == "" ]] || [[ "$commit_source" == "template" ]]; then
@@ -183,6 +187,8 @@ cat > "$HOOKS_DIR/post-merge" << 'EOF'
#!/usr/bin/env bash
# Post-merge hook - Actions after merge
set -euo pipefail
echo "🔀 Post-merge validation..."
# Run CI after merge to ensure integration is clean
@@ -212,8 +218,10 @@ cat > "$HOOKS_DIR/pre-rebase" << 'EOF'
#!/usr/bin/env bash
# Pre-rebase hook - Validation before rebase
set -euo pipefail
upstream="$1"
branch="$2"
branch="${2:-}"
echo "🔄 Pre-rebase validation..."
echo "Rebasing: ${branch:-$(git rev-parse --abbrev-ref HEAD)} onto $upstream"

View File

@@ -1,4 +1,14 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
# Safely kill the MEV bot process
kill -9 $(ps -aux | grep -v grep | grep mev | awk '{print $2 }')
set -euo pipefail
# Find and kill MEV bot processes
if pgrep -f "mev-bot|mev-beta" >/dev/null 2>&1; then
echo "Killing MEV bot processes..."
pkill -f "mev-bot|mev-beta" && echo "✅ MEV bot stopped" || echo "❌ Failed to stop MEV bot"
else
echo "No MEV bot processes found"
exit 1
fi

View File

@@ -754,7 +754,8 @@ main() {
;;
"cleanup")
init_config
cleanup_old_archives
setup_directories
intelligent_cleanup
;;
"start-daemon")
init_config

View File

@@ -137,8 +137,12 @@ start_monitoring() {
start_mev_bot() {
log "🚀 Starting MEV Bot in PRODUCTION mode..."
# Set production environment
export $(cat .env.production.secure | grep -v '^#' | xargs)
# Set production environment safely (avoid code injection)
if [[ -f ".env.production.secure" ]]; then
set -a
source .env.production.secure
set +a
fi
# Additional production environment
export GO_ENV=production
@@ -249,7 +253,11 @@ quick_deploy() {
log "🚀 QUICK DEPLOYMENT MODE - MAXIMUM SPEED TO PROFIT"
# Skip most checks, assume environment is ready
export $(cat .env.production.secure | grep -v '^#' | xargs)
if [[ -f ".env.production.secure" ]]; then
set -a
source .env.production.secure
set +a
fi
export GO_ENV=production
export DEBUG=false

View File

@@ -1,9 +1,14 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail
# run.sh - Run the MEV bot
# Builds and starts the MEV bot with production configuration
echo "Running MEV bot..."
# Set default GO_ENV if not already set (production by default)
export GO_ENV="${GO_ENV:-production}"
# Build the application first
./scripts/build.sh
@@ -14,29 +19,41 @@ if [ $? -eq 0 ]; then
export GO_ENV
fi
# Load environment variables from .env.production if it exists
if [ -f ".env.production" ]; then
echo "🔧 Loading production environment variables from .env.production..."
set -a # Automatically export all variables
source .env.production
set +a # Stop automatically exporting
# Load environment variables based on GO_ENV
if [ "$GO_ENV" = "development" ]; then
echo "🔧 Development mode: Using .env for local configuration..."
if [ -f ".env" ]; then
set -a
source .env
set +a
fi
else
echo "❌ .env.production file not found! Creating one with defaults..."
echo "Please configure .env.production for production deployment"
exit 1
# Production mode requires .env.production
if [ -f ".env.production" ]; then
echo "🔧 Loading production environment variables from .env.production..."
set -a # Automatically export all variables
source .env.production
set +a # Stop automatically exporting
else
echo "❌ .env.production file not found! Creating one with defaults..."
echo "Please configure .env.production for production deployment"
exit 1
fi
fi
# Validate required environment variables
if [ -z "$MEV_BOT_ENCRYPTION_KEY" ]; then
echo "❌ MEV_BOT_ENCRYPTION_KEY not found in .env.production"
echo "Please set this variable for secure operations"
exit 1
fi
if [ -z "$CONTRACT_ARBITRAGE_EXECUTOR" ]; then
echo "❌ CONTRACT_ARBITRAGE_EXECUTOR not found in .env.production"
echo "Please set the deployed arbitrage executor contract address"
exit 1
# Validate required environment variables (production mode only)
if [ "$GO_ENV" != "development" ]; then
if [ -z "${MEV_BOT_ENCRYPTION_KEY:-}" ]; then
echo "❌ MEV_BOT_ENCRYPTION_KEY not found in .env.production"
echo "Please set this variable for secure operations"
exit 1
fi
if [ -z "${CONTRACT_ARBITRAGE_EXECUTOR:-}" ]; then
echo "❌ CONTRACT_ARBITRAGE_EXECUTOR not found in .env.production"
echo "Please set the deployed arbitrage executor contract address"
exit 1
fi
fi
# Set required environment variables with production values
@@ -57,22 +74,35 @@ if [ $? -eq 0 ]; then
env | grep MEV_BOT_KEYSTORE_PATH
echo ""
echo "🚀 PRODUCTION MEV BOT STARTUP"
echo "================================"
if [ "$GO_ENV" = "development" ]; then
echo "🚀 DEVELOPMENT MEV BOT STARTUP"
echo "==============================="
else
echo "🚀 PRODUCTION MEV BOT STARTUP"
echo "=============================="
fi
echo "Environment: $GO_ENV"
echo ""
echo "📡 Network Configuration:"
echo " RPC: $ARBITRUM_RPC_ENDPOINT"
echo " WS: $ARBITRUM_WS_ENDPOINT"
echo " Metrics Port: $METRICS_PORT"
echo ""
echo "📝 Deployed Contracts:"
echo " ArbitrageExecutor: $CONTRACT_ARBITRAGE_EXECUTOR"
echo " FlashSwapper: $CONTRACT_FLASH_SWAPPER"
echo " DataFetcher: $CONTRACT_DATA_FETCHER"
echo ""
echo "🔐 Security:"
echo " Encryption Key: ${MEV_BOT_ENCRYPTION_KEY:0:8}...***"
echo " RPC: ${ARBITRUM_RPC_ENDPOINT:-not set}"
echo " WS: ${ARBITRUM_WS_ENDPOINT:-not set}"
echo " Metrics Port: ${METRICS_PORT:-9090}"
echo ""
if [ "$GO_ENV" != "development" ] && [ -n "${CONTRACT_ARBITRAGE_EXECUTOR:-}" ]; then
echo "📝 Deployed Contracts:"
echo " ArbitrageExecutor: $CONTRACT_ARBITRAGE_EXECUTOR"
echo " FlashSwapper: ${CONTRACT_FLASH_SWAPPER:-not set}"
echo " DataFetcher: ${CONTRACT_DATA_FETCHER:-not set}"
echo ""
fi
if [ -n "${MEV_BOT_ENCRYPTION_KEY:-}" ]; then
echo "🔐 Security:"
echo " Encryption Key: ${MEV_BOT_ENCRYPTION_KEY:0:8}...***"
echo ""
fi
# Set provider config path if not already set
export PROVIDER_CONFIG_PATH="${PROVIDER_CONFIG_PATH:-$PWD/config/providers_runtime.yaml}"
echo "📋 Provider Config: $PROVIDER_CONFIG_PATH"

View File

@@ -1,10 +1,16 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail
# Setup script for MEV Bot environment
echo "Setting up MEV Bot environment..."
# Copy the fixed .env file
cp .env.fixed .env
# Copy the fixed .env file if it exists
if [[ -f ".env.fixed" ]]; then
cp .env.fixed .env
echo "✅ Copied .env.fixed to .env"
else
echo "⚠️ Warning: .env.fixed not found, skipping copy"
fi
# Create required directories
mkdir -p keystore backups logs

View File

@@ -1,8 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash
# MEV Bot Keystore Setup Script
# Encrypts and stores the private key securely
set -e
set -euo pipefail
KEYSTORE_DIR="keystore/production"
PRIVATE_KEY_FILE="/tmp/wallet_key.txt"
@@ -21,7 +21,8 @@ if [ ! -f "$PRIVATE_KEY_FILE" ]; then
fi
# Check if encryption key is set
if [ -z "${!ENCRYPTION_KEY_ENV}" ]; then
ENCRYPTION_KEY="${MEV_BOT_ENCRYPTION_KEY:-}"
if [ -z "$ENCRYPTION_KEY" ]; then
echo "⚠️ Warning: $ENCRYPTION_KEY_ENV not set in environment"
echo ""
echo "📝 Setting up encryption key..."

View File

@@ -1,14 +1,15 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail
# test.sh - Run tests for the MEV bot
# Executes all tests in the project with verbose output
echo "Running tests..."
# Run all tests
go test -v ./...
if [ $? -eq 0 ]; then
if go test -v ./...; then
echo "All tests passed!"
exit 0
else
echo "Some tests failed!"
exit 1