Add script build-image.sh (#273)

This commit is contained in:
Han
2026-01-27 11:27:14 +09:00
committed by GitHub
parent a9fb04dea8
commit 54ec4894a6
40 changed files with 591 additions and 205 deletions

181
.github/scripts/build-image.sh vendored Executable file
View File

@@ -0,0 +1,181 @@
#!/bin/bash
set -euo pipefail
# Default values
ZKVM=""
IMAGE_TAG=""
IMAGE_REGISTRY=""
BUILD_BASE=false
BUILD_COMPILER=false
BUILD_SERVER=false
CUDA=false
CUDA_ARCH=""
RUSTFLAGS=""
usage() {
echo "Usage: $0 --zkvm <zkvm> --tag <tag> [--base] [--compiler] [--server] [--registry <registry>] [--cuda] [--cuda-arch <arch>] [--rustflags <flags>]"
echo ""
echo "Required:"
echo " --zkvm <zkvm> zkVM to build for (e.g., zisk, sp1, risc0)"
echo " --tag <tag> Image tag (e.g., 0.1.3, a8d7bc0, local)"
echo ""
echo "Image types (at least one required):"
echo " --base Build the base images"
echo " --compiler Build the compiler image"
echo " --server Build the server image"
echo ""
echo "Optional:"
echo " --registry <reg> Registry prefix (e.g., ghcr.io/eth-act/ere)"
echo " --cuda Enable CUDA support (appends -cuda to tag)"
echo " --cuda-arch <arch> Set CUDA architecture (e.g., sm_120)"
echo " --rustflags <flags> Pass RUSTFLAGS to build"
exit 1
}
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--zkvm)
ZKVM="$2"
shift 2
;;
--tag)
IMAGE_TAG="$2"
shift 2
;;
--registry)
IMAGE_REGISTRY="$2"
shift 2
;;
--base)
BUILD_BASE=true
shift
;;
--compiler)
BUILD_COMPILER=true
shift
;;
--server)
BUILD_SERVER=true
shift
;;
--cuda)
CUDA=true
shift
;;
--cuda-arch)
CUDA_ARCH="$2"
shift 2
;;
--rustflags)
RUSTFLAGS="$2"
shift 2
;;
--help|-h)
usage
;;
*)
echo "Unknown option: $1"
usage
;;
esac
done
# Validate required arguments
if [ -z "$ZKVM" ]; then
echo "Error: --zkvm is required"
usage
fi
if [ -z "$IMAGE_TAG" ]; then
echo "Error: --tag is required"
usage
fi
if [ "$BUILD_BASE" = false ] && [ "$BUILD_COMPILER" = false ] && [ "$BUILD_SERVER" = false ]; then
echo "Error: At least one of --base, --compiler, --server is required"
usage
fi
# Format tag with optional -cuda suffix
if [ "$CUDA" = true ]; then
IMAGE_TAG="${IMAGE_TAG}-cuda"
fi
# Format image prefix
if [ -n "$IMAGE_REGISTRY" ]; then
# Remove trailing slash if present
IMAGE_REGISTRY="${IMAGE_REGISTRY%/}"
IMAGE_PREFIX="${IMAGE_REGISTRY}/"
else
IMAGE_PREFIX=""
fi
# Format image
BASE_IMAGE="${IMAGE_PREFIX}ere-base:${IMAGE_TAG}"
BASE_ZKVM_IMAGE="${IMAGE_PREFIX}ere-base-${ZKVM}:${IMAGE_TAG}"
COMPILER_ZKVM_IMAGE="${IMAGE_PREFIX}ere-compiler-${ZKVM}:${IMAGE_TAG}"
SERVER_ZKVM_IMAGE="${IMAGE_PREFIX}ere-server-${ZKVM}:${IMAGE_TAG}"
# Prepare build arguments
BASE_BUILD_ARGS=()
BASE_ZKVM_BUILD_ARGS=(--build-arg "BASE_IMAGE=$BASE_IMAGE")
COMPILER_ZKVM_BUILD_ARGS=(--build-arg "BASE_ZKVM_IMAGE=$BASE_ZKVM_IMAGE")
SERVER_ZKVM_BUILD_ARGS=(--build-arg "BASE_ZKVM_IMAGE=$BASE_ZKVM_IMAGE")
if [ "$CUDA" = true ]; then
BASE_BUILD_ARGS+=(--build-arg "CUDA=1")
BASE_ZKVM_BUILD_ARGS+=(--build-arg "CUDA=1")
SERVER_ZKVM_BUILD_ARGS+=(--build-arg "CUDA=1")
fi
if [ -n "$CUDA_ARCH" ]; then
BASE_ZKVM_BUILD_ARGS+=(--build-arg "CUDA_ARCH=$CUDA_ARCH")
SERVER_ZKVM_BUILD_ARGS+=(--build-arg "CUDA_ARCH=$CUDA_ARCH")
fi
if [ -n "$RUSTFLAGS" ]; then
BASE_ZKVM_BUILD_ARGS+=(--build-arg "RUSTFLAGS=$RUSTFLAGS")
SERVER_ZKVM_BUILD_ARGS+=(--build-arg "RUSTFLAGS=$RUSTFLAGS")
fi
# Build images
if [ "$BUILD_BASE" = true ]; then
echo "Building base image: $BASE_IMAGE"
docker build \
--file "docker/Dockerfile.base" \
--tag "$BASE_IMAGE" \
"${BASE_BUILD_ARGS[@]}" \
.
echo "Building zkvm base image: $BASE_ZKVM_IMAGE"
docker build \
--file "docker/${ZKVM}/Dockerfile.base" \
--tag "$BASE_ZKVM_IMAGE" \
"${BASE_ZKVM_BUILD_ARGS[@]}" \
.
fi
if [ "$BUILD_COMPILER" = true ]; then
echo "Building zkvm compiler image: $COMPILER_ZKVM_IMAGE"
docker build \
--file "docker/${ZKVM}/Dockerfile.compiler" \
--tag "$COMPILER_ZKVM_IMAGE" \
"${COMPILER_ZKVM_BUILD_ARGS[@]}" \
.
fi
if [ "$BUILD_SERVER" = true ]; then
echo "Building zkvm server image: $SERVER_ZKVM_IMAGE"
docker build \
--file "docker/${ZKVM}/Dockerfile.server" \
--tag "$SERVER_ZKVM_IMAGE" \
"${SERVER_ZKVM_BUILD_ARGS[@]}" \
.
fi
echo "Build complete!"

