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
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ members = [
"crates/rpc",
"crates/store",
"crates/test-macro",
"crates/tracing",
"crates/tracing-macro",
"crates/utils",
"crates/validator",
"proto",
Expand Down Expand Up @@ -44,6 +46,8 @@ miden-node-proto-build = { path = "proto", version = "0.13" }
miden-node-rpc = { path = "crates/rpc", version = "0.13" }
miden-node-store = { path = "crates/store", version = "0.13" }
miden-node-test-macro = { path = "crates/test-macro" }
miden-node-tracing = { path = "crates/tracing", version = "0.13" }
miden-node-tracing-macro = { path = "crates/tracing-macro", version = "0.13" }
miden-node-utils = { path = "crates/utils", version = "0.13" }
miden-node-validator = { path = "crates/validator", version = "0.13" }
miden-remote-prover-client = { path = "crates/remote-prover-client", version = "0.13" }
Expand Down
1 change: 1 addition & 0 deletions crates/block-producer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ itertools = { workspace = true }
miden-block-prover = { workspace = true }
miden-node-proto = { workspace = true }
miden-node-proto-build = { features = ["internal"], workspace = true }
miden-node-tracing = { workspace = true }
miden-node-utils = { features = ["testing"], workspace = true }
miden-protocol = { default-features = true, workspace = true }
miden-remote-prover-client = { features = ["batch-prover", "block-prover"], workspace = true }
Expand Down
21 changes: 11 additions & 10 deletions crates/block-producer/src/batch_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::time::Duration;
use futures::never::Never;
use futures::{FutureExt, TryFutureExt};
use miden_node_proto::domain::batch::BatchInputs;
use miden_node_tracing::instrument_with_err_report;
use miden_node_utils::tracing::OpenTelemetrySpanExt;
use miden_protocol::MIN_PROOF_SECURITY_LEVEL;
use miden_protocol::batch::{BatchId, ProposedBatch, ProvenBatch};
Expand All @@ -14,7 +15,7 @@ use miden_tx_batch_prover::LocalBatchProver;
use rand::Rng;
use tokio::task::JoinSet;
use tokio::time;
use tracing::{Instrument, Span, instrument};
use tracing::{Instrument, Span};
use url::Url;

use crate::domain::batch::SelectedBatch;
Expand Down Expand Up @@ -102,7 +103,7 @@ impl BatchBuilder {
}
}

