Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable MacOS support #14

Merged
merged 42 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6325fda
enable MacOS support
dmirgaleev Aug 16, 2024
1b0c978
Add the release job
dmirgaleev Aug 16, 2024
3d4e733
Fix TRAGET_ARCH
dmirgaleev Aug 17, 2024
eae6181
Upd
dmirgaleev Aug 17, 2024
b3eceeb
Update dockerfiles
dmirgaleev Aug 17, 2024
c0bbc9e
Add linux/arm to release
dmirgaleev Aug 17, 2024
513f519
Fix ghcr meta and deb naming
dmirgaleev Aug 18, 2024
b3a1a22
Add tests to MacOS static binaries builds
dmirgaleev Aug 18, 2024
f668d65
Rework linux release
dmirgaleev Aug 18, 2024
6f2515a
Fix path for builds
dmirgaleev Aug 18, 2024
f3bd161
Merge releases
dmirgaleev Aug 18, 2024
25ecb5c
Fix dependencies
dmirgaleev Aug 18, 2024
80cde43
Install dependencies first
dmirgaleev Aug 18, 2024
0023b3c
Add --break-system-packages for MacOS
dmirgaleev Aug 18, 2024
b1429c7
Fix permission for linux
dmirgaleev Aug 18, 2024
051c406
Skip cairo-run to avoid MacOS x64 failure
dmirgaleev Aug 18, 2024
e70eb58
Fix path
dmirgaleev Aug 18, 2024
a868aa4
Split build and test
dmirgaleev Aug 18, 2024
ed52993
Fix
dmirgaleev Aug 18, 2024
874d98c
fix package_deb.sh
Zaariel91 Aug 19, 2024
0720239
fix rename on release.yml
Zaariel91 Aug 19, 2024
1bd279c
add macos binaries
Zaariel91 Aug 19, 2024
078d931
fix release
Zaariel91 Aug 19, 2024
2ec6108
add macos binaries
Zaariel91 Aug 19, 2024
dfc2798
fix arm binaries, rename arm64 to aarch64
Zaariel91 Aug 20, 2024
574e932
fix arm64 binaries and Dockerfile
Zaariel91 Aug 20, 2024
8f549b6
fix ghcr and delete arch from release
Zaariel91 Aug 20, 2024
39606c9
add arm64 arch to ghcr
Zaariel91 Aug 21, 2024
897ab73
Use MacOS for arm docker builds
dmirgaleev Aug 21, 2024
c545d3d
docker installation for MacOS
dmirgaleev Aug 21, 2024
aed3f5b
Fix docker
dmirgaleev Aug 21, 2024
dcf9782
Try --cask docker
dmirgaleev Aug 21, 2024
6a1b94e
Add debug step for docker
dmirgaleev Aug 21, 2024
79f73c6
Debug
dmirgaleev Aug 21, 2024
2acc007
Fix docker path
dmirgaleev Aug 21, 2024
c515663
Downgrade to macos-13
dmirgaleev Aug 21, 2024
f82e20c
Rename static binaries
dmirgaleev Aug 21, 2024
4c649a7
Trying QEMU
dmirgaleev Aug 21, 2024
feee523
trying add qemu-static on Dockerfile
Zaariel91 Aug 21, 2024
61ae02e
Clean up
dmirgaleev Aug 21, 2024
ca16f40
Upd
dmirgaleev Aug 21, 2024
fc4ce21
Clean dependencies
dmirgaleev Aug 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ on:
jobs:
build:
name: Docker images for ghcr.io
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
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

Expand Down Expand Up @@ -48,8 +48,7 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta-all.outputs.tags }}
labels: ${{ steps.meta-all.coutputs.labels }}

labels: ${{ steps.meta-all.outputs.labels }}

# Prover

Expand All @@ -58,6 +57,7 @@ jobs:
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/cpu_air_prover

- name: Prover image build & push
uses: docker/build-push-action@v3
with:
Expand All @@ -67,7 +67,7 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.coutputs.labels }}
labels: ${{ steps.meta.outputs.labels }}

# Verifier

Expand All @@ -76,6 +76,7 @@ jobs:
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/cpu_air_verifier

- name: Verifier image build & push
uses: docker/build-push-action@v3
with:
Expand All @@ -85,4 +86,4 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta-ver.outputs.tags }}
labels: ${{ steps.meta-ver.coutputs.labels }}
labels: ${{ steps.meta-ver.outputs.labels }}
108 changes: 65 additions & 43 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,69 @@ on:

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 }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-14]

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 and deb
- name: Set output
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT

- name: Extract files and build DEB package
run: |
chmod +x ./build_deb.sh # Ensure your script is executable
./build_deb.sh ${{ steps.vars.outputs.tag }}

- name: Verify file existence#2
run: ls -la /tmp/stone-prover

- name: Upload files to a GitHub release
id: create_release
uses: softprops/action-gh-release@v2
with:
files: /tmp/stone-prover/usr/bin/cpu_air*

