Skip to content

Commit

Permalink
Internal: replace stone-prover module by stone-prover-sdk
Browse files Browse the repository at this point in the history
The code of the `stone-prover` crate has been moved to
`stone-prover-sdk`.
  • Loading branch information
odesenfans committed Feb 23, 2024
1 parent 17e0df2 commit 45e9db6
Show file tree
Hide file tree
Showing 29 changed files with 65 additions and 910 deletions.
42 changes: 25 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:

env:
CARGO_TERM_COLOR: always
STONE_SDK_VERSION: v0.3.0
STONE_INSTALL_DIR: ./dependencies/stone

jobs:
build:
Expand Down Expand Up @@ -47,18 +49,32 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Log in to Github container registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Set cache image environment variables
- name: Set Stone SDK version in context
id: set-env-sdk-version
run: |
# Uppercase characters are not allowed in Docker tags
cache_image=$(echo ghcr.io/${GITHUB_REPOSITORY}/build-cache | tr '[:upper:]' '[:lower:]')
echo "STONE_PROVER_DOCKER_CACHE=$(echo ${cache_image})" >> $GITHUB_ENV
echo "STONE_SDK_VERSION=${STONE_SDK_VERSION}" >> $GITHUB_ENV
echo "STONE_INSTALL_DIR=${STONE_INSTALL_DIR}" >> $GITHUB_ENV
- name: Cache Stone prover and verifier
id: cache-stone
uses: actions/cache@v4
with:
path: ${{ env.STONE_INSTALL_DIR }}
key: stone-${{ runner.os }}-${{ env.STONE_SDK_VERSION }}

- name: Download Stone
if: steps.cache-stone.outputs.cache-hit != 'true'
run: |
mkdir -p "${STONE_INSTALL_DIR}"
wget https://github.com/Moonsong-Labs/stone-prover-sdk/releases/download/${STONE_SDK_VERSION}/cpu_air_prover -O "${STONE_INSTALL_DIR}/cpu_air_prover"
wget https://github.com/Moonsong-Labs/stone-prover-sdk/releases/download/${STONE_SDK_VERSION}/cpu_air_verifier -O "${STONE_INSTALL_DIR}/cpu_air_verifier"
- name: Download Docker cache image (if available)
run: docker pull ${STONE_PROVER_DOCKER_CACHE} || true
- name: Set Stone in PATH
run: |
INSTALL_DIR=$(readlink -f ${STONE_INSTALL_DIR})
echo "${INSTALL_DIR}" >> $GITHUB_PATH
chmod +x ${INSTALL_DIR}/cpu_air_prover
chmod +x ${INSTALL_DIR}/cpu_air_verifier
- name: Build
run: cargo build --verbose
Expand All @@ -71,11 +87,3 @@ jobs:

- name: Run tests
run: cargo test --verbose

- name: Push the image to the cache
# It's not possible to push packages from fork PRs.
if: github.event.pull_request.head.repo.full_name == github.repository
run: |
docker tag stone-prover-build:latest ${STONE_PROVER_DOCKER_CACHE}
docker push ${STONE_PROVER_DOCKER_CACHE}
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[workspace]
resolver = "2"

members = ["integration-tests", "madara-prover-common", "madara-prover-rpc-client", "madara-prover-rpc-server", "stone-prover", "test-cases", "test-fixtures", "integration-tests/evm-test"]
members = ["integration-tests", "madara-prover-rpc-client", "madara-prover-rpc-server", "test-cases", "test-fixtures", "integration-tests/evm-test"]

