Source mirror · commit 369512f · 2026-10-26 · MIT · canonical repo: gitlab.com/jiapunk/upgrade-airlock
git clone https://upgrade-airlock.pages.dev/source/upgrade-airlock.git
upgrade-airlock / scripts / sepolia / status.sh
scripts/sepolia/status.sh75 lines · 4194 bytes
1#!/usr/bin/env bash
2# The last N proposals: Pending (no verdict yet) / Cleared / Vetoed / Executed, who gave the verdict, whether the
3# CRE has judged it (AirlockAdmin.oracleJudged; an approver's clearance leaves it "no" until the sweeper answers),
4# the rule, the evidence hash and the verdict and execute transactions.
5#
6# scripts/sepolia/status.sh [N] # live Sepolia (default N = 10)
7# FORK=19631 scripts/sepolia/status.sh [N]
8# Every read is retried on a transient RPC error (RPC_TRIES, default 3). The verdict events are scanned from the
9# deployment block in windows, on SEPOLIA_RPC and then an RPC that keeps the full history (lib.sh events_since;
10# HISTORY_RPC overrides the list, EVENTS_FROM=<block> starts the scan later). When no RPC serves a window, the rows in
11# it show '-' for by, rule, evidence and verdict tx, and the header line ("proposals so far: N") still shows that the
12# chain is reachable.
13source "$(dirname "$0")/lib.sh"
14N=${1:-10}
15[[ "$N" =~ ^[0-9]+$ ]] || die "usage: [FORK=<port>] $0 [N]"
16check_rpc
17GA=$(dep airlockAdmin)
18PROXY=$(dep proxy)
19NOW=$(block_now)
20NEXT=$(rpc_retry cast call "$GA" 'nextId()(uint256)' --rpc-url "$RPC")
21DELAY=$(rpc_retry cast call "$GA" 'delayBlocks()(uint64)' --rpc-url "$RPC")
22PAUSED=$(rpc_retry cast call "$GA" 'paused()(bool)' --rpc-url "$RPC")
23IMPL=$(cast parse-bytes32-address "$(rpc_retry cast storage "$PROXY" "$IMPL_SLOT" --rpc-url "$RPC")")
24RX=$(dep receiver)
25say "Upgrade Airlock on $NET, block $NOW"
26say " AirlockAdmin $(addr_ref "$GA")"
27say " delay $DELAY blocks (~$(fmt_secs $((DELAY * SEPOLIA_BLOCK_SECS))) at 12 s blocks); proposals so far: $((NEXT - 1)); proxy implementation: $(impl_name "$IMPL")$([ "$PAUSED" = true ] && echo ' (PAUSED)')"
28say " receiver is guardian: $(rpc_retry cast call "$GA" 'isGuardian(address)(bool)' "$RX" --rpc-url "$RPC"); guardians: $(rpc_retry cast call "$GA" 'guardianCount()(uint256)' --rpc-url "$RPC")"
29[ "$NEXT" -gt 1 ] || exit 0
30
31EV=$(events_since "$(dep startBlock)")
32FIRST=$((NEXT - N))
33[ "$FIRST" -ge 1 ] || FIRST=1
34C=0 V=0 P=0 X=0 W=0
35ROWS=()
36for ((id = FIRST; id < NEXT; id++)); do
37 read -r KIND ST TARGET READY _ PBLOCK < <(proposal "$id") || die "could not read proposal #$id from $RPC (try again, or set SEPOLIA_RPC)"
38 CL=$(clearance "$id")
39 STATE_N=$(state_name "$ST" "$CL")
40 CRE=$(oracle_judged "$id")
41 case "$CRE" in true) CRE=yes ;; false) CRE=no ;; esac
42 [ "$ST" = 1 ] && [ "$CRE" = no ] && W=$((W + 1))
43 RULE=- EVID=- BY=- VTX=- XTX=-
44 case "$STATE_N" in
45 Vetoed)
46 V=$((V + 1))
47 read -r _ _ RH WHO TXH _ < <(first_event vetoed "$id" "$EV") || RH=
48 if [ -n "${RH:-}" ]; then RULE=$(rule_name "$RH"); BY=$(who_name "$WHO"); VTX=$TXH; fi
49 read -r _ _ EVID _ _ _ < <(first_event reason "$id" "$EV") || EVID=-
50 ;;
51 Cleared | Executed)
52 if [ "$CL" != "$ZERO32" ]; then
53 EVID=$CL
54 read -r _ _ _ WHO TXH _ < <(first_event cleared "$id" "$EV") || WHO=
55 if [ -n "${WHO:-}" ]; then BY=$(who_name "$WHO"); VTX=$TXH; fi
56 fi
57 if [ "$STATE_N" = Executed ]; then
58 X=$((X + 1))
59 read -r _ _ _ _ XTX _ < <(first_event executed "$id" "$EV") || XTX=-
60 else C=$((C + 1)); fi
61 ;;
62 Pending) P=$((P + 1)) ;;
63 esac
64 WHEN=$READY
65 [ "$ST" = 1 ] && [ "$NOW" -lt "$READY" ] && WHEN="$READY(+$((READY - NOW)))"
66 ROWS+=("$(printf ' %-4s %-15s %-15s %-9s %-13s %-4s %-9s %-14s %-24s %-14s %s' "$id" "${KIND_NAMES[$KIND]}" "$(impl_name "$TARGET")" \
67 "$STATE_N" "$BY" "$CRE" "$PBLOCK" "$WHEN" "$RULE" "$(short "$EVID")" "$( [ "$VTX" = - ] && echo - || tx_ref "$VTX")")")
68 [ "$XTX" = - ] || ROWS+=("$(printf ' %-4s %-15s executed in tx %s' '' '' "$(tx_ref "$XTX")")")
69done
70printf '\n %-4s %-15s %-15s %-9s %-13s %-4s %-9s %-14s %-24s %-14s %s\n' id kind target state by cre proposed ready rule evidence "verdict tx"
71for r in "${ROWS[@]}"; do say "$r"; done
72say ""
73say " shown: $C cleared (not executed yet), $V vetoed, $X executed, $P pending without a verdict"
74[ "$W" = 0 ] || say " $W pending without a CRE verdict (cre = no): the sweeper judges them, approver-cleared ones included"
75[ "$CRE" != '?' ] || say " cre = ?: this deployment has no AirlockAdmin.oracleJudged"