Skip to content

Commit bbca6a1

Browse files
tomyrdSantiagoPittella
authored andcommitted
feat: re-add tonic-web dependency (#786)
* feat: re-add `tonic-web` * update `miden-base` * review: add comments to explain `tonic_web::enable`
1 parent 7b22511 commit bbca6a1

7 files changed

Lines changed: 52 additions & 49 deletions

File tree

Cargo.lock

Lines changed: 44 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/faucet/src/stub_rpc_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub async fn serve_stub(endpoint: &Url) -> anyhow::Result<()> {
159159

160160
tonic::transport::Server::builder()
161161
.accept_http1(true)
162-
.add_service(api_service)
162+
.add_service(tonic_web::enable(api_service)) // tonic_web::enable is needed to support grpc-web calls
163163
.serve_with_incoming(TcpListenerStream::new(listener))
164164
.await
165165
.context("failed to serve stub RPC API")

bin/stress-test/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ fn create_batch(txs: &[ProvenTransaction], block_ref: &BlockHeader) -> ProvenBat
348348
.collect();
349349
let input_notes = txs.iter().flat_map(|tx| tx.input_notes().iter().cloned()).collect();
350350
let output_notes = txs.iter().flat_map(|tx| tx.output_notes().iter().cloned()).collect();
351-
ProvenBatch::new_unchecked(
351+
ProvenBatch::new(
352352
BatchId::from_transactions(txs.iter()),
353353
block_ref.commitment(),
354354
block_ref.block_num(),
@@ -358,6 +358,7 @@ fn create_batch(txs: &[ProvenTransaction], block_ref: &BlockHeader) -> ProvenBat
358358
BlockNumber::from(u32::MAX),
359359
OrderedTransactionHeaders::new_unchecked(txs.iter().map(TransactionHeader::from).collect()),
360360
)
361+
.unwrap()
361362
}
362363

363364
/// For each pair of account and note, creates a transaction that consumes the note.

crates/block-producer/src/errors.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ use miden_block_prover::ProvenBlockError;
22
use miden_node_proto::errors::ConversionError;
33
use miden_node_utils::{ErrorReport, formatting::format_opt};
44
use miden_objects::{
5-
Digest, ProposedBatchError, ProposedBlockError,
5+
Digest, ProposedBatchError, ProposedBlockError, ProvenBatchError,
66
block::BlockNumber,
77
note::{NoteId, Nullifier},
88
transaction::TransactionId,
99
};
1010
use miden_proving_service_client::RemoteProverError;
11-
use miden_tx_batch_prover::errors::ProvenBatchError;
1211
use thiserror::Error;
1312
use tokio::task::JoinError;
1413

crates/block-producer/src/test_utils/batch.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl TransactionBatchConstructor for ProvenBatch {
5656
output_notes.extend(tx.output_notes().iter().cloned());
5757
}
5858

59-
ProvenBatch::new_unchecked(
59+
ProvenBatch::new(
6060
BatchId::from_transactions(txs.iter().copied()),
6161
Digest::default(),
6262
BlockNumber::GENESIS,
@@ -68,6 +68,7 @@ impl TransactionBatchConstructor for ProvenBatch {
6868
txs.into_iter().map(TransactionHeader::from).collect(),
6969
),
7070
)
71+
.unwrap()
7172
}
7273

7374
fn from_notes_created(starting_account_index: u32, notes_per_tx: &[u64]) -> Self {

crates/rpc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ miden-tx = { workspace = true }
2323
tokio = { workspace = true, features = ["macros", "net", "rt-multi-thread"] }
2424
tokio-stream = { workspace = true, features = ["net"] }
2525
tonic = { workspace = true }
26+
tonic-web = { version = "0.12" }
2627
tracing = { workspace = true }
2728

2829
[dev-dependencies]

crates/rpc/src/server/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl Rpc {
4646
pub async fn serve(self) -> anyhow::Result<()> {
4747
tonic::transport::Server::builder()
4848
.accept_http1(true)
49-
.add_service(self.api_service)
49+
.add_service(tonic_web::enable(self.api_service)) // tonic_web::enable is needed to support grpc-web calls
5050
.serve_with_incoming(TcpListenerStream::new(self.listener))
5151
.await
5252
.context("failed to serve RPC API")

0 commit comments

Comments
 (0)