Skip to content

Commit

Permalink
Merge pull request #10 from dipdup-io/na/release
Browse files Browse the repository at this point in the history
add instructions for use to README
  • Loading branch information
dmirgaleev authored Jul 17, 2024
2 parents 5463291 + 97ef14a commit ee4a104
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 29 deletions.
31 changes: 4 additions & 27 deletions .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ jobs:
id: meta-all
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/stone-prover

- name: Prover&Verifier image build & push
uses: docker/build-push-action@v3
with:
Expand All @@ -56,7 +57,7 @@ jobs:
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}-prover
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 @@ -74,7 +75,7 @@ jobs:
id: meta-ver
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}-verifier
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,27 +86,3 @@ jobs:
cache-to: type=gha,mode=max
tags: ${{ steps.meta-ver.outputs.tags }}
labels: ${{ steps.meta-ver.coutputs.labels }}

#Release files

- 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 .
docker cp $container_id:/usr/bin/cpu_air_verifier .
docker rm $container_id
- name: Verify file existence#1
run: pwd

- name: Verify file existence#2
run: ls -l

- name: Upload files to a GitHub release
uses: svenstaro/upload-release-action@2.4.0
with:
file_glob: true
overwrite: true
tag: ${{ github.ref }}
file: /home/runner/work/stone-packaging/stone-packaging/cpu_air*
repo_token: ${{ secrets.GITHUB_TOKEN }}
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: release

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

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
id: create_release
uses: softprops/action-gh-release@v2
with:
files: /tmp/cpu_air*
92 changes: 92 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,95 @@ Follow-up work:
- 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

1) Find the latest release version.
2) Download the necessary binaries. For example:

```bash
wget https://github.com/dipdup-io/stone-packaging/releases/download/v2.0.1/cpu_air_prover
wget https://github.com/dipdup-io/stone-packaging/releases/download/v2.0.1/cpu_air_verifier
```

Make the downloaded file executable.

```bash
chmod +x cpu_air_prover
```

### Creating and verifying a test proof using binaries

Clone the repository:

```bash
git clone https://github.com/dipdup-io/stone-packaging.git
```

Navigate to the example test directory (`test_files/`):

```bash
cd test_files/
```

Copy or download from latest release the binary files to this directory.

Run the prover:
```bash
./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
```

The proof is now available in the file `fibonacci_proof.json`.

Finally, run the verifier to verify the proof:
```bash
./cpu_air_verifier --in_file=fibonacci_proof.json && echo "Successfully verified example proof."
```

## Download minimal docker images for x86_64

Download the necessary package. Package stone-prover contains cpu_air_prover and cpu_air_verifier. For example:

```bash
docker pull ghcr.io/dipdup-io/stone-packaging/stone-prover:latest
```

### Creating and verifying a test proof using docker images

Clone the repository:

```bash
git clone https://github.com/dipdup-io/stone-packaging.git
```

Navigate to the example test directory (`test_files/`):

```bash
cd test_files/
```

Run docker images with volume:

```bash
docker run --entrypoint /bin/bash -v /your_directory/stone-packaging/test_files:/app/prover ghcr.io/dipdup-io/stone-packaging/stone-prover -c "cd /app/prover && exec 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"
```

The proof is now available in the file test_files/fibonacci_proof.json

Run the verifier to verify the proof:

```bash
docker run --entrypoint /bin/bash -v /your_directory/stone-packaging/test_files:/app/prover ghcr.io/dipdup-io/stone-packaging/stone-prover -c "cd /app/prover && exec cpu_air_verifier --in_file=fibonacci_proof.json && echo 'Successfully verified example proof.'"
```
4 changes: 2 additions & 2 deletions test_files/fibonacci_private_input.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"trace_path": "/home/zaariel/stone-prover/test_files/fibonacci_trace.json",
"memory_path": "/home/zaariel/stone-prover/test_files/fibonacci_memory.json",
"trace_path": "./fibonacci_trace.json",
"memory_path": "./fibonacci_memory.json",
"pedersen": [],
"range_check": [],
"ecdsa": []
Expand Down

0 comments on commit ee4a104

Please sign in to comment.