Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions crates/block-producer/src/block_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ impl BlockProver {
&self,
tx_batches: OrderedBatches,
block_inputs: BlockInputs,
block_header: &BlockHeader,
block_header: BlockHeader,
) -> Result<BlockProof, ProverError> {
match self {
Self::Local(prover) => {
let prover = prover.clone();
let block_header = block_header.clone();

spawn_blocking_in_current_span(move || {
prover
Expand Down
2 changes: 1 addition & 1 deletion crates/block-producer/src/proof_scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ async fn generate_block_proof(
.map_err(|e| ProveBlockError::Fatal(ProofSchedulerError::DeserializationFailed(e)))?;

let proof = block_prover
.prove(request.tx_batches, request.block_inputs, &request.block_header)
.prove(request.tx_batches, request.block_inputs, request.block_header)
.await
.map_err(ProveBlockError::from_prover_error)?;

Expand Down
45 changes: 27 additions & 18 deletions crates/remote-prover-client/src/remote_prover/block_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloc::vec::Vec;
use core::time::Duration;

use miden_protocol::batch::{OrderedBatches, ProvenBatch};
use miden_protocol::block::{BlockHeader, BlockInputs, BlockProof, ProposedBlock, ProvenBlock};
use miden_protocol::block::{BlockHeader, BlockInputs, BlockProof, ProvenBlock};
use miden_protocol::transaction::{OrderedTransactionHeaders, TransactionHeader};
use miden_protocol::utils::serde::{Deserializable, DeserializationError, Serializable};
use tokio::sync::Mutex;
Expand Down Expand Up @@ -105,7 +105,7 @@ impl RemoteBlockProver {
pub async fn prove(
&self,
tx_batches: OrderedBatches,
block_header: &BlockHeader,
block_header: BlockHeader,
block_inputs: BlockInputs,
) -> Result<BlockProof, RemoteProverClientError> {
self.connect().await?;
Expand All @@ -120,16 +120,11 @@ impl RemoteBlockProver {
})?
.clone();

let block_proof_request =
ProposedBlock::new_at(block_inputs, tx_batches.into_vec(), block_header.timestamp())
.map_err(|err| {
RemoteProverClientError::other_with_source(
"failed to create proposed block",
err,
)
})?;

let request = tonic::Request::new(block_proof_request.into());
let request = tonic::Request::new(encode_block_proof_request(
&tx_batches,
&block_header,
&block_inputs,
));

let response = client.prove(request).await.map_err(|err| {
RemoteProverClientError::other_with_source("failed to prove block", err)
Expand Down Expand Up @@ -158,11 +153,25 @@ impl TryFrom<proto::Proof> for BlockProof {
}
}

impl From<ProposedBlock> for proto::ProofRequest {
fn from(proposed_block: ProposedBlock) -> Self {
proto::ProofRequest {
proof_type: proto::ProofType::Block.into(),
payload: proposed_block.to_bytes(),
}
/// Encodes a block proof request in the wire format the remote prover server expects.
///
/// The server decodes the `BLOCK` payload as a `miden_node_proto::BlockProofRequest`, whose
/// serialized layout is `tx_batches`, then `block_header`, then `block_inputs`. This crate also
/// builds for `wasm32` (where `miden-node-proto`, via tonic transport / tokio net, does not
/// compile), so it cannot depend on that type and instead mirrors its layout here. Keep this in
/// sync with `BlockProofRequest`'s `Serializable` impl.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@Mirko-von-Leipzig any suggestions as to how to handle this better? Can't use BlockProofRequest from miden-node-proto because this crate needs wasm compilation

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes - we delete all this.

See #995 (comment).

cc @SantiagoPittella - could we just delete this client crate now? I think so..

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, I think we can delete it

fn encode_block_proof_request(
tx_batches: &OrderedBatches,
block_header: &BlockHeader,
block_inputs: &BlockInputs,
) -> proto::ProofRequest {
let mut payload = Vec::new();
tx_batches.write_into(&mut payload);
block_header.write_into(&mut payload);
block_inputs.write_into(&mut payload);

proto::ProofRequest {
proof_type: proto::ProofType::Block.into(),
payload,
}
}
Loading