mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-02 13:23:13 +00:00
135 lines
4.6 KiB
Bash
Executable File
135 lines
4.6 KiB
Bash
Executable File
#!/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)"
|
|
if [ -f "${ROOT_DIR}/versions.env" ]; then
|
|
# shellcheck disable=SC1091
|
|
. "${ROOT_DIR}/versions.env"
|
|
fi
|
|
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}"
|
|
LINUX_DIR_REL_DEFAULT="${NOMOS_CIRCUITS_LINUX_DIR_REL:-.tmp/nomos-circuits-linux}"
|
|
LINUX_STAGE_DIR="${LINUX_STAGE_DIR:-${ROOT_DIR}/${LINUX_DIR_REL_DEFAULT}}"
|
|
HOST_DIR_REL_DEFAULT="${NOMOS_CIRCUITS_HOST_DIR_REL:-.tmp/nomos-circuits-host}"
|
|
VERSION="${1:-${VERSION:-v0.3.1}}"
|
|
STACK_DIR="${STACK_DIR:-${ROOT_DIR}/${KZG_DIR_REL}}"
|
|
HOST_DIR="${HOST_DIR:-${ROOT_DIR}/${HOST_DIR_REL_DEFAULT}}"
|
|
NOMOS_NODE_REV="${NOMOS_NODE_REV:-d2dd5a5084e1daef4032562c77d41de5e4d495f8}"
|
|
|
|
# Force non-interactive installs so repeated runs do not prompt.
|
|
export NOMOS_CIRCUITS_NONINTERACTIVE=1
|
|
|
|
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}/${KZG_FILE}"
|
|
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}"
|
|
stage_real="$(python3 - <<'PY'
|
|
import os, sys
|
|
print(os.path.realpath(sys.argv[1]))
|
|
PY "${LINUX_STAGE_DIR}")"
|
|
stack_real="$(python3 - <<'PY'
|
|
import os, sys
|
|
print(os.path.realpath(sys.argv[1]))
|
|
PY "${STACK_DIR}")"
|
|
|
|
if [ "$stage_real" = "$stack_real" ]; then
|
|
# No staging copy needed; install directly into STACK_DIR.
|
|
rm -rf "$STACK_DIR"
|
|
fetch_bundle "$LINUX_PLATFORM" "$STACK_DIR" 0
|
|
fetch_kzg_params "$STACK_DIR"
|
|
else
|
|
rm -rf "${LINUX_STAGE_DIR}"
|
|
mkdir -p "${LINUX_STAGE_DIR}"
|
|
fetch_bundle "$LINUX_PLATFORM" "${LINUX_STAGE_DIR}" 0
|
|
rm -rf "$STACK_DIR"
|
|
mkdir -p "$STACK_DIR"
|
|
cp -R "${LINUX_STAGE_DIR}/." "$STACK_DIR/"
|
|
fetch_kzg_params "$STACK_DIR"
|
|
fi
|
|
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
|