Files
ethereum-rpc-docker/multicurl.sh
Claude Agent 1134a3774a sync-status: dRPC-homogeneous block-lag status + fix never-used reference fallbacks
Match the dRPC gateway's per-chain "how many blocks behind is ok" model instead of a
fixed 2s/5s timestamp tolerance:
- check-health.sh: compare the reference head vs local head by BLOCK NUMBER and classify
  with the chain's dRPC lag thresholds (LAGGING_LAG/SYNCING_LAG, in blocks, from
  chains.yaml). dRPC uses the two thresholds inconsistently across chains (sometimes
  lagging<syncing, sometimes the reverse) so the smaller is the online boundary and the
  larger the syncing/drop boundary. Defaults 2/6 when a chain has no thresholds.
- multicurl.sh: also skip responses with result:null (a lagging endpoint lacking the
  requested block) so the fallback reference URLs are actually tried. Previously the first
  endpoint's {"result":null} was accepted as success -> fallbacks never ran, and the null
  reference hash made check-health report false "forked" (the online/forked flapping).
- sync-status.sh: resolve the lag thresholds (by drpc slug or chain id) and export
  LAGGING_LAG/SYNCING_LAG.
- reference-rpc-endpoint.sh: add --lags and --block-time-ms lookups.
- reference-rpc-endpoint.json: regenerated with per-chain block_time_ms + lagging_lag +
  syncing_lag (additive).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 05:55:55 +00:00

74 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# echo "$@"
urls=()
options=()
while [[ $# -gt 0 ]]; do
case "$1" in
--url)
urls+=("$2")
shift 2
;;
*)
options+=("$1")
shift 1
;;
esac
done
if [[ ${#urls[@]} -eq 0 ]]; then
echo "No URLs provided"
exit 1
fi
original_output=""
temp_file=""
for i in "${!options[@]}"; do
if [[ "${options[i]}" == "-o" ]]; then
output_file="${options[i+1]}"
temp_file=$(mktemp)
options[i+1]="$temp_file"
original_output="$output_file"
break
fi
done
output=""
for url in "${urls[@]}"; do
#echo "curl -s ${options[@]} $url"
output=$(eval "curl -s ${options[@]@Q} '$url' --fail")
if [[ $? -eq 0 ]]; then
# Skip and try the next reference URL when the response is a JSON-RPC error OR has a
# null result (a lagging endpoint that doesn't have the requested block/data yet).
# Without the result==null check the first endpoint's {"result":null} was accepted as
# success and the remaining fallback URLs were never tried.
if cat "$temp_file" | jq -e 'has("error") or (.result == null)' > /dev/null 2>&1; then
continue # Try the next URL
fi
if [ -n "$original_output" ]; then
#echo "$(cat $temp_file)"
cat "$temp_file" > "$original_output"
fi
echo "$output"
exit 0
else
continue
fi
done
# Write the final output to the original output file if specified
if [ -n "$original_output" ]; then
cat "$temp_file" > "$original_output"
fi
# Print the output to stdout
echo "$output"
exit 1