Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
NickVolynkin committed Aug 9, 2023
1 parent b834bcc commit 3a4af96
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 56 deletions.
45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: '3.5'

services:
zkllvm:
build:
context: .
dockerfile_inline: |
ARG user_id
ARG group_id
FROM ghcr.io/nilfoundation/zkllvm-template:0.0.86
RUN useradd nil -u $user_id -g $group_id
args:
user_id: ${user_id}
group_id: ${group_id}
platform: linux/amd64
user: "${user_id}:${group_id}"
volumes:
- ./:/opt/zkllvm-template
command: bash -c "while true; do sleep 60; done"
tty: true

toolchain:
# Proof Market toolchain
image: ghcr.io/nilfoundation/proof-market-toolchain:0.0.37
platform: linux/amd64
user: "${user_id}:${group_id}"
volumes:
- ./:/opt/zkllvm-template
- ./.config:/.config/
- ./.config:/root/.config/
- ./.config/.user:/proof-market-toolchain/scripts/.user
- ./.config/.secret:/proof-market-toolchain/scripts/.secret
command: bash -c "while true; do sleep 60; done"
tty: true

verifier:
image: ghcr.io/nilfoundation/evm-placeholder-verification:latest
platform: linux/amd64
user: "${user_id}:${group_id}"
volumes:
- ./:/opt/zkllvm-template
- ./build/template:/opt/evm-placeholder-verification/contracts/zkllvm/template
command: bash -c "while true; do sleep 60; done"
tty: true

75 changes: 19 additions & 56 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ REPO_ROOT="$SCRIPT_DIR/.."
echo "using nilfoundation/zkllvm-template:${ZKLLVM_VERSION:=0.0.86}"
echo "using nilfoundation/proof-market-toolchain:${TOOLCHAIN_VERSION:=0.0.37}"

# podman is a safer option for using on CI machines
if ! command -v podman; then
DOCKER="docker"
DOCKER_OPTS=""
else
DOCKER="podman"
DOCKER_OPTS='--detach-keys= --userns=keep-id'
fi
DOCKER="docker"
DOCKER_OPTS=""

# checking files that should be produced
# on all steps of the pipeline
Expand All @@ -44,6 +38,15 @@ check_file_exists() {
fi
}

init() {
touch .config/.user
touch .config/.secret
mkdir -p build/template
export user_id=$(id -u)
export group_id=$(id -g)
docker compose up -d
}