0
.github/scripts/free-up-disk-space.sh vendored Normal file → Executable file
View File

104
.github/scripts/pull-or-build-base-zkvm-image.sh vendored Normal file → Executable file
View File

@@ -1,38 +1,92 @@
#!/bin/bash
set -e -o pipefail
set -euo pipefail
ZKVM=$1
IMAGE_REGISTRY=$2
IMAGE_TAG=$3
CACHED_IMAGE_TAG=$4
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Default values
ZKVM=""
IMAGE_REGISTRY=""
IMAGE_TAG=""
CACHED_IMAGE_TAG=""
usage() {
echo "Usage: $0 --zkvm <zkvm> --registry <registry> --tag <tag> [--cached-tag <cached-tag>]"
echo ""
echo "Required:"
echo " --zkvm <zkvm> zkVM to build for (e.g., zisk, sp1, risc0)"
echo " --registry <registry> Registry prefix (e.g., ghcr.io/eth-act/ere)"
echo " --tag <tag> Image tag (e.g., 0.1.3, a8d7bc0)"
echo ""
echo "Optional:"
echo " --cached-tag <cached-tag> Cached image tag to try pulling from (skips pull if empty)"
exit 1
}
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--zkvm)
ZKVM="$2"
shift 2
;;
--registry)
IMAGE_REGISTRY="$2"
shift 2
;;
--tag)
IMAGE_TAG="$2"
shift 2
;;
--cached-tag)
CACHED_IMAGE_TAG="$2"
shift 2
;;
--help|-h)
usage
;;
*)
echo "Unknown option: $1"
usage
;;
esac
done
# Validate required arguments
if [ -z "$ZKVM" ]; then
echo "Error: --zkvm is required"
usage
fi
if [ -z "$IMAGE_REGISTRY" ]; then
echo "Error: --registry is required"
usage
fi
if [ -z "$IMAGE_TAG" ]; then
echo "Error: --tag is required"
usage
fi
BASE_IMAGE="$IMAGE_REGISTRY/ere-base:$IMAGE_TAG"
BASE_ZKVM_IMAGE="$IMAGE_REGISTRY/ere-base-$ZKVM:$IMAGE_TAG"
CACHED_BASE_IMAGE="$IMAGE_REGISTRY/ere-base:$CACHED_IMAGE_TAG"
CACHED_BASE_ZKVM_IMAGE="$IMAGE_REGISTRY/ere-base-$ZKVM:$CACHED_IMAGE_TAG"
# Pull or build ere-base locally
if docker image pull $CACHED_BASE_IMAGE; then
# Pull or build ere-base and ere-base-$ZKVM locally
if [ -n "$CACHED_IMAGE_TAG" ] \
&& docker image pull "$CACHED_BASE_IMAGE" \
&& docker image pull "$CACHED_BASE_ZKVM_IMAGE";
then
echo "Tagging ere-base from cache"
docker tag $CACHED_BASE_IMAGE $BASE_IMAGE
else
echo "Building ere-base"
docker build \
--file docker/Dockerfile.base \
--tag $BASE_IMAGE \
.
fi
# Pull or build ere-base-$ZKVM locally
if docker image pull $CACHED_BASE_ZKVM_IMAGE; then
docker tag "$CACHED_BASE_IMAGE" "$BASE_IMAGE"
echo "Tagging ere-base-$ZKVM from cache"
docker tag $CACHED_BASE_ZKVM_IMAGE $BASE_ZKVM_IMAGE
docker tag "$CACHED_BASE_ZKVM_IMAGE" "$BASE_ZKVM_IMAGE"
else
echo "Building ere-base-$ZKVM"
docker build \
--file docker/$ZKVM/Dockerfile.base \
--tag $BASE_ZKVM_IMAGE \
--build-arg BASE_IMAGE=$BASE_IMAGE \
.
echo "Building base images using build-image.sh"
"$SCRIPT_DIR/build-image.sh" \
--zkvm "$ZKVM" \
--registry "$IMAGE_REGISTRY" \
--tag "$IMAGE_TAG" \
--base
fi

View File

@@ -1,5 +1,9 @@
name: Check formatting
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:

View File

@@ -1,5 +1,9 @@
name: Test and clippy common crates
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:

View File

@@ -1,9 +1,15 @@
name: Test and clippy Airbender
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
jobs:
@@ -14,5 +20,4 @@ jobs:
packages: write
with:
zkvm: airbender
toolchain: nightly
skip_prove_test: true

View File

@@ -1,9 +1,15 @@
name: Test and clippy Jolt
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
jobs:
@@ -14,4 +20,3 @@ jobs:
packages: write
with:
zkvm: jolt
toolchain: 1.88.0

