Skip to content

Commit 7aadf1c

Browse files
committed
more scripts
Signed-off-by: Tomás Migone <[email protected]>
1 parent 806ee23 commit 7aadf1c

File tree

6 files changed

+122
-12
lines changed

6 files changed

+122
-12
lines changed

scripts/upgrade-indexer/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ kubectl exec -ti shell-0 -- bash -s < fetch.sh
4646
kubectl exec -ti shell-0 -- env DRY_RUN=false bash -s < close-duplicates.sh
4747
```
4848

49+
### Create lost allocations
50+
51+
```bash
52+
kubectl cp allos-snapshot-before.json shell-0:/allos-snapshot-before.json
53+
kubectl exec -ti shell-0 -- env AFTER=allocations.json bash -s < create-lost.sh
54+
```
55+
4956
### Other useful commands
5057
```bash
5158
graph indexer actions get --network arbitrum-one --source "horizon-bulk-reallocate" -w 24 --status failed

scripts/upgrade-indexer/compare.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -e
55

66
BEFORE="${1:-allos-snapshot-before.json}"
77
AFTER="${2:-allos-snapshot-current.json}"
8+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
LOST_ALLOWLIST="${LOST_ALLOWLIST:-$SCRIPT_DIR/lost-allowlist.txt}"
810

911
# Colors for output
1012
RED='\033[0;31m'
@@ -89,8 +91,7 @@ LEGACY_CHANGE=$((BEFORE_LEGACY - AFTER_LEGACY))
8991
FAILED=0
9092

9193
if [[ "$MIGRATED_COUNT" -ne "$LEGACY_CHANGE" ]]; then
92-
echo -e "${RED}SANITY CHECK FAILED: Migrated ($MIGRATED_COUNT) != Legacy change ($LEGACY_CHANGE)${NC}"
93-
FAILED=1
94+
echo -e "${YELLOW}Note: Migrated ($MIGRATED_COUNT) != Legacy change ($LEGACY_CHANGE)${NC}"
9495
fi
9596

9697
if [[ "$BOTH_COUNT" -ne 0 ]]; then
@@ -105,8 +106,21 @@ if [[ "$MULTI_HORIZON_COUNT" -ne 0 ]]; then
105106
FAILED=1
106107
fi
107108

