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/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..9143d52f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,62 @@ +name: release + +on: + release: + types: [created] + +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 }} + + - name: Extract binary from Docker image + run: | + container_id=$(docker create ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}:pr-3) + docker cp $container_id:/usr/bin/cpu_air_prover /tmp/cpu_air_prover + docker cp $container_id:/usr/bin/cpu_air_verifier /tmp/cpu_air_verifier + docker rm $container_id + + - name: Verify file existence#2 + run: ls -l /tmp/cpu* + + - name: Upload files to a GitHub release + uses: svenstaro/upload-release-action@2.4.0 + with: + file_glob: true + tag: ${{ github.ref }} + file: /tmp/cpu_air* 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 00000000..04a9e34a Binary files /dev/null and b/test_files/fibonacci_memory.json differ 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 00000000..3241cdf8 Binary files /dev/null and b/test_files/fibonacci_trace.json differ