diff --git a/integration-tests/tests/test_integration.rs b/integration-tests/tests/test_integration.rs index 9cdc0f7..ac2bfcc 100644 --- a/integration-tests/tests/test_integration.rs +++ b/integration-tests/tests/test_integration.rs @@ -11,7 +11,7 @@ mod tests { use tonic::transport::{Endpoint, Uri}; use tower::service_fn; - use madara_prover_rpc_client::client::{execute_program, prove_execution}; + use madara_prover_rpc_client::client::{execute_and_prove, execute_program, prove_execution}; use madara_prover_rpc_client::prover::prover_client::ProverClient; use madara_prover_rpc_server::error::ServerError; use madara_prover_rpc_server::{run_grpc_server, BindAddress}; @@ -96,4 +96,26 @@ mod tests { let proof = result.unwrap(); assert_eq!(proof.proof_hex, test_case.proof.proof_hex); } + + #[rstest] + #[tokio::test] + async fn test_execute_and_prove( + #[future] rpc_client_server: (RpcClient, RpcServer), + #[from(parsed_prover_test_case)] test_case: ParsedProverTestCase, + ) { + let (mut client, _server) = rpc_client_server.await; + + let result = execute_and_prove( + &mut client, + test_case.compiled_program, + test_case.prover_config, + test_case.prover_parameters, + ) + .await; + + assert!(result.is_ok(), "{:?}", result); + + let proof = result.unwrap(); + assert_eq!(proof.proof_hex, test_case.proof.proof_hex); + } } diff --git a/madara-prover-common/src/models.rs b/madara-prover-common/src/models.rs index 4503f73..8cf042a 100644 --- a/madara-prover-common/src/models.rs +++ b/madara-prover-common/src/models.rs @@ -78,16 +78,6 @@ pub struct MemorySegmentAddresses { pub stop_ptr: u32, } -#[derive(Serialize, Deserialize, Debug)] -pub struct MemorySegments { - pub program: MemorySegmentAddresses, - pub execution: MemorySegmentAddresses, - pub output: MemorySegmentAddresses, - pub pedersen: MemorySegmentAddresses, - pub range_check: MemorySegmentAddresses, - pub ecdsa: MemorySegmentAddresses, -} - #[derive(Serialize, Deserialize, Debug)] pub struct PublicMemoryEntry { pub address: u32, diff --git a/madara-prover-rpc-server/src/lib.rs b/madara-prover-rpc-server/src/lib.rs index 6c618ee..52de398 100644 --- a/madara-prover-rpc-server/src/lib.rs +++ b/madara-prover-rpc-server/src/lib.rs @@ -171,8 +171,10 @@ impl Prover for ProverService { let prover_parameters: ProverParameters = serde_json::from_str(&prover_parameters_str) .map_err(|_| Status::invalid_argument("Could not read prover parameters"))?; - let execution_artifacts = run_cairo_program_in_proof_mode(&program) + let execution_artifacts = run_cairo_program_in_proof_mode(&program); + let execution_artifacts = execution_artifacts .map_err(|e| Status::internal(format!("Failed to run program: {e}")))?; + let prover_result = call_prover(&execution_artifacts, &prover_config, &prover_parameters).await; diff --git a/test-fixtures/src/lib.rs b/test-fixtures/src/lib.rs index 053ad6a..9319e64 100644 --- a/test-fixtures/src/lib.rs +++ b/test-fixtures/src/lib.rs @@ -29,6 +29,8 @@ pub fn read_proof_file>(proof_file: P) -> Proof { /// All the files forming a complete prover test case. pub struct ProverTestCase { + pub program_file: PathBuf, + pub compiled_program_file: PathBuf, pub public_input_file: PathBuf, pub prover_config_file: PathBuf, pub prover_parameter_file: PathBuf, @@ -39,6 +41,8 @@ pub struct ProverTestCase { #[fixture] pub fn fibonacci() -> ProverTestCase { + let program_file = get_test_case_file_path("fibonacci/fibonacci.cairo"); + let compiled_program_file = get_test_case_file_path("fibonacci/fibonacci_compiled.json"); let public_input_file = get_test_case_file_path("fibonacci/fibonacci_public_input.json"); let prover_config_file = get_test_case_file_path("fibonacci/cpu_air_prover_config.json"); let prover_parameter_file = get_test_case_file_path("fibonacci/cpu_air_params.json"); @@ -47,6 +51,8 @@ pub fn fibonacci() -> ProverTestCase { let proof_file = get_test_case_file_path("fibonacci/fibonacci_proof.json"); ProverTestCase { + program_file, + compiled_program_file, public_input_file, prover_config_file, prover_parameter_file, @@ -97,6 +103,7 @@ pub fn prover_cli_test_case(#[from(fibonacci)] files: ProverTestCase) -> ProverC } pub struct ParsedProverTestCase { + pub compiled_program: Vec, pub public_input: PublicInput, pub memory: Vec, pub trace: Vec, @@ -107,6 +114,7 @@ pub struct ParsedProverTestCase { #[fixture] pub fn parsed_prover_test_case(#[from(fibonacci)] files: ProverTestCase) -> ParsedProverTestCase { + let compiled_program = std::fs::read(files.compiled_program_file).unwrap(); let public_input: PublicInput = read_json_from_file(files.public_input_file).unwrap(); let prover_config: ProverConfig = read_json_from_file(files.prover_config_file).unwrap(); let prover_parameters: ProverParameters = @@ -117,6 +125,7 @@ pub fn parsed_prover_test_case(#[from(fibonacci)] files: ProverTestCase) -> Pars let proof = read_proof_file(&files.proof_file); ParsedProverTestCase { + compiled_program, public_input, memory, trace,