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>
This commit is contained in:
91
scripts/generate-bindings-from-official-abis.sh
Executable file
91
scripts/generate-bindings-from-official-abis.sh
Executable file
@@ -0,0 +1,91 @@
|
||||
#!/bin/sh
|
||||
# Generate Go bindings from extracted official ABIs
|
||||
# Run this AFTER extract-official-abis.sh
|
||||
|
||||
set -e
|
||||
|
||||
PROJECT_ROOT="/docker/mev-beta"
|
||||
BINDINGS_DIR="$PROJECT_ROOT/bindings"
|
||||
|
||||
cd "$PROJECT_ROOT" || exit 1
|
||||
|
||||
echo "🔧 Generating Go bindings from official contract ABIs"
|
||||
echo "===================================================="
|
||||
echo ""
|
||||
|
||||
# Check if abigen is available
|
||||
if ! command -v abigen > /dev/null 2>&1; then
|
||||
echo "⚠️ abigen not found, installing..."
|
||||
go install github.com/ethereum/go-ethereum/cmd/abigen@v1.13.15
|
||||
fi
|
||||
|
||||
# Function to generate binding from ABI
|
||||
generate_binding() {
|
||||
local abi_file=$1
|
||||
local pkg_name=$2
|
||||
local type_name=$3
|
||||
local output_file=$4
|
||||
|
||||
if [ ! -f "$abi_file" ]; then
|
||||
echo "⚠️ ABI file not found: $abi_file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "📄 Generating $type_name..."
|
||||
abigen \
|
||||
--abi="$abi_file" \
|
||||
--pkg="$pkg_name" \
|
||||
--type="$type_name" \
|
||||
--out="$output_file"
|
||||
|
||||
echo " ✅ Generated: $output_file"
|
||||
return 0
|
||||
}
|
||||
|
||||
echo "🦄 Uniswap V2 Bindings"
|
||||
echo "---------------------"
|
||||
|
||||
generate_binding \
|
||||
"$BINDINGS_DIR/uniswap_v2/IUniswapV2Pair_abi.json" \
|
||||
"uniswap_v2" \
|
||||
"UniswapV2Pair" \
|
||||
"$BINDINGS_DIR/uniswap_v2/pair.go"
|
||||
|
||||
# Use existing manually created router ABI if official extraction doesn't work
|
||||
if [ -f "$BINDINGS_DIR/uniswap_v2/IUniswapV2Router02.json" ]; then
|
||||
generate_binding \
|
||||
"$BINDINGS_DIR/uniswap_v2/IUniswapV2Router02.json" \
|
||||
"uniswap_v2" \
|
||||
"UniswapV2Router" \
|
||||
"$BINDINGS_DIR/uniswap_v2/router.go"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🦄 Uniswap V3 Bindings"
|
||||
echo "---------------------"
|
||||
|
||||
generate_binding \
|
||||
"$BINDINGS_DIR/uniswap_v3/ISwapRouter_abi.json" \
|
||||
"uniswap_v3" \
|
||||
"SwapRouter" \
|
||||
"$BINDINGS_DIR/uniswap_v3/router.go"
|
||||
|
||||
# Use existing manually created router ABI if needed
|
||||
if [ -f "$BINDINGS_DIR/uniswap_v3/ISwapRouter.json" ]; then
|
||||
generate_binding \
|
||||
"$BINDINGS_DIR/uniswap_v3/ISwapRouter.json" \
|
||||
"uniswap_v3" \
|
||||
"SwapRouter" \
|
||||
"$BINDINGS_DIR/uniswap_v3/router.go"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✅ Binding generation complete!"
|
||||
echo ""
|
||||
echo "Generated bindings:"
|
||||
find "$BINDINGS_DIR" -name "*.go" -type f | sort
|
||||
|
||||
echo ""
|
||||
echo "💡 Import in your Go code:"
|
||||
echo " import \"github.com/your-org/mev-bot/bindings/uniswap_v2\""
|
||||
echo " import \"github.com/your-org/mev-bot/bindings/uniswap_v3\""
|
||||
Reference in New Issue
Block a user