diff --git a/Cargo.lock b/Cargo.lock index f354ff921..9cfe10639 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2030,7 +2030,7 @@ dependencies = [ [[package]] name = "miden-proving-service-client" -version = "0.1.0" +version = "0.8.0" dependencies = [ "async-trait", "getrandom", diff --git a/bin/proving-service/Cargo.toml b/bin/proving-service/Cargo.toml index f9ad82844..40ae16a98 100644 --- a/bin/proving-service/Cargo.toml +++ b/bin/proving-service/Cargo.toml @@ -3,7 +3,7 @@ name = "miden-proving-service" version = "0.8.0" description = "Miden rollup proving service" readme = "README.md" -keywords = ["miden", "proving-service"] +keywords = ["miden", "proving", "service"] license.workspace = true authors.workspace = true homepage.workspace = true diff --git a/bin/proving-service/build.rs b/bin/proving-service/build.rs index 973451b07..264d3dd2d 100644 --- a/bin/proving-service/build.rs +++ b/bin/proving-service/build.rs @@ -12,6 +12,9 @@ use protox::prost::Message; /// otherwise the docs will fail to build there. Note that writing to `OUT_DIR` is fine. const BUILD_GENERATED_FILES_IN_SRC: bool = option_env!("BUILD_GENERATED_FILES_IN_SRC").is_some(); +const REPO_PROTO_DIR: &str = "../../proto"; +const CRATE_PROTO_DIR: &str = "proto"; + /// Generates Rust protobuf bindings from .proto files. /// /// Because the proto generated files will be written to ./src/generated, this should be a no-op @@ -23,27 +26,37 @@ fn main() -> miette::Result<()> { return Ok(()); } + copy_proto_files()?; compile_tonic_server_proto() } + +// HELPER FUNCTIONS +// ================================================================================================ + +/// Copies all api.proto file from the root proto directory to the proto directory of this crate. +fn copy_proto_files() -> miette::Result<()> { + let src_file = format!("{REPO_PROTO_DIR}/api.proto"); + let dest_file = format!("{CRATE_PROTO_DIR}/api.proto"); + + fs::remove_dir_all(CRATE_PROTO_DIR).into_diagnostic()?; + fs::create_dir_all(CRATE_PROTO_DIR).into_diagnostic()?; + fs::copy(src_file, dest_file).into_diagnostic()?; + + Ok(()) +} + fn compile_tonic_server_proto() -> miette::Result<()> { let crate_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR should be set")); let dst_dir = crate_root.join("src").join("generated"); - // Construct the path to the proto/api.proto file - let proto_dir = crate_root - .parent() // Go up to the workspace root - .expect("bin directory should exist") - .parent() // Go up to the workspace root - .expect("Workspace root should exist") - .join("proto"); - // Remove `api.rs` if it exists. fs::remove_file(dst_dir.join("api.rs")).into_diagnostic().ok(); let out_dir = env::var("OUT_DIR").into_diagnostic()?; let file_descriptor_path = PathBuf::from(out_dir).join("file_descriptor_set.bin"); + let proto_dir: PathBuf = CRATE_PROTO_DIR.into(); let protos = &[proto_dir.join("api.proto")]; let includes = &[proto_dir]; diff --git a/bin/proving-service/proto/api.proto b/bin/proving-service/proto/api.proto new file mode 100644 index 000000000..4555b326f --- /dev/null +++ b/bin/proving-service/proto/api.proto @@ -0,0 +1,15 @@ +// Specification of the user facing gRPC API. +syntax = "proto3"; +package api; + +service Api { + rpc ProveTransaction(ProveTransactionRequest) returns (ProveTransactionResponse) {} +} + +message ProveTransactionRequest { + bytes transaction_witness = 1; +} + +message ProveTransactionResponse { + bytes proven_transaction = 1; +} diff --git a/crates/miden-proving-service-client/Cargo.toml b/crates/miden-proving-service-client/Cargo.toml index 023a68182..77441dba9 100644 --- a/crates/miden-proving-service-client/Cargo.toml +++ b/crates/miden-proving-service-client/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "miden-proving-service-client" -version = "0.1.0" -description = "client library that provides a client for the remote provers" +version = "0.8.0" +description = "Client library for the Miden rollup proving service" readme = "README.md" -keywords = ["miden", "miden-proving-service-client"] +keywords = ["miden", "proving", "service"] license.workspace = true authors.workspace = true repository.workspace = true diff --git a/crates/miden-proving-service-client/build.rs b/crates/miden-proving-service-client/build.rs index 4e271ec4c..ad10d95b7 100644 --- a/crates/miden-proving-service-client/build.rs +++ b/crates/miden-proving-service-client/build.rs @@ -13,6 +13,9 @@ use protox::prost::Message; /// otherwise the docs will fail to build there. Note that writing to `OUT_DIR` is fine. const BUILD_GENERATED_FILES_IN_SRC: bool = option_env!("BUILD_GENERATED_FILES_IN_SRC").is_some(); +const REPO_PROTO_DIR: &str = "../../proto"; +const CRATE_PROTO_DIR: &str = "proto"; + /// Generates Rust protobuf bindings from .proto files. /// /// Because the proto generated files will be written to ./src/generated, this should be a no-op @@ -24,28 +27,37 @@ fn main() -> miette::Result<()> { return Ok(()); } + copy_proto_files()?; compile_tonic_client_proto() } +// HELPER FUNCTIONS +// ================================================================================================ + +/// Copies all api.proto file from the root proto directory to the proto directory of this crate. +fn copy_proto_files() -> miette::Result<()> { + let src_file = format!("{REPO_PROTO_DIR}/api.proto"); + let dest_file = format!("{CRATE_PROTO_DIR}/api.proto"); + + fs::remove_dir_all(CRATE_PROTO_DIR).into_diagnostic()?; + fs::create_dir_all(CRATE_PROTO_DIR).into_diagnostic()?; + fs::copy(src_file, dest_file).into_diagnostic()?; + + Ok(()) +} + fn compile_tonic_client_proto() -> miette::Result<()> { let crate_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR should be set")); let dst_dir = crate_root.join("src").join("generated"); - // Compute the directory of the `proto` definitions - let proto_dir = crate_root - .parent() - .expect("crates directory should exist") - .parent() - .expect("workspace root should exist") - .join("proto"); - // Remove `api.rs` if it exists. fs::remove_file(dst_dir.join("api.rs")).into_diagnostic().ok(); let out_dir = env::var("OUT_DIR").into_diagnostic()?; let file_descriptor_path = PathBuf::from(out_dir).join("file_descriptor_set.bin"); + let proto_dir: PathBuf = CRATE_PROTO_DIR.into(); let protos = &[proto_dir.join("api.proto")]; let includes = &[proto_dir]; diff --git a/crates/miden-proving-service-client/proto/api.proto b/crates/miden-proving-service-client/proto/api.proto new file mode 100644 index 000000000..4555b326f --- /dev/null +++ b/crates/miden-proving-service-client/proto/api.proto @@ -0,0 +1,15 @@ +// Specification of the user facing gRPC API. +syntax = "proto3"; +package api; + +service Api { + rpc ProveTransaction(ProveTransactionRequest) returns (ProveTransactionResponse) {} +} + +message ProveTransactionRequest { + bytes transaction_witness = 1; +} + +message ProveTransactionResponse { + bytes proven_transaction = 1; +} diff --git a/crates/miden-proving-service-client/src/lib.rs b/crates/miden-proving-service-client/src/lib.rs index 66124f6cc..a12fd0251 100644 --- a/crates/miden-proving-service-client/src/lib.rs +++ b/crates/miden-proving-service-client/src/lib.rs @@ -21,7 +21,7 @@ mod prover; pub use prover::RemoteTransactionProver; /// Protobuf definition for the Miden proving service -pub const SERVICE_PROTO: &str = include_str!("../../../proto/api.proto"); +pub const SERVICE_PROTO: &str = include_str!("../proto/api.proto"); /// ERRORS /// ===============================================================================================