diff --git a/scripts/run-demo.sh b/scripts/run-demo.sh new file mode 100755 index 0000000..180edaa --- /dev/null +++ b/scripts/run-demo.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash +set -euo pipefail + +# All-in-one helper: prepare circuits (Linux + host), rebuild the image, and run +# the chosen runner binary. +# +# Usage: scripts/run-demo.sh [compose|local|k8s] [run-seconds] +# compose -> runs examples/src/bin/compose_runner.rs (default) +# local -> runs examples/src/bin/local_runner.rs +# k8s -> runs examples/src/bin/k8s_runner.rs +# run-seconds defaults to 60 +# +# Env overrides: +# VERSION - circuits version (default v0.3.1) +# NOMOS_TESTNET_IMAGE - image tag (default nomos-testnet:local) +# NOMOS_CIRCUITS_PLATFORM - override host platform detection +# NOMOS_CIRCUITS_REBUILD_RAPIDSNARK - set to 1 to force rapidsnark rebuild +# NOMOS_NODE_REV - nomos-node git rev for local binaries (default 2f60a0372c228968c3526c341ebc7e58bbd178dd) + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +MODE="${1:-compose}" +RUN_SECS="${2:-60}" +VERSION="${VERSION:-v0.3.1}" +IMAGE="${NOMOS_TESTNET_IMAGE:-nomos-testnet:local}" +NOMOS_NODE_REV="${NOMOS_NODE_REV:-2f60a0372c228968c3526c341ebc7e58bbd178dd}" + +case "$MODE" in + compose) BIN="compose_runner" ;; + local) BIN="local_runner" ;; + k8s) BIN="k8s_runner" ;; + *) echo "Unknown mode '$MODE' (use compose|local)" >&2; exit 1 ;; +esac + +ensure_host_binaries() { + # Build nomos-node/nomos-executor for the host if not already present. + HOST_SRC="${ROOT_DIR}/.tmp/nomos-node-host-src" + HOST_TARGET="${ROOT_DIR}/.tmp/nomos-node-host-target" + HOST_NODE_BIN_DEFAULT="${HOST_TARGET}/debug/nomos-node" + HOST_EXEC_BIN_DEFAULT="${HOST_TARGET}/debug/nomos-executor" + + if [ -n "${NOMOS_NODE_BIN:-}" ] && [ -x "${NOMOS_NODE_BIN}" ] && [ -x "${NOMOS_EXECUTOR_BIN:-}" ]; then + echo "Using provided host binaries:" + echo " NOMOS_NODE_BIN=${NOMOS_NODE_BIN}" + echo " NOMOS_EXECUTOR_BIN=${NOMOS_EXECUTOR_BIN}" + return + fi + + if [ -x "${HOST_NODE_BIN_DEFAULT}" ] && [ -x "${HOST_EXEC_BIN_DEFAULT}" ]; then + echo "Host binaries already built at ${HOST_TARGET}" + NOMOS_NODE_BIN="${HOST_NODE_BIN_DEFAULT}" + NOMOS_EXECUTOR_BIN="${HOST_EXEC_BIN_DEFAULT}" + export NOMOS_NODE_BIN NOMOS_EXECUTOR_BIN + return + fi + + echo "Building host nomos-node/nomos-executor from ${NOMOS_NODE_REV}" + mkdir -p "${HOST_SRC}" + if [ ! -d "${HOST_SRC}/.git" ]; then + git clone https://github.com/logos-co/nomos-node.git "${HOST_SRC}" + fi + ( + cd "${HOST_SRC}" + git fetch --depth 1 origin "${NOMOS_NODE_REV}" + git checkout "${NOMOS_NODE_REV}" + git reset --hard + git clean -fdx + RUSTFLAGS='--cfg feature="pol-dev-mode"' \ + NOMOS_CIRCUITS="${HOST_BUNDLE_PATH}" \ + cargo build --features "testing" \ + -p nomos-node -p nomos-executor -p nomos-cli \ + --target-dir "${HOST_TARGET}" + ) + NOMOS_NODE_BIN="${HOST_NODE_BIN_DEFAULT}" + NOMOS_EXECUTOR_BIN="${HOST_EXEC_BIN_DEFAULT}" + export NOMOS_NODE_BIN NOMOS_EXECUTOR_BIN +} + +echo "==> Preparing circuits (version ${VERSION})" +SETUP_OUT="/tmp/nomos-setup-output.$$" +"${ROOT_DIR}/scripts/setup-circuits-stack.sh" "${VERSION}" Rebuilding testnet image (${IMAGE})" + "${ROOT_DIR}/testing-framework/assets/stack/scripts/build_test_image.sh" +fi + +if [ "$MODE" = "local" ]; then + ensure_host_binaries +fi + +echo "==> Running ${BIN} for ${RUN_SECS}s" +cd "${ROOT_DIR}" +POL_PROOF_DEV_MODE=true \ +NOMOS_TESTNET_IMAGE="${IMAGE}" \ +NOMOS_CIRCUITS="${HOST_BUNDLE_PATH}" \ +NOMOS_KZGRS_PARAMS_PATH="${HOST_BUNDLE_PATH}/kzgrs_test_params" \ +COMPOSE_DEMO_RUN_SECS="${RUN_SECS}" \ +LOCAL_DEMO_RUN_SECS="${RUN_SECS}" \ +K8S_DEMO_RUN_SECS="${RUN_SECS}" \ +NOMOS_NODE_BIN="${NOMOS_NODE_BIN:-}" \ +NOMOS_EXECUTOR_BIN="${NOMOS_EXECUTOR_BIN:-}" \ + cargo run -p runner-examples --bin "${BIN}" diff --git a/scripts/setup-circuits-stack.sh b/scripts/setup-circuits-stack.sh new file mode 100755 index 0000000..2354ac8 --- /dev/null +++ b/scripts/setup-circuits-stack.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash +set -euo pipefail + +# One-stop helper to prepare circuits for both the Docker image (Linux/x86_64) +# and the host (for witness generators). It populates +# testing-framework/assets/stack/kzgrs_test_params with a Linux bundle for the +# image, and if the host is not Linux/x86_64, it also fetches a host-native +# bundle and tells you where to point NOMOS_CIRCUITS. +# +# Usage: scripts/setup-circuits-stack.sh [VERSION] +# VERSION defaults to v0.3.1 +# +# Env overrides: +# STACK_DIR - where to place the Linux bundle (default: testing-framework/assets/stack/kzgrs_test_params) +# HOST_DIR - where to place the host bundle (default: .tmp/nomos-circuits-host) +# NOMOS_CIRCUITS_PLATFORM - force host platform (e.g., macos-aarch64) +# NOMOS_CIRCUITS_REBUILD_RAPIDSNARK - set to 1 to force rebuild (not needed for mac arm/x86 bundles) + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +VERSION="${1:-v0.3.1}" +STACK_DIR="${STACK_DIR:-${ROOT_DIR}/testing-framework/assets/stack/kzgrs_test_params}" +HOST_DIR="${HOST_DIR:-${ROOT_DIR}/.tmp/nomos-circuits-host}" +NOMOS_NODE_REV="${NOMOS_NODE_REV:-2f60a0372c228968c3526c341ebc7e58bbd178dd}" + +detect_platform() { + local os arch + case "$(uname -s)" in + Linux*) os="linux" ;; + Darwin*) os="macos" ;; + MINGW*|MSYS*|CYGWIN*) os="windows" ;; + *) echo "Unsupported OS: $(uname -s)" >&2; exit 1 ;; + esac + + case "$(uname -m)" in + x86_64) arch="x86_64" ;; + aarch64|arm64) arch="aarch64" ;; + *) echo "Unsupported arch: $(uname -m)" >&2; exit 1 ;; + esac + + echo "${os}-${arch}" +} + +fetch_bundle() { + local platform="$1" + local dest="$2" + local rebuild="${3:-0}" + + rm -rf "$dest" + mkdir -p "$dest" + + NOMOS_CIRCUITS_PLATFORM="$platform" \ + NOMOS_CIRCUITS_REBUILD_RAPIDSNARK="$rebuild" \ + "${ROOT_DIR}/scripts/setup-nomos-circuits.sh" "$VERSION" "$dest" +} + +fetch_kzg_params() { + local dest_dir="$1" + local dest_file="${dest_dir}/kzgrs_test_params" + local url="https://raw.githubusercontent.com/logos-co/nomos-node/${NOMOS_NODE_REV}/tests/kzgrs/kzgrs_test_params" + + echo "Fetching KZG parameters from ${url}" + curl -fsSL "$url" -o "$dest_file" +} + +echo "Preparing circuits (version ${VERSION})" +echo "Workspace: ${ROOT_DIR}" + +LINUX_PLATFORM="linux-x86_64" + +echo "Installing Linux bundle for Docker image into ${STACK_DIR}" +tmp_linux="$(mktemp -d)" +fetch_bundle "$LINUX_PLATFORM" "$tmp_linux" 0 +rm -rf "$STACK_DIR" +mkdir -p "$STACK_DIR" +cp -R "${tmp_linux}/." "$STACK_DIR/" +rm -rf "$tmp_linux" +fetch_kzg_params "$STACK_DIR" +echo "Linux bundle ready at ${STACK_DIR}" + +host_platform="${NOMOS_CIRCUITS_PLATFORM:-$(detect_platform)}" +if [[ "$host_platform" == "$LINUX_PLATFORM" ]]; then + echo "Host platform ${host_platform} matches Linux bundle; host can reuse ${STACK_DIR}" + echo "Export if you want to be explicit:" + echo " export NOMOS_CIRCUITS=\"${STACK_DIR}\"" +else + echo "Host platform detected: ${host_platform}; installing host-native bundle into ${HOST_DIR}" + fetch_bundle "$host_platform" "$HOST_DIR" "${NOMOS_CIRCUITS_REBUILD_RAPIDSNARK:-0}" + fetch_kzg_params "$HOST_DIR" + echo "Host bundle ready at ${HOST_DIR}" + echo + echo "Set for host runs:" + echo " export NOMOS_CIRCUITS=\"${HOST_DIR}\"" +fi + +cat <<'EOF' + +Done. +- For Docker/compose: rebuild the image to bake the Linux bundle: + testing-framework/assets/stack/scripts/build_test_image.sh +- For host runs (e.g., compose_runner): ensure NOMOS_CIRCUITS points to the host bundle above. +EOF diff --git a/testing-framework/core/src/scenario/cfgsync.rs b/testing-framework/core/src/scenario/cfgsync.rs index 8e91473..60f3656 100644 --- a/testing-framework/core/src/scenario/cfgsync.rs +++ b/testing-framework/core/src/scenario/cfgsync.rs @@ -90,7 +90,7 @@ pub fn apply_topology_overrides( cfg.old_blobs_check_interval = da.old_blobs_check_interval; cfg.blobs_validity_duration = da.blobs_validity_duration; cfg.global_params_path = if use_kzg_mount { - "/kzgrs_test_params/pol/proving_key.zkey".into() + "/kzgrs_test_params/kzgrs_test_params".into() } else { da.global_params_path.clone() };