[workspace.dependencies]
cairo-vm = { git = "https://github.com/Moonsong-Labs/cairo-vm", rev = "b2f69d230416129a84ad8237ccc13d088992f74b", features=["extensive_hints"] }
cairo-vm = { git = "https://github.com/Moonsong-Labs/cairo-vm", rev = "b2f69d230416129a84ad8237ccc13d088992f74b", features = ["extensive_hints"] }
prost = "0.12.1"
serde = { version = "1.0.192", features = ["derive"] }
serde_json = "1.0.108"
stark_evm_adapter = "0.1.5"
stone-prover-sdk = { git = "https://github.com/Moonsong-Labs/stone-prover-sdk", tag = "v0.3.0" }
tempfile = "3.8.1"
thiserror = "1.0.50"
tokio = { version = "1.34.0", features = ["macros", "process", "rt-multi-thread"] }
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ pub async fn prove_cairo_program() -> Result((), Box<dyn Error>) {
## Project structure

* `integration-tests`: Integration tests.
* `madara-prover-common`: Types and functions used in both the server and client.
* `madara-prover-rpc-client`: Prover API client.
* `madara-prover-rpc-server`: Prover API server.
* `protocols`: Protocol buffers are stored here.
* `stone-prover`: Rust wrapper for the Stone prover.
* `test-cases`: Cairo programs used as test cases.
* `test-fixtures`: Shared test fixtures and utilities.

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ publish = false

[dev-dependencies]
rand = "0.8.5"
madara-prover-common = { path = "../madara-prover-common" }
madara-prover-rpc-client = { path = "../madara-prover-rpc-client" }
madara-prover-rpc-server = { path = "../madara-prover-rpc-server" }
evm-adapter = { path = "../integration-tests/evm-test" }
rstest = { workspace = true }
serde_json = { workspace = true }
stone-prover-sdk = { workspace = true }
test-cases = { path = "../test-cases" }
test-fixtures = { path = "../test-fixtures" }
tokio = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/tests/integration/test_starknet_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ mod tests {
use crate::integration::toolkit::{starknet_prover_client_server, RpcServer};
use madara_prover_rpc_client::services::starknet_prover::execute_and_prove;
use rstest::rstest;
use madara_prover_common::models::Proof;
use madara_prover_common::toolkit::read_json_from_file;
use stone_prover_sdk::models::Proof;
use stone_prover_sdk::json::read_json_from_file;
use madara_prover_rpc_client::services::starknet_prover::starknet_prover_proto::starknet_prover_client::StarknetProverClient;
use test_cases::get_test_case_file_path;

Expand Down
6 changes: 1 addition & 5 deletions integration-tests/tests/integration/toolkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use tokio::net::UnixStream;
use tokio::task::JoinHandle;
use tonic::transport::{Endpoint, Uri};
use tower::service_fn;
use test_fixtures::prover_in_path;

pub type RpcServer = JoinHandle<Result<(), ServerError>>;

Expand Down Expand Up @@ -56,15 +55,12 @@ async fn rpc_client_server<T>(
}

#[fixture]
pub async fn prover_client_server(
#[from(prover_in_path)] _path: (),
) -> (ProverClient<tonic::transport::Channel>, RpcServer) {
pub async fn prover_client_server() -> (ProverClient<tonic::transport::Channel>, RpcServer) {
rpc_client_server(ProverClient::new).await
}

#[fixture]
pub async fn starknet_prover_client_server(
#[from(prover_in_path)] _path: (),
) -> (StarknetProverClient<tonic::transport::Channel>, RpcServer) {
rpc_client_server(StarknetProverClient::new).await
}
17 changes: 0 additions & 17 deletions madara-prover-common/Cargo.toml

This file was deleted.

2 changes: 0 additions & 2 deletions madara-prover-common/src/lib.rs

This file was deleted.

186 changes: 0 additions & 186 deletions madara-prover-common/src/models.rs

This file was deleted.

24 changes: 0 additions & 24 deletions madara-prover-common/src/toolkit.rs

This file was deleted.

2 changes: 1 addition & 1 deletion madara-prover-rpc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2021"

[dependencies]
cairo-vm = { workspace = true }
madara-prover-common = { path = "../madara-prover-common" }
prost = { workspace = true }
serde_json = { workspace = true }
stone-prover-sdk = { workspace = true }
tokio = { workspace = true }
tonic = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion madara-prover-rpc-client/src/services/prover.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cairo_vm::air_private_input::AirPrivateInput;
use tonic::Status;

use madara_prover_common::models::{Proof, ProverConfig, ProverParameters, PublicInput};
use stone_prover_sdk::models::{Proof, ProverConfig, ProverParameters, PublicInput};

use prover_proto::prover_client::ProverClient;
use prover_proto::{ExecutionRequest, ExecutionResponse, ProverRequest, ProverResponse};
Expand Down
Loading

0 comments on commit 45e9db6

Please sign in to comment.