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: use remote batch prover #701

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

SantiagoPittella
Copy link
Collaborator

This PR replaces the local batch prover with the remote one.

It adds the remote_batch_prover endpoint to the configuration file, that will be used at node startup to create a RemoteBatchProver.

At the moment, I removed the miden-faucet package from certain makefile commands because of an error regarding the mix of async and non async usage of miden-base dependencies.

The formatting of the Cargo.toml is a bit odd after adding some dependencies, but it is compliant with taplo. I'm investigating what can be causing the issue.

Copy link
Contributor

@Mirko-von-Leipzig Mirko-von-Leipzig left a comment

Choose a reason for hiding this comment

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

The code seems good; I'm just unhappy with requiring an external service out-of-process by default. Feels pretty unergonomic

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. Not a full review, but I left some comments inline.

Comment on lines 35 to 42
f.write_fmt(format_args!(
"{{ endpoint: \"{}\", store_url: \"{}\" }}",
self.endpoint, self.store_url
"{{ endpoint: \"{}\", store_url: \"{}\", remote_batch_prover: \"{}\" }}",
self.endpoint,
self.store_url,
self.remote_batch_prover
.as_ref()
.map_or("None".to_string(), |url| url.to_string())
))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: is there a better way to write this out? e.g., using multiple statements instead of a single statement.

Comment on lines 314 to 330
pub fn new_local(security_level: u32) -> Self {
warn!(target: COMPONENT, "Using local batch prover");
Self::Local(LocalBatchProver::new(security_level))
}

pub fn new_remote(endpoint: impl Into<String>) -> Self {
warn!(target: COMPONENT, "Using remote batch prover");
Self::Remote(RemoteBatchProver::new(endpoint))
}
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 use warn! here?

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 was using it with debug purposes (I using Ghostty and not having search scrollback is not playing out nice), to distinguish these logs easily. I'm replacing it with info.

Self::Remote(RemoteBatchProver::new(endpoint))
}

pub async fn prove(&self, proposed_batch: ProposedBatch) -> Result<ProvenBatch, BuildBatchError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably instrument this function, no? And then maybe we don't need the info! statements inside?