run_zkllvm() {
cd $REPO_ROOT
# silently stop the existing container if it's running already
Expand Down Expand Up @@ -78,17 +81,11 @@ run_proof_market_toolchain() {
compile() {
if [ "$USE_DOCKER" = true ] ; then
cd "$REPO_ROOT"
$DOCKER run $DOCKER_OPTS \
--rm \
--platform=linux/amd64 \
--user $(id -u ${USER}):$(id -g ${USER}) \
--volume $(pwd):/opt/zkllvm-template \
ghcr.io/nilfoundation/zkllvm-template:${ZKLLVM_VERSION} \
sh -c "bash ./scripts/run.sh compile"
$DOCKER compose exec zkllvm bash ./scripts/run.sh compile
cd -
else
rm -rf "$REPO_ROOT/build"
mkdir -p "$REPO_ROOT/build"
mkdir -p "$REPO_ROOT/build/template"
cd "$REPO_ROOT/build"
cmake -DCIRCUIT_ASSEMBLY_OUTPUT=TRUE ..
VERBOSE=1 make template
Expand All @@ -103,13 +100,7 @@ compile() {
build_constraint() {
if [ "$USE_DOCKER" = true ] ; then
cd "$REPO_ROOT"
$DOCKER run $DOCKER_OPTS \
--rm \
--platform=linux/amd64 \
--user $(id -u ${USER}):$(id -g ${USER}) \
--volume $(pwd):/opt/zkllvm-template \
ghcr.io/nilfoundation/zkllvm-template:${ZKLLVM_VERSION} \
sh -c "bash ./scripts/run.sh build_constraint"
$DOCKER compose exec zkllvm bash ./scripts/run.sh build_constraint
cd -
else
cd "$REPO_ROOT/build"
Expand All @@ -128,13 +119,7 @@ build_constraint() {
build_circuit_params() {
if [ "$USE_DOCKER" = true ] ; then
cd "$REPO_ROOT"
$DOCKER run $DOCKER_OPTS \
--rm \
--platform=linux/amd64 \
--user $(id -u ${USER}):$(id -g ${USER}) \
--volume $(pwd):/opt/zkllvm-template \
ghcr.io/nilfoundation/zkllvm-template:${ZKLLVM_VERSION} \
sh -c "bash ./scripts/run.sh build_circuit_params"
$DOCKER compose exec zkllvm bash ./scripts/run.sh build_circuit_params
cd -
else
cd "$REPO_ROOT/build"
Expand Down Expand Up @@ -167,16 +152,7 @@ build_circuit_params() {
build_statement() {
if [ "$USE_DOCKER" = true ] ; then
cd "$REPO_ROOT"
$DOCKER run $DOCKER_OPTS \
--rm \
--platform=linux/amd64 \
--user $(id -u ${USER}):$(id -g ${USER}) \
--volume $(pwd):/opt/zkllvm-template \
--volume $(pwd)/.config:/.config/ \
--volume $(pwd)/.config:/root/.config/ \
--volume $(pwd)/.config:/proof-market-toolchain/.config/ \
ghcr.io/nilfoundation/proof-market-toolchain:${TOOLCHAIN_VERSION} \
sh -c "bash /opt/zkllvm-template/scripts/run.sh build_statement"
$DOCKER compose exec toolchain bash /opt/zkllvm-template/scripts/run.sh build_statement
cd -
else
cd /opt/zkllvm-template/
Expand All @@ -203,16 +179,7 @@ prove() {
# workaround for https://github.com/NilFoundation/proof-market-toolchain/issues/61
mkdir -p .config
touch .config/config.ini
$DOCKER run $DOCKER_OPTS \
--rm \
--platform=linux/amd64 \
--user $(id -u ${USER}):$(id -g ${USER}) \
--volume $(pwd):/opt/zkllvm-template \
--volume $(pwd)/.config:/.config/ \
--volume $(pwd)/.config:/root/.config/ \
--volume $(pwd)/.config:/proof-market-toolchain/.config/ \
ghcr.io/nilfoundation/proof-market-toolchain:${TOOLCHAIN_VERSION} \
sh -c "bash /opt/zkllvm-template/scripts/run.sh prove"
$DOCKER compose exec toolchain bash /opt/zkllvm-template/scripts/run.sh prove
cd -
else
cd "$REPO_ROOT"
Expand All @@ -227,12 +194,7 @@ prove() {
verify() {
if [ "$USE_DOCKER" = true ] ; then
cd "$REPO_ROOT"
$DOCKER run $DOCKER_OPTS \
--rm \
--volume $(pwd):/opt/zkllvm-template \
--volume $(pwd)/build/template:/opt/evm-placeholder-verification/contracts/zkllvm/template \
ghcr.io/nilfoundation/evm-placeholder-verification:latest \
sh -c "bash /opt/zkllvm-template/scripts/run.sh verify"
$DOCKER compose exec verifier bash /opt/zkllvm-template/scripts/run.sh verify
cd -
else
cd /opt/evm-placeholder-verification
Expand Down Expand Up @@ -264,6 +226,7 @@ while [[ "$#" -gt 0 ]]; do
build_statement) SUBCOMMAND=build_statement ;;
prove) SUBCOMMAND=prove ;;
verify) SUBCOMMAND=verify ;;
init) SUBCOMMAND=init ;;
run_zkllvm) SUBCOMMAND=run_zkllvm ;;
run_proof_market_toolchain) SUBCOMMAND=run_proof_market_toolchain ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
Expand Down

0 comments on commit 3a4af96

Please sign in to comment.