View File

@@ -1,9 +1,15 @@
name: Test and clippy Miden
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
jobs:
@@ -14,4 +20,3 @@ jobs:
packages: write
with:
zkvm: miden
toolchain: 1.90.0

View File

@@ -1,9 +1,15 @@
name: Test and clippy Nexus
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
jobs:
@@ -14,4 +20,3 @@ jobs:
packages: write
with:
zkvm: nexus
toolchain: nightly-2025-04-06

View File

@@ -1,9 +1,15 @@
name: Test and clippy OpenVM
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
jobs:
@@ -14,4 +20,3 @@ jobs:
packages: write
with:
zkvm: openvm
toolchain: nightly

View File

@@ -1,9 +1,15 @@
name: Test and clippy Pico
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
jobs:
@@ -14,4 +20,3 @@ jobs:
packages: write
with:
zkvm: pico
toolchain: nightly-2025-08-04

View File

@@ -1,9 +1,15 @@
name: Test and clippy Risc0
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
jobs:
@@ -14,4 +20,3 @@ jobs:
packages: write
with:
zkvm: risc0
toolchain: 1.88.0

View File

@@ -1,9 +1,15 @@
name: Test and clippy SP1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
jobs:
@@ -14,4 +20,3 @@ jobs:
packages: write
with:
zkvm: sp1
toolchain: 1.88.0

View File

@@ -1,9 +1,15 @@
name: Test and clippy Ziren
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
jobs:
@@ -14,4 +20,3 @@ jobs:
packages: write
with:
zkvm: ziren
toolchain: nightly

View File

@@ -1,9 +1,15 @@
name: Test and clippy ZisK
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
jobs:
@@ -14,5 +20,4 @@ jobs:
packages: write
with:
zkvm: zisk
toolchain: 1.88.0
skip_prove_test: true

View File

