Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: split miden-tx-prover into miden-proving-service and miden-remote-provers #1047

Merged

Conversation

SantiagoPittella
Copy link
Collaborator

This approach uses a single protobuf file placed in miden-remote-provers/proto/ and replaced the name of RemoteTransactionProverError with RemoteProverError in order of being used by other types of provers.

It uses the feature tx-prover to activate the RemoteTransactionProver, this is needed because we don't want to trigger the async feature for the whole workspace by default.

The miden-proving-service now only generates the file for the std version of the api, since it doesn't support WASM.

@bobbinth bobbinth requested a review from igamigo January 13, 2025 17:11
@SantiagoPittella SantiagoPittella force-pushed the santiagopittella-split-tx-prover-crates-same-repo-approach branch from 02fb98a to ac627ee Compare January 13, 2025 22:09
@SantiagoPittella SantiagoPittella force-pushed the santiagopittella-split-tx-prover-crates-same-repo-approach branch from ac627ee to 62d5605 Compare January 13, 2025 22:15
@SantiagoPittella
Copy link
Collaborator Author

I addressed the comments and changed a bit the README s. Also rebased because it had tons of conflicts.

cc @bobbinth

@SantiagoPittella SantiagoPittella marked this pull request as ready for review January 13, 2025 22:15
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Looks good. Not a full review, but I left some comments inline.

Cargo.toml Show resolved Hide resolved
bin/proving-service/Cargo.toml Outdated Show resolved Hide resolved
bin/proving-service/src/generated/std/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file still contains the generated client code. Do we actually need it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I leave the client code here because we use it in the test placed in main.rs.

bin/proving-service/build.rs Show resolved Hide resolved
miden-remote-provers/src/generated/std/mod.rs Outdated Show resolved Hide resolved
miden-remote-provers/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, left some comments about the file structure and make target organization mostly, but other than that I think this is ready to be merged

[package]
name = "miden-remote-provers"
version = "0.1.0"
description = "client library that provides a client for the remote provers"
Copy link
Collaborator

@igamigo igamigo Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Is it worth changing the name to miden-remote-prover-clients? Maybe it's too much of a mouthful but it sounds more descriptive at a first glance (miden-remote-provers sounds more ambiguous in comparison). cc @bobbinth since I think he suggested these names

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of miden-remote-prover-clients, maybe something like miden-prover-clients?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

miden-prover-client may be fine, but also maybe miden-proving-service-client is better? (it immediately indicates that this is a "companion" crate for miden-proving-service crate).

miden-remote-provers/README.md Outdated Show resolved Hide resolved
bin/proving-service/build.rs Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
Makefile Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
bin/proving-service/build.rs Show resolved Hide resolved
miden-remote-provers/README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I left a couple more nits, but I think this is good to merge already if we can test it works well on the client.

miden-remote-provers/src/lib.rs Show resolved Hide resolved
miden-remote-provers/src/lib.rs Show resolved Hide resolved
miden-remote-provers/build.rs Show resolved Hide resolved
@SantiagoPittella
Copy link
Collaborator Author

I'm merging it in order to merge other "child" PRs on the client, I can address any further comment in a followup PR.

@SantiagoPittella SantiagoPittella merged commit 0e65f4f into next Jan 15, 2025
11 checks passed
@SantiagoPittella SantiagoPittella deleted the santiagopittella-split-tx-prover-crates-same-repo-approach branch January 15, 2025 20:35
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you. I know this PR is merged, but I left some comments inline which I think we should address in a follow-up PR (before we can release these crates).

Also, it seems like we are doing some things in the proving service crate purely for testing reasons (e.g., building the client part of the protobuf service). I wonder if there is a better way to handle these.

async = ["miden-tx/async"]
default = ["std"]
std = ["miden-objects/std", "miden-tx/std", "dep:tokio", "dep:tonic-web", "dep:tokio-stream", "dep:axum", "dep:tracing", "dep:tracing-subscriber", "tonic/transport"]
default = ["concurrent"]
testing = ["miden-objects/testing", "miden-lib/testing", "miden-tx/testing"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's check if we still need the testing feature.

Comment on lines 19 to 23
Note that for the prover worker you might need to enable the `testing` feature in case the transactions were executed with reduced proof-of-work requirements (or otherwise, the proving process will fail). This step will also generate the necessary protobuf-related files. You can achieve that by generating the binary with:

```bash
make install-tx-prover-testing
make install-proving-service-testing
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should no longer be needed.

Comment on lines 156 to 159
| ------------ | ------------------------------------------------------------------------------------------------------------|
| `std` | Enable usage of Rust's `std`, use `--no-default-features` for `no-std` support. |
| `concurrent` | Enables concurrent code to speed up runtime execution. |
| `async` | Enables the `RemoteTransactionProver` struct, that implements an async version of `TransactionProver` trait.|
| `testing` | Enables testing utilities and reduces proof-of-work requirements to speed up tests' runtimes. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think std feature is no longer relevant. Also, we should be able to remove the testing feature as mentioned in other comments.

tonic-web = { version = "0.12" }
tracing = { version = "0.1" }
tracing-opentelemetry = "0.28"
tracing-subscriber = { version = "0.3", features = ["fmt", "json", "env-filter"] }
uuid = { version = "1.11", features = ["v4"] }
winter-maybe-async = { version = "0.10" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need winter-maybe-async dependency here. What is it used for? Also, let'd make sure we only have dependencies that are required.

pingora = { version = "0.4", features = [ "lb" ] }
pingora-core = "0.4"
pingora-proxy = "0.4"
pingora-limits = "0.4"
reqwest = { version = "0.11" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the latest version of request is now 0.12 - can we update to it?

Comment on lines +80 to +84
let mut client = self
.client
.write()
.take()
.ok_or_else(|| TransactionProverError::other("client should be connected"))?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: why do we need to do take() here now? (I don't think this was needed before, right?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced the .take with a .as_ref and then cloning the client.

This change was needed because of a clippy error. We didn't ran the linter earlier because it was only enabled when using the "async" feature and it was disabled in the Makefile. Now that we have clippy for no-std, the linter is throwing an error because the MutexGuard was held through an .await call.

Comment on lines +15 to +16
/// Contains the protobuf definitions
pub const PROTO_MESSAGES: &str = include_str!("../../proto/api.proto");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change the doc comment to something like: "Protobuf definitions for the Miden proving service".

Also nit: maybe we should change the constant name to something like SERVICE_PROTO?

@@ -0,0 +1,35 @@
extern crate alloc;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not be more like this:

#![no_std]

#[cfg(feature = "std")]
extern crate std;

@@ -23,7 +23,7 @@ clippy: ## Runs Clippy with configs

.PHONY: clippy-no-std
clippy-no-std: ## Runs Clippy with configs
cargo clippy --no-default-features --target wasm32-unknown-unknown --workspace --lib -- -D warnings
cargo clippy --no-default-features --target wasm32-unknown-unknown --workspace --lib --exclude miden-proving-service --features tx-prover -- -D warnings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could we swap --features and --exclude places? i.e., so that it looks like:

cargo clippy --no-default-features --target wasm32-unknown-unknown --workspace --lib --features tx-prover --exclude miden-proving-service -- -D warnings

And do the same for other commands below.

Comment on lines +133 to +135
.PHONY: install-proving-service-testing
install-proving-service-testing: ## Install proving service's CLI intended for testing purposes
cargo install --path bin/proving-service --bin miden-proving-service --locked --features concurrent,testing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in one of the other comments, I don't think this will be needed any longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants