From eafbb2e2c3cbad611fc2d12f906ca5b38e6f9e25 Mon Sep 17 00:00:00 2001 From: goldsquid Date: Sat, 31 Jan 2026 11:24:14 +0700 Subject: [PATCH] fix --- reference-rpc-endpoint.json | 1 + reference-rpc-endpoint.sh | 39 ++++++++++++++++++++++++++++--------- sync-status.sh | 34 +++++++++++++++++--------------- 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/reference-rpc-endpoint.json b/reference-rpc-endpoint.json index a3d5cdfb..cd0bb0b6 100644 --- a/reference-rpc-endpoint.json +++ b/reference-rpc-endpoint.json @@ -1541,6 +1541,7 @@ ] }, "aztec-testnet": { + "rollup_version": "2500495677", "urls": [ "https://rpc.testnet.aztec-labs.com" ] diff --git a/reference-rpc-endpoint.sh b/reference-rpc-endpoint.sh index 34add709..34f0cb4f 100755 --- a/reference-rpc-endpoint.sh +++ b/reference-rpc-endpoint.sh @@ -1,6 +1,35 @@ #!/bin/bash -# Check if more than two arguments are provided +BASEPATH="$(dirname "$0")" +json_file="${BASEPATH}/reference-rpc-endpoint.json" + +# Check if JSON file exists +if [ ! -f "$json_file" ]; then + # Fallback for legacy path + json_file="/root/rpc/reference-rpc-endpoint.json" +fi +if [ ! -f "$json_file" ]; then + echo "JSON file not found: $json_file" + exit 1 +fi + +# Look up by rollup_version (for Aztec: version from result.header.globalVariables.version) +if [ "$1" = "--rollup-version" ]; then + if [ $# -lt 2 ]; then + echo "Usage: $0 --rollup-version " + exit 1 + fi + version="$2" + urls=$(jq -r --arg v "$version" '.[] | select(.rollup_version == $v) | .urls[]' "$json_file" 2>/dev/null | tr '\n' ' ') + if [ -z "$urls" ]; then + echo "Rollup version not found: $version" + exit 1 + fi + echo "$urls" + exit 0 +fi + +# Look up by chain id if [ $# -gt 2 ]; then echo "Usage: $0 []" exit 1 @@ -14,14 +43,6 @@ if [[ "$id" == "0x"* ]]; then id=$(printf "%d" "$id") fi -json_file="/root/rpc/reference-rpc-endpoint.json" - -# Check if JSON file exists -if [ ! -f "$json_file" ]; then - echo "JSON file not found: $json_file" - exit 1 -fi - # Find the object with matching id object=$(jq --arg id "$id" '.[] | select(.id == ($id | tonumber))' "$json_file") diff --git a/sync-status.sh b/sync-status.sh index 7542b431..0e62c64a 100755 --- a/sync-status.sh +++ b/sync-status.sh @@ -51,22 +51,24 @@ for path in $pathlist; do ref="$2" else if $is_aztec; then - # Aztec: resolve ref by path (mainnet/testnet/devnet) - case "$path" in - *aztec-mainnet*) - ref=$($BASEPATH/reference-rpc-endpoint.sh 418) - ;; - *aztec-testnet*) - ref=$($BASEPATH/reference-rpc-endpoint.sh 11124) - ;; - *aztec-devnet*) - ref=$($BASEPATH/reference-rpc-endpoint.sh 11125) - ;; - *) - echo "error: unknown aztec path $path" - exit 1 - ;; - esac + # Aztec: resolve ref by rollup_version from node (result.header.globalVariables.version) + aztec_block_response=$(curl -L --ipv4 -m 1 -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"node_getBlock","params":["latest"],"id":1}' $RPC_URL) + if [ $? -ne 0 ]; then + echo "error: failed to get Aztec block from $RPC_URL" + exit 1 + fi + version_hex=$(echo "$aztec_block_response" | jq -r '.result.header.globalVariables.version' 2>/dev/null) + if [ -z "$version_hex" ] || [ "$version_hex" = "null" ]; then + echo "error: could not parse rollup version from Aztec node" + exit 1 + fi + # Convert hex (e.g. 0x950a893d) to decimal for JSON lookup + version_decimal=$((16#${version_hex#0x})) + ref=$($BASEPATH/reference-rpc-endpoint.sh --rollup-version "$version_decimal") + if [ $? -ne 0 ]; then + echo "error: no reference endpoint for Aztec rollup_version $version_decimal" + exit 1 + fi elif $is_starknet; then # Starknet chain ID detection chain_id_response=$(curl -L --ipv4 -m 1 -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"starknet_chainId","params":[],"id":1}' $RPC_URL)