Fix MEV backend and token-aggregation deployment wiring
All checks were successful
Deploy to Phoenix / deploy (push) Successful in 12s

This commit is contained in:
defiQUG
2026-04-15 03:25:30 -07:00
parent 382e776599
commit 59006f520a
12 changed files with 264 additions and 15 deletions

View File

@@ -115,6 +115,28 @@ try {
} catch (_) {
process.exit(0);
}
derive_repo_example_env_value() {
local env_key="$1"
local env_file="$REPO_ROOT/.env.master.example"
[[ -f "$env_file" ]] || return 0
node - <<'NODE' "$env_file" "$env_key"
const fs = require('fs');
const file = process.argv[2];
const key = process.argv[3];
try {
const line = fs
.readFileSync(file, 'utf8')
.split(/\r?\n/)
.find((entry) => entry.startsWith(`${key}=`));
if (!line) process.exit(0);
const value = line.slice(key.length + 1).trim();
if (value) process.stdout.write(value);
} catch (_) {
process.exit(0);
}
NODE
}
@@ -169,6 +191,9 @@ NODE
;;
CW_MAX_OUTSTANDING_*)
derived_value="$(derive_gru_transport_policy_amount "$key" || true)"
if [[ -z "$derived_value" ]]; then
derived_value="$(derive_repo_example_env_value "$key" || true)"
fi
value="${!key:-$derived_value}"
;;
CW_GAS_OUTSTANDING_*|CW_GAS_ESCROWED_*|CW_GAS_TREASURY_BACKED_*|CW_GAS_TREASURY_CAP_*)

View File

