diff --git a/Cargo.toml b/Cargo.toml index 30cc114..4400074 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] resolver = "2" -members = ["madara-prover-rpc-client", "madara-prover-rpc-server", "stone-prover", "test-toolkit"] +members = ["madara-prover-common", "madara-prover-rpc-client", "madara-prover-rpc-server", "stone-prover", "test-cases"] [workspace.dependencies] cairo-vm = { version = "0.9.0", features = ["lambdaworks-felt"] } diff --git a/madara-prover-common/Cargo.toml b/madara-prover-common/Cargo.toml new file mode 100644 index 0000000..7ec2e0a --- /dev/null +++ b/madara-prover-common/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "madara-prover-common" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +cairo-vm = { workspace = true } +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true } + +[dev-dependencies] +rstest = { workspace = true } +test-cases = { path = "../test-cases" } \ No newline at end of file diff --git a/madara-prover-common/src/lib.rs b/madara-prover-common/src/lib.rs new file mode 100644 index 0000000..180e38a --- /dev/null +++ b/madara-prover-common/src/lib.rs @@ -0,0 +1,2 @@ +pub mod models; +pub mod toolkit; diff --git a/stone-prover/src/models.rs b/madara-prover-common/src/models.rs similarity index 99% rename from stone-prover/src/models.rs rename to madara-prover-common/src/models.rs index af7499b..c14c71e 100644 --- a/stone-prover/src/models.rs +++ b/madara-prover-common/src/models.rs @@ -128,7 +128,7 @@ pub struct Proof { #[cfg(test)] mod tests { use std::path::Path; - use test_toolkit::load_fixture; + use test_cases::load_fixture; use super::*; diff --git a/stone-prover/src/toolkit.rs b/madara-prover-common/src/toolkit.rs similarity index 100% rename from stone-prover/src/toolkit.rs rename to madara-prover-common/src/toolkit.rs diff --git a/madara-prover-rpc-server/Cargo.toml b/madara-prover-rpc-server/Cargo.toml index d8d2e75..fc75970 100644 --- a/madara-prover-rpc-server/Cargo.toml +++ b/madara-prover-rpc-server/Cargo.toml @@ -7,9 +7,10 @@ edition = "2021" [dependencies] cairo-vm = { version = "0.9.0", features = ["lambdaworks-felt"] } +madara-prover-common = { path = "../madara-prover-common" } prost = { workspace = true } stone-prover = { path = "../stone-prover" } -thiserror = {workspace = true } +thiserror = { workspace = true } tokio = { workspace = true } tonic = { workspace = true } serde_json = { workspace = true } @@ -20,5 +21,5 @@ bincode = "2.0.0-rc.3" tonic-build = { workspace = true } [dev-dependencies] -test-toolkit = { path = "../test-toolkit" } +test-cases = { path = "../test-cases" } diff --git a/madara-prover-rpc-server/src/main.rs b/madara-prover-rpc-server/src/main.rs index 37be2b8..84235d6 100644 --- a/madara-prover-rpc-server/src/main.rs +++ b/madara-prover-rpc-server/src/main.rs @@ -1,9 +1,9 @@ use tokio_stream::wrappers::ReceiverStream; use tonic::{transport::Server, Request, Response, Status}; +use madara_prover_common::models::{Proof, ProverConfig, ProverParameters, PublicInput}; use prover::ProverRequest; use stone_prover::error::ProverError; -use stone_prover::models::{Proof, ProverConfig, ProverParameters, PublicInput}; use stone_prover::prover::run_prover_async; use crate::cairo::{extract_run_artifacts, run_in_proof_mode}; diff --git a/stone-prover/Cargo.toml b/stone-prover/Cargo.toml index d4325b6..11d5b86 100644 --- a/stone-prover/Cargo.toml +++ b/stone-prover/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" description = "A Rust wrapper around StarkWare's Stone Prover." [dependencies] -cairo-vm = { workspace = true } +madara-prover-common = { path = "../madara-prover-common" } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } tempfile = "3.8.1" @@ -14,4 +14,4 @@ tokio = { workspace = true } [dev-dependencies] rstest = { workspace = true } -test-toolkit = { path = "../test-toolkit" } \ No newline at end of file +test-cases = { path = "../test-cases" } \ No newline at end of file diff --git a/stone-prover/src/lib.rs b/stone-prover/src/lib.rs index 4530de4..8427903 100644 --- a/stone-prover/src/lib.rs +++ b/stone-prover/src/lib.rs @@ -1,4 +1,2 @@ pub mod error; -pub mod models; pub mod prover; -pub mod toolkit; diff --git a/stone-prover/src/prover.rs b/stone-prover/src/prover.rs index 7299b06..e06eadb 100644 --- a/stone-prover/src/prover.rs +++ b/stone-prover/src/prover.rs @@ -3,8 +3,10 @@ use std::path::{Path, PathBuf}; use tempfile::tempdir; use crate::error::ProverError; -use crate::models::{PrivateInput, Proof, ProverConfig, ProverParameters, PublicInput}; -use crate::toolkit::{read_json_from_file, write_json_to_file}; +use madara_prover_common::models::{ + PrivateInput, Proof, ProverConfig, ProverParameters, PublicInput, +}; +use madara_prover_common::toolkit::{read_json_from_file, write_json_to_file}; /// Call the Stone Prover from the command line. /// @@ -226,10 +228,10 @@ mod test { use rstest::{fixture, rstest}; use tempfile::NamedTempFile; - use test_toolkit::get_fixture_path; + use test_cases::get_fixture_path; - use crate::models::{PrivateInput, Proof}; - use crate::toolkit::read_json_from_file; + use madara_prover_common::models::{PrivateInput, Proof}; + use madara_prover_common::toolkit::read_json_from_file; use super::*; diff --git a/test-toolkit/Cargo.toml b/test-cases/Cargo.toml similarity index 87% rename from test-toolkit/Cargo.toml rename to test-cases/Cargo.toml index f1b55bd..0a9dbc9 100644 --- a/test-toolkit/Cargo.toml +++ b/test-cases/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "test-toolkit" +name = "test-cases" version = "0.1.0" edition = "2021" diff --git a/stone-prover/tests/fixtures/fibonacci-no-hint/fibonacci.cairo b/test-cases/cases/fibonacci-no-hint/fibonacci.cairo similarity index 100% rename from stone-prover/tests/fixtures/fibonacci-no-hint/fibonacci.cairo rename to test-cases/cases/fibonacci-no-hint/fibonacci.cairo diff --git a/stone-prover/tests/fixtures/fibonacci-no-hint/fibonacci_compiled.json b/test-cases/cases/fibonacci-no-hint/fibonacci_compiled.json similarity index 100% rename from stone-prover/tests/fixtures/fibonacci-no-hint/fibonacci_compiled.json rename to test-cases/cases/fibonacci-no-hint/fibonacci_compiled.json diff --git a/stone-prover/tests/fixtures/fibonacci/cpu_air_params.json b/test-cases/cases/fibonacci/cpu_air_params.json similarity index 100% rename from stone-prover/tests/fixtures/fibonacci/cpu_air_params.json rename to test-cases/cases/fibonacci/cpu_air_params.json diff --git a/stone-prover/tests/fixtures/fibonacci/cpu_air_prover_config.json b/test-cases/cases/fibonacci/cpu_air_prover_config.json similarity index 100% rename from stone-prover/tests/fixtures/fibonacci/cpu_air_prover_config.json rename to test-cases/cases/fibonacci/cpu_air_prover_config.json diff --git a/stone-prover/tests/fixtures/fibonacci/fibonacci.cairo b/test-cases/cases/fibonacci/fibonacci.cairo similarity index 100% rename from stone-prover/tests/fixtures/fibonacci/fibonacci.cairo rename to test-cases/cases/fibonacci/fibonacci.cairo diff --git a/stone-prover/tests/fixtures/fibonacci/fibonacci_compiled.json b/test-cases/cases/fibonacci/fibonacci_compiled.json similarity index 100% rename from stone-prover/tests/fixtures/fibonacci/fibonacci_compiled.json rename to test-cases/cases/fibonacci/fibonacci_compiled.json diff --git a/stone-prover/tests/fixtures/fibonacci/fibonacci_memory.bin b/test-cases/cases/fibonacci/fibonacci_memory.bin similarity index 100% rename from stone-prover/tests/fixtures/fibonacci/fibonacci_memory.bin rename to test-cases/cases/fibonacci/fibonacci_memory.bin diff --git a/stone-prover/tests/fixtures/fibonacci/fibonacci_private_input.json b/test-cases/cases/fibonacci/fibonacci_private_input.json similarity index 100% rename from stone-prover/tests/fixtures/fibonacci/fibonacci_private_input.json rename to test-cases/cases/fibonacci/fibonacci_private_input.json diff --git a/stone-prover/tests/fixtures/fibonacci/fibonacci_proof.json b/test-cases/cases/fibonacci/fibonacci_proof.json similarity index 100% rename from stone-prover/tests/fixtures/fibonacci/fibonacci_proof.json rename to test-cases/cases/fibonacci/fibonacci_proof.json diff --git a/stone-prover/tests/fixtures/fibonacci/fibonacci_public_input.json b/test-cases/cases/fibonacci/fibonacci_public_input.json similarity index 100% rename from stone-prover/tests/fixtures/fibonacci/fibonacci_public_input.json rename to test-cases/cases/fibonacci/fibonacci_public_input.json diff --git a/stone-prover/tests/fixtures/fibonacci/fibonacci_trace.bin b/test-cases/cases/fibonacci/fibonacci_trace.bin similarity index 100% rename from stone-prover/tests/fixtures/fibonacci/fibonacci_trace.bin rename to test-cases/cases/fibonacci/fibonacci_trace.bin diff --git a/stone-prover/tests/fixtures/hello-world/hello_world.cairo b/test-cases/cases/hello-world/hello_world.cairo similarity index 100% rename from stone-prover/tests/fixtures/hello-world/hello_world.cairo rename to test-cases/cases/hello-world/hello_world.cairo diff --git a/stone-prover/tests/fixtures/hello-world/hello_world_compiled.json b/test-cases/cases/hello-world/hello_world_compiled.json similarity index 100% rename from stone-prover/tests/fixtures/hello-world/hello_world_compiled.json rename to test-cases/cases/hello-world/hello_world_compiled.json diff --git a/test-toolkit/src/lib.rs b/test-cases/src/lib.rs similarity index 87% rename from test-toolkit/src/lib.rs rename to test-cases/src/lib.rs index 2142a6c..f3991dd 100644 --- a/test-toolkit/src/lib.rs +++ b/test-cases/src/lib.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; pub fn get_fixture_path(filename: &str) -> PathBuf { Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../stone-prover/tests/fixtures") + .join("cases") .join(filename) }