@@ -27,6 +27,7 @@ struct NormalizedRpcConfig {
struct NormalizedBlockProducerConfig {
endpoint: Url,
verify_tx_proofs: bool,
remote_batch_prover: Option<Url>,
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 probably name this: batch_prover_url.

@@ -10,6 +10,7 @@ pub const DEFAULT_NODE_RPC_PORT: u16 = 57291;
pub const DEFAULT_BLOCK_PRODUCER_PORT: u16 = 48046;
pub const DEFAULT_STORE_PORT: u16 = 28943;
pub const DEFAULT_FAUCET_SERVER_PORT: u16 = 8080;
pub const DEFAULT_BATCH_PROVER_PORT: u16 = 8082;
Copy link
Contributor

Choose a reason for hiding this comment

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

How did we come up with this default port value?

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 was using it to match the value that i was using in the Makefile target that was initializing the worker. Since now we have a local prover coexisting with the remote, this default value is not needed anymore since we are defaulting to local. I'm removing the constant.

@@ -90,6 +97,7 @@ impl BlockProducer {
store,
rpc_listener,
chain_tip,
remote_batch_prover,
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder whether instead of making remote_batch_prover a field in BlockProducer, we should just pass it to the BatchBuilder. Specifically, we could have BatchBuilder::new() constructor which looks something like this:

impl BatchBuilder {
    pub fn new(prover_url: Option<Url>) -> Self {
        ...
    }
}

Then, how to construct the prover would be the internal concern of the BatchBuilder, and here, we'd just do something like:

BatchBuilder::new(config.batch_prover_url)

Comment on lines 55 to 60
pub async fn run(
self,
mempool: SharedMempool,
store: StoreClient,
batch_prover: BatchProver,
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Related to the previous comment, if we make batch_prover a field of BatchBuilder, we won't need to pass it here.

Also, not from this PR, but we have a slight inconsistency here between batch and block builders: BlockBuilder takes the store as a construction parameter, but BatchBuilder takes it via the run method. Should we also move store into the constructor for BatchBuilder? @Mirko-von-Leipzig - what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I've been meaning to relook at these as part of #676.

Its also semi-related to properly decoupling components, i.e. a block-producer should be able to startup independently from the store.

I think we can align them now; but we should take a closer look in the medium term. Bit of a non-answer I know 🙃

@SantiagoPittella SantiagoPittella force-pushed the santiagopittella-use-remote-batch-prover branch from 38ad61d to d03caff Compare February 24, 2025 20:07
@SantiagoPittella SantiagoPittella changed the base branch from next to pgackst-migrate-block-prover February 24, 2025 20:08
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not loving how I break the formatting, but since I introduced a multi line dependency taplo is formatting this way.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could try fiddle with some of these: https://taplo.tamasfe.dev/configuration/formatter-options.html.

I imagine it would look nicer as a field per line once it exceeds the column limit.

But in the end if nothing looks good then it is what it is :) At least its consistent.

@SantiagoPittella
Copy link
Collaborator Author

SantiagoPittella commented Feb 24, 2025

@bobbinth I ended up rebasing with Philipp's branch. It does not use any of the features provided in his PR, but the changes the changes for it to work with the latest in miden base.

I'm currently running the client integration tests against this branch. Just ended up the run, it works 👌🏼

Base automatically changed from pgackst-migrate-block-prover to next February 25, 2025 06:40
@Mirko-von-Leipzig
Copy link
Contributor

@SantiagoPittella I think you need to rebase to next because that PR was merged.

@SantiagoPittella SantiagoPittella force-pushed the santiagopittella-use-remote-batch-prover branch from 99be9e4 to c0e0b04 Compare February 25, 2025 15:18
docs: add PR number to Changelog

remove remote prover from CI and makefile

remove remote prover from README

feat: create BatchProver enum, make remote proving optional

update to latest changes in miden-base

fix: udpate with miden-base latest

review: use multiple statements to print the configs

review: replace warn! with info! in prover init

review: add instrumentation to batch prover

review: rename remote_batch_prover to batch_prover_url

review: remove default batch prover url constant

review: move the batch_prover field from BatchProducer to BatchBuilder

fix: rollback changes in Makefile

docs: update CHANGELOG, add change to readme

fix: make it compatible with miden-base
@SantiagoPittella SantiagoPittella force-pushed the santiagopittella-use-remote-batch-prover branch from c0e0b04 to 7b80750 Compare February 25, 2025 18:22
Copy link
Contributor

@Mirko-von-Leipzig Mirko-von-Leipzig left a comment

Choose a reason for hiding this comment

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

Some minor doc nits, but LGTM

Comment on lines +38 to +41
/// The batch prover to use.
///
/// If not provided, a local batch prover is used.
batch_prover: BatchProver,
Copy link
Contributor

Choose a reason for hiding this comment

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

The optional conversion happens in new so lets document it there only.

Suggested change
/// The batch prover to use.
///
/// If not provided, a local batch prover is used.
batch_prover: BatchProver,
/// The batch prover to use.
batch_prover: BatchProver,

Comment on lines +45 to +48
/// Creates a new [`BatchBuilder`] with the given batch prover URL.
///
/// If no URL is provided, a local batch prover is used.
pub fn new(batch_prover_url: Option<Url>) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Creates a new [`BatchBuilder`] with the given batch prover URL.
///
/// If no URL is provided, a local batch prover is used.
pub fn new(batch_prover_url: Option<Url>) -> Self {
/// Creates a new [`BatchBuilder`] with the given batch prover URL.
///
/// Defaults to [`BatchProver::Local`] is no URL is provided.
pub fn new(batch_prover_url: Option<Url>) -> Self {

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