-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcatch-up-loop.sh
More file actions
executable file
·50 lines (45 loc) · 1.7 KB
/
Copy pathcatch-up-loop.sh
File metadata and controls
executable file
·50 lines (45 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Full catch-up loop — runs AFTER the 10-block validation passes.
# Keeps re-running catch-up (crash-safe / resumes from last checkpoint) until
# the operator kills it or we're near the tip.
#
# Usage:
# Phase 1 (ubt-node tunnel, for 25,340,001 → near tip):
# RPC_URL=http://127.0.0.1:8545 bash catch-up-loop.sh
# Phase 2 (local EL, for the last few hundred blocks once near tip):
# RPC_URL=http://127.0.0.1:8545 bash catch-up-loop.sh
#
# Keep the tunnel open in a separate screen/tmux:
# tsh ssh -L 8555:127.0.0.1:8545 0xalizk@ubt-node
set -euo pipefail
RPC_URL="${RPC_URL:-http://127.0.0.1:8545}"
ETHREX=~/sharded-pir/binary-node/ethrex/target/release/ethrex
DATADIR=~/sharded-pir/binary-node/bn-datadir
echo "catch-up-loop: source=$RPC_URL binary=$ETHREX"
# Raise FD limit; fall back to sudo prlimit if hard limit is too low.
FD_OK=0
ulimit -n 1048576 2>/dev/null && FD_OK=1
if [[ $FD_OK -eq 0 ]]; then
echo "ulimit -n 1048576 failed (hard limit=$(ulimit -Hn)); will use sudo prlimit per run."
fi
run_catchup() {
if [[ $FD_OK -eq 1 ]]; then
"$ETHREX" --datadir "$DATADIR" --network mainnet catch-up "$RPC_URL"
else
sudo prlimit --nofile=1048576:1048576 \
"$ETHREX" --datadir "$DATADIR" --network mainnet catch-up "$RPC_URL"
fi
}
attempt=0
while true; do
attempt=$((attempt + 1))
echo "[$(date -u +%FT%TZ)] attempt #$attempt — running catch-up against $RPC_URL"
run_catchup && status=0 || status=$?
echo "[$(date -u +%FT%TZ)] catch-up exited (status=$status)"
if [[ $status -eq 0 ]]; then
echo "catch-up reached tip cleanly — re-running to close the gap."
else
echo "catch-up crashed (status=$status) — sleeping 10s then resuming."
sleep 10
fi
done