108-
if [[ "$LOST_COUNT" -ne 0 ]]; then
109-
echo -e "${RED}SANITY CHECK FAILED: Legacy closed without Horizon replacement ($LOST_COUNT) != 0${NC}"
109+
# Filter lost allocations against allowlist
110+
if [[ -f "$LOST_ALLOWLIST" ]]; then
111+
LOST_NOT_ALLOWED=$(echo "$LOST" | while IFS=$'\t' read -r deployment id; do
112+
if ! grep -q "^$deployment$" "$LOST_ALLOWLIST"; then
113+
echo -e "$deployment\t$id"
114+
fi
115+
done)
116+
LOST_NOT_ALLOWED_COUNT=$(echo "$LOST_NOT_ALLOWED" | grep -c . || true)
117+
else
118+
LOST_NOT_ALLOWED="$LOST"
119+
LOST_NOT_ALLOWED_COUNT="$LOST_COUNT"
120+
fi
121+
122+
if [[ "$LOST_NOT_ALLOWED_COUNT" -ne 0 ]]; then
123+
echo -e "${RED}SANITY CHECK FAILED: Legacy closed without Horizon replacement ($LOST_NOT_ALLOWED_COUNT not in allowlist) != 0${NC}"
110124
FAILED=1
111125
fi
112126
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
# Create allocations for legacy allocations that were closed without a horizon replacement
3+
4+
set -e
5+
6+
# Configuration
7+
NETWORK="${NETWORK:-arbitrum-one}"
8+
BEFORE="${BEFORE:-allos-snapshot-before.json}"
9+
AFTER="${AFTER:-allos-snapshot-current.json}"
10+
AMOUNT="${AMOUNT:-1}"
11+
DRY_RUN="${DRY_RUN:-true}"
12+
13+
# Colors for output
14+
RED='\033[0;31m'
15+
GREEN='\033[0;32m'
16+
YELLOW='\033[1;33m'
17+
NC='\033[0m' # No Color
18+
19+
echo -e "${YELLOW}=== Create Lost Allocations ===${NC}"
20+
echo "Network: $NETWORK"
21+
echo "Before: $BEFORE"
22+
echo "After: $AFTER"
23+
echo "Amount: $AMOUNT"
24+
echo "Dry run: $DRY_RUN"
25+
echo ""
26+
27+
# Check if files exist
28+
if [[ ! -f "$BEFORE" ]]; then
29+
echo -e "${RED}Error: $BEFORE not found${NC}"
30+
exit 1
31+
fi
32+
if [[ ! -f "$AFTER" ]]; then
33+
echo -e "${RED}Error: $AFTER not found${NC}"
34+
exit 1
35+
fi
36+
37+
# Get lost deployments (legacy closed without horizon replacement)
38+
# Using INDEX for O(1) lookups instead of O(n) with index()
39+
LOST=$(jq -r -n --slurpfile before "$BEFORE" --slurpfile after "$AFTER" '
40+
($after[0] | [.[] | .subgraphDeployment] | INDEX(.) ) as $after_deps |
41+
[$before[0][] | select(.isLegacy == "Yes" and ($after_deps[.subgraphDeployment] == null))]
42+
| .[].subgraphDeployment
43+
' | sort -u)
44+
45+
LOST_COUNT=$(echo "$LOST" | grep -c . || true)
46+
47+
echo -e "Found ${RED}$LOST_COUNT${NC} lost deployments to recreate"
48+
echo ""
49+
50+
if [[ "$LOST_COUNT" -eq 0 ]]; then
51+
echo -e "${GREEN}No lost allocations to create${NC}"
52+
exit 0
53+
fi
54+
55+
SOURCE="${SOURCE:-horizon-create-lost}"
56+
REASON="create-lost-allocation"
57+
58+
if [[ "$DRY_RUN" == "true" ]]; then
59+
echo -e "${YELLOW}DRY RUN - Commands that would be executed:${NC}"
60+
echo ""
61+
echo "$LOST" | while read -r deployment; do
62+
echo "graph indexer actions queue allocate $deployment $AMOUNT --network $NETWORK --source $SOURCE --reason $REASON"
63+
done
64+
echo ""
65+
echo -e "${YELLOW}To execute, run with DRY_RUN=false${NC}"
66+
else
67+
echo "Queueing allocations..."
68+
echo ""
69+
70+
CURRENT=0
71+
72+
echo "$LOST" | while read -r deployment; do
73+
((CURRENT++)) || true
74+
PERCENT=$((CURRENT * 100 / LOST_COUNT))
75+
echo -n "[$CURRENT/$LOST_COUNT] ($PERCENT%) Queueing $deployment... "
76+
if graph indexer actions queue allocate "$deployment" "$AMOUNT" --network "$NETWORK" --source "$SOURCE" --reason "$REASON" > /dev/null 2>&1; then
77+
echo -e "${GREEN}OK${NC}"
78+
else
79+
echo -e "${RED}FAILED${NC}"
80+
fi
81+
done
82+
83+
echo ""
84+
echo -e "${GREEN}Done! Run approve.sh and execute.sh to process the queued actions.${NC}"
85+
fi
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
QmWEUXLNBpfe3PiDUxwjpcvtyCTEeux6cpDAXQL4jFQhCQ
2+
QmdDGiCRZTjcbBUsKfPruJ6Eeevsqoxi2ACqiXPTGidJE3
3+
QmeHq6gLb9XEWUFaRZS7jHvnPUV7epjCRaJ4NdkKxTE5uw
4+
QmQG9pM6yTL5J8EMMSgJAkcjSKsrWpTd7TpuYto4q2CCRs
5+
QmfCCZWh4DUBG2i3rXXdt1jt3HrksG7riyizJNQK4cYpFw
6+
QmcPjxX2zZAWP1thJEZmV3xPtWwyYhG5DWYWKHVAgaRt3d
7+
QmVKNfmz7i6oqubvXu4hnG36VyTqGTJZ1wqWoQTknQR2u6
8+
QmYP1y2E7NGjEz95UgWi3MTDbTykf2fkGvVyXBWyFdzdp5
9+
QmZaS8UGvHQ2L6gwQoVu3hShPzX12VHxwnEdtaFJb4MrgA
10+
QmVhqJH4NaUwPq58HgutmxdvFUwNf6jv3qKy3tUhKMjz6Y
11+
QmQzWUopeU9u5tRsXvA9UKon4LPVjrZnbzKbzMk2KAsAFM

scripts/upgrade-indexer/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ for ((i=1; i<=RUNS; i++)); do
4545
echo ""
4646
echo -e "Run $i completed in $((SECONDS - RUN_START))s"
4747
echo ""
48+
say "Run $i completed"
4849
done
4950

5051
echo -e "${GREEN}=== All runs completed in $((SECONDS - TOTAL_START))s ===${NC}"

scripts/upgrade-indexer/status.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,3 @@ echo " Approved: $(get_count approved)"
3333
echo " Pending: $(get_count pending)"
3434
echo " Success: $(get_count success)"
3535
echo " Failed: $(get_count failed)"
36-
37-
# Show any failures
38-
FAILED_COUNT=$(get_count failed)
39-
if [[ "$FAILED_COUNT" -gt 0 ]]; then
40-
echo ""
41-
echo -e "${RED}Failed actions:${NC}"
42-
graph indexer actions get --status failed --source "$SOURCE" --network "$NETWORK" --fields id,deploymentID,failureReason
43-
fi

0 commit comments

Comments
 (0)