- name: Upload dep to a GitHub release
id: create_release_deb
uses: softprops/action-gh-release@v2
with:
files: /tmp/stone-prover/stone-prover.deb
- name: Checkout code
uses: actions/checkout@v2

- name: Set up environment
run: |
echo "Setting up environment for ${{ matrix.os }}"
if [ "${{ matrix.os }}" == "ubuntu-22.04" ]; then
echo "TARGET_ARCH=x86_64" >> $GITHUB_ENV
elif [ "${{ matrix.os }}" == "macos-14" ]; then
echo "TARGET_ARCH=arm64" >> $GITHUB_ENV
fi

- name: Build
run: |
chmod +x ./build.sh
./build.sh

- name: Test
run: |
chmod +x ./test.sh
./test.sh

- name: Set output
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT

- name: Extract files and build DEB package
if: matrix.os == 'ubuntu-22.04'
run: |
chmod +x ./package_deb.sh
./package_deb.sh ${{ steps.vars.outputs.tag }}

- name: Rename binaries ubuntu
if: matrix.os == 'ubuntu-22.04'
run: |
echo "Renaming binaries to include architecture"
mv /tmp/stone-prover/build/bazelbin/src/starkware/main/cpu/cpu_air_prover ./cpu_air_prover-${TARGET_ARCH}
mv /tmp/stone-prover/build/bazelbin/src/starkware/main/cpu/cpu_air_verifier ./cpu_air_verifier-${TARGET_ARCH}
mv /tmp/stone-prover/stone-prover.deb /tmp/stone-prover/stone-prover-linux-${TARGET_ARCH}.deb

- name: Rename binaries macos
if: matrix.os == 'macos-14'
run: |
echo "Renaming binaries to include architecture"
mv /tmp/stone-prover/build/bazelbin/src/starkware/main/cpu/cpu_air_prover ./cpu_air_prover-${TARGET_ARCH}
mv /tmp/stone-prover/build/bazelbin/src/starkware/main/cpu/cpu_air_verifier ./cpu_air_verifier-${TARGET_ARCH}

- name: Verify file existence#2
run: |
ls -la ./
ls -la /tmp/stone-prover/