@@ -7,11 +7,6 @@ on:
description: 'zkVM to test'
required: true
type: string
toolchain:
description: 'Rust toolchain to use'
required: false
type: string
default: 1.88.0
# Remove when we use larger runners, currently only needed to skip for zisk
skip_prove_test:
description: 'Whether to skip prove test and ere-dockerized test or not'
@@ -44,9 +39,6 @@ jobs:
- name: Free up disk space
run: bash .github/scripts/free-up-disk-space.sh
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
@@ -59,24 +51,26 @@ jobs:
uses: tj-actions/changed-files@v46
with:
files: |
docker/Dockerfile.base
docker/${{ inputs.zkvm }}/**
scripts/sdk_installers/install_${{ inputs.zkvm }}_sdk.sh
docker/**
scripts/**
- name: Get image metadata
id: image_meta
run: |
ZKVM_CRATE_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "ere-${{ inputs.zkvm }}") | .version')
TAG="${{ github.ref_name }}"
SHA="${{ github.sha }}"
GIT_REV="${{ github.sha }}"
if [ "${{ github.event_name }}" == "pull_request" ] && [ "${{ steps.changed_files.outputs.any_changed }}" == "false" ]; then
CACHED_GIT_REV="${{ github.event.pull_request.base.sha }}"
if [ "${{ github.ref_type }}" == "tag" ]; then
IMAGE_TAG="${TAG#v}"
else
CACHED_GIT_REV="$GIT_REV"
IMAGE_TAG="${SHA:0:7}"
fi
IMAGE_TAG="$ZKVM_CRATE_VERSION-${GIT_REV:0:7}"
CACHED_IMAGE_TAG="$ZKVM_CRATE_VERSION-${CACHED_GIT_REV:0:7}"
CACHED_IMAGE_TAG=""
if [ "${{ github.event_name }}" == "pull_request" ] && [ "${{ steps.changed_files.outputs.any_changed }}" == "false" ]; then
CACHED_IMAGE_TAG="${{ github.event.pull_request.base.sha }}"
CACHED_IMAGE_TAG="${CACHED_IMAGE_TAG:0:7}"
fi
IMAGE_REGISTRY="ghcr.io/${{ github.repository }}"
BASE_IMAGE="$IMAGE_REGISTRY/ere-base:$IMAGE_TAG"
@@ -92,47 +86,36 @@ jobs:
echo "compiler_zkvm_image=$COMPILER_ZKVM_IMAGE" >> $GITHUB_OUTPUT
echo "server_zkvm_image=$SERVER_ZKVM_IMAGE" >> $GITHUB_OUTPUT
- name: Build ere-base image
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event.pull_request.head.repo.full_name == github.repository && steps.changed_files.outputs.any_changed == 'true')
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile.base
push: true
tags: ${{ steps.image_meta.outputs.base_image }}
- name: Build and push ere-base and ere-base-${{ inputs.zkvm }} images
if: github.event_name == 'push'
run: |
bash .github/scripts/build-image.sh \
--zkvm ${{ inputs.zkvm }} \
--registry ${{ steps.image_meta.outputs.image_registry }} \
--tag ${{ steps.image_meta.outputs.image_tag }} \
--base
docker push ${{ steps.image_meta.outputs.base_image }}
docker push ${{ steps.image_meta.outputs.base_zkvm_image }}
- name: Build ere-base-${{ inputs.zkvm }} image
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event.pull_request.head.repo.full_name == github.repository && steps.changed_files.outputs.any_changed == 'true')
uses: docker/build-push-action@v6
with:
context: .
file: docker/${{ inputs.zkvm }}/Dockerfile.base
push: true
tags: ${{ steps.image_meta.outputs.base_zkvm_image }}
build-args: |
BASE_IMAGE=${{ steps.image_meta.outputs.base_image }}
- name: Build and push ere-compiler-${{ inputs.zkvm }} image
if: github.event_name == 'push'
run: |
bash .github/scripts/build-image.sh \
--zkvm ${{ inputs.zkvm }} \
--registry ${{ steps.image_meta.outputs.image_registry }} \
--tag ${{ steps.image_meta.outputs.image_tag }} \
--compiler
docker push ${{ steps.image_meta.outputs.compiler_zkvm_image }}
- name: Build ere-compiler-${{ inputs.zkvm }} image
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: docker/build-push-action@v6
with:
context: .
file: docker/${{ inputs.zkvm }}/Dockerfile.compiler
push: true
tags: ${{ steps.image_meta.outputs.compiler_zkvm_image }}
build-args: |
BASE_ZKVM_IMAGE=${{ steps.image_meta.outputs.base_zkvm_image }}
- name: Build ere-server-${{ inputs.zkvm }} image
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: docker/build-push-action@v6
with:
context: .
file: docker/${{ inputs.zkvm }}/Dockerfile.server
push: true
tags: ${{ steps.image_meta.outputs.server_zkvm_image }}
build-args: |
BASE_ZKVM_IMAGE=${{ steps.image_meta.outputs.base_zkvm_image }}
- name: Build and push ere-server-${{ inputs.zkvm }} image
if: github.event_name == 'push'
run: |
bash .github/scripts/build-image.sh \
--zkvm ${{ inputs.zkvm }} \
--registry ${{ steps.image_meta.outputs.image_registry }} \
--tag ${{ steps.image_meta.outputs.image_tag }} \
--server
docker push ${{ steps.image_meta.outputs.server_zkvm_image }}
clippy_via_docker:
name: Clippy via Docker
@@ -148,15 +131,20 @@ jobs:
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
key: rust-${{ inputs.toolchain }}-${{ inputs.zkvm }}-${{ hashFiles('Cargo.lock') }}
key: rust-${{ inputs.zkvm }}-${{ hashFiles('Cargo.lock') }}
- name: Pull base zkvm image or build locally
if: github.event_name == 'pull_request'
run: |
bash .github/scripts/pull-or-build-base-zkvm-image.sh \
${{ inputs.zkvm }} \
${{ needs.build_image.outputs.image_registry }} \
${{ needs.build_image.outputs.image_tag }} \
${{ needs.build_image.outputs.cached_image_tag }}
--zkvm ${{ inputs.zkvm }} \
--registry ${{ needs.build_image.outputs.image_registry }} \
--tag ${{ needs.build_image.outputs.image_tag }} \
--cached-tag "${{ needs.build_image.outputs.cached_image_tag }}"
- name: Pull base zkvm image
if: github.event_name == 'push'
run: docker pull ${{ needs.build_image.outputs.base_zkvm_image }}
- name: Run cargo clippy for ere-${{ inputs.zkvm }} via Docker
run: |
@@ -197,15 +185,20 @@ jobs:
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
key: rust-${{ inputs.toolchain }}-${{ inputs.zkvm }}-${{ hashFiles('Cargo.lock') }}
key: rust-${{ inputs.zkvm }}-${{ hashFiles('Cargo.lock') }}
- name: Pull base zkvm image or build locally
if: github.event_name == 'pull_request'
run: |
bash .github/scripts/pull-or-build-base-zkvm-image.sh \
${{ inputs.zkvm }} \
${{ needs.build_image.outputs.image_registry }} \
${{ needs.build_image.outputs.image_tag }} \
${{ needs.build_image.outputs.cached_image_tag }}
--zkvm ${{ inputs.zkvm }} \
--registry ${{ needs.build_image.outputs.image_registry }} \
--tag ${{ needs.build_image.outputs.image_tag }} \
--cached-tag "${{ needs.build_image.outputs.cached_image_tag }}"
- name: Pull base zkvm image
if: github.event_name == 'push'
run: docker pull ${{ needs.build_image.outputs.base_zkvm_image }}
- name: Run cargo test for ere-${{ inputs.zkvm }} via Docker
run: |
@@ -244,40 +237,32 @@ jobs:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.toolchain }}
toolchain: 1.88.0
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
key: rust-${{ inputs.toolchain }}-${{ inputs.zkvm }}-${{ hashFiles('Cargo.lock') }}
key: rust-${{ inputs.zkvm }}-${{ hashFiles('Cargo.lock') }}
- name: Pull images or build locally
if: github.event_name == 'pull_request'
run: |
bash .github/scripts/pull-or-build-base-zkvm-image.sh \
${{ inputs.zkvm }} \
${{ needs.build_image.outputs.image_registry }} \
${{ needs.build_image.outputs.image_tag }} \
${{ needs.build_image.outputs.cached_image_tag }}
--zkvm ${{ inputs.zkvm }} \
--registry ${{ needs.build_image.outputs.image_registry }} \
--tag ${{ needs.build_image.outputs.image_tag }} \
--cached-tag "${{ needs.build_image.outputs.cached_image_tag }}"
# Build ere-compiler-${{ inputs.zkvm }}
echo "Building ere-compiler-${{ inputs.zkvm }}"
docker build \
--file docker/${{ inputs.zkvm }}/Dockerfile.compiler \
--tag ${{ needs.build_image.outputs.compiler_zkvm_image }} \
--build-arg BASE_ZKVM_IMAGE=${{ needs.build_image.outputs.base_zkvm_image }} \
.
# Build ere-server-${{ inputs.zkvm }}
echo "Building ere-server-${{ inputs.zkvm }}"
docker build \
--file docker/${{ inputs.zkvm }}/Dockerfile.server \
--tag ${{ needs.build_image.outputs.server_zkvm_image }} \
--build-arg BASE_ZKVM_IMAGE=${{ needs.build_image.outputs.base_zkvm_image }} \
.
# Build ere-compiler-${{ inputs.zkvm }} and ere-server-${{ inputs.zkvm }}
bash .github/scripts/build-image.sh \
--zkvm ${{ inputs.zkvm }} \
--registry ${{ needs.build_image.outputs.image_registry }} \
--tag ${{ needs.build_image.outputs.image_tag }} \
--compiler \
--server
- name: Pull ere-compiler-${{ inputs.zkvm }} and ere-server-${{ inputs.zkvm }} images
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
if: github.event_name == 'push'
run: |
docker pull ${{ needs.build_image.outputs.compiler_zkvm_image }}
docker pull ${{ needs.build_image.outputs.server_zkvm_image }}

58
Cargo.lock generated
View File

@@ -3797,7 +3797,7 @@ dependencies = [
[[package]]
name = "ere-airbender"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"bincode 2.0.1",
@@ -3814,14 +3814,14 @@ dependencies = [
[[package]]
name = "ere-build-utils"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"cargo_metadata 0.19.2",
]
[[package]]
name = "ere-common"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"ere-build-utils",
"serde",
@@ -3830,7 +3830,7 @@ dependencies = [
[[package]]
name = "ere-compile-utils"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"cargo_metadata 0.19.2",
@@ -3840,7 +3840,7 @@ dependencies = [
[[package]]
name = "ere-compiler"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"bincode 2.0.1",
@@ -3864,7 +3864,7 @@ dependencies = [
[[package]]
name = "ere-dockerized"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"ere-common",
@@ -3881,7 +3881,7 @@ dependencies = [
[[package]]
name = "ere-io"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"bincode 2.0.1",
"ciborium",
@@ -3892,7 +3892,7 @@ dependencies = [
[[package]]
name = "ere-jolt"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"ark-serialize 0.5.0",
@@ -3910,7 +3910,7 @@ dependencies = [
[[package]]
name = "ere-miden"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"ere-build-utils",
@@ -3928,7 +3928,7 @@ dependencies = [
[[package]]
name = "ere-nexus"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"bincode 2.0.1",
@@ -3947,7 +3947,7 @@ dependencies = [
[[package]]
name = "ere-openvm"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"ere-build-utils",
@@ -3968,7 +3968,7 @@ dependencies = [
[[package]]
name = "ere-pico"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"bincode 2.0.1",
@@ -3987,7 +3987,7 @@ dependencies = [
[[package]]
name = "ere-platform-airbender"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"ere-platform-trait",
"riscv_common",
@@ -3995,7 +3995,7 @@ dependencies = [
[[package]]
name = "ere-platform-jolt"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"ere-platform-trait",
"jolt-sdk",
@@ -4004,7 +4004,7 @@ dependencies = [
[[package]]
name = "ere-platform-nexus"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"ere-platform-trait",
"nexus-rt",
@@ -4012,7 +4012,7 @@ dependencies = [
[[package]]
name = "ere-platform-openvm"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"ere-platform-trait",
"openvm",
@@ -4020,7 +4020,7 @@ dependencies = [
[[package]]
name = "ere-platform-pico"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"ere-platform-trait",
"pico-sdk",
@@ -4028,7 +4028,7 @@ dependencies = [
[[package]]
name = "ere-platform-risc0"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"ere-platform-trait",
"risc0-zkvm",
@@ -4037,7 +4037,7 @@ dependencies = [
[[package]]
name = "ere-platform-sp1"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"ere-platform-trait",
"sp1-zkvm",
@@ -4045,14 +4045,14 @@ dependencies = [
[[package]]
name = "ere-platform-trait"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"digest 0.10.7",
]
[[package]]
name = "ere-platform-ziren"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"ere-platform-trait",
"zkm-zkvm",
@@ -4060,7 +4060,7 @@ dependencies = [
[[package]]
name = "ere-platform-zisk"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"ere-platform-trait",
"ziskos",
@@ -4068,7 +4068,7 @@ dependencies = [
[[package]]
name = "ere-risc0"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"bincode 2.0.1",
@@ -4088,7 +4088,7 @@ dependencies = [
[[package]]
name = "ere-server"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"bincode 2.0.1",
@@ -4119,7 +4119,7 @@ dependencies = [
[[package]]
name = "ere-sp1"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"bincode 2.0.1",
@@ -4136,7 +4136,7 @@ dependencies = [
[[package]]
name = "ere-test-utils"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"ere-io",
"ere-platform-trait",
@@ -4149,7 +4149,7 @@ dependencies = [
[[package]]
name = "ere-ziren"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"bincode 2.0.1",
@@ -4165,7 +4165,7 @@ dependencies = [
[[package]]
name = "ere-zisk"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"blake3",
@@ -4184,7 +4184,7 @@ dependencies = [
[[package]]
name = "ere-zkvm-interface"
version = "0.0.16"
version = "0.1.0"
dependencies = [
"anyhow",
"auto_impl",

View File

@@ -37,7 +37,7 @@ members = [
resolver = "2"
[workspace.package]
version = "0.0.16"
version = "0.1.0"
edition = "2024"
rust-version = "1.88"
license = "MIT OR Apache-2.0"

View File

@@ -1,7 +1,20 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
use cargo_metadata::MetadataCommand;
use std::{env, fs, path::Path};
use std::{
env, fs, io,
path::{Path, PathBuf},
};
/// Returns path of `Cargo.lock` from the `CARGO_MANIFEST_DIR` of caller, which
/// is `depth` far from the workspace.
pub fn cargo_lock_path(depth: usize) -> io::Result<PathBuf> {
let mut manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
for _ in 0..depth {
manifest_dir.pop();
}
manifest_dir.join("Cargo.lock").canonicalize()
}
// Detect and generate a Rust source file that contains the name and version of the SDK.
pub fn detect_and_generate_name_and_sdk_version(name: &str, sdk_dep_name: &str) {
@@ -32,23 +45,55 @@ pub fn gen_name_and_sdk_version(name: &str, version: &str) {
format!("const NAME: &str = \"{name}\";\nconst SDK_VERSION: &str = \"{version}\";"),
)
.unwrap();
println!("cargo:rerun-if-changed=Cargo.lock");
}
/// Detects version of the crate of the `build.rs` that being ran.
pub fn detect_self_crate_version() -> String {
/// Generate tag for Docker image.
///
/// Returns:
/// - Git tag in SemVer if current commit has a tag (e.g., `v0.1.0` -> `0.1.0`)
/// - Short git revision (7 digits) if no tag found
/// - Crate version from Cargo.toml as fallback if git is not available
pub fn get_docker_image_tag() -> String {
// Try to get a tag pointing to the current commit
let tag_output = std::process::Command::new("git")
.args(["describe", "--tags", "--exact-match", "HEAD"])
.output();
match tag_output {
Ok(output) if output.status.success() => {
let tag = String::from_utf8_lossy(&output.stdout).trim().to_string();
// Remove 'v' prefix if present
let semver_or_tag = tag.strip_prefix('v').unwrap_or(&tag);
if !semver_or_tag.is_empty() {
return semver_or_tag.to_string();
}
}
_ => {}
}
// No tag found, try to get short revision
let rev_output = std::process::Command::new("git")
.args(["rev-parse", "--short=7", "HEAD"])
.output();
match rev_output {
Ok(output) if output.status.success() => {
let rev = String::from_utf8_lossy(&output.stdout).trim().to_string();
if !rev.is_empty() {
return rev;
}
}
_ => {}
}
// Fallback to crate version
let meta = MetadataCommand::new()
.exec()
.expect("Failed to get cargo metadata");
// `root_package` returns the crate of the `build.rs` that being ran.
let version = meta.root_package().unwrap().version.to_string();
let output = std::process::Command::new("git")
.args(["rev-parse", "--short=7", "HEAD"])
.output()
.expect("Failed to get git revision");
let rev = String::from_utf8_lossy(&output.stdout).trim().to_string();
format!("{version}-{rev}")
meta.root_package()
.expect("crate to have version")
.version
.to_string()
}

View File

@@ -1,21 +1,31 @@
use ere_build_utils::{detect_sdk_version, detect_self_crate_version};
use std::{env, fs, path::Path};
use ere_build_utils::{detect_sdk_version, get_docker_image_tag};
use std::{
env, fs,
path::{Path, PathBuf},
};
fn main() {
generate_crate_version();
generate_docker_image_tag();
generate_zkvm_sdk_version_impl();
println!("cargo:rerun-if-changed=Cargo.lock");
}
fn generate_crate_version() {
let crate_version = format!(
"/// Crate version in format of `{{semantic_version}}-{{git_sha:7}}`\npub const CRATE_VERSION: &str = \"{}\";",
detect_self_crate_version()
fn generate_docker_image_tag() {
let docker_image_tag = format!(
"/// Docker image tag.\npub const DOCKER_IMAGE_TAG: &str = \"{}\";",
get_docker_image_tag()
);
let out_dir = env::var("OUT_DIR").unwrap();
let dst = Path::new(&out_dir).join("crate_version.rs");
fs::write(dst, crate_version).unwrap();
let dst = Path::new(&out_dir).join("docker_image_tag.rs");
fs::write(dst, docker_image_tag).unwrap();
if let Ok(dot_git) = workspace().join(".git").canonicalize() {
for dir in ["HEAD", "refs", "packed-refs"] {
if dot_git.join(dir).exists() {
println!("cargo:rerun-if-changed={}", dot_git.join(dir).display());
}
}
}
}
fn generate_zkvm_sdk_version_impl() {
@@ -66,4 +76,16 @@ fn generate_zkvm_sdk_version_impl() {
let out_dir = env::var("OUT_DIR").unwrap();
let dst = Path::new(&out_dir).join("zkvm_sdk_version_impl.rs");
fs::write(dst, zkvm_sdk_version_impl).unwrap();
if let Ok(cargo_lock) = workspace().join("Cargo.lock").canonicalize() {
println!("cargo:rerun-if-changed={}", cargo_lock.display());
}
}
fn workspace() -> PathBuf {
let mut manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
manifest_dir.pop();
manifest_dir.pop();
manifest_dir.pop();
manifest_dir
}

View File

@@ -4,5 +4,5 @@ pub mod zkvm;
pub use compiler::CompilerKind;
pub use zkvm::zkVMKind;
include!(concat!(env!("OUT_DIR"), "/crate_version.rs"));
include!(concat!(env!("OUT_DIR"), "/docker_image_tag.rs"));
include!(concat!(env!("OUT_DIR"), "/zkvm_sdk_version_impl.rs"));

View File

@@ -1,4 +1,4 @@
use crate::{CRATE_VERSION, util::env::image_registry, zkVMKind};
use crate::{DOCKER_IMAGE_TAG, util::env::image_registry, zkVMKind};
/// Returns tag of images in format of `{version}{suffix}`.
pub fn image_tag(zkvm_kind: zkVMKind, gpu: bool) -> String {
@@ -10,7 +10,7 @@ pub fn image_tag(zkvm_kind: zkVMKind, gpu: bool) -> String {
}
_ => "",
};
format!("{CRATE_VERSION}{suffix}")
format!("{DOCKER_IMAGE_TAG}{suffix}")
}
/// Returns `ere-base:{image_tag}`

View File

@@ -78,4 +78,4 @@ pub use crate::{
compiler::{DockerizedCompiler, SerializedProgram},
zkvm::DockerizedzkVM,
};
pub use ere_common::{CRATE_VERSION, CompilerKind, zkVMKind};
pub use ere_common::{CompilerKind, DOCKER_IMAGE_TAG, zkVMKind};

View File

@@ -1,5 +1,9 @@
use ere_build_utils::detect_and_generate_name_and_sdk_version;
use ere_build_utils::{cargo_lock_path, detect_and_generate_name_and_sdk_version};
fn main() {
detect_and_generate_name_and_sdk_version("airbender", "execution_utils");
if let Ok(cargo_lock) = cargo_lock_path(3) {
println!("cargo:rerun-if-changed={}", cargo_lock.display());
}
}

View File

@@ -1,5 +1,9 @@
use ere_build_utils::detect_and_generate_name_and_sdk_version;
use ere_build_utils::{cargo_lock_path, detect_and_generate_name_and_sdk_version};
fn main() {
detect_and_generate_name_and_sdk_version("jolt", "jolt-sdk");
if let Ok(cargo_lock) = cargo_lock_path(3) {
println!("cargo:rerun-if-changed={}", cargo_lock.display());
}
}

View File

@@ -1,5 +1,9 @@
use ere_build_utils::detect_and_generate_name_and_sdk_version;
use ere_build_utils::{cargo_lock_path, detect_and_generate_name_and_sdk_version};
fn main() {
detect_and_generate_name_and_sdk_version("miden", "miden-core");
if let Ok(cargo_lock) = cargo_lock_path(3) {
println!("cargo:rerun-if-changed={}", cargo_lock.display());
}
}

View File

@@ -1,5 +1,9 @@
use ere_build_utils::detect_and_generate_name_and_sdk_version;
use ere_build_utils::{cargo_lock_path, detect_and_generate_name_and_sdk_version};
fn main() {
detect_and_generate_name_and_sdk_version("nexus", "nexus-sdk");
if let Ok(cargo_lock) = cargo_lock_path(3) {
println!("cargo:rerun-if-changed={}", cargo_lock.display());
}
}

View File

@@ -1,5 +1,9 @@
use ere_build_utils::detect_and_generate_name_and_sdk_version;
use ere_build_utils::{cargo_lock_path, detect_and_generate_name_and_sdk_version};
fn main() {
detect_and_generate_name_and_sdk_version("openvm", "openvm-sdk");
if let Ok(cargo_lock) = cargo_lock_path(3) {
println!("cargo:rerun-if-changed={}", cargo_lock.display());
}
}

View File

@@ -1,5 +1,9 @@
use ere_build_utils::detect_and_generate_name_and_sdk_version;
use ere_build_utils::{cargo_lock_path, detect_and_generate_name_and_sdk_version};
fn main() {
detect_and_generate_name_and_sdk_version("pico", "pico-vm");
if let Ok(cargo_lock) = cargo_lock_path(3) {
println!("cargo:rerun-if-changed={}", cargo_lock.display());
}
}

View File

@@ -1,5 +1,9 @@
use ere_build_utils::detect_and_generate_name_and_sdk_version;
use ere_build_utils::{cargo_lock_path, detect_and_generate_name_and_sdk_version};
fn main() {
detect_and_generate_name_and_sdk_version("risc0", "risc0-zkvm");
if let Ok(cargo_lock) = cargo_lock_path(3) {
println!("cargo:rerun-if-changed={}", cargo_lock.display());
}
}

View File

@@ -1,5 +1,9 @@
use ere_build_utils::detect_and_generate_name_and_sdk_version;
use ere_build_utils::{cargo_lock_path, detect_and_generate_name_and_sdk_version};
fn main() {
detect_and_generate_name_and_sdk_version("sp1", "sp1-sdk");
if let Ok(cargo_lock) = cargo_lock_path(3) {
println!("cargo:rerun-if-changed={}", cargo_lock.display());
}
}

View File

@@ -1,5 +1,9 @@
use ere_build_utils::detect_and_generate_name_and_sdk_version;
use ere_build_utils::{cargo_lock_path, detect_and_generate_name_and_sdk_version};
fn main() {
detect_and_generate_name_and_sdk_version("ziren", "zkm-sdk");
if let Ok(cargo_lock) = cargo_lock_path(3) {
println!("cargo:rerun-if-changed={}", cargo_lock.display());
}
}

View File

@@ -24,7 +24,7 @@ impl Compiler for RustMips32r2Customized {
let mut cmd = Command::new("cargo");
let output = cmd
.current_dir(guest_directory)
.env("RUSTUP_TOOLCHAIN", "nightly")
.env("RUSTUP_TOOLCHAIN", "nightly-2025-07-17")
.env("RUSTC", rustc_path(ZKM_TOOLCHAIN)?)
.env("ZIREN_ZKM_CC", "mipsel-zkm-zkvm-elf-gcc")
.args(["ziren", "build"])

View File

@@ -1,5 +1,9 @@
use ere_build_utils::detect_and_generate_name_and_sdk_version;
use ere_build_utils::{cargo_lock_path, detect_and_generate_name_and_sdk_version};
fn main() {
detect_and_generate_name_and_sdk_version("zisk", "ziskos");
if let Ok(cargo_lock) = cargo_lock_path(3) {
println!("cargo:rerun-if-changed={}", cargo_lock.display());
}
}

View File

@@ -2,8 +2,8 @@ ARG BASE_IMAGE=ere-base:latest
FROM $BASE_IMAGE
# Set default toolchain to nightly
RUN rustup default nightly
# Set default toolchain to nightly-2025-07-25
RUN rustup default nightly-2025-07-25
# Whether to enable CUDA feature or not.
ARG CUDA

View File

@@ -7,8 +7,8 @@ RUN curl -fsSL https://golang.org/dl/go1.23.1.linux-amd64.tar.gz | tar -C /usr/l
ENV PATH=/usr/local/go/bin:$PATH
# Set default toolchain to nightly
RUN rustup default nightly
# Set default toolchain to nightly-2025-07-17
RUN rustup default nightly-2025-07-17
# Copy the Ziren SDK installer script
COPY --chmod=755 scripts/sdk_installers/install_ziren_sdk.sh /tmp/install_ziren_sdk.sh

View File

@@ -46,10 +46,7 @@ COPY --chmod=755 scripts/sdk_installers/install_zisk_sdk.sh /tmp/install_zisk_sd
# Run the ZisK SDK installation script using ziskup.
# This script installs the 'zisk' Rust toolchain and `cargo-zisk`
RUN /tmp/install_zisk_sdk.sh && \
rm /tmp/install_zisk_sdk.sh && \
# Remove the merkle tree of proving key to reduce docker image size (~20 GB).
# Re-generating takes only ~30 seconds.
find "/root/.zisk/provingKey" -name "*.consttree" -type f -delete
rm /tmp/install_zisk_sdk.sh
# The 'zisk' Rust toolchain is now installed.
# cargo-zisk is installed in /root/.zisk/bin.

View File

@@ -28,9 +28,11 @@ ensure_tool_installed "cargo" "to build and install Rust packages"
AIRBENDER_CLI_VERSION_TAG="v0.5.2"
AIRBENDER_TOOLCHAIN="nightly-2025-07-25"
# Install airbender-cli using the specified toolchain and version tag
echo "Installing airbender-cli (version ${AIRBENDER_CLI_VERSION_TAG}) from GitHub repository (matter-labs/zksync-airbender)..."
cargo +nightly install --locked --git https://github.com/matter-labs/zksync-airbender.git --tag "${AIRBENDER_CLI_VERSION_TAG}" ${CUDA:+-F gpu} cli
cargo +${AIRBENDER_TOOLCHAIN} install --locked --git https://github.com/matter-labs/zksync-airbender.git --tag "${AIRBENDER_CLI_VERSION_TAG}" ${CUDA:+-F gpu} cli
# Rename cli to airbender-cli
CARGO_HOME=${CARGO_HOME:-$HOME/.cargo}
@@ -47,5 +49,5 @@ else
fi
# Install cargo-binutils to objcopy ELF to binary file
rustup +nightly component add llvm-tools
rustup +${AIRBENDER_TOOLCHAIN} component add llvm-tools
cargo install cargo-binutils

View File

@@ -29,6 +29,7 @@ ensure_tool_installed "curl" "to download the zkmup installer"
ensure_tool_installed "sh" "as the zkmup installer script uses sh"
ZIREM_VERSION="1.2.3"
ZIREM_TOOLCHAIN_VERSION="nightly-2025-07-17"
# Step 1: Download and run the script that installs the zkmup binary itself.
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/ProjectZKM/toolchain/refs/heads/main/setup.sh | sh
@@ -39,7 +40,7 @@ export PATH="${PATH}:${HOME}/.zkm-toolchain/bin"
# Step 3: Link the latest toolchain as toolchain `zkm`
rustup toolchain link zkm $(ls -d $HOME/.zkm-toolchain/* | grep "$(zkmup list-available | cut -d' ' -f1)$")
# Step 4: Install cargo-ziren by building from source
cargo +nightly install --locked --git https://github.com/ProjectZKM/Ziren.git --tag "v${ZIREM_VERSION}" zkm-cli
cargo "+${ZIREM_TOOLCHAIN_VERSION}" install --locked --git https://github.com/ProjectZKM/Ziren.git --tag "v${ZIREM_VERSION}" zkm-cli
# Verify ZKM installation
echo "Verifying ZKM installation..."

View File

@@ -31,9 +31,10 @@ ensure_tool_installed "rustup" "for managing Rust toolchains (ZisK installs its
ensure_tool_installed "cargo" "as cargo-zisk is a cargo subcommand"
# Step 1: Download and run the script that installs the ziskup binary itself.
# Export SETUP_KEY=proving to ensure no interactive options in `ziskup`.
# Export SETUP_KEY=proving-no-consttree to download proving key but avoid doing
# cargo-zisk check-setup.
export ZISK_VERSION="0.15.0"
export SETUP_KEY=${SETUP_KEY:=proving}
export SETUP_KEY=${SETUP_KEY:=proving-no-consttree}
curl "https://raw.githubusercontent.com/0xPolygonHermez/zisk/main/ziskup/install.sh" | bash
unset SETUP_KEY