#[instrument(parent = None, target = COMPONENT, name = "batch_builder.build_batch", skip_all)]
#[instrument_with_err_report(parent = None, target = COMPONENT, name = "batch_builder.build_batch", skip_all)]
async fn build_batch(&mut self, mempool: SharedMempool) {
Span::current().set_attribute("workers.count", self.worker_pool.len());

Expand Down Expand Up @@ -130,7 +131,7 @@ impl BatchBuilder {
/// require the same logic as here to handle the case when the pool is at capacity. This
/// design was chosen instead as it removes this branching logic by "always" having the pool
/// at max capacity. Instead completed workers wait to be culled by this function.
#[instrument(target = COMPONENT, name = "batch_builder.wait_for_available_worker", skip_all)]
#[instrument_with_err_report(target = COMPONENT, name = "batch_builder.wait_for_available_worker", skip_all)]
async fn wait_for_available_worker(&mut self) {
// We must crash here because otherwise we have a batch that has been selected from the
// mempool, but which is now in limbo. This effectively corrupts the mempool.
Expand Down Expand Up @@ -189,12 +190,12 @@ impl BatchJob {
.await;
}

#[instrument(target = COMPONENT, name = "batch_builder.select_batch", skip_all)]
#[instrument_with_err_report(target = COMPONENT, name = "batch_builder.select_batch", skip_all)]
async fn select_batch(&self) -> Option<SelectedBatch> {
self.mempool.lock().await.select_batch()
}

#[instrument(target = COMPONENT, name = "batch_builder.get_batch_inputs", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "batch_builder.get_batch_inputs", skip_all, err)]
async fn get_batch_inputs(
&self,
batch: SelectedBatch,
Expand All @@ -217,7 +218,7 @@ impl BatchJob {
.map(|inputs| (batch, inputs))
}

#[instrument(target = COMPONENT, name = "batch_builder.propose_batch", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "batch_builder.propose_batch", skip_all, err)]
async fn propose_batch(
selected: SelectedBatch,
inputs: BatchInputs,
Expand All @@ -237,7 +238,7 @@ impl BatchJob {
.map_err(BuildBatchError::ProposeBatchError)
}

#[instrument(target = COMPONENT, name = "batch_builder.prove_batch", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "batch_builder.prove_batch", skip_all, err)]
async fn prove_batch(
&self,
proposed_batch: ProposedBatch,
Expand Down Expand Up @@ -267,7 +268,7 @@ impl BatchJob {
}
}

#[instrument(target = COMPONENT, name = "batch_builder.inject_failure", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "batch_builder.inject_failure", skip_all, err)]
async fn inject_failure<T>(&self, value: T) -> Result<T, BuildBatchError> {
let roll = rand::rng().random::<f64>();

Expand All @@ -281,12 +282,12 @@ impl BatchJob {
}
}

#[instrument(target = COMPONENT, name = "batch_builder.commit_batch", skip_all)]
#[instrument_with_err_report(target = COMPONENT, name = "batch_builder.commit_batch", skip_all)]
async fn commit_batch(&self, batch: Arc<ProvenBatch>) {
self.mempool.lock().await.commit_batch(batch);
}

#[instrument(target = COMPONENT, name = "batch_builder.rollback_batch", skip_all)]
#[instrument_with_err_report(target = COMPONENT, name = "batch_builder.rollback_batch", skip_all)]
async fn rollback_batch(&self, batch_id: BatchId) {
self.mempool.lock().await.rollback_batch(batch_id);
}
Expand Down
25 changes: 13 additions & 12 deletions crates/block-producer/src/block_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::sync::Arc;
use futures::FutureExt;
use futures::never::Never;
use miden_block_prover::LocalBlockProver;
use miden_node_tracing::instrument_with_err_report;
use miden_node_utils::tracing::OpenTelemetrySpanExt;
use miden_protocol::MIN_PROOF_SECURITY_LEVEL;
use miden_protocol::batch::{OrderedBatches, ProvenBatch};
Expand All @@ -22,7 +23,7 @@ use miden_protocol::transaction::{OrderedTransactionHeaders, TransactionHeader};
use miden_remote_prover_client::remote_prover::block_prover::RemoteBlockProver;
use rand::Rng;
use tokio::time::Duration;
use tracing::{Span, info, instrument};
use tracing::{Span, info};
use url::Url;

use crate::errors::BuildBlockError;
Expand Down Expand Up @@ -116,7 +117,7 @@ impl BlockBuilder {
/// - Each stage has its own child span and are free to add further field data.
/// - A failed stage will emit an error event, and both its own span and the root span will be
/// marked as errors.
#[instrument(parent = None, target = COMPONENT, name = "block_builder.build_block", skip_all)]
#[instrument_with_err_report(parent = None, target = COMPONENT, name = "block_builder.build_block", skip_all)]
async fn build_block(&self, mempool: &SharedMempool) {
use futures::TryFutureExt;

Expand Down Expand Up @@ -145,7 +146,7 @@ impl BlockBuilder {
.await
}

#[instrument(target = COMPONENT, name = "block_builder.select_block", skip_all)]
#[instrument_with_err_report(target = COMPONENT, name = "block_builder.select_block", skip_all)]
async fn select_block(mempool: &SharedMempool) -> SelectedBlock {
let (block_number, batches) = mempool.lock().await.select_block();
SelectedBlock { block_number, batches }
Expand All @@ -167,7 +168,7 @@ impl BlockBuilder {
/// which nullifiers the block will actually create, we fetch witnesses for all nullifiers
/// created by batches. If we knew that a certain note will be erased, we would not have to
/// supply a nullifier witness for it.
#[instrument(target = COMPONENT, name = "block_builder.get_block_inputs", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "block_builder.get_block_inputs", skip_all, err)]
async fn get_block_inputs(
&self,
selected_block: SelectedBlock,
Expand Down Expand Up @@ -210,7 +211,7 @@ impl BlockBuilder {
Ok(BlockBatchesAndInputs { batches, inputs })
}

#[instrument(target = COMPONENT, name = "block_builder.propose_block", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "block_builder.propose_block", skip_all, err)]
async fn propose_block(
&self,
batches_inputs: BlockBatchesAndInputs,
Expand All @@ -224,7 +225,7 @@ impl BlockBuilder {
Ok((proposed_block, inputs))
}

#[instrument(target = COMPONENT, name = "block_builder.validate_block", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "block_builder.validate_block", skip_all, err)]
async fn validate_block(
&self,
proposed_block: ProposedBlock,
Expand Down Expand Up @@ -256,7 +257,7 @@ impl BlockBuilder {
Ok((ordered_batches, block_inputs, header, signature, body))
}

#[instrument(target = COMPONENT, name = "block_builder.prove_block", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "block_builder.prove_block", skip_all, err)]
async fn prove_block(
&self,
ordered_batches: OrderedBatches,
Expand Down Expand Up @@ -288,7 +289,7 @@ impl BlockBuilder {
Ok(proven_block)
}

#[instrument(target = COMPONENT, name = "block_builder.commit_block", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "block_builder.commit_block", skip_all, err)]
async fn commit_block(
&self,
mempool: &SharedMempool,
Expand All @@ -304,12 +305,12 @@ impl BlockBuilder {
Ok(())
}

#[instrument(target = COMPONENT, name = "block_builder.rollback_block", skip_all)]
#[instrument_with_err_report(target = COMPONENT, name = "block_builder.rollback_block", skip_all)]
async fn rollback_block(&self, mempool: &SharedMempool, block: BlockNumber) {
mempool.lock().await.rollback_block(block);
}

#[instrument(target = COMPONENT, name = "block_builder.simulate_proving", skip_all)]
#[instrument_with_err_report(target = COMPONENT, name = "block_builder.simulate_proving", skip_all)]
async fn simulate_proving(&self) {
let proving_duration = rand::rng().random_range(self.simulated_proof_time.clone());

Expand All @@ -320,7 +321,7 @@ impl BlockBuilder {
tokio::time::sleep(proving_duration).await;
}

#[instrument(target = COMPONENT, name = "block_builder.inject_failure", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "block_builder.inject_failure", skip_all, err)]
fn inject_failure<T>(&self, value: T) -> Result<T, BuildBlockError> {
let roll = rand::rng().random::<f64>();

Expand Down Expand Up @@ -449,7 +450,7 @@ impl BlockProver {
Self::Remote(RemoteBlockProver::new(endpoint))
}

#[instrument(target = COMPONENT, skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, skip_all, err)]
async fn prove(
&self,
tx_batches: OrderedBatches,
Expand Down
13 changes: 7 additions & 6 deletions crates/block-producer/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ use miden_node_proto::clients::{Builder, StoreBlockProducerClient};
use miden_node_proto::domain::batch::BatchInputs;
use miden_node_proto::errors::{ConversionError, MissingFieldHelper};
use miden_node_proto::{AccountState, generated as proto};
use miden_node_tracing::instrument_with_err_report;
use miden_node_utils::formatting::format_opt;
use miden_protocol::Word;
use miden_protocol::account::AccountId;
use miden_protocol::block::{BlockHeader, BlockInputs, BlockNumber, ProvenBlock};
use miden_protocol::note::Nullifier;
use miden_protocol::transaction::ProvenTransaction;
use miden_protocol::utils::Serializable;
use tracing::{debug, info, instrument};
use tracing::{debug, info};
use url::Url;

use crate::COMPONENT;
Expand Down Expand Up @@ -136,7 +137,7 @@ impl StoreClient {
}

/// Returns the latest block's header from the store.
#[instrument(target = COMPONENT, name = "store.client.latest_header", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "store.client.latest_header", skip_all, err)]
pub async fn latest_header(&self) -> Result<BlockHeader, StoreError> {
let response = self
.client
Expand All @@ -154,7 +155,7 @@ impl StoreClient {
BlockHeader::try_from(response).map_err(Into::into)
}

#[instrument(target = COMPONENT, name = "store.client.get_tx_inputs", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "store.client.get_tx_inputs", skip_all, err)]
pub async fn get_tx_inputs(
&self,
proven_tx: &ProvenTransaction,
Expand Down Expand Up @@ -199,7 +200,7 @@ impl StoreClient {
Ok(tx_inputs)
}

#[instrument(target = COMPONENT, name = "store.client.get_block_inputs", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "store.client.get_block_inputs", skip_all, err)]
pub async fn get_block_inputs(
&self,
updated_accounts: impl Iterator<Item = AccountId> + Send,
Expand All @@ -221,7 +222,7 @@ impl StoreClient {
store_response.try_into().map_err(Into::into)
}

#[instrument(target = COMPONENT, name = "store.client.get_batch_inputs", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "store.client.get_batch_inputs", skip_all, err)]
pub async fn get_batch_inputs(
&self,
block_references: impl Iterator<Item = (BlockNumber, Word)> + Send,
Expand All @@ -237,7 +238,7 @@ impl StoreClient {
store_response.try_into().map_err(Into::into)
}

#[instrument(target = COMPONENT, name = "store.client.apply_block", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "store.client.apply_block", skip_all, err)]
pub async fn apply_block(&self, block: &ProvenBlock) -> Result<(), StoreError> {
let request = tonic::Request::new(proto::blockchain::Block { block: block.to_bytes() });

Expand Down
5 changes: 3 additions & 2 deletions crates/block-producer/src/validator/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use miden_node_proto::clients::{Builder, ValidatorClient};
use miden_node_proto::generated as proto;
use miden_node_tracing::instrument_with_err_report;
use miden_protocol::block::ProposedBlock;
use miden_protocol::crypto::dsa::ecdsa_k256_keccak::Signature;
use miden_protocol::utils::{Deserializable, DeserializationError, Serializable};
use thiserror::Error;
use tracing::{info, instrument};
use tracing::info;
use url::Url;

use crate::COMPONENT;
Expand Down Expand Up @@ -47,7 +48,7 @@ impl BlockProducerValidatorClient {
Self { client: validator }
}

#[instrument(target = COMPONENT, name = "validator.client.validate_block", skip_all, err)]
#[instrument_with_err_report(target = COMPONENT, name = "validator.client.validate_block", skip_all, err)]
pub async fn sign_block(
&self,
proposed_block: ProposedBlock,
Expand Down
1 change: 1 addition & 0 deletions crates/ntx-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ anyhow = { workspace = true }
futures = { workspace = true }
indexmap = { workspace = true }
miden-node-proto = { workspace = true }
miden-node-tracing = { workspace = true }
miden-node-utils = { workspace = true }
miden-protocol = { default-features = true, workspace = true }
miden-remote-prover-client = { features = ["tx-prover"], workspace = true }
Expand Down
Loading
Loading