Skip to content

Commit

Permalink
chore: rename api.proto file to tx_prover.proto
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiagoPittella committed Jan 27, 2025
1 parent fb2284b commit cd26afa
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 32 deletions.
13 changes: 7 additions & 6 deletions bin/proving-service/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ fn main() -> miette::Result<()> {
// HELPER FUNCTIONS
// ================================================================================================

/// Copies all api.proto file from the root proto directory to the proto directory of this crate.
/// Copies the tx_prover.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");
let src_file = format!("{REPO_PROTO_DIR}/tx_prover.proto");
let dest_file = format!("{CRATE_PROTO_DIR}/tx_prover.proto");

fs::remove_dir_all(CRATE_PROTO_DIR).into_diagnostic()?;
fs::create_dir_all(CRATE_PROTO_DIR).into_diagnostic()?;
Expand All @@ -50,14 +51,14 @@ fn compile_tonic_server_proto() -> miette::Result<()> {
PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR should be set"));
let dst_dir = crate_root.join("src").join("generated");

// Remove `api.rs` if it exists.
fs::remove_file(dst_dir.join("api.rs")).into_diagnostic().ok();
// Remove `tx_prover.rs` if it exists.
fs::remove_file(dst_dir.join("tx_prover.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 protos = &[proto_dir.join("tx_prover.proto")];
let includes = &[proto_dir];

let file_descriptors = protox::compile(protos, includes)?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Specification of the user facing gRPC API.
syntax = "proto3";
package api;
package tx_prover;

service Api {
rpc ProveTransaction(ProveTransactionRequest) returns (ProveTransactionResponse) {}
Expand Down
4 changes: 2 additions & 2 deletions bin/proving-service/src/generated/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use miden_objects::transaction::ProvenTransaction;
use miden_tx::utils::{Deserializable, DeserializationError, Serializable};

#[rustfmt::skip]
pub mod api;
pub mod tx_prover;

pub use api::*;
pub use tx_prover::*;

// CONVERSIONS
// ================================================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,12 @@ pub mod api_client {
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/api.Api/ProveTransaction");
let path = http::uri::PathAndQuery::from_static(
"/tx_prover.Api/ProveTransaction",
);
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("api.Api", "ProveTransaction"));
req.extensions_mut()
.insert(GrpcMethod::new("tx_prover.Api", "ProveTransaction"));
self.inner.unary(req, path, codec).await
}
}
Expand Down Expand Up @@ -220,7 +223,7 @@ pub mod api_server {
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/api.Api/ProveTransaction" => {
"/tx_prover.Api/ProveTransaction" => {
#[allow(non_camel_case_types)]
struct ProveTransactionSvc<T: Api>(pub Arc<T>);
impl<
Expand Down Expand Up @@ -298,7 +301,7 @@ pub mod api_server {
}
}
/// Generated gRPC service name
pub const SERVICE_NAME: &str = "api.Api";
pub const SERVICE_NAME: &str = "tx_prover.Api";
impl<T> tonic::server::NamedService for ApiServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
Expand Down
17 changes: 9 additions & 8 deletions crates/miden-proving-service-client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ fn main() -> miette::Result<()> {
// HELPER FUNCTIONS
// ================================================================================================

/// Copies all api.proto file from the root proto directory to the proto directory of this crate.
/// Copies the tx_prover.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");
let src_file = format!("{REPO_PROTO_DIR}/tx_prover.proto");
let dest_file = format!("{CRATE_PROTO_DIR}/tx_prover.proto");

fs::remove_dir_all(CRATE_PROTO_DIR).into_diagnostic()?;
fs::create_dir_all(CRATE_PROTO_DIR).into_diagnostic()?;
Expand All @@ -51,14 +52,14 @@ fn compile_tonic_client_proto() -> miette::Result<()> {
PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR should be set"));
let dst_dir = crate_root.join("src").join("generated");

// Remove `api.rs` if it exists.
fs::remove_file(dst_dir.join("api.rs")).into_diagnostic().ok();
// Remove `tx_prover.rs` if it exists.
fs::remove_file(dst_dir.join("tx_prover.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 protos = &[proto_dir.join("tx_prover.proto")];
let includes = &[proto_dir];

let file_descriptors = protox::compile(protos, includes)?;
Expand All @@ -70,9 +71,9 @@ fn compile_tonic_client_proto() -> miette::Result<()> {
build_tonic_client(&file_descriptor_path, &std_path, protos, includes, false)?;
build_tonic_client(&file_descriptor_path, &nostd_path, protos, includes, true)?;

// Replace `std` references with `core` and `alloc` in `api.rs`.
// Replace `std` references with `core` and `alloc` in `tx_prover.rs`.
// (Only for nostd version)
let nostd_file_path = nostd_path.join("api.rs");
let nostd_file_path = nostd_path.join("tx_prover.rs");
let file_content = fs::read_to_string(&nostd_file_path).into_diagnostic()?;
let updated_content = file_content
.replace("std::result", "core::result")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Specification of the user facing gRPC API.
syntax = "proto3";
package api;
package tx_prover;

service Api {
rpc ProveTransaction(ProveTransactionRequest) returns (ProveTransactionResponse) {}
Expand Down
4 changes: 2 additions & 2 deletions crates/miden-proving-service-client/src/generated/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ compile_error!("The `std` feature cannot be used when targeting `wasm32`.");
#[cfg(feature = "std")]
mod std;
#[cfg(feature = "std")]
pub use std::api::*;
pub use std::tx_prover::*;

#[cfg(not(feature = "std"))]
mod nostd;
#[cfg(not(feature = "std"))]
pub use nostd::api::*;
pub use nostd::tx_prover::*;

// CONVERSIONS
// ================================================================================================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#[rustfmt::skip]
pub mod api;
pub mod tx_prover;
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ pub mod api_client {
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/api.Api/ProveTransaction");
let path = http::uri::PathAndQuery::from_static(
"/tx_prover.Api/ProveTransaction",
);
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("api.Api", "ProveTransaction"));
req.extensions_mut()
.insert(GrpcMethod::new("tx_prover.Api", "ProveTransaction"));
self.inner.unary(req, path, codec).await
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#[rustfmt::skip]
pub mod api;
pub mod tx_prover;
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,12 @@ pub mod api_client {
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/api.Api/ProveTransaction");
let path = http::uri::PathAndQuery::from_static(
"/tx_prover.Api/ProveTransaction",
);
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("api.Api", "ProveTransaction"));
req.extensions_mut()
.insert(GrpcMethod::new("tx_prover.Api", "ProveTransaction"));
self.inner.unary(req, path, codec).await
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/miden-proving-service-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/tx_prover.proto");

/// ERRORS
/// ===============================================================================================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Specification of the user facing gRPC API.
syntax = "proto3";
package api;
package tx_prover;

service Api {
rpc ProveTransaction(ProveTransactionRequest) returns (ProveTransactionResponse) {}
Expand Down

0 comments on commit cd26afa

Please sign in to comment.