LAN-only 3-node testnet compose, paced miner and helper script under deploy/night. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.7 KiB
Bash
Executable File
33 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# sim-testnet: private 3-node testnet fixture for WikiDeck Night 1 (poweredge-r350, LAN only).
|
|
# Usage (from the repo root):
|
|
# deploy/night/testnet.sh up build the image from this checkout and (re)start the 3 nodes
|
|
# deploy/night/testnet.sh mine N [W] mine N real RandomX blocks with W workers (default 4, max 8)
|
|
# deploy/night/testnet.sh status tip/height of each node
|
|
# deploy/night/testnet.sh down stop the nodes (volumes, i.e. the ledgers, are kept)
|
|
# STATE_DIR (default ~/.local/share/wikideck-night) holds the disposable testnet wallets and mined.log.
|
|
# It is outside the repo on purpose: never commit wallets.
|
|
set -eu
|
|
P=wikideck-night
|
|
LAN_IP=${LAN_IP:-192.168.1.32}
|
|
STATE_DIR=${STATE_DIR:-$HOME/.local/share/wikideck-night}
|
|
DC="docker compose -p $P -f compose.testnet.yaml -f deploy/night/compose.lan.yaml"
|
|
case "${1:-}" in
|
|
up) $DC build node-a && $DC up -d --no-build ;;
|
|
down) $DC down ;;
|
|
mine)
|
|
mkdir -p "$STATE_DIR"
|
|
W=${3:-4}
|
|
docker rm -f $P-miner >/dev/null 2>&1 || true
|
|
docker run -d --name $P-miner --network ${P}_default --cpus "$W" --memory 1600m \
|
|
--user "$(id -u):$(id -g)" -e WIKIDECK_NETWORK=testnet -e WIKIDECK_GENESIS_TIME=1792411200 \
|
|
-e MIN_GAP="${MIN_GAP:-45}" -v "$STATE_DIR":/state -v "$PWD/deploy/night":/night:ro \
|
|
wikideck:testnet node --experimental-strip-types /night/mine.ts "$2" "$W"
|
|
echo "follow with: docker logs -f $P-miner" ;;
|
|
status)
|
|
for port in 3101 3102 3103; do
|
|
docker run --rm --network host wikideck:testnet node -e "fetch('http://$LAN_IP:$port/p2p/status').then(r=>r.json()).then(s=>console.log($port,'blocks',s.size,'tip',s.tip.slice(0,16))).catch(e=>console.log($port,'DOWN',e.message))"
|
|
done ;;
|
|
*) sed -n 2,9p "$0"; exit 1 ;;
|
|
esac
|