- name: Upload files to a GitHub release
uses: softprops/action-gh-release@v2
with:
files: |
./cpu_air*
/tmp/stone-prover/*.deb

61 changes: 44 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,59 @@
# Stage 1: Base Image
FROM ciimage/python:3.9 AS base_image
FROM --platform=$BUILDPLATFORM ubuntu:22.04 AS build

# 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
RUN git clone https://github.com/baking-bad/stone-prover.git /app

# Set the working directory to the cloned repository
WORKDIR /app/prover
WORKDIR /app

# Run the installation scripts from the cloned repository
RUN /app/prover/install_deps.sh
RUN ./docker_common_deps.sh
COPY . .

# Change ownership of the /app directory
RUN chown -R starkware:starkware /app
# Install dependencies.
RUN ./install_deps.sh

# Build the project using Bazel
RUN bazel build //...
# Build.
RUN bazelisk build //...

FROM build AS test

# Run tests.
RUN bazelisk test //...

# Copy cpu_air_prover and cpu_air_verifier.
RUN ln -s /app/build/bazelbin/src/starkware/main/cpu/cpu_air_prover /bin/cpu_air_prover
RUN ln -s /app/build/bazelbin/src/starkware/main/cpu/cpu_air_verifier /bin/cpu_air_verifier

# End to end test.
WORKDIR /app/e2e_test/CairoZero

RUN cairo-compile fibonacci.cairo --output fibonacci_compiled.json --proof_mode

RUN cairo-run \
--program=fibonacci_compiled.json \
--layout=small \
--program_input=fibonacci_input.json \
--air_public_input=fibonacci_public_input.json \
--air_private_input=fibonacci_private_input.json \
--trace_file=fibonacci_trace.json \
--memory_file=fibonacci_memory.json \
--print_output \
--proof_mode

RUN cpu_air_prover \
--out_file=fibonacci_proof.json \
--private_input_file=fibonacci_private_input.json \
--public_input_file=fibonacci_public_input.json \
--prover_config_file=cpu_air_prover_config.json \
--parameter_file=cpu_air_params.json

RUN cpu_air_verifier --in_file=fibonacci_proof.json && echo "Successfully verified example proof."

# 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/
COPY --from=build /app/build/bazelbin/src/starkware/main/cpu/cpu_air_prover /usr/bin/
COPY --from=build /app/build/bazelbin/src/starkware/main/cpu/cpu_air_verifier /usr/bin/

# Install the necessary runtime dependencies
RUN apt update && apt install -y libdw1
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,34 @@ The goal of this project is to reduce the friction and time to start producing p
## Roadmap

- [x] Releases with static binaries for x86_64
- [x] Releases with static binaries for arm64
- [x] Minimal docker images for x86_64
- [x] Native packages for Debian/Ubuntu
- [ ] Native packages for Fedora
- [ ] ARM builds

Follow-up work:
- Native packages for Fedora
- Native packages for Alpine
- Native packages for Homebrew
- Technical docs for file formats (inputs, outputs, memory, trace, proof), test data
- Docs hosted on github pages
- Integrated proof decomposition (related to https://github.com/zksecurity/stark-evm-adapter)
- Observability suite (metrics, dashboard, configurable logging)
- Stwo support

# Instructions for use

## Download binaries for x86_64
### Download binaries for x86_64

```bash
sudo wget https://github.com/dipdup-io/stone-packaging/releases/latest/download/cpu_air_prover -O /usr/bin/cpu_air_prover && sudo chmod +x /usr/bin/cpu_air_prover
sudo wget https://github.com/dipdup-io/stone-packaging/releases/latest/download/cpu_air_verifier -O /usr/bin/cpu_air_verifier && sudo chmod +x /usr/bin/cpu_air_verifier
sudo wget https://github.com/dipdup-io/stone-packaging/releases/latest/download/cpu_air_prover-x86_64 -O /usr/local/bin/cpu_air_prover && sudo chmod +x /usr/local/bin/cpu_air_prover
sudo wget https://github.com/dipdup-io/stone-packaging/releases/latest/download/cpu_air_verifier-x86_64 -O /usr/local/bin/cpu_air_verifier && sudo chmod +x /usr/local/bin/cpu_air_verifier
```

### Download binaries for MacOS Arm64

```bash
wget https://github.com/dipdup-io/stone-packaging/releases/latest/download/cpu_air_prover-arm64 -O /usr/local/bin/cpu_air_prover && chmod +x /usr/local/bin/cpu_air_prover
wget https://github.com/dipdup-io/stone-packaging/releases/latest/download/cpu_air_verifier-arm64 -O /usr/local/bin/cpu_air_verifier && chmod +x /usr/local/bin/cpu_air_verifier
```

### Creating and verifying a test proof using binaries
Expand Down Expand Up @@ -78,12 +88,6 @@ Clone the repository:
git clone https://github.com/dipdup-io/stone-packaging.git /tmp/stone-packaging
```

Navigate to the example test directory (`/tmp/stone-packaging/test_files/`):

```bash
cd /tmp/stone-packaging/test_files/
```

Run docker images with volume:

```bash
Expand All @@ -108,7 +112,7 @@ docker run --entrypoint /bin/bash -v /tmp/stone-packaging/test_files:/app/prover
Download the deb package from the latest release. For example:

```bash
wget https://github.com/dipdup-io/stone-packaging/releases/latest/download/stone-prover.deb && sudo dpkg -i stone-prover.deb
wget https://github.com/dipdup-io/stone-packaging/releases/latest/download/stone-prover-linux-x86_64.deb && sudo dpkg -i stone-prover-linux-x86_64.deb
```

### Creating and verifying a test proof using deb package
Expand Down
63 changes: 43 additions & 20 deletions air_prover/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,58 @@
# Stage 1: Base Image
FROM ciimage/python:3.9 AS base_image
FROM ubuntu:22.04 AS build

# 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
RUN git clone https://github.com/baking-bad/stone-prover.git /app

# Set the working directory to the cloned repository
WORKDIR /app/prover
WORKDIR /app

# Run the installation scripts from the cloned repository
RUN /app/prover/install_deps.sh
RUN ./docker_common_deps.sh
COPY . .

# Change ownership of the /app directory
RUN chown -R starkware:starkware /app
# Install dependencies.
RUN ./install_deps.sh

# Build the project using Bazel
RUN bazel build //...
# Build.
RUN bazelisk build //...

FROM build AS test

# Run tests.
RUN bazelisk test //...

# Copy cpu_air_prover and cpu_air_verifier.
RUN ln -s /app/build/bazelbin/src/starkware/main/cpu/cpu_air_prover /bin/cpu_air_prover
RUN ln -s /app/build/bazelbin/src/starkware/main/cpu/cpu_air_verifier /bin/cpu_air_verifier

# End to end test.
WORKDIR /app/e2e_test/CairoZero

RUN cairo-compile fibonacci.cairo --output fibonacci_compiled.json --proof_mode

RUN cairo-run \
--program=fibonacci_compiled.json \
--layout=small \
--program_input=fibonacci_input.json \
--air_public_input=fibonacci_public_input.json \
--air_private_input=fibonacci_private_input.json \
--trace_file=fibonacci_trace.json \
--memory_file=fibonacci_memory.json \
--print_output \
--proof_mode

RUN cpu_air_prover \
--out_file=fibonacci_proof.json \
--private_input_file=fibonacci_private_input.json \
--public_input_file=fibonacci_public_input.json \
--prover_config_file=cpu_air_prover_config.json \
--parameter_file=cpu_air_params.json

RUN cpu_air_verifier --in_file=fibonacci_proof.json && echo "Successfully verified example proof."

# 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/
COPY --from=build /app/build/bazelbin/src/starkware/main/cpu/cpu_air_prover /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"]
Loading
Loading