Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [BREAKING] Removed `CheckNullifiers` endpoint ([#2049](https://github.com/0xMiden/node/pull/2049)).
- Replaced blocking-in-async operations in the validator, remote prover, and ntx-builder with `spawn_blocking` to avoid starving the Tokio runtime ([#2041](https://github.com/0xMiden/node/pull/2041)).
- Replaced local store block proving with `spawn_blocking` to avoid starving the Tokio runtime ([#1976](https://github.com/0xMiden/node/issues/1976)).
- Replaced blocking proof verification in RPC transaction submission endpoints with `spawn_blocking` to avoid starving the Tokio runtime ([#1976](https://github.com/0xMiden/node/issues/1976)).
- Implemented persistent RocksDB backend for `AccountStateForest`, improving startup time ([#2020](https://github.com/0xMiden/node/pull/2020)).
- [BREAKING] Replaced binding URL env vars and CLI flags with listen socket addresses ([#2054](https://github.com/0xMiden/node/pull/2054)).
- [BREAKING] `BlockRange.block_to` is now required for all RPC endpoints ([#2056](https://github.com/0xMiden/node/pull/2056)).
Expand Down
44 changes: 31 additions & 13 deletions crates/rpc/src/server/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use miden_node_utils::limiter::{
QueryParamStorageMapKeyTotalLimit,
};
use miden_node_utils::lru_cache::LruCache;
use miden_node_utils::spawn::spawn_blocking_in_current_span;
use miden_node_utils::tracing::OpenTelemetrySpanExt;
use miden_protocol::batch::{ProposedBatch, ProvenBatch};
use miden_protocol::block::{BlockHeader, BlockNumber};
Expand Down Expand Up @@ -526,14 +527,20 @@ impl api_server::Api for RpcService {
));
}

let tx_verifier = TransactionVerifier::new(MIN_PROOF_SECURITY_LEVEL);
tx_verifier.verify(&tx).map_err(|err| {
Status::invalid_argument(format!(
"Invalid proof for transaction {}: {}",
tx.id(),
err.as_report()
))
})?;
let tx_id = tx.id();
spawn_blocking_in_current_span(move || {
TransactionVerifier::new(MIN_PROOF_SECURITY_LEVEL).verify(&tx).map_err(|err| {
Status::invalid_argument(format!(
"Invalid proof for transaction {}: {}",
tx_id,
err.as_report()
))
})
})
.await
.map_err(|err| {
Status::internal(format!("transaction proof verification task failed: {err}"))
})??;

// Transaction inputs must be provided in order to allow for transaction re-execution via
// the Validator.
Expand Down Expand Up @@ -613,11 +620,22 @@ impl api_server::Api for RpcService {
//
// Need to do this because ProvenBatch has no real kernel yet, so we can only
// really check that the calculated proof matches the one given in the request.
let expected_proof = LocalBatchProver::new(MIN_PROOF_SECURITY_LEVEL)
.prove(proposed_batch.clone())
.map_err(|err| {
Status::invalid_argument(err.as_report_context("proposed block proof failed"))
})?;
let expected_proof = spawn_blocking_in_current_span({
let proposed_batch = proposed_batch.clone();
move || {
LocalBatchProver::new(MIN_PROOF_SECURITY_LEVEL).prove(proposed_batch).map_err(
|err| {
Status::invalid_argument(
err.as_report_context("proposed block proof failed"),
)
},
)
}
})
.await
.map_err(|err| {
Status::internal(format!("batch proof verification task failed: {err}"))
})??;

if expected_proof != proven_batch {
return Err(Status::invalid_argument("batch proof did not match proposed batch"));
Expand Down
Loading