220 lines
7.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
say() { printf "%s\n" "$*"; }
section() { printf "\n==> %s\n" "$*"; }
have() { command -v "$1" >/dev/null 2>&1; }
bytes_to_human() {
local bytes="${1:-0}"
local kib=$((1024))
local mib=$((1024 * 1024))
local gib=$((1024 * 1024 * 1024))
if [ "$bytes" -ge "$gib" ]; then
awk -v b="$bytes" 'BEGIN{printf "%.1fGiB", b/1024/1024/1024}'
elif [ "$bytes" -ge "$mib" ]; then
awk -v b="$bytes" 'BEGIN{printf "%.1fMiB", b/1024/1024}'
elif [ "$bytes" -ge "$kib" ]; then
awk -v b="$bytes" 'BEGIN{printf "%.1fKiB", b/1024}'
else
printf "%sB" "$bytes"
fi
}
warn() { say "WARN: $*"; }
ok() { say "OK: $*"; }
section "Workspace"
say "root: ${ROOT_DIR}"
if [ -f "${ROOT_DIR}/versions.env" ]; then
# shellcheck disable=SC1091
. "${ROOT_DIR}/versions.env"
ok "versions.env present"
say "VERSION=${VERSION:-<unset>}"
say "NOMOS_NODE_REV=${NOMOS_NODE_REV:-<unset>}"
if [ -n "${NOMOS_NODE_PATH:-}" ]; then
say "NOMOS_NODE_PATH=${NOMOS_NODE_PATH}"
fi
else
warn "versions.env missing (scripts depend on it)"
fi
if [ -f "${ROOT_DIR}/paths.env" ]; then
# shellcheck disable=SC1091
. "${ROOT_DIR}/paths.env"
ok "paths.env present"
fi
section "Disk Space"
if have df; then
df -h "${ROOT_DIR}" | sed -n '1,2p'
fi
tmp_dir="${ROOT_DIR}/.tmp"
if [ -d "${tmp_dir}" ]; then
if have du; then
say ".tmp size: $(du -sh "${tmp_dir}" 2>/dev/null | awk '{print $1}')"
fi
else
say ".tmp: <absent>"
fi
if [ -d "${ROOT_DIR}/target" ] && have du; then
say "target size: $(du -sh "${ROOT_DIR}/target" 2>/dev/null | awk '{print $1}')"
fi
section "KZG Params"
KZG_DIR_REL="${NOMOS_KZG_DIR_REL:-testing-framework/assets/stack/kzgrs_test_params}"
KZG_FILE="${NOMOS_KZG_FILE:-kzgrs_test_params}"
KZG_CONTAINER_PATH="${NOMOS_KZG_CONTAINER_PATH:-/kzgrs_test_params/kzgrs_test_params}"
HOST_KZG_PATH="${ROOT_DIR}/${KZG_DIR_REL}/${KZG_FILE}"
say "host: ${HOST_KZG_PATH}"
say "container: ${KZG_CONTAINER_PATH}"
if [ -f "${HOST_KZG_PATH}" ]; then
ok "KZG params file exists"
else
warn "KZG params file missing (DA workloads will fail); run: scripts/run-examples.sh <mode> (auto) or scripts/setup-nomos-circuits.sh"
fi
section "Rust Toolchain"
if have rustup; then
ok "rustup: $(rustup --version | head -n1)"
if [ -f "${ROOT_DIR}/rust-toolchain.toml" ]; then
channel="$(awk -F '\"' '/^[[:space:]]*channel[[:space:]]*=/{print $2; exit}' "${ROOT_DIR}/rust-toolchain.toml" 2>/dev/null || true)"
say "rust-toolchain.toml channel: ${channel:-<unknown>}"
fi
elif have rustc; then
ok "rustc: $(rustc --version)"
else
warn "rust toolchain not found (rustup/rustc missing)"
fi
section "Docker (compose/k8s image + linux bundle builds)"
if have docker; then
ok "docker client: $(docker version --format '{{.Client.Version}}' 2>/dev/null || docker --version)"
server_arch="$(docker version --format '{{.Server.Os}}/{{.Server.Arch}}' 2>/dev/null || true)"
if [ -n "${server_arch}" ]; then
say "docker engine: ${server_arch}"
else
warn "could not query docker engine arch (is Docker running?)"
fi
bundle_platform="${NOMOS_BUNDLE_DOCKER_PLATFORM:-${NOMOS_BIN_PLATFORM:-}}"
if [ -z "${bundle_platform}" ]; then
say "NOMOS_BUNDLE_DOCKER_PLATFORM=<auto>"
if [[ "${server_arch}" == *"linux/arm64"* ]]; then
say "bundle docker platform (auto): linux/arm64"
else
say "bundle docker platform (auto): linux/amd64"
fi
bundle_platform="auto"
else
say "NOMOS_BUNDLE_DOCKER_PLATFORM=${bundle_platform}"
fi
if [[ "${server_arch}" == *"linux/arm64"* ]] && [ "${bundle_platform}" = "linux/amd64" ]; then
warn "Docker engine is linux/arm64 but bundle platform is linux/amd64 (emulation). If builds are slow/flaky, set: NOMOS_BUNDLE_DOCKER_PLATFORM=linux/arm64"
fi
image="${NOMOS_TESTNET_IMAGE:-logos-blockchain-testing:local}"
say "NOMOS_TESTNET_IMAGE=${image}"
if docker image inspect "${image}" >/dev/null 2>&1; then
ok "testnet image present locally"
else
warn "testnet image not present locally (compose/k8s runs will rebuild or fail if NOMOS_SKIP_IMAGE_BUILD=1)"
fi
else
warn "docker not found (compose/k8s unavailable; linux bundle build on macOS requires docker)"
fi
section "Docker Compose"
if have docker; then
if docker compose version >/dev/null 2>&1; then
ok "docker compose available"
else
warn "docker compose not available"
fi
fi
section "Kubernetes (k8s runner)"
if have kubectl; then
ok "kubectl: $(kubectl version --client=true --short 2>/dev/null || true)"
ctx="$(kubectl config current-context 2>/dev/null || true)"
if [ -n "${ctx}" ]; then
say "current-context: ${ctx}"
fi
if kubectl cluster-info >/dev/null 2>&1; then
ok "cluster reachable"
kubectl get nodes -o wide 2>/dev/null | sed -n '1,3p' || true
else
warn "cluster not reachable (k8s runner will skip with ClientInit error)"
fi
else
warn "kubectl not found (k8s runner unavailable)"
fi
if have helm; then
ok "helm: $(helm version --short 2>/dev/null || true)"
else
warn "helm not found (k8s runner uses helm)"
fi
section "K8s Image Visibility"
image="${NOMOS_TESTNET_IMAGE:-logos-blockchain-testing:local}"
if [ -n "${ctx:-}" ]; then
case "${ctx}" in
docker-desktop)
ok "docker-desktop context shares local Docker images"
;;
kind-*)
if [[ "${image}" == *":local" ]]; then
warn "kind cluster won't see local Docker images by default"
say "Suggested: kind load docker-image ${image}"
fi
;;
minikube)
if [[ "${image}" == *":local" ]]; then
warn "minikube may not see local Docker images by default"
say "Suggested: minikube image load ${image}"
fi
;;
*)
if [[ "${image}" == *":local" ]]; then
warn "current context is ${ctx}; a :local image tag may not be reachable by cluster nodes"
say "Suggested: push to a registry and set NOMOS_TESTNET_IMAGE, or load into the cluster if supported"
fi
;;
esac
fi
section "Docker Desktop Kubernetes Health (best-effort)"
if have kubectl && [ "${ctx:-}" = "docker-desktop" ]; then
if ! kubectl -n kube-system get pod storage-provisioner >/dev/null 2>&1; then
warn "storage-provisioner pod not found"
else
phase="$(kubectl -n kube-system get pod storage-provisioner -o jsonpath='{.status.phase}' 2>/dev/null || true)"
reason="$(kubectl -n kube-system get pod storage-provisioner -o jsonpath='{.status.containerStatuses[0].state.waiting.reason}' 2>/dev/null || true)"
if [ "${phase}" = "Running" ] || [ "${phase}" = "Succeeded" ]; then
ok "storage-provisioner: ${phase}"
else
warn "storage-provisioner: ${phase:-<unknown>} ${reason}"
fi
fi
fi
section "Runner Debug Flags (optional)"
say "SLOW_TEST_ENV=${SLOW_TEST_ENV:-<unset>} (if true: doubles readiness timeouts)"
say "NOMOS_SKIP_IMAGE_BUILD=${NOMOS_SKIP_IMAGE_BUILD:-<unset>} (compose/k8s)"
say "COMPOSE_RUNNER_PRESERVE=${COMPOSE_RUNNER_PRESERVE:-<unset>} (compose)"
say "K8S_RUNNER_PRESERVE=${K8S_RUNNER_PRESERVE:-<unset>} (k8s)"
say "K8S_RUNNER_DEBUG=${K8S_RUNNER_DEBUG:-<unset>} (k8s helm debug)"
say "COMPOSE_RUNNER_HOST=${COMPOSE_RUNNER_HOST:-<unset>} (compose readiness host override)"
say "K8S_RUNNER_NODE_HOST=${K8S_RUNNER_NODE_HOST:-<unset>} (k8s NodePort host override)"
say "K8S_RUNNER_NAMESPACE=${K8S_RUNNER_NAMESPACE:-<unset>} (k8s fixed namespace)"
section "Done"
say "If something looks off, start with: scripts/run-examples.sh <mode> -t 60 -v 1 -e 1"