-
Notifications
You must be signed in to change notification settings - Fork 48
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
base: next
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
There was a problem hiding this 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.
crates/block-producer/src/config.rs
Outdated
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()) | ||
)) |
There was a problem hiding this comment.
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.
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)) | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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?
bin/node/src/config.rs
Outdated
@@ -27,6 +27,7 @@ struct NormalizedRpcConfig { | |||
struct NormalizedBlockProducerConfig { | |||
endpoint: Url, | |||
verify_tx_proofs: bool, | |||
remote_batch_prover: Option<Url>, |
There was a problem hiding this comment.
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
.
crates/utils/src/config.rs
Outdated
@@ -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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
crates/block-producer/src/server.rs
Outdated
@@ -90,6 +97,7 @@ impl BlockProducer { | |||
store, | |||
rpc_listener, | |||
chain_tip, | |||
remote_batch_prover, |
There was a problem hiding this comment.
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)
pub async fn run( | ||
self, | ||
mempool: SharedMempool, | ||
store: StoreClient, | ||
batch_prover: BatchProver, | ||
) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 🙃
38ad61d
to
d03caff
Compare
crates/block-producer/Cargo.toml
Outdated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@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.
|
@SantiagoPittella I think you need to rebase to |
99be9e4
to
c0e0b04
Compare
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
c0e0b04
to
7b80750
Compare
There was a problem hiding this 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
/// The batch prover to use. | ||
/// | ||
/// If not provided, a local batch prover is used. | ||
batch_prover: BatchProver, |
There was a problem hiding this comment.
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.
/// 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, |
/// 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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// 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 { |
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 aRemoteBatchProver
.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 ofmiden-base
dependencies.The formatting of the
Cargo.toml
is a bit odd after adding some dependencies, but it is compliant withtaplo
. I'm investigating what can be causing the issue.