@@ -19,6 +19,8 @@ set -euo pipefail
BUNDLE_ROOT="${1:?Usage: $0 /path/to/token-aggregation-build}"
SERVICE_SRC="$BUNDLE_ROOT/smom-dbis-138/services/token-aggregation"
CONFIG_SRC="$BUNDLE_ROOT/config"
PMM_CONFIG_SRC="$BUNDLE_ROOT/cross-chain-pmm-lps/config"
EXPLORER_SSH="${EXPLORER_SSH:-root@192.168.11.140}"
REMOTE_DIR="${REMOTE_DIR:-/opt/token-aggregation}"
REMOTE_SERVICE="${REMOTE_SERVICE:-token-aggregation}"
@@ -28,6 +30,10 @@ if [[ ! -d "$SERVICE_SRC" || ! -f "$SERVICE_SRC/dist/index.js" ]]; then
echo "Expected built service at $SERVICE_SRC (run deploy-token-aggregation-for-publication.sh first)." >&2
exit 1
fi
if [[ ! -d "$CONFIG_SRC" || ! -d "$PMM_CONFIG_SRC" ]]; then
echo "Expected bundle config directories at $CONFIG_SRC and $PMM_CONFIG_SRC." >&2
exit 1
fi
echo "Rsync $SERVICE_SRC/ → ${EXPLORER_SSH}:${REMOTE_DIR}/"
rsync_args=(
@@ -46,6 +52,16 @@ fi
RSYNC_RSH="ssh -o BatchMode=yes" rsync "${rsync_args[@]}" \
"$SERVICE_SRC/" "${EXPLORER_SSH}:${REMOTE_DIR}/"
echo "Rsync $CONFIG_SRC/ → ${EXPLORER_SSH}:${REMOTE_DIR}/config/"
RSYNC_RSH="ssh -o BatchMode=yes" rsync -avz --delete \
"$CONFIG_SRC/" "${EXPLORER_SSH}:${REMOTE_DIR}/config/"
echo "Rsync $PMM_CONFIG_SRC/ → ${EXPLORER_SSH}:${REMOTE_DIR}/cross-chain-pmm-lps/config/"
ssh -o BatchMode=yes "$EXPLORER_SSH" \
"mkdir -p '${REMOTE_DIR}/cross-chain-pmm-lps/config'"
RSYNC_RSH="ssh -o BatchMode=yes" rsync -avz --delete \
"$PMM_CONFIG_SRC/" "${EXPLORER_SSH}:${REMOTE_DIR}/cross-chain-pmm-lps/config/"
if [[ -n "$REMOTE_SERVICE" ]]; then
echo "Restart ${REMOTE_SERVICE} on ${EXPLORER_SSH}..."
ssh -o BatchMode=yes "$EXPLORER_SSH" "systemctl restart '${REMOTE_SERVICE}'" || {

View File

@@ -380,6 +380,19 @@ if [[ -z "$tx_hash" ]]; then
exit 1
fi
receipt_output="$(cast receipt "$tx_hash" --rpc-url "$RPC_URL" 2>&1 || true)"
receipt_status="$(printf '%s\n' "$receipt_output" | awk '/^status[[:space:]]/ {print $2; exit}')"
if [[ -z "$receipt_status" ]]; then
echo "[fail] could not determine transaction receipt status for $tx_hash" >&2
printf '%s\n' "$receipt_output" >&2
exit 1
fi
if [[ "$receipt_status" != "1" ]]; then
echo "[fail] transaction reverted on-chain for ${tx_mode}: txHash=$tx_hash status=$receipt_status" >&2
printf '%s\n' "$receipt_output" >&2
exit 1
fi
balance_in_after="$(cast call "$TOKEN_IN" 'balanceOf(address)(uint256)' "$DEPLOYER" --rpc-url "$RPC_URL" | awk '{print $1}')"
balance_out_after="$(cast call "$TOKEN_OUT" 'balanceOf(address)(uint256)' "$DEPLOYER" --rpc-url "$RPC_URL" | awk '{print $1}')"
amount_out_delta=$((balance_out_after - balance_out_before))
@@ -409,6 +422,7 @@ echo "minOut=$MIN_OUT"
echo "tokenIn=$TOKEN_IN"
echo "tokenOut=$TOKEN_OUT"
echo "txHash=$tx_hash"
echo "txReceiptStatus=$receipt_status"
echo "tokenInBalanceBefore=$balance_in_before"
echo "tokenInBalanceAfter=$balance_in_after"
echo "tokenOutBalanceBefore=$balance_out_before"

View File

@@ -157,7 +157,7 @@ PATCH_CMD+=(--apply)
CT_VERIFY_CMD=$(cat <<EOF
set -euo pipefail
printf '== env ==\n'
grep -E '^(MEV_CONFIG|MEV_ADMIN_PORT|MEV_SUPERVISOR_PORT|MEV_SUBMIT_DISABLED|MEV_ADMIN_API_KEY|MEV_EXECUTOR_PRIVATE_KEY)=' /etc/mev-platform/backend.env || true
grep -E '^(MEV_CONFIG|MEV_ADMIN_PORT|MEV_SUPERVISOR_PORT|MEV_SUPERVISOR_URL|MEV_SUBMIT_DISABLED|MEV_ADMIN_API_KEY|MEV_EXECUTOR_PRIVATE_KEY)=' /etc/mev-platform/backend.env || true
printf '\n== services ==\n'
systemctl restart mev-supervisor.service
systemctl restart mev-admin-api.service
@@ -166,6 +166,9 @@ systemctl --no-pager --full status mev-supervisor.service mev-admin-api.service
printf '\n== local api ==\n'
curl -fsS http://127.0.0.1:9090/api/health | jq .
curl -fsS http://127.0.0.1:9090/api/auth/check | jq .
if [ -n "${API_KEY:-}" ]; then
curl -fsS -H "X-API-Key: ${API_KEY}" http://127.0.0.1:9090/api/control/status | jq .
fi
if [ -n "${API_KEY:-}" ]; then
curl -fsS -H "X-API-Key: ${API_KEY}" http://127.0.0.1:9090/api/infra | jq .
curl -fsS -H "X-API-Key: ${API_KEY}" http://127.0.0.1:9090/api/safety/signer | jq .

View File

@@ -55,9 +55,14 @@ CUSDC_V2="${COMPLIANT_USDC_V2:-${CUSDC_V2_ADDRESS_138:-0x219522c60e83dEe01FC5b03
BLOCKERS=()
WARNINGS=()
NOTES=()
KNOWN_REGISTRY_ORPHANS=(
"0x9AA44008f30B7F6D2BfB74016420c5eA49c5ebE4"
)
ok() { printf '[OK] %s\n' "$*"; }
warn() { printf '[WARN] %s\n' "$*"; WARNINGS+=("$*"); }
note() { printf '[NOTE] %s\n' "$*"; NOTES+=("$*"); }
block() { printf '[BLOCKER] %s\n' "$*"; BLOCKERS+=("$*"); }
call_or_fail() {
@@ -204,7 +209,11 @@ audit_registry_orphans() {
[[ -z "$address" ]] && continue
code="$(cast code "$address" --rpc-url "$RPC_URL" 2>/dev/null || true)"
if [[ -z "$code" || "$code" == "0x" ]]; then
warn "UniversalAssetRegistry has an active GRU entry with no bytecode: $address"
if printf '%s\n' "${KNOWN_REGISTRY_ORPHANS[@]}" | grep -Fqx "$address"; then
note "UniversalAssetRegistry still contains the known orphaned GRU entry from the interrupted 2026-04-03 rollout: $address"
else
warn "UniversalAssetRegistry has an active GRU entry with no bytecode: $address"
fi
fi
done
}
@@ -220,7 +229,7 @@ if [[ "$RUN_LOCAL_TESTS" == "1" ]]; then
run_local_suite
ok "Local CompliantFiatTokenV2 suite passed."
else
warn "Skipping local Foundry suite. Re-run with --run-local-tests or RUN_LOCAL_TESTS=1 to include it."
note "Skipping local Foundry suite. Re-run with --run-local-tests or RUN_LOCAL_TESTS=1 to include it."
fi
check_token "cUSDT V2" "$CUSDT_V2" "cUSDT" "USD"
@@ -228,9 +237,17 @@ check_token "cUSDC V2" "$CUSDC_V2" "cUSDC" "USD"
audit_registry_orphans
printf '\n=== Summary ===\n'
printf 'Notes: %s\n' "${#NOTES[@]}"
printf 'Warnings: %s\n' "${#WARNINGS[@]}"
printf 'Blockers: %s\n' "${#BLOCKERS[@]}"
if [[ "${#NOTES[@]}" -gt 0 ]]; then
printf '\nNotes:\n'
for item in "${NOTES[@]}"; do
printf ' - %s\n' "$item"
done
fi
if [[ "${#WARNINGS[@]}" -gt 0 ]]; then
printf '\nWarnings:\n'
for item in "${WARNINGS[@]}"; do

View File

@@ -180,6 +180,13 @@ if submit_disabled.strip().lower() in truthy:
else:
add_row("MEV_SUBMIT_DISABLED", str(env_path), submit_disabled or "0", "ok")
supervisor_url = os.environ.get("MEV_SUPERVISOR_URL") or env_values.get("MEV_SUPERVISOR_URL", "")
if supervisor_url:
add_row("MEV_SUPERVISOR_URL", str(env_path), supervisor_url, "ok")
else:
add_row("MEV_SUPERVISOR_URL", str(env_path), "(missing)", "missing")
issues.append("MEV_SUPERVISOR_URL is not configured")
if chain is None:
add_row(f"chains.{chain_key}", str(config_path), "(missing chain section)", "missing")
issues.append(f"chains.{chain_key} section is missing")

View File

@@ -14,6 +14,12 @@ WETH10="0xf4BB2e28688e89fCcE3c0580D37d36A7672E8A9f"
USDT="0x004b63A7B5b0E06f6bB6adb4a5F9f590BF3182D1"
USDC="0x71D6687F38b93CCad569Fa6352c876eea967201b"
ROOT_V1_CODE="000"
TOKEN_AGG_V1_CODE="000"
V2_CAPS_CODE="000"
V2_PLAN_CODE="000"
V2_INTERNAL_PLAN_CODE="000"
try_path() {
local prefix="$1"
local path="$2"
@@ -77,12 +83,36 @@ echo ""
echo "== planner-v2 checks =="
echo ""
echo "-- prefix: /token-aggregation (published v2 path) --"
try_path "/token-aggregation" "/api/v2/providers/capabilities?chainId=138"
V2_CAPS_CODE=$(curl -sS -o /tmp/ta-check.json -w "%{http_code}" -m 25 \
"${BASE_URL}/token-aggregation/api/v2/providers/capabilities?chainId=138" 2>/dev/null || echo "000")
echo " $V2_CAPS_CODE /token-aggregation/api/v2/providers/capabilities?chainId=138"
if [[ "$V2_CAPS_CODE" == "200" ]]; then
head -c 220 /tmp/ta-check.json
echo
fi
if [[ -f /tmp/ta-check.json ]] && head -c 20 /tmp/ta-check.json | grep -qi '<!DOCTYPE'; then
echo " [WARN] capabilities response looks like HTML — nginx may not proxy /token-aggregation/api/v2/ to token-aggregation (VMID 5000: scripts/fix-explorer-token-aggregation-api-v2-proxy.sh)"
fi
try_post_path "/token-aggregation" "/api/v2/routes/plan" "{\"sourceChainId\":138,\"tokenIn\":\"${WETH10}\",\"tokenOut\":\"${USDT}\",\"amountIn\":\"100000000000000000\"}"
try_post_path "/token-aggregation" "/api/v2/routes/internal-execution-plan" "{\"sourceChainId\":138,\"tokenIn\":\"${WETH10}\",\"tokenOut\":\"${USDT}\",\"amountIn\":\"100000000000000000\"}"
V2_PLAN_CODE=$(curl -sS -o /tmp/ta-check.json -w "%{http_code}" -m 25 \
-H "content-type: application/json" \
-X POST \
--data "{\"sourceChainId\":138,\"tokenIn\":\"${WETH10}\",\"tokenOut\":\"${USDT}\",\"amountIn\":\"100000000000000000\"}" \
"${BASE_URL}/token-aggregation/api/v2/routes/plan" 2>/dev/null || echo "000")
echo " $V2_PLAN_CODE POST /token-aggregation/api/v2/routes/plan"
if [[ "$V2_PLAN_CODE" == "200" || "$V2_PLAN_CODE" == "400" ]]; then
head -c 260 /tmp/ta-check.json
echo
fi
V2_INTERNAL_PLAN_CODE=$(curl -sS -o /tmp/ta-check.json -w "%{http_code}" -m 25 \
-H "content-type: application/json" \
-X POST \
--data "{\"sourceChainId\":138,\"tokenIn\":\"${WETH10}\",\"tokenOut\":\"${USDT}\",\"amountIn\":\"100000000000000000\"}" \
"${BASE_URL}/token-aggregation/api/v2/routes/internal-execution-plan" 2>/dev/null || echo "000")
echo " $V2_INTERNAL_PLAN_CODE POST /token-aggregation/api/v2/routes/internal-execution-plan"
if [[ "$V2_INTERNAL_PLAN_CODE" == "200" || "$V2_INTERNAL_PLAN_CODE" == "400" ]]; then
head -c 260 /tmp/ta-check.json
echo
fi
echo ""
echo "== DODO stable depth sanity =="
@@ -140,7 +170,32 @@ echo " - gas-registry 404: redeploy token-aggregation from repo (implements GET
echo " - Health: curl -s http://127.0.0.1:3001/health on explorer VM (not always proxied as /health)."
echo " - planner-v2 publishes under /token-aggregation/api/v2/* so it does not collide with Blockscout /api/v2/* on explorer.d-bis.org."
echo " - Apex https://explorer.d-bis.org/api/v1/* returns 400 while /token-aggregation/api/v1/* works: add HTTP+HTTPS location /api/v1/ → token-aggregation (scripts/fix-explorer-http-api-v1-proxy.sh on explorer VM)."
echo " - POST /token-aggregation/api/v2/* returns 405: insert v2 proxy block (scripts/fix-explorer-token-aggregation-api-v2-proxy.sh on VMID 5000)."
echo " - If POST /token-aggregation/api/v2/* returns 405 or HTML instead of JSON, insert the v2 proxy block (scripts/fix-explorer-token-aggregation-api-v2-proxy.sh on VMID 5000)."
echo " - Fresh binary + PMM env: bash scripts/deploy-token-aggregation-for-publication.sh then rsync dist/node_modules/.env to /opt/token-aggregation; systemctl restart token-aggregation (see TOKEN_AGGREGATION_REPORT_API_RUNBOOK.md)."
echo " - DODO v3 pilot routes should return provider=dodo_v3, routePlanPresent=true, and an internal-execution-plan object targeting EnhancedSwapRouterV2 when CHAIN138_ENABLE_DODO_V3_EXECUTION is live."
echo " - The funded canonical cUSDC/USDC DODO pool should report non-zero route-tree depth on Chain 138; if it falls back to near-zero TVL again, check the DODO valuation path and the canonical PMM integration address."
ROOT_V1_CODE=$(curl -sS -o /tmp/ta-root-v1.json -w "%{http_code}" -m 25 \
"${BASE_URL}/api/v1/tokens?chainId=138&limit=1" 2>/dev/null || echo "000")
TOKEN_AGG_V1_CODE=$(curl -sS -o /tmp/ta-tokenagg-v1.json -w "%{http_code}" -m 25 \
"${BASE_URL}/token-aggregation/api/v1/tokens?chainId=138&limit=1" 2>/dev/null || echo "000")
echo ""
echo "== summary =="
echo "root_v1=$ROOT_V1_CODE token_aggregation_v1=$TOKEN_AGG_V1_CODE v2_caps=$V2_CAPS_CODE v2_plan=$V2_PLAN_CODE v2_internal_plan=$V2_INTERNAL_PLAN_CODE"
if [[ "$V2_CAPS_CODE" != "200" || "$V2_PLAN_CODE" != "200" || "$V2_INTERNAL_PLAN_CODE" != "200" ]]; then
echo "[fail] planner-v2 publication is unhealthy" >&2
exit 1
fi
if [[ "$TOKEN_AGG_V1_CODE" == "502" || "$TOKEN_AGG_V1_CODE" == "000" ]]; then
echo "[fail] published /token-aggregation/api/v1 surface is unhealthy" >&2
exit 1
fi
if [[ "$ROOT_V1_CODE" == "400" ]]; then
echo "[warn] apex /api/v1 remains routed to Blockscout and not token-aggregation; use /token-aggregation/api/v1 or add the dedicated apex proxy if required." >&2
fi
echo "[OK] token-aggregation planner-v2 is healthy; published v1 surface is reachable."