refactor: move all remaining files to orig/ directory
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>
This commit is contained in:
401
orig/scripts/organize-scripts.sh
Executable file
401
orig/scripts/organize-scripts.sh
Executable file
@@ -0,0 +1,401 @@
|
||||
#!/bin/bash
|
||||
# Script Organization and Cleanup
|
||||
# Based on SCRIPT_ANALYSIS_REPORT.md recommendations
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e "${BLUE}MEV Bot Script Organization${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo ""
|
||||
|
||||
# Check if we're in the right directory
|
||||
if [ ! -f "go.mod" ]; then
|
||||
echo -e "${RED}❌ Error: Must be run from project root${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create status before changes
|
||||
echo -e "${BLUE}📊 Capturing git status before changes...${NC}"
|
||||
git status --short > /tmp/mev-bot-git-status-before.txt
|
||||
echo ""
|
||||
|
||||
# Create deprecated directory
|
||||
echo -e "${BLUE}📁 Creating directories...${NC}"
|
||||
mkdir -p scripts/deprecated
|
||||
mkdir -p scripts/demos
|
||||
echo -e "${GREEN}✅ Created scripts/deprecated/ and scripts/demos/${NC}"
|
||||
echo ""
|
||||
|
||||
# Move redundant log management scripts to deprecated
|
||||
echo -e "${BLUE}🗂️ Moving redundant log management scripts...${NC}"
|
||||
|
||||
DEPRECATED_SCRIPTS=(
|
||||
"scripts/archive-logs.sh"
|
||||
"scripts/quick-archive.sh"
|
||||
"scripts/view-latest-archive.sh"
|
||||
"scripts/rotate-logs.sh"
|
||||
"scripts/setup-log-rotation.sh"
|
||||
)
|
||||
|
||||
for script in "${DEPRECATED_SCRIPTS[@]}"; do
|
||||
if [ -f "$script" ]; then
|
||||
echo -e " Moving: $script → scripts/deprecated/"
|
||||
git mv "$script" "scripts/deprecated/$(basename "$script")"
|
||||
else
|
||||
echo -e "${YELLOW} Skipped: $script (not found)${NC}"
|
||||
fi
|
||||
done
|
||||
echo -e "${GREEN}✅ Moved ${#DEPRECATED_SCRIPTS[@]} scripts to deprecated/${NC}"
|
||||
echo ""
|
||||
|
||||
# Move demo scripts
|
||||
echo -e "${BLUE}🎬 Moving demo scripts...${NC}"
|
||||
|
||||
DEMO_SCRIPTS=(
|
||||
"scripts/demo-production-logs.sh"
|
||||
)
|
||||
|
||||
for script in "${DEMO_SCRIPTS[@]}"; do
|
||||
if [ -f "$script" ]; then
|
||||
echo -e " Moving: $script → scripts/demos/"
|
||||
git mv "$script" "scripts/demos/$(basename "$script")"
|
||||
else
|
||||
echo -e "${YELLOW} Skipped: $script (not found)${NC}"
|
||||
fi
|
||||
done
|
||||
echo -e "${GREEN}✅ Moved ${#DEMO_SCRIPTS[@]} scripts to demos/${NC}"
|
||||
echo ""
|
||||
|
||||
# Create README for deprecated scripts
|
||||
echo -e "${BLUE}📝 Creating README for deprecated scripts...${NC}"
|
||||
cat > scripts/deprecated/README.md << 'EOF'
|
||||
# Deprecated Scripts
|
||||
|
||||
These scripts have been moved here because their functionality is now handled by more comprehensive tools.
|
||||
|
||||
## Log Management Scripts (Superseded by log-manager.sh)
|
||||
|
||||
All of these scripts have been replaced by `scripts/log-manager.sh`, which provides:
|
||||
|
||||
- Real-time analysis with health scoring
|
||||
- Performance monitoring with MEV-specific metrics
|
||||
- Corruption detection and integrity validation
|
||||
- Multi-channel alerting (email, Slack)
|
||||
- Background monitoring daemon
|
||||
- Operations dashboard generation
|
||||
- Intelligent rotation (size and time-based)
|
||||
- Advanced archiving with metadata
|
||||
|
||||
### Deprecated Scripts
|
||||
|
||||
1. **archive-logs.sh** → Use `./scripts/log-manager.sh archive`
|
||||
2. **quick-archive.sh** → Use `./scripts/log-manager.sh full`
|
||||
3. **view-latest-archive.sh** → Use `./scripts/log-manager.sh status`
|
||||
4. **rotate-logs.sh** → Use `./scripts/log-manager.sh rotate`
|
||||
5. **setup-log-rotation.sh** → Use `./scripts/log-manager.sh init`
|
||||
|
||||
## Migration Guide
|
||||
|
||||
**Instead of:**
|
||||
```bash
|
||||
./scripts/archive-logs.sh
|
||||
```
|
||||
|
||||
**Use:**
|
||||
```bash
|
||||
./scripts/log-manager.sh archive
|
||||
```
|
||||
|
||||
**Instead of:**
|
||||
```bash
|
||||
./scripts/quick-archive.sh --clear-logs
|
||||
```
|
||||
|
||||
**Use:**
|
||||
```bash
|
||||
./scripts/log-manager.sh full
|
||||
```
|
||||
|
||||
## Why These Were Deprecated
|
||||
|
||||
The individual log management scripts were created before the comprehensive `log-manager.sh` system was implemented. The new system provides:
|
||||
|
||||
- **Unified Interface**: Single command with multiple subcommands
|
||||
- **Production Grade**: Health monitoring, alerting, and metrics
|
||||
- **Better Maintenance**: One script to maintain instead of five
|
||||
- **More Features**: Dashboard generation, daemon mode, performance tracking
|
||||
- **Safer Operations**: Validation and corruption detection
|
||||
|
||||
## Can I Still Use These?
|
||||
|
||||
Yes, these scripts still work and are kept for backwards compatibility. However, it's recommended to migrate to `log-manager.sh` for better functionality and ongoing support.
|
||||
|
||||
## When Will These Be Removed?
|
||||
|
||||
These scripts will be kept for at least one major version release to allow for migration. They may be removed in a future version once all users have migrated to `log-manager.sh`.
|
||||
|
||||
---
|
||||
|
||||
**See:** `docs/SCRIPT_ANALYSIS_REPORT.md` for the full analysis
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✅ Created README for deprecated scripts${NC}"
|
||||
echo ""
|
||||
|
||||
# Create README for demos
|
||||
echo -e "${BLUE}📝 Creating README for demo scripts...${NC}"
|
||||
cat > scripts/demos/README.md << 'EOF'
|
||||
# Demo & Example Scripts
|
||||
|
||||
These scripts are for demonstration and testing purposes only. They should not be used in production environments.
|
||||
|
||||
## Available Demos
|
||||
|
||||
### demo-production-logs.sh
|
||||
|
||||
Demonstrates the production log management system capabilities.
|
||||
|
||||
**Purpose:** Show how the log-manager.sh system works
|
||||
**Usage:**
|
||||
```bash
|
||||
./scripts/demos/demo-production-logs.sh
|
||||
```
|
||||
|
||||
**What it does:**
|
||||
- Generates sample log entries
|
||||
- Runs log analysis
|
||||
- Shows health checks
|
||||
- Demonstrates alerting
|
||||
- Creates performance reports
|
||||
- Generates operations dashboard
|
||||
|
||||
**Note:** This is a demonstration script. For production log management, use `./scripts/log-manager.sh`
|
||||
|
||||
---
|
||||
|
||||
**See:** `docs/SCRIPT_ANALYSIS_REPORT.md` for more information
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✅ Created README for demo scripts${NC}"
|
||||
echo ""
|
||||
|
||||
# Create index README for scripts directory
|
||||
echo -e "${BLUE}📝 Creating scripts directory index...${NC}"
|
||||
cat > scripts/README.md << 'EOF'
|
||||
# MEV Bot Scripts Directory
|
||||
|
||||
This directory contains all operational, utility, and development scripts for the MEV Bot project.
|
||||
|
||||
## Core Scripts
|
||||
|
||||
### Build & Runtime
|
||||
- **build.sh** - Universal Go build script with configurable options
|
||||
- **run.sh** - Main MEV bot execution script with production environment loading
|
||||
- **test.sh** - Basic test runner
|
||||
|
||||
### Log Management
|
||||
- **log-manager.sh** ⭐ Production-grade log management system
|
||||
- Real-time analysis and health monitoring
|
||||
- Performance tracking with MEV metrics
|
||||
- Corruption detection and alerting
|
||||
- Background daemon and dashboard generation
|
||||
- See: `./scripts/log-manager.sh --help`
|
||||
|
||||
## CI/CD & Quality Assurance
|
||||
|
||||
### Primary CI Pipeline
|
||||
- **../harness/local-ci-pipeline.sh** - Comprehensive CI/CD pipeline
|
||||
- **ci-precommit.sh** - Fast pre-commit validation (10-30s)
|
||||
- **ci-quick.sh** - Quick CI pipeline (30-60s)
|
||||
- **ci-dev.sh** - Development CI pipeline (1-2min)
|
||||
- **ci-full.sh** - Full CI pipeline (3-5min)
|
||||
- **ci-container.sh** - Containerized CI execution
|
||||
- **ci-watch.sh** - Watch mode for continuous validation
|
||||
|
||||
### Testing
|
||||
- **test-runner.sh** - Configurable test execution (levels: basic, unit, integration, comprehensive, audit)
|
||||
- **run_audit_suite.sh** - Mathematical correctness audit
|
||||
- **security-validation.sh** - Comprehensive security validation
|
||||
- **quick-test.sh** - Quick fix validation (30s)
|
||||
- **run-stress-tests.sh** - Stress testing
|
||||
- **run-fork-tests.sh** - Blockchain fork testing
|
||||
|
||||
## Deployment & Production
|
||||
|
||||
### Contract Deployment
|
||||
- **deploy-contracts.sh** - Deploy smart contracts to Arbitrum
|
||||
- **verify-contracts.sh** - Verify contracts on Arbiscan
|
||||
- **deploy-staging.sh** - Staging environment deployment
|
||||
- **deploy-production.sh** - Full production deployment with Docker Compose
|
||||
|
||||
### Production Operations
|
||||
- **production-start.sh** - Start production MEV bot
|
||||
- **production-validation.sh** - Pre-deployment validation checks
|
||||
- **pre-run-validation.sh** - Environment validation before startup
|
||||
|
||||
## Wallet Management
|
||||
|
||||
- **setup-keystore.sh** - Encrypt and securely store private keys (AES-256-CBC)
|
||||
- **fund-bot-wallet.sh** - Fund MEV bot wallet using Foundry cast
|
||||
- **check-wallet-balance.sh** - Check wallet balance on Arbitrum One
|
||||
|
||||
## Monitoring & Analysis
|
||||
|
||||
- **watch-live.sh** - Real-time MEV bot activity monitor
|
||||
- **analyze.sh** - Comprehensive system analysis (tests, benchmarks, coverage, static analysis)
|
||||
- **performance-profile.sh** - Performance profiling with pprof
|
||||
|
||||
## Development Utilities
|
||||
|
||||
### Environment Setup
|
||||
- **setup-env.sh** - Environment variable setup
|
||||
- **setup-dev.sh** - Development environment setup
|
||||
- **fix-rpc-config.sh** - Fix RPC configuration issues
|
||||
|
||||
### Git Workflow
|
||||
- **git-hooks-setup.sh** - Install git hooks
|
||||
- **git-enhanced.sh** - Enhanced git workflow commands
|
||||
- **git-local-server.sh** - Local git server simulation
|
||||
|
||||
### Data & Code Generation
|
||||
- **fetch_arbiscan_tx.sh** - Fetch transaction data from Arbiscan
|
||||
- **extract_multicall_fixture.sh** - Extract multicall fixtures for testing
|
||||
- **refresh-mev-datasets.sh** - Update MEV research datasets
|
||||
- **generate-bindings.sh** - Generate Go bindings for smart contracts
|
||||
|
||||
### Other Utilities
|
||||
- **kill-bot.sh** - Stop running MEV bot processes
|
||||
- **dependency-scan.sh** - Scan for dependency vulnerabilities
|
||||
- **verify-organization.sh** - Verify project organization
|
||||
- **24h-validation-test.sh** - 24-hour validation test
|
||||
|
||||
## Special Directories
|
||||
|
||||
### deprecated/
|
||||
Contains scripts that have been superseded by better alternatives. See `deprecated/README.md` for migration guide.
|
||||
|
||||
**Replaced by log-manager.sh:**
|
||||
- archive-logs.sh
|
||||
- quick-archive.sh
|
||||
- view-latest-archive.sh
|
||||
- rotate-logs.sh
|
||||
- setup-log-rotation.sh
|
||||
|
||||
### demos/
|
||||
Contains demonstration and example scripts for testing purposes only. Not for production use.
|
||||
|
||||
## Quick Reference
|
||||
|
||||
### Development Workflow
|
||||
```bash
|
||||
# Setup
|
||||
./scripts/setup-dev.sh
|
||||
|
||||
# Quick validation
|
||||
./scripts/ci-precommit.sh
|
||||
|
||||
# Run tests
|
||||
./scripts/test-runner.sh --level comprehensive --coverage
|
||||
|
||||
# Security check
|
||||
./scripts/security-validation.sh
|
||||
|
||||
# Math audit
|
||||
./scripts/run_audit_suite.sh
|
||||
```
|
||||
|
||||
### Production Deployment
|
||||
```bash
|
||||
# Validate environment
|
||||
./scripts/production-validation.sh
|
||||
|
||||
# Deploy contracts
|
||||
./scripts/deploy-contracts.sh
|
||||
|
||||
# Setup wallet
|
||||
./scripts/setup-keystore.sh
|
||||
./scripts/check-wallet-balance.sh
|
||||
|
||||
# Deploy and start
|
||||
./scripts/deploy-production.sh
|
||||
./scripts/run.sh
|
||||
```
|
||||
|
||||
### Monitoring
|
||||
```bash
|
||||
# Live activity monitor
|
||||
./scripts/watch-live.sh
|
||||
|
||||
# Log management
|
||||
./scripts/log-manager.sh analyze
|
||||
./scripts/log-manager.sh health
|
||||
./scripts/log-manager.sh dashboard
|
||||
|
||||
# Performance profiling
|
||||
./scripts/performance-profile.sh
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
For detailed script analysis and recommendations, see:
|
||||
- **docs/SCRIPT_ANALYSIS_REPORT.md** - Comprehensive script analysis
|
||||
- **Makefile** - Build automation targets and workflows
|
||||
|
||||
## Contributing
|
||||
|
||||
When adding new scripts:
|
||||
1. Make scripts executable: `chmod +x script-name.sh`
|
||||
2. Add shebang: `#!/bin/bash` or `#!/usr/bin/env bash`
|
||||
3. Use set -e for error handling
|
||||
4. Add descriptive comments
|
||||
5. Update this README
|
||||
6. Add help text (use --help flag)
|
||||
|
||||
---
|
||||
|
||||
**Total Scripts:** 80+
|
||||
**Active Scripts:** 50+
|
||||
**Deprecated Scripts:** 5
|
||||
**Demo Scripts:** 1
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✅ Created scripts directory index${NC}"
|
||||
echo ""
|
||||
|
||||
# Capture status after changes
|
||||
echo -e "${BLUE}📊 Capturing git status after changes...${NC}"
|
||||
git status --short > /tmp/mev-bot-git-status-after.txt
|
||||
echo ""
|
||||
|
||||
# Show summary
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e "${GREEN}✅ Script Organization Complete!${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo ""
|
||||
echo -e "${BLUE}📝 Summary:${NC}"
|
||||
echo -e " • Created: scripts/deprecated/"
|
||||
echo -e " • Created: scripts/demos/"
|
||||
echo -e " • Moved: ${#DEPRECATED_SCRIPTS[@]} scripts to deprecated/"
|
||||
echo -e " • Moved: ${#DEMO_SCRIPTS[@]} scripts to demos/"
|
||||
echo -e " • Created: 3 README files"
|
||||
echo ""
|
||||
echo -e "${BLUE}📊 Git Status Changes:${NC}"
|
||||
echo -e "${YELLOW}Before:${NC}"
|
||||
cat /tmp/mev-bot-git-status-before.txt | head -10
|
||||
echo ""
|
||||
echo -e "${YELLOW}After:${NC}"
|
||||
git status --short | head -20
|
||||
echo ""
|
||||
echo -e "${BLUE}⏭️ Next Steps:${NC}"
|
||||
echo -e " 1. Review changes: ${YELLOW}git diff --cached${NC}"
|
||||
echo -e " 2. Commit changes: ${YELLOW}git commit -m \"refactor: organize scripts into logical directories\"${NC}"
|
||||
echo -e " 3. Read report: ${YELLOW}docs/SCRIPT_ANALYSIS_REPORT.md${NC}"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user