#!/usr/bin/env bash # Devnet 3 (0.3.22) on igneum-build-1: the seed as a bare process and the hands' second instances. Dry run by default, --go executes. # infra/build-server/devnet3/devnet3.sh seed [--go] start the Devnet 3 seed (empty datadir, NET_FLAGS, the seed ports), read back # infra/build-server/devnet3/devnet3.sh node1 [--go] a second node1 instance on Devnet 3 (own datadir and ports), read back # infra/build-server/devnet3/devnet3.sh observer-node [--go] the same for the observer node (p2p on loopback, peers node1-dn3) # infra/build-server/devnet3/devnet3.sh status pids, ports, digest and genesis lines of the three # Read-back per instance: the first log line (igneumd/-), the commit string count in the running binary, the # "Consensus params digest" line (the devnet-3 digest), the "[igneum-exec] genesis executed" line, the GRPC and P2P server # lines. No unit yet: the processes are detached (setsid nohup) under the build user like the Devnet 2 seed; units follow once the # network is green. The old devnet's node1 and observer-node are not touched. set -euo pipefail HERE=$(cd "$(dirname "$0")" && pwd); . "$HERE/devnet3.env" KEY="${IGNEUM_BUILD_KEY:-$HOME/.ssh/igneum_ed25519}"; HOST=$(head -1 "${IGNEUM_BUILD_HOST_FILE:-$HOME/.config/igneum/build-server}" | tr -d '[:space:]') SSH=(ssh -i "$KEY" -o BatchMode=yes -o ConnectTimeout=15 "$HOST") say() { echo "$(TZ=Europe/London date '+%H:%M:%S %Z') devnet3: $*" >&2; } mode="${1:-}"; shift || true; GO=0; [ "${1:-}" = --go ] && GO=1 case "$NET_FLAGS" in *suffix=3*) say "NET_FLAGS is still the placeholder ($NET_FLAGS): the node lane's flag goes into devnet3.env first" ;; esac case "$IGNEUMD" in *PLACEHOLDER*) [ "$mode" = status ] || { say "IGNEUMD is the placeholder: the 0.3.22 candidate's build fills it"; [ "$GO" = 0 ] || exit 1; } ;; esac start_one() { # [extra args...] local name="$1" appdir="$2" p2p="$3" rpc="$4" json="$5" evm="$6" log="$7"; shift 7 local args="$NET_FLAGS --appdir=$appdir --rpclisten=127.0.0.1:$rpc --rpclisten-json=127.0.0.1:$json --evm-rpclisten=127.0.0.1:$evm --listen=$p2p --nodnsseed --disable-upnp --nologfiles --yes $*" if [ "$GO" = 0 ]; then say "DRY $name: $IGNEUMD $args > $log"; return 0; fi "${SSH[@]}" bash -s -- "$name" "$IGNEUMD" "$appdir" "$log" "$args" <<'REMOTE' set -euo pipefail; name="$1"; bin="$2"; appdir="$3"; log="$4"; args="$5" [ -x "$bin" ] || { echo "no binary $bin"; exit 1; } mkdir -p "$appdir"; [ -z "$(ls -A "$appdir")" ] || echo "note: $appdir is not empty" cd "$(dirname "$log")"; setsid nohup "$bin" $args > "$log" 2>&1 < /dev/null & pid=$!; sleep 8 echo "$name pid $pid alive=$(kill -0 $pid 2>/dev/null && echo yes || echo NO) commit-strings=$(grep -a -c "$(echo "$bin" | grep -oE '[0-9a-f]{8}' | tail -1)" /proc/$pid/exe 2>/dev/null || echo ?)" head -1 "$log" | cut -c1-120; grep -oE "Consensus params digest: [0-9a-f]+" "$log" | head -1 for i in $(seq 1 20); do grep -qE "genesis [0-9a-f]{8,} executed|P2P Server starting" "$log" && break; sleep 1; done grep -oE "genesis [0-9a-f]+ executed" "$log" | head -1; grep -E "GRPC Server starting|P2P Server starting" "$log" | head -2 | cut -c1-100 grep -iE "panic|error" "$log" | head -2 | cut -c1-140 || true REMOTE } case "$mode" in seed) start_one dn3-seed "$DN3_SEED_APPDIR" "0.0.0.0:$DN3_SEED_P2P" "$DN3_SEED_RPC" "$DN3_SEED_JSON" "$DN3_SEED_EVM" "$DN3_SEED_LOG" --maxinpeers=128 --outpeers=8 ;; node1) start_one node1-dn3 "$DN3_NODE1_APPDIR" "0.0.0.0:$DN3_NODE1_P2P" "$DN3_NODE1_RPC" "$DN3_NODE1_JSON" "$DN3_NODE1_EVM" /srv/hands/node1-dn3.log --enable-unsynced-mining --addpeer=127.0.0.1:$DN3_SEED_P2P --maxinpeers=128 --outpeers=8 ;; observer-node) # the fleet lane's instance: its unit (installed 16:39Z, disabled); IGNEUMD_DN3 and DN3_PEERS come from /srv/hands/dn3/dn3.env if [ "$GO" = 0 ]; then say "DRY observer-node: sudo systemctl enable --now igneum-observer-node-dn3 (reads $DN3_OBS_SCRIPT; dn3.env IGNEUMD_DN3 must name the 0.3.22 artefact)"; "${SSH[@]}" 'grep -E "^(IGNEUMD_DN3|DN3_PEERS|DN3_LISTEN)=" /srv/hands/dn3/dn3.env'; else ssh -i "$KEY" -o BatchMode=yes "root@${HOST#*@}" 'systemctl enable --now igneum-observer-node-dn3 && sleep 8 && systemctl is-active igneum-observer-node-dn3 && journalctl -u igneum-observer-node-dn3 --since "-60 s" --no-pager | grep -oE "igneumd/[^ ]+|Consensus params digest: [0-9a-f]+|genesis [0-9a-f]+ executed|P2P Server starting on: [^ ]+" | head -4'; fi ;; status) "${SSH[@]}" "for l in $DN3_SEED_LOG /srv/hands/node1-dn3.log; do [ -f \$l ] && { echo \"== \$l\"; head -1 \$l | cut -c1-100; grep -oE 'Consensus params digest: [0-9a-f]+|genesis [0-9a-f]+ executed' \$l | head -2; tail -1 \$l | cut -c1-120; }; done; ss -ltn | awk '{print \$4}' | grep -E ':(26631|26651|26671|27630|26650|26670)\$' | tr '\n' ' '; echo" ;; *) sed -n '2,12p' "$0" | sed 's/^# \{0,1\}//'; exit 2 ;; esac