Skip to content
Merged
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
6 changes: 3 additions & 3 deletions bin/benchmark/src/inclusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::collections::HashMap;
use std::time::{Duration, SystemTime, UNIX_EPOCH};

use miden_node_proto::clients::RpcClient;
use miden_node_proto::generated::rpc::BlockHeaderByNumberRequest;
use miden_node_proto::generated::rpc::GetBlockHeaderByNumberRequest;
use miden_node_proto::{DecodeMessageExt, generated as proto};
use miden_protocol::block::BlockHeader;
use miden_protocol::transaction::TransactionId;
Expand Down Expand Up @@ -110,7 +110,7 @@ pub(crate) async fn scan_with_drain(
// Scan every unwatched block, capped at the max-bound target.
let scan_to = tip.min(max_target);
while next_block <= scan_to {
let request = proto::rpc::BlockRequest {
let request = proto::rpc::GetBlockByNumberRequest {
block_num: next_block,
include_proof: None,
};
Expand Down Expand Up @@ -217,7 +217,7 @@ pub(crate) async fn scan_with_drain(

pub(crate) async fn current_block_height(mut client: RpcClient) -> u32 {
let response = client
.get_block_header_by_number(BlockHeaderByNumberRequest {
.get_block_header_by_number(GetBlockHeaderByNumberRequest {
block_num: None,
include_mmr_proof: None,
include_protocol_config: None,
Expand Down
14 changes: 9 additions & 5 deletions bin/benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use miden_node_proto::domain::encryption::{
TransactionInputsSealer,
TrustedTransactionEncryptionState,
};
use miden_node_proto::generated::rpc::BlockHeaderByNumberRequest;
use miden_node_proto::generated::rpc::GetBlockHeaderByNumberRequest;
use miden_node_proto::{DecodeMessageExt, VerifyWith};
use miden_protocol::Word;
use miden_protocol::block::{BlockHeader, BlockNumber};
Expand Down Expand Up @@ -222,10 +222,14 @@ pub(crate) async fn create_genesis_aware_rpc_client_pool(
}
let key = pool[0]
.clone()
.get_transaction_encryption_key(())
.get_transaction_encryption_key(
miden_node_proto::generated::rpc::GetTransactionEncryptionKeyRequest {},
)
.await
.context("Failed to fetch the transaction encryption key")?
.into_inner();
.into_inner()
.key
.ok_or_else(|| tonic::Status::internal("missing transaction encryption key"))?;
let trusted_keys = [trusted_validator_signing_key];
let verified = key
.verify_with(TrustedTransactionEncryptionState::new(genesis, &trusted_keys))
Expand All @@ -234,8 +238,8 @@ pub(crate) async fn create_genesis_aware_rpc_client_pool(
Ok((pool, TransactionInputsSealer::new(verified)))
}

pub(crate) fn get_genesis_header_request() -> BlockHeaderByNumberRequest {
BlockHeaderByNumberRequest {
pub(crate) fn get_genesis_header_request() -> GetBlockHeaderByNumberRequest {
GetBlockHeaderByNumberRequest {
block_num: Some(BlockNumber::GENESIS.as_u32()),
include_mmr_proof: None,
include_protocol_config: None,
Expand Down
8 changes: 4 additions & 4 deletions bin/benchmark/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use std::time::{Duration, Instant};
use anyhow::{Context, Result};
use miden_node_proto::clients::{Builder, RemoteProverClient};
use miden_node_proto::errors::ConversionError;
use miden_node_proto::generated::remote_prover::proof_request::Request;
use miden_node_proto::generated::remote_prover::{DecodedProof, ProofRequest};
use miden_node_proto::generated::remote_prover::prove_request::Request;
use miden_node_proto::generated::remote_prover::{DecodedProveResponse, ProveRequest};
use miden_node_proto::{BuildUnchecked, DecodeMessage};
use miden_node_tracing::spawn::spawn_blocking_in_current_span;
use miden_protocol::transaction::{ExecutedTransaction, ProvenTransaction, TransactionInputs};
Expand Down Expand Up @@ -200,7 +200,7 @@ impl RemoteTransactionProver {
&self,
tx_inputs: &TransactionInputs,
) -> Result<ProvenTransaction, TransactionProverError> {
let request = tonic::Request::new(ProofRequest {
let request = tonic::Request::new(ProveRequest {
request: Some(Request::Transaction(tx_inputs.into())),
});

Expand All @@ -211,7 +211,7 @@ impl RemoteTransactionProver {
response
.into_inner()
.decode_fields()
.and_then(DecodedProof::into_transaction)
.and_then(DecodedProveResponse::into_transaction)
// SAFETY: This benchmark trusts the configured prover to return a valid proof for the
// requested transaction.
.and_then(|transaction| transaction.build_unchecked().map_err(ConversionError::new))
Expand Down
10 changes: 8 additions & 2 deletions bin/benchmark/src/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ async fn submit_all(
sealed_transaction_inputs: Some(sealed_inputs),
};
let t0 = Instant::now();
let outcome = match client.submit_proven_tx(request).await {
let outcome = match client
.submit_proven_tx(proto::rpc::SubmitProvenTxRequest { submission: Some(request) })
.await
{
Ok(_) => SubmitOutcome {
index: i,
result: Ok(t0.elapsed()),
Expand Down Expand Up @@ -285,7 +288,10 @@ async fn submit_sequential(
};

let t0 = Instant::now();
let outcome = match client.submit_proven_tx(request).await {
let outcome = match client
.submit_proven_tx(proto::rpc::SubmitProvenTxRequest { submission: Some(request) })
.await
{
Ok(_) => SubmitOutcome {
index: i,
result: Ok(t0.elapsed()),
Expand Down
36 changes: 23 additions & 13 deletions bin/funding-service/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ use miden_node_proto::domain::encryption::{
TrustedTransactionEncryptionState,
};
use miden_node_proto::domain::protocol_config::ensure_protocol_config_is_present_and_matches_header;
use miden_node_proto::generated::rpc::account_request::AccountDetailRequest;
use miden_node_proto::generated::rpc::get_account_request::AccountDetailRequest;
use miden_node_proto::generated::rpc::{
AccountRequest as ProtoAccountRequest,
BlockHeaderByNumberRequest,
BlockRange,
FinalityLevel,
NotesByIdRequest,
GetAccountRequest as ProtoAccountRequest,
GetBlockHeaderByNumberRequest,
GetNotesByIdRequest,
SyncChainMmrRequest,
SyncNotesRequest,
SyncNullifiersRequest,
Expand Down Expand Up @@ -248,7 +248,7 @@ impl RpcNodeClient {
let response = self
.rpc_client
.clone()
.get_notes_by_id(NotesByIdRequest { note_ids })
.get_notes_by_id(GetNotesByIdRequest { note_ids })
.await
.context("failed to fetch notes from RPC")?
.into_inner();
Expand Down Expand Up @@ -389,7 +389,7 @@ impl RpcNodeClient {
let status = self
.rpc_client
.clone()
.status(())
.status(miden_node_proto::generated::rpc::StatusRequest {})
.await
.context("failed to fetch the node status")?
.into_inner();
Expand All @@ -412,7 +412,13 @@ impl RpcNodeClient {
transaction: Some(proven_tx.into()),
sealed_transaction_inputs: Some(sealed),
};
let result = self.rpc_client.clone().submit_proven_tx(request).await;
let result = self
.rpc_client
.clone()
.submit_proven_tx(miden_node_proto::generated::rpc::SubmitProvenTxRequest {
submission: Some(request),
})
.await;

if result.is_err() {
// The encryption key can be stale. Fetch it again for the next submission.
Expand All @@ -434,10 +440,14 @@ impl RpcNodeClient {
let key = self
.rpc_client
.clone()
.get_transaction_encryption_key(())
.get_transaction_encryption_key(
miden_node_proto::generated::rpc::GetTransactionEncryptionKeyRequest {},
)
.await
.context("failed to fetch the transaction encryption key")?
.into_inner();
.into_inner()
.key
.ok_or_else(|| tonic::Status::internal("missing transaction encryption key"))?;
let verified = key
.verify_with(TrustedTransactionEncryptionState::new(
self.genesis_commitment,
Expand Down Expand Up @@ -577,7 +587,7 @@ async fn fetch_block_header(
rpc_client: &mut RpcClient,
block_num: Option<BlockNumber>,
) -> Result<BlockHeader> {
let request = BlockHeaderByNumberRequest {
let request = GetBlockHeaderByNumberRequest {
block_num: block_num.map(|block_num| block_num.as_u32()),
include_mmr_proof: None,
include_protocol_config: None,
Expand Down Expand Up @@ -606,7 +616,7 @@ async fn fetch_genesis_header_and_config(
rpc_client: &mut RpcClient,
) -> Result<(BlockHeader, ProtocolConfig)> {
let response = rpc_client
.get_block_header_by_number(BlockHeaderByNumberRequest {
.get_block_header_by_number(GetBlockHeaderByNumberRequest {
block_num: Some(BlockNumber::GENESIS.as_u32()),
include_mmr_proof: None,
include_protocol_config: Some(true),
Expand Down Expand Up @@ -688,8 +698,8 @@ async fn fetch_public_account(
account_id: AccountId,
block_num: BlockNumber,
) -> Result<(Account, AccountWitness)> {
use miden_node_proto::generated::rpc::account_request::AccountDetailRequest;
use miden_node_proto::generated::rpc::account_request::account_detail_request::StorageRequest;
use miden_node_proto::generated::rpc::get_account_request::AccountDetailRequest;
use miden_node_proto::generated::rpc::get_account_request::account_detail_request::StorageRequest;

// Dummy commitments force the server to include code and vault data in the response.
let dummy: miden_node_proto::generated::primitives::Word = Word::default().into();
Expand Down
14 changes: 8 additions & 6 deletions bin/funding-service/src/node/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ impl TestChain {
}
}

fn notes_by_id(&self, request: &NotesByIdRequest) -> rpc::NotesByIdResponse {
rpc::NotesByIdResponse {
fn notes_by_id(&self, request: &GetNotesByIdRequest) -> rpc::GetNotesByIdResponse {
rpc::GetNotesByIdResponse {
notes: request
.note_ids
.iter()
Expand Down Expand Up @@ -223,10 +223,12 @@ impl Service<http::Request<Body>> for RpcFixture {
return Box::pin(async { Ok(tonic::Status::unavailable("retry").into_http()) });
}
match method {
"Status" => self.respond(request, |chain, _: &()| rpc::RpcStatus {
chain_tip: chain.tip,
..Default::default()
}),
"Status" => {
self.respond(request, |chain, _: &rpc::StatusRequest| rpc::StatusResponse {
chain_tip: chain.tip,
..Default::default()
})
},
"SyncTransactions" => self.respond(request, TestChain::sync_transactions),
"SyncNotes" => self.respond(request, TestChain::sync_notes),
"GetNotesById" => self.respond(request, TestChain::notes_by_id),
Expand Down
8 changes: 4 additions & 4 deletions bin/funding-service/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::time::Duration;

use anyhow::{Context, Result};
use miden_node_proto::clients::{Builder, RemoteProverClient};
use miden_node_proto::generated::remote_prover::proof_request::Request as ProofRequestVariant;
use miden_node_proto::generated::remote_prover::{DecodedProof, ProofRequest};
use miden_node_proto::generated::remote_prover::prove_request::Request as ProofRequestVariant;
use miden_node_proto::generated::remote_prover::{DecodedProveResponse, ProveRequest};
use miden_node_proto::{BuildUnchecked, DecodeMessage};
use miden_node_tracing::spawn::spawn_blocking_in_current_span;
use miden_node_tracing::{ErrorReport, warn};
Expand Down Expand Up @@ -96,7 +96,7 @@ impl RemoteProver {

/// Proves one transaction on the remote prover.
async fn prove_remotely(&self, executed_tx: &ExecutedTransaction) -> Result<ProvenTransaction> {
let request = tonic::Request::new(ProofRequest {
let request = tonic::Request::new(ProveRequest {
request: Some(ProofRequestVariant::Transaction(executed_tx.tx_inputs().into())),
});

Expand All @@ -110,7 +110,7 @@ impl RemoteProver {
response
.into_inner()
.decode_fields()
.and_then(DecodedProof::into_transaction)
.and_then(DecodedProveResponse::into_transaction)
.context("failed to decode the response of the remote transaction prover")?
.build_unchecked()
.context("failed to build the response of the remote transaction prover")
Expand Down
40 changes: 23 additions & 17 deletions bin/large-account-benchmark/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use miden_node_proto::domain::encryption::{
};
use miden_node_proto::domain::protocol_config::ensure_protocol_config_is_present_and_matches_header;
use miden_node_proto::generated::account::account_storage_header::storage_slot::Content as SlotContent;
use miden_node_proto::generated::rpc::account_request::AccountDetailRequest;
use miden_node_proto::generated::rpc::get_account_request::AccountDetailRequest;
use miden_node_proto::generated::rpc::{
AccountRequest,
BlockHeaderByNumberRequest,
BlockHeaderByNumberResponse,
GetAccountRequest,
GetBlockHeaderByNumberRequest,
GetBlockHeaderByNumberResponse,
};
use miden_node_proto::generated::submission::ProvenTransactionSubmission as ProtoProvenTransaction;
use miden_node_proto::{DecodeMessageExt, VerifyWith};
Expand Down Expand Up @@ -136,7 +136,7 @@ impl SubmissionClient {
let status = self
.rpc
.clone()
.status(())
.status(miden_node_proto::generated::rpc::StatusRequest {})
.await
.context("failed to read node status")?
.into_inner();
Expand All @@ -151,7 +151,7 @@ impl SubmissionClient {
/// this tool submitted, while the counter account's slot only advances when the ntx-builder has
/// actually loaded the large account and consumed a network note.
pub async fn slot_value(&self, account_id: AccountId, slot_name: &str) -> Result<Option<u64>> {
let request = AccountRequest {
let request = GetAccountRequest {
account_id: Some(account_id.into()),
block_num: None,
details: Some(AccountDetailRequest {
Expand Down Expand Up @@ -214,7 +214,7 @@ impl SubmissionClient {
account_id: AccountId,
block_num: BlockNumber,
) -> Result<AccountWitness> {
let request = AccountRequest {
let request = GetAccountRequest {
account_id: Some(account_id.into()),
block_num: Some(block_num.into()),
details: None,
Expand Down Expand Up @@ -252,10 +252,14 @@ impl SubmissionClient {
let key = self
.rpc
.clone()
.get_transaction_encryption_key(())
.get_transaction_encryption_key(
miden_node_proto::generated::rpc::GetTransactionEncryptionKeyRequest {},
)
.await
.context("failed to fetch the transaction encryption key")?
.into_inner();
.into_inner()
.key
.ok_or_else(|| tonic::Status::internal("missing transaction encryption key"))?;

let verified = key
.verify_with(TrustedTransactionEncryptionState::new(
Expand Down Expand Up @@ -306,9 +310,11 @@ impl SubmissionClient {
let response = self
.rpc
.clone()
.submit_proven_tx(ProtoProvenTransaction {
transaction: Some(proven_tx.into()),
sealed_transaction_inputs: Some(sealed),
.submit_proven_tx(miden_node_proto::generated::rpc::SubmitProvenTxRequest {
submission: Some(ProtoProvenTransaction {
transaction: Some(proven_tx.into()),
sealed_transaction_inputs: Some(sealed),
}),
})
.await
.context("failed to submit the proven transaction")?;
Expand All @@ -330,7 +336,7 @@ async fn genesis_block_state(rpc: &mut RpcClient) -> Result<(BlockHeader, Protoc
}

fn decode_genesis_block_state(
response: BlockHeaderByNumberResponse,
response: GetBlockHeaderByNumberResponse,
) -> Result<(BlockHeader, ProtocolConfig)> {
let header = response
.block_header
Expand All @@ -345,8 +351,8 @@ fn decode_genesis_block_state(
Ok((header, protocol_config))
}

fn genesis_header_request() -> BlockHeaderByNumberRequest {
BlockHeaderByNumberRequest {
fn genesis_header_request() -> GetBlockHeaderByNumberRequest {
GetBlockHeaderByNumberRequest {
block_num: Some(BlockNumber::GENESIS.as_u32()),
include_mmr_proof: None,
include_protocol_config: Some(true),
Expand All @@ -364,7 +370,7 @@ fn is_stale_key(err: &anyhow::Error) -> bool {

#[cfg(test)]
mod tests {
use miden_node_proto::generated::rpc::BlockHeaderByNumberResponse;
use miden_node_proto::generated::rpc::GetBlockHeaderByNumberResponse;
use miden_protocol::account::AccountId;
use miden_protocol::testing::account_id::ACCOUNT_ID_PUBLIC_FUNGIBLE_FAUCET_1;
use miden_testing::MockChain;
Expand All @@ -381,7 +387,7 @@ mod tests {
)
.build()
.expect("chain should build");
let response = BlockHeaderByNumberResponse {
let response = GetBlockHeaderByNumberResponse {
block_header: Some(chain.genesis_block_header().into()),
mmr_path: None,
chain_length: None,
Expand Down
Loading
Loading