From 8f42044994af5112f95c1a794d4ab96b586c4694 Mon Sep 17 00:00:00 2001 From: Aditya Bisht Date: Wed, 25 Sep 2024 07:21:55 +0000 Subject: [PATCH] chore: update Dockerfile --- packages/prover/Dockerfile | 39 +++++++++++++++++++++++++----- packages/prover/circom_proofgen.sh | 3 ++- packages/prover/core.py | 12 +++++++-- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/packages/prover/Dockerfile b/packages/prover/Dockerfile index 45d2165b..25cfa7f7 100644 --- a/packages/prover/Dockerfile +++ b/packages/prover/Dockerfile @@ -1,15 +1,41 @@ -FROM python:3.10 +FROM nvidia/cuda:12.4.0-devel-ubuntu22.04 RUN apt-get update && apt-get upgrade -y # Update the package list and install necessary dependencies RUN apt-get update && \ - apt install -y cmake build-essential pkg-config libssl-dev libgmp-dev libsodium-dev nasm git awscli gcc nodejs npm curl m4 + DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \ + cmake \ + build-essential \ + pkg-config \ + libssl-dev \ + libgmp-dev \ + libffi-dev \ + libsodium-dev \ + nasm \ + git \ + awscli \ + gcc \ + nodejs \ + npm \ + curl \ + m4 \ + python3 \ + python3-pip \ + python3-dev \ + wget \ + software-properties-common \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +# Set Python 3 as the default python version +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 \ + && update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 # Node install RUN npm install -g n RUN n 22 RUN npm install -g yarn snarkjs -RUN git clone -b feat/body-parsing-with-audit-fix https://github.com/zkemail/ether-email-auth.git +RUN git clone -b feat/gpu https://github.com/zkemail/ether-email-auth.git WORKDIR /ether-email-auth/packages/prover RUN pip install -r requirements.txt RUN cp ./circom_proofgen.sh /root @@ -32,8 +58,9 @@ RUN yarn RUN git submodule init RUN git submodule update RUN ./build_gmp.sh host -RUN mkdir build_prover && cd build_prover -RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package +RUN mkdir build_prover +WORKDIR /root/rapidsnark/build_prover +RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package -DNVML_LIBRARY=/usr/local/cuda-12.4/targets/x86_64-linux/lib/stubs/libnvidia-ml.so RUN make -j$(nproc) && make install -RUN chmod +x package/bin/prover_cuda +RUN chmod +x ../package/bin/prover_cuda WORKDIR /root \ No newline at end of file diff --git a/packages/prover/circom_proofgen.sh b/packages/prover/circom_proofgen.sh index 07315087..7a7cb174 100755 --- a/packages/prover/circom_proofgen.sh +++ b/packages/prover/circom_proofgen.sh @@ -20,8 +20,9 @@ public_path="${buildDir}/rapidsnark_public_${circuitName}_${nonce}.json" cd "${SCRIPT_DIR}" echo "entered zk email path: ${SCRIPT_DIR}" +echo "Testing" -./email_auth_with_body_parsing_with_qp_encoding "${input_path}" "${witness_path}" | tee /dev/stderr +${SCRIPT_DIR}/email_auth_with_body_parsing_with_qp_encoding "${input_path}" "${witness_path}" 2>&1 | tee /dev/stderr status_jswitgen=$? echo "✓ Finished witness generation with cpp! ${status_jswitgen}" diff --git a/packages/prover/core.py b/packages/prover/core.py index 194fd9f0..db22addd 100644 --- a/packages/prover/core.py +++ b/packages/prover/core.py @@ -3,7 +3,7 @@ import json import logging -logger = logging.getLogger(__name__) +# logger = logging.getLogger(__name__) def gen_email_auth_proof(nonce: str, is_local: bool, input: dict) -> dict: @@ -19,18 +19,26 @@ def gen_email_auth_proof(nonce: str, is_local: bool, input: dict) -> dict: def store_input(circuit_name: str, nonce: str, json_data: dict): + print("Storing input") cur_dir = get_cur_dir() + print(f"Current dir: {cur_dir}") build_dir = os.path.join(cur_dir, "build") + if not os.path.exists(build_dir): + os.makedirs(build_dir) # check if build_dir exists if not os.path.exists(build_dir): os.makedirs(build_dir) + print(f"Build dir: {build_dir}") json_file_path = os.path.join( build_dir, "input_" + circuit_name + "_" + nonce + ".json" ) + print(f"Json file path: {json_file_path}") + print(f"Json data: {json_data}") logger.info(f"Store user input to {json_file_path}") with open(json_file_path, "w") as json_file: - json_file.write(json_data) + json_file.write(json.dumps(json_data)) + print("Stored input") def load_proof(circuit_name: str, nonce: str) -> dict: