igneum/infra/devnet/restart-hand-nodes.sh
igneum-labs 7943f83c17 Devnet hands under launchd: hands-launchd.sh (plists, kickstart, status), restart-hand-nodes.sh hands the start to it; CLAUDE.md rule
6 October 2026, 18:2x UK: the desktop app crashed and both hand nodes, nohup children of agent shells, died with it for about 70 minutes. A LaunchAgent per hand (KeepAlive, RunAtLoad, ThrottleInterval 10, logs under ~/Library/Logs/Igneum) keeps them up; every restart goes through launchctl and prints the pids with parent 1, versions, digests and exec tips.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 18:52:33 +00:00

44 lines
4.5 KiB
Bash
Executable file

#!/usr/bin/env bash
# Restarts the two hand-run devnet nodes on this Mac (the observer, then node 1) on the 2b6d23ef node binary with
# the override file given as ONE JSON argument, the exact object the update manifest's consensus.override carries
# (docs/plans/fee-switch-devnet.md). Both nodes must print the same consensus digest as every app node before the
# fee switch height, or the handshake splits the network (docs/plans/release-0.3.6.md section 7).
# infra/devnet/restart-hand-nodes.sh '{"difficulty_v2_activation_daa":33000,"proving_v0_activation_daa":84100,"fees_v1_activation_daa":210000}'
# Ends by printing the new pids with their start times and the fee and digest lines of each node (5 October 2026
# lesson: a restart script that does not print the new pids has not proven the restart).
set -euo pipefail
OVJSON="${1:?override JSON object}"
BIN="${IGNEUMD:-/Users/joshm/Projects/igneum/vendor/igneum-node/target-036/release/igneumd}"
# the fork commit the binary must carry (0.3.9: a24ab01a, release-0.3.6 with txgen-export; 2b6d23ef read the switch too)
COMMIT="${IGNEUMD_COMMIT:-a24ab01a}"
OV=/tmp/igneum-devnet/override-v3.json
# 6 October 2026 (the exec recovery after the 15:44Z reorg): IGNEUMD_EXEC_SNAPSHOT="<path>,<sha256>" adds --igneum-exec-snapshot
# to both nodes (the exec state to start from when the data dir's own file is bad or missing); IGNEUM_EXEC_RESET=1 deletes each
# node's persisted exec files (exec-snapshot.bin, the tip-0 file a genesis replay writes, and exec-snapshot.prev.bin) after the
# stop, so the start takes the flag's file and not the bad one. Both off by default.
SNAP="${IGNEUMD_EXEC_SNAPSHOT:-}"; SNAPARG=""; [ -n "$SNAP" ] && SNAPARG="--igneum-exec-snapshot=$SNAP"
reset_exec() { if [ "${IGNEUM_EXEC_RESET:-0}" = 1 ]; then rm -f "$1/igneum-devnet/datadir/evm/exec-snapshot.bin" "$1/igneum-devnet/datadir/evm/exec-snapshot.prev.bin"; echo "exec files reset under $1"; fi; }
echo "$OVJSON" | python3 -c 'import json,sys; o=json.load(sys.stdin); assert isinstance(o, dict) and "fees_v1_activation_daa" in o, "the object must carry fees_v1_activation_daa"; print("override:", json.dumps(o, sort_keys=True))'
# grep -c, not grep -q: -q closes the pipe early and pipefail turns strings' SIGPIPE into a refusal of a good binary (5 October 2026, 17:48Z)
[ "$(strings "$BIN" | grep -c "$COMMIT")" -gt 0 ] || { echo "$BIN is not the $COMMIT node (a 0.3.5 node refuses an override file with fees_v1_activation_daa)"; exit 1; }
cp -p "$OV" "$OV.prev-$(date -u +%Y%m%dT%H%M%SZ)" 2>/dev/null || true
printf '%s\n' "$OVJSON" > "$OV"
# the pid is an igneumd process, never a shell whose command line carries the pattern's text (6 October 2026: pgrep -f matched the
# caller's own zsh -c "..." and the stop waited 11 minutes on it)
stop() { local p; p=$( { for c in $(pgrep -f "$1" || true); do if [ "$(ps -o comm= -p "$c" 2>/dev/null | xargs basename 2>/dev/null)" = igneumd ]; then echo "$c"; fi; done; true; } | head -1 ); if [ -n "$p" ]; then kill -INT "$p"; while kill -0 "$p" 2>/dev/null; do sleep 1; done; fi; } # the filter never fails the pipeline (17:43Z: a trailing caffeinate pid made the loop exit 1 and set -e ended the script before node 1)
lines() { sleep 10; grep -E "Calibrated v1 fees from the override file|Fees on igneum-devnet|Consensus params digest" "$1" | tail -3 || true; }
# 6 October 2026, 19:5x UK: the hands run under launchd (infra/devnet/hands-launchd.sh; a LaunchAgent per hand, KeepAlive), never
# as children of this shell: the desktop app's crash at 18:2x UK took both nohup children down for about 70 minutes. This
# script keeps the object check, the override file and the binary pin, then hands the start to launchd: each hand is booted
# out (and any stray igneumd outside launchd stopped), its exec files reset if asked, and `hands-launchd.sh install` writes
# the plists for THIS binary, starts the observer, waits for its evm port, then node 1, and reads both back.
HERE="$(cd "$(dirname "$0")" && pwd)"
for label in network.igneum.devnet.observer network.igneum.devnet.node1; do launchctl bootout "gui/$(id -u)/$label" 2>/dev/null || true; done
stop "igneumd --devnet.*observer-v4"
stop "igneumd --devnet.*appdir=/tmp/igneum-devnet/node1 "
reset_exec /tmp/igneum-devnet/observer-v4
reset_exec /tmp/igneum-devnet/node1
"$HERE/hands-launchd.sh" install "$BIN" "$SNAP"
lines "$HOME/Library/Logs/Igneum/observer.out"
lines "$HOME/Library/Logs/Igneum/node1.out"
echo "running now (launchd children, parent pid 1):"; ps -o pid=,ppid=,lstart=,command= -p "$(pgrep -f 'igneumd --devnet' | tr '\n' ',' | sed 's/,$//')" | cut -c1-160