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

feat: adds native workflow for fedora #5

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
78 changes: 78 additions & 0 deletions .github/workflows/release-fedora.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Release Stone Prover for Fedora

on:
push:
tags:
- 'v*.*.*'

jobs:
build:
runs-on: ubuntu-latest
env:
TARGET_ARCH: x86_64

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build Docker image (Fedora)
run: |
docker buildx build --target test --file Dockerfile.fedora --load -t stone-prover-fedora-test .

- name: Extract binaries from Docker image
run: |
docker create --name temp stone-prover-fedora-test
docker cp temp:/usr/bin/cpu_air_prover ./cpu_air_prover-${TARGET_ARCH}
docker cp temp:/usr/bin/cpu_air_verifier ./cpu_air_verifier-${TARGET_ARCH}
docker rm temp

- name: Run tests in Fedora container
run: |
docker run --rm stone-prover-fedora-test /bin/bash -c "
bazelisk test //... &&
cd /app/e2e_test/CairoZero &&
cairo-compile fibonacci.cairo --output fibonacci_compiled.json --proof_mode &&
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 --min_steps=512 --print_output --proof_mode &&
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 &&
cpu_air_verifier --in_file=fibonacci_proof.json && echo 'Successfully verified example proof.'
"

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

- name: Build target Docker image (Fedora)
run: |
docker buildx build --target target --file Dockerfile.fedora --load -t stone-prover-fedora .

- name: Package RPM inside Fedora container
run: |
docker run --rm -v $(pwd):/rpmbuild/SOURCES stone-prover-fedora \
bash -c "dnf install -y rpm-build && \
mkdir -p /rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} && \
cp /rpmbuild/SOURCES/stone-prover.spec /rpmbuild/SPECS/ && \
rpmbuild -ba /rpmbuild/SPECS/stone-prover.spec \
--define \"version ${{ steps.vars.outputs.tag }}\" \
--define \"_topdir /rpmbuild\""

- name: Rename RPM package
run: |
mv ./RPMS/x86_64/*.rpm ./stone-prover-fedora-${TARGET_ARCH}.rpm

- name: Verify file existence
run: |
ls -la ./
ls -la ./RPMS/x86_64/

- name: Upload files to GitHub release
uses: softprops/action-gh-release@v2
with:
files: |
./cpu_air_prover-${TARGET_ARCH}
./cpu_air_verifier-${TARGET_ARCH}
./stone-prover-fedora-${TARGET_ARCH}.rpm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77 changes: 77 additions & 0 deletions Dockerfile.fedora
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Stage 1: Build
FROM fedora:latest AS build

WORKDIR /app

# Install dependencies
RUN dnf update -y && dnf install -y \
gcc gcc-c++ make python3-pip wget git \
elfutils-libelf-devel gmp-devel python3-devel \
elfutils-devel clang libstdc++-devel libcxx libcxx-devel \
ncurses-compat-libs cairo-devel \
&& dnf clean all \
&& rm -rf /var/cache/dnf
RUN pip install cpplint pytest numpy sympy==1.12.1 cairo-lang==0.12.0

# Install Bazelisk
RUN wget https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64 \
&& chmod +x bazelisk-linux-amd64 \
&& mv bazelisk-linux-amd64 /usr/local/bin/bazelisk

COPY . .

# Build
RUN bazelisk build //... --disk_cache=/tmp/bazel-disk-cache --cxxopt='-std=c++17'


# Stage 2: Test
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 \
--min_steps=512 \
--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 3: Target Image
FROM fedora:latest AS target

# Copy necessary binaries
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/
COPY --from=build /usr/local/bin/bazelisk /usr/local/bin/

# Install necessary runtime dependencies
RUN dnf update -y && dnf install -y \
elfutils-libelf gmp libstdc++ \
&& dnf clean all \
&& rm -rf /var/cache/dnf

ENTRYPOINT ["/bin/bash"]
33 changes: 33 additions & 0 deletions stone-prover.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Name: stone-prover
Version: %{version}
Release: 1%{?dist}
Summary: High-performance proof verification tool

License: MIT
URL: https://github.com/baking-bad/stone-prover
Source0: %{name}-%{version}.tar.gz

BuildRequires: gcc gcc-c++ make bazel python3-devel gmp-devel elfutils-libelf-devel
Requires: python3 python3-numpy python3-sympy gmp elfutils-libelf

%description
Stone-prover is a high-performance proof verification tool.

%prep
%autosetup -n %{name}-%{version}

%build
./build.sh

%install
mkdir -p %{buildroot}%{_bindir}
install -m 755 bazelbin/src/starkware/main/cpu/cpu_air_prover %{buildroot}%{_bindir}/cpu_air_prover
install -m 755 bazelbin/src/starkware/main/cpu/cpu_air_verifier %{buildroot}%{_bindir}/cpu_air_verifier

%files
%{_bindir}/cpu_air_prover
%{_bindir}/cpu_air_verifier

%changelog
* Wed Oct 02 2024 Your Name <[email protected]> - %{version}-1
- Initial RPM package for stone-prover.