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>
This commit is contained in:
@@ -44,6 +44,51 @@ if [ "$1" = "--protocol" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Look up the expected block time (milliseconds) for a registry key (drpc slug) or chain id.
|
||||
# Used by sync-status.sh / check-health.sh to scale the lag thresholds per chain.
|
||||
if [ "$1" = "--block-time-ms" ]; then
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "Usage: $0 --block-time-ms <slug|chainid>"
|
||||
exit 1
|
||||
fi
|
||||
key="$2"
|
||||
# Try by slug first
|
||||
bt=$(jq -r --arg k "$key" '.[$k].block_time_ms // empty' "$json_file" 2>/dev/null)
|
||||
if [ -z "$bt" ]; then
|
||||
# Fall back to lookup by chain id (decimal; convert hex)
|
||||
idk="$key"
|
||||
[[ "$idk" == 0x* ]] && idk=$(printf "%d" "$idk" 2>/dev/null)
|
||||
if [[ "$idk" =~ ^[0-9]+$ ]]; then
|
||||
bt=$(jq -r --arg id "$idk" 'first(.[] | select(.id == ($id | tonumber)) | .block_time_ms) // empty' "$json_file" 2>/dev/null)
|
||||
fi
|
||||
fi
|
||||
[ -z "$bt" ] && exit 1
|
||||
echo "$bt"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Look up the dRPC lag thresholds (in BLOCKS) for a registry key (slug) or chain id.
|
||||
# Prints "<lagging_lag> <syncing_lag>". Used by sync-status.sh -> check-health.sh so our
|
||||
# online/lagging/syncing status matches the dRPC gateway's per-chain lag model.
|
||||
if [ "$1" = "--lags" ]; then
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "Usage: $0 --lags <slug|chainid>"
|
||||
exit 1
|
||||
fi
|
||||
key="$2"
|
||||
lags=$(jq -r --arg k "$key" 'if (.[$k].lagging_lag != null and .[$k].syncing_lag != null) then "\(.[$k].lagging_lag) \(.[$k].syncing_lag)" else empty end' "$json_file" 2>/dev/null)
|
||||
if [ -z "$lags" ]; then
|
||||
idk="$key"
|
||||
[[ "$idk" == 0x* ]] && idk=$(printf "%d" "$idk" 2>/dev/null)
|
||||
if [[ "$idk" =~ ^[0-9]+$ ]]; then
|
||||
lags=$(jq -r --arg id "$idk" 'first(.[] | select(.id == ($id | tonumber)) | select(.lagging_lag != null and .syncing_lag != null) | "\(.lagging_lag) \(.syncing_lag)") // empty' "$json_file" 2>/dev/null)
|
||||
fi
|
||||
fi
|
||||
[ -z "$lags" ] && exit 1
|
||||
echo "$lags"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Look up by rollup_version (for Aztec: version from result.header.globalVariables.version)
|
||||
if [ "$1" = "--rollup-version" ]; then
|
||||
if [ $# -lt 2 ]; then
|
||||
|
||||
Reference in New Issue
Block a user