Completed clean root directory structure: - Root now contains only: .git, .env, docs/, orig/ - Moved all remaining files and directories to orig/: - Config files (.claude, .dockerignore, .drone.yml, etc.) - All .env variants (except active .env) - Git config (.gitconfig, .github, .gitignore, etc.) - Tool configs (.golangci.yml, .revive.toml, etc.) - Documentation (*.md files, @prompts) - Build files (Dockerfiles, Makefile, go.mod, go.sum) - Docker compose files - All source directories (scripts, tests, tools, etc.) - Runtime directories (logs, monitoring, reports) - Dependency files (node_modules, lib, cache) - Special files (--delete) - Removed empty runtime directories (bin/, data/) V2 structure is now clean: - docs/planning/ - V2 planning documents - orig/ - Complete V1 codebase preserved - .env - Active environment config (not in git) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
113 lines
3.1 KiB
Bash
Executable File
113 lines
3.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Test script for forked Arbitrum environment
|
|
set -e
|
|
|
|
echo "🚀 Setting up forked Arbitrum environment for MEV bot testing..."
|
|
|
|
# Check if anvil is available
|
|
if ! command -v anvil &> /dev/null; then
|
|
echo "❌ Anvil not found. Please install Foundry first:"
|
|
echo "curl -L https://foundry.paradigm.xyz | bash"
|
|
echo "foundryup"
|
|
exit 1
|
|
fi
|
|
|
|
# Kill any existing anvil processes
|
|
echo "🔄 Stopping any existing anvil processes..."
|
|
pkill -f anvil || true
|
|
sleep 2
|
|
|
|
# Set up environment variables for forked network
|
|
export ARBITRUM_RPC_ENDPOINT="https://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57"
|
|
export ARBITRUM_WS_ENDPOINT="ws://localhost:8545"
|
|
export METRICS_ENABLED="false"
|
|
export MEV_BOT_ENCRYPTION_KEY="test-fork-encryption-key-32-chars"
|
|
export MEV_BOT_ALLOW_LOCALHOST="true"
|
|
|
|
# Start anvil with Arbitrum fork
|
|
echo "🔗 Starting anvil with Arbitrum One fork..."
|
|
anvil \
|
|
--fork-url "$ARBITRUM_RPC_ENDPOINT" \
|
|
--fork-block-number 250000000 \
|
|
--host 0.0.0.0 \
|
|
--port 8545 \
|
|
--accounts 10 \
|
|
--balance 1000 \
|
|
--gas-limit 30000000 \
|
|
--gas-price 100000000 \
|
|
--block-time 1 \
|
|
--silent &
|
|
|
|
ANVIL_PID=$!
|
|
echo "📊 Anvil started with PID: $ANVIL_PID"
|
|
|
|
# Wait for anvil to be ready
|
|
echo "⏳ Waiting for anvil to be ready..."
|
|
sleep 5
|
|
|
|
# Verify anvil is running
|
|
if ! curl -s -X POST \
|
|
-H "Content-Type: application/json" \
|
|
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
|
|
http://localhost:8545 > /dev/null; then
|
|
echo "❌ Anvil failed to start properly"
|
|
kill $ANVIL_PID 2>/dev/null || true
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ Anvil fork ready on http://localhost:8545"
|
|
|
|
# Update RPC endpoint to use local fork
|
|
export ARBITRUM_RPC_ENDPOINT="http://localhost:8545"
|
|
|
|
# Build the MEV bot
|
|
echo "🔨 Building MEV bot..."
|
|
go build -o bin/mev-bot cmd/mev-bot/main.go
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Failed to build MEV bot"
|
|
kill $ANVIL_PID 2>/dev/null || true
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ MEV bot built successfully"
|
|
|
|
# Test the bot with fork
|
|
echo "🧪 Testing MEV bot with forked environment..."
|
|
|
|
# Run bot for 30 seconds to test
|
|
timeout 30 ./bin/mev-bot start || true
|
|
|
|
echo "🎯 Fork test completed"
|
|
|
|
# Cleanup function
|
|
cleanup() {
|
|
echo "🧹 Cleaning up..."
|
|
kill $ANVIL_PID 2>/dev/null || true
|
|
wait $ANVIL_PID 2>/dev/null || true
|
|
echo "✅ Cleanup completed"
|
|
}
|
|
|
|
# Set up trap for cleanup
|
|
trap cleanup EXIT
|
|
|
|
# Keep anvil running if requested
|
|
if [ "$1" = "--keep-running" ]; then
|
|
echo "🔄 Keeping anvil running. Press Ctrl+C to stop."
|
|
echo "📍 Fork URL: http://localhost:8545"
|
|
echo "🔗 Chain ID: 42161 (Arbitrum One)"
|
|
echo "💰 Test accounts funded with 1000 ETH each"
|
|
echo ""
|
|
echo "To test manually:"
|
|
echo "export ARBITRUM_RPC_ENDPOINT=\"http://localhost:8545\""
|
|
echo "export ARBITRUM_WS_ENDPOINT=\"ws://localhost:8545\""
|
|
echo "export MEV_BOT_ENCRYPTION_KEY=\"test-fork-encryption-key-32-chars\""
|
|
echo "export MEV_BOT_ALLOW_LOCALHOST=\"true\""
|
|
echo "./bin/mev-bot start"
|
|
|
|
# Wait for user interrupt
|
|
wait $ANVIL_PID
|
|
else
|
|
echo "🏁 Test completed. Use --keep-running to keep the fork active."
|
|
fi |