From 50af7e5c16b9dbf0f6f958ed3382581706c1b011 Mon Sep 17 00:00:00 2001 From: dmir Date: Sun, 30 Jun 2024 19:05:28 +0300 Subject: [PATCH] CI: Add docker images --- .github/workflows/ghcr.yml | 87 ++++++++++ Dockerfile | 35 ++++ air_prover/Dockerfile | 35 ++++ air_verifier/Dockerfile | 35 ++++ test_files/cpu_air_params.json | 17 ++ test_files/cpu_air_prover_config.json | 9 + test_files/fibonacci_memory.json | Bin 0 -> 3840 bytes test_files/fibonacci_private_input.json | 7 + test_files/fibonacci_public_input.json | 220 ++++++++++++++++++++++++ test_files/fibonacci_trace.json | Bin 0 -> 12288 bytes 10 files changed, 445 insertions(+) create mode 100644 .github/workflows/ghcr.yml create mode 100644 Dockerfile create mode 100644 air_prover/Dockerfile create mode 100644 air_verifier/Dockerfile create mode 100644 test_files/cpu_air_params.json create mode 100644 test_files/cpu_air_prover_config.json create mode 100644 test_files/fibonacci_memory.json create mode 100644 test_files/fibonacci_private_input.json create mode 100644 test_files/fibonacci_public_input.json create mode 100644 test_files/fibonacci_trace.json diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml new file mode 100644 index 00000000..219862c9 --- /dev/null +++ b/.github/workflows/ghcr.yml @@ -0,0 +1,87 @@ +name: Build +on: + push: + branches: + - 'master' + tags: + - 'v*.*.*' + pull_request: + branches: + - 'master' + +jobs: + build: + name: Docker images for ghcr.io + runs-on: ubuntu-latest + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + DOCKER_REGISTRY: ghcr.io + DOCKER_IMAGE_BASE: ${{ github.repository }} + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to the registry + uses: docker/login-action@v2 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Prover and Verifier + + - name: Prover&Verifier image tags & labels + id: meta-all + uses: docker/metadata-action@v3 + with: + images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }} + - name: Prover&Verifier image build & push + uses: docker/build-push-action@v3 + with: + context: . + file: Dockerfile + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + tags: ${{ steps.meta-all.outputs.tags }} + labels: ${{ steps.meta-all.coutputs.labels }} + + + # Prover + + - name: Prover image tags & labels + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}-prover + - name: Prover image build & push + uses: docker/build-push-action@v3 + with: + context: . + file: air_prover/Dockerfile + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.coutputs.labels }} + + # Verifier + + - name: Verifier image tags & labels + id: meta-ver + uses: docker/metadata-action@v3 + with: + images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}-verifier + - name: Verifier image build & push + uses: docker/build-push-action@v3 + with: + context: . + file: air_verifier/Dockerfile + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + tags: ${{ steps.meta-ver.outputs.tags }} + labels: ${{ steps.meta-ver.coutputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..34d93c2a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# Stage 1: Base Image +FROM ciimage/python:3.9 AS base_image + +# Install necessary dependencies including git +RUN apt-get update && apt-get install -y git + +# Clone the public prover repository +RUN git clone https://github.com/starkware-libs/stone-prover.git /app/prover + +# Set the working directory to the cloned repository +WORKDIR /app/prover + +# Run the installation scripts from the cloned repository +RUN /app/prover/install_deps.sh +RUN ./docker_common_deps.sh + +# Change ownership of the /app directory +RUN chown -R starkware:starkware /app + +# Build the project using Bazel +RUN bazel build //... + +# Stage 2: Target Image +FROM debian:stable-slim AS target + +# Copy the built binary from the base image to the target image +COPY --from=base_image /app/prover/build/bazelbin/src/starkware/main/cpu/cpu_air_prover /usr/bin/ +# Uncomment the following line if you need to copy the verifier as well +COPY --from=base_image /app/prover/build/bazelbin/src/starkware/main/cpu/cpu_air_verifier /usr/bin/ + +# Install the necessary runtime dependencies +RUN apt update && apt install -y libdw1 + +# Set the entry point for the container +#ENTRYPOINT ["cpu_air_prover"] diff --git a/air_prover/Dockerfile b/air_prover/Dockerfile new file mode 100644 index 00000000..51a516bd --- /dev/null +++ b/air_prover/Dockerfile @@ -0,0 +1,35 @@ +# Stage 1: Base Image +FROM ciimage/python:3.9 AS base_image + +# Install necessary dependencies including git +RUN apt-get update && apt-get install -y git + +# Clone the public prover repository +RUN git clone https://github.com/starkware-libs/stone-prover.git /app/prover + +# Set the working directory to the cloned repository +WORKDIR /app/prover + +# Run the installation scripts from the cloned repository +RUN /app/prover/install_deps.sh +RUN ./docker_common_deps.sh + +# Change ownership of the /app directory +RUN chown -R starkware:starkware /app + +# Build the project using Bazel +RUN bazel build //... + +# Stage 2: Target Image +FROM debian:stable-slim AS target + +# Copy the built binary from the base image to the target image +COPY --from=base_image /app/prover/build/bazelbin/src/starkware/main/cpu/cpu_air_prover /usr/bin/ +# Uncomment the following line if you need to copy the verifier as well +# COPY --from=base_image /app/prover/bazel-bin/src/starkware/main/cpu/cpu_air_verifier /usr/bin/ + +# Install the necessary runtime dependencies +RUN apt update && apt install -y libdw1 + +# Set the entry point for the container +ENTRYPOINT ["cpu_air_prover"] diff --git a/air_verifier/Dockerfile b/air_verifier/Dockerfile new file mode 100644 index 00000000..5b070650 --- /dev/null +++ b/air_verifier/Dockerfile @@ -0,0 +1,35 @@ +# Stage 1: Base Image +FROM ciimage/python:3.9 AS base_image + +# Install necessary dependencies including git +RUN apt-get update && apt-get install -y git + +# Clone the public prover repository +RUN git clone https://github.com/starkware-libs/stone-prover.git /app/prover + +# Set the working directory to the cloned repository +WORKDIR /app/prover + +# Run the installation scripts from the cloned repository +RUN /app/prover/install_deps.sh +RUN ./docker_common_deps.sh + +# Change ownership of the /app directory +RUN chown -R starkware:starkware /app + +# Build the project using Bazel +RUN bazel build //... + +# Stage 2: Target Image +FROM debian:stable-slim AS target + +# Copy the built binary from the base image to the target image +#COPY --from=base_image /app/prover/build/bazelbin/src/starkware/main/cpu/cpu_air_prover /usr/bin/ +# Uncomment the following line if you need to copy the verifier as well +COPY --from=base_image /app/prover/build/bazelbin/src/starkware/main/cpu/cpu_air_verifier /usr/bin/ + +# Install the necessary runtime dependencies +RUN apt update && apt install -y libdw1 + +# Set the entry point for the container +ENTRYPOINT ["cpu_air_verifier"] diff --git a/test_files/cpu_air_params.json b/test_files/cpu_air_params.json new file mode 100644 index 00000000..a3658860 --- /dev/null +++ b/test_files/cpu_air_params.json @@ -0,0 +1,17 @@ +{ + "field": "PrimeField0", + "stark": { + "fri": { + "fri_step_list": [ + 0, + 4, + 3 + ], + "last_layer_degree_bound": 64, + "n_queries": 18, + "proof_of_work_bits": 24 + }, + "log_n_cosets": 4 + }, + "use_extension_field": false +} diff --git a/test_files/cpu_air_prover_config.json b/test_files/cpu_air_prover_config.json new file mode 100644 index 00000000..423f1ed8 --- /dev/null +++ b/test_files/cpu_air_prover_config.json @@ -0,0 +1,9 @@ +{ + "cached_lde_config": { + "store_full_lde": false, + "use_fft_for_eval": false + }, + "constraint_polynomial_task_size": 256, + "n_out_of_memory_merkle_layers": 1, + "table_prover_n_tasks_per_segment": 32 +} diff --git a/test_files/fibonacci_memory.json b/test_files/fibonacci_memory.json new file mode 100644 index 0000000000000000000000000000000000000000..04a9e34a21119496c8d140c0e11c32f724cb6672 GIT binary patch literal 3840 zcma);*LKuE5JXqDu@{p~&L$Z!IcHe1ZNTK5zeIZHh2Q1CBE<169Xvz3cKuN5>Z|FV z(MaQ>v+%3Sx-6=(5yDJ{aEdIm*cet=70utsI)$mKkTlIJUd9Feh2=+egVC|YIw{3ccpGL?XAa&Vq)@7*2ZJA8SY1X-@ro#T#!)d?jwp2G@{BHJrU4ENP^NKfe(O-B!!eKYT zg&T_eW)0jtw_jzv&RgJIe_IC}Z(Ga#Z0b&j>$kn-mR{!_;sWKlc6Taoz6ZPDe$@Z} zv7frT;oQ1R!tF&P*%KuaU*mjE{50H$AwJD3-p_@;Z}L+;fYE+GQh-=}Ic^HxeP0d^ z$Q^=nbq~X7K7^S}SqIC+(z9z?!dYJ?!xK3 zCd}j>jytFC!>N8Y5XKDZ<}nNB`kRAu=f?v$_r5)ZQ+>ir9^tro%)`0<9>eK9&I)2Y zLEZQ7DV*v@<2@tc=J6cP_4fkqZB!8dCF;(jS8%Ey4f~peo5veC*Prs=qk{PFOkU~t aT&TYMR6k(2d3=O({e2mb`vmtDjpPrd19hnY literal 0 HcmV?d00001 diff --git a/test_files/fibonacci_private_input.json b/test_files/fibonacci_private_input.json new file mode 100644 index 00000000..15a9eddf --- /dev/null +++ b/test_files/fibonacci_private_input.json @@ -0,0 +1,7 @@ +{ + "trace_path": "/home/zaariel/stone-prover/test_files/fibonacci_trace.json", + "memory_path": "/home/zaariel/stone-prover/test_files/fibonacci_memory.json", + "pedersen": [], + "range_check": [], + "ecdsa": [] +} diff --git a/test_files/fibonacci_public_input.json b/test_files/fibonacci_public_input.json new file mode 100644 index 00000000..b626a13c --- /dev/null +++ b/test_files/fibonacci_public_input.json @@ -0,0 +1,220 @@ +{ + "layout": "small", + "rc_min": 32763, + "rc_max": 32769, + "n_steps": 512, + "memory_segments": { + "program": { + "begin_addr": 1, + "stop_ptr": 5 + }, + "execution": { + "begin_addr": 34, + "stop_ptr": 95 + }, + "output": { + "begin_addr": 95, + "stop_ptr": 97 + }, + "pedersen": { + "begin_addr": 97, + "stop_ptr": 97 + }, + "range_check": { + "begin_addr": 289, + "stop_ptr": 289 + }, + "ecdsa": { + "begin_addr": 353, + "stop_ptr": 353 + } + }, + "public_memory": [ + { + "address": 1, + "value": "0x40780017fff7fff", + "page": 0 + }, + { + "address": 2, + "value": "0x1", + "page": 0 + }, + { + "address": 3, + "value": "0x1104800180018000", + "page": 0 + }, + { + "address": 4, + "value": "0x4", + "page": 0 + }, + { + "address": 5, + "value": "0x10780017fff7fff", + "page": 0 + }, + { + "address": 6, + "value": "0x0", + "page": 0 + }, + { + "address": 7, + "value": "0x40780017fff7fff", + "page": 0 + }, + { + "address": 8, + "value": "0x1", + "page": 0 + }, + { + "address": 9, + "value": "0x400380007ffd8000", + "page": 0 + }, + { + "address": 10, + "value": "0x480680017fff8000", + "page": 0 + }, + { + "address": 11, + "value": "0x1", + "page": 0 + }, + { + "address": 12, + "value": "0x480680017fff8000", + "page": 0 + }, + { + "address": 13, + "value": "0x1", + "page": 0 + }, + { + "address": 14, + "value": "0x480a80007fff8000", + "page": 0 + }, + { + "address": 15, + "value": "0x1104800180018000", + "page": 0 + }, + { + "address": 16, + "value": "0x6", + "page": 0 + }, + { + "address": 17, + "value": "0x400280017ffd7fff", + "page": 0 + }, + { + "address": 18, + "value": "0x482680017ffd8000", + "page": 0 + }, + { + "address": 19, + "value": "0x2", + "page": 0 + }, + { + "address": 20, + "value": "0x208b7fff7fff7ffe", + "page": 0 + }, + { + "address": 21, + "value": "0x20780017fff7ffd", + "page": 0 + }, + { + "address": 22, + "value": "0x4", + "page": 0 + }, + { + "address": 23, + "value": "0x480a7ffc7fff8000", + "page": 0 + }, + { + "address": 24, + "value": "0x208b7fff7fff7ffe", + "page": 0 + }, + { + "address": 25, + "value": "0x480a7ffc7fff8000", + "page": 0 + }, + { + "address": 26, + "value": "0x482a7ffc7ffb8000", + "page": 0 + }, + { + "address": 27, + "value": "0x482680017ffd8000", + "page": 0 + }, + { + "address": 28, + "value": "0x800000000000011000000000000000000000000000000000000000000000000", + "page": 0 + }, + { + "address": 29, + "value": "0x1104800180018000", + "page": 0 + }, + { + "address": 30, + "value": "0x800000000000010fffffffffffffffffffffffffffffffffffffffffffffff9", + "page": 0 + }, + { + "address": 31, + "value": "0x208b7fff7fff7ffe", + "page": 0 + }, + { + "address": 32, + "value": "0x22", + "page": 0 + }, + { + "address": 33, + "value": "0x0", + "page": 0 + }, + { + "address": 34, + "value": "0x5f", + "page": 0 + }, + { + "address": 94, + "value": "0x61", + "page": 0 + }, + { + "address": 95, + "value": "0xa", + "page": 0 + }, + { + "address": 96, + "value": "0x90", + "page": 0 + } + ], + "dynamic_params": null +} diff --git a/test_files/fibonacci_trace.json b/test_files/fibonacci_trace.json new file mode 100644 index 0000000000000000000000000000000000000000..3241cdf8dd8a6493cae5fe1fe26dd49ad55a4f87 GIT binary patch literal 12288 zcmeH}=_-X$7=@1{k%$OKQe?`Ip@R$^WXO;qLxynwccE>s=g+EBE@1hydY`lNu)Mx+ z&o=7Utg=fvXS`eUyk)QE1>=1kc)$3fogdJ=WPDKbvhg9!E0$w6^ZBIss(s$nyk>k# z^SbeA%^Q|@o#WlK^LV$6Mlx%0Ms&i6a;RtL`W(!USSZRfmyhVA!- zkBI*$;iJZR-}Qw5HIN?aBBY1(P#Vbdq3%I?NDrj}-ly4z>_hgU(a1fa{vV`=^iUee zd!g<@dPonYf!vqs9;Ao#P#VZRq3%I?NDrlf+!N{^q=)oS8pu7N?m>D;52bK>$r^iUeeJ)!PFdPonYf&bnUegSsZ5@G-V literal 0 HcmV?d00001