2025-12-04 12:44:32 +01:00
|
|
|
#!/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)"
|
2025-12-09 15:38:33 +01:00
|
|
|
if [ -f "${ROOT_DIR}/versions.env" ]; then
|
|
|
|
|
# shellcheck disable=SC1091
|
|
|
|
|
. "${ROOT_DIR}/versions.env"
|
|
|
|
|
fi
|
2025-12-09 16:03:19 +01:00
|
|
|
if [ -f "${ROOT_DIR}/paths.env" ]; then
|
|
|
|
|
# shellcheck disable=SC1091
|
|
|
|
|
. "${ROOT_DIR}/paths.env"
|
|
|
|
|
fi
|
|
|
|
|
KZG_DIR_REL="${NOMOS_KZG_DIR_REL:-testing-framework/assets/stack/kzgrs_test_params}"
|
|
|
|
|
KZG_FILE="${NOMOS_KZG_FILE:-kzgrs_test_params}"
|
|
|
|
|
HOST_DIR_REL_DEFAULT="${NOMOS_CIRCUITS_HOST_DIR_REL:-.tmp/nomos-circuits-host}"
|
2025-12-09 15:38:33 +01:00
|
|
|
VERSION="${1:-${VERSION:-v0.3.1}}"
|
2025-12-09 16:03:19 +01:00
|
|
|
STACK_DIR="${STACK_DIR:-${ROOT_DIR}/${KZG_DIR_REL}}"
|
|
|
|
|
HOST_DIR="${HOST_DIR:-${ROOT_DIR}/${HOST_DIR_REL_DEFAULT}}"
|
2025-12-06 10:17:06 +01:00
|
|
|
NOMOS_NODE_REV="${NOMOS_NODE_REV:-d2dd5a5084e1daef4032562c77d41de5e4d495f8}"
|
2025-12-04 12:44:32 +01:00
|
|
|
|
|
|
|
|
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"
|
2025-12-09 16:03:19 +01:00
|
|
|
local dest_file="${dest_dir}/${KZG_FILE}"
|
2025-12-04 12:44:32 +01:00
|
|
|
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
|