Skip to content
Draft
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
4 changes: 3 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ jobs:
with:
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/next' }}
- name: Fmt
run: make format-check
run: make format
- name: Diff check
run: git diff --exit-code

clippy:
name: clippy
Expand Down
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ fix: ## Runs Fix with configs


.PHONY: format
format: ## Runs Format using nightly toolchain
fmt format: ## Runs Format using nightly toolchain
./scripts/reflow.sh
cargo +nightly fmt --all


.PHONY: format-check
format-check: ## Runs Format using nightly toolchain but only in check mode
cargo +nightly fmt --all --check


.PHONY: machete
machete: ## Runs machete to find unused dependencies
cargo machete
Expand Down
4 changes: 2 additions & 2 deletions bin/network-monitor/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use crate::monitor::tasks::Tasks;

/// Start the network monitoring service.
///
/// This function initializes all monitoring tasks including RPC status checking,
/// remote prover testing, faucet testing, and the web frontend.
/// This function initializes all monitoring tasks including RPC status checking, remote prover
/// testing, faucet testing, and the web frontend.
#[instrument(target = COMPONENT, name = "start-monitor", skip_all, fields(port = %config.port))]
pub async fn start_monitor(config: MonitorConfig) -> Result<()> {
// Load configuration from command-line arguments and environment variables
Expand Down
8 changes: 4 additions & 4 deletions bin/network-monitor/src/counter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Counter increment task functionality.
//!
//! This module contains the implementation for periodically incrementing the counter
//! of the network account deployed at startup by creating and submitting network notes.
//! This module contains the implementation for periodically incrementing the counter of the network
//! account deployed at startup by creating and submitting network notes.

use std::path::Path;
use std::sync::Arc;
Expand Down Expand Up @@ -315,8 +315,8 @@ fn send_status(tx: &watch::Sender<ServiceStatus>, status: ServiceStatus) -> Resu

/// Run the counter tracking task.
///
/// This function periodically fetches the current counter value from the network
/// and updates the tracking details.
/// This function periodically fetches the current counter value from the network and updates the
/// tracking details.
///
/// # Arguments
///
Expand Down
13 changes: 5 additions & 8 deletions bin/network-monitor/src/deploy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ use crate::deploy::wallet::{create_wallet_account, save_wallet_account};
pub mod counter;
pub mod wallet;

/// Create an RPC client configured with the correct genesis metadata in the
/// `Accept` header so that write RPCs such as `SubmitProvenTransaction` are
/// accepted by the node.
/// Create an RPC client configured with the correct genesis metadata in the `Accept` header so that
/// write RPCs such as `SubmitProvenTransaction` are accepted by the node.
pub async fn create_genesis_aware_rpc_client(
rpc_url: &Url,
timeout: Duration,
Expand Down Expand Up @@ -98,9 +97,8 @@ pub async fn create_genesis_aware_rpc_client(

/// Ensure accounts exist, creating them if they don't.
///
/// This function checks if the wallet and counter account files exist.
/// If they don't exist, it creates new accounts and saves them to the specified files.
/// If they do exist, it does nothing.
/// This function checks if the wallet and counter account files exist. If they don't exist, it
/// creates new accounts and saves them to the specified files. If they do exist, it does nothing.
///
/// # Arguments
///
Expand Down Expand Up @@ -141,8 +139,7 @@ pub async fn ensure_accounts_exist(

/// Deploy counter account to the network.
///
/// This function creates a counter program account,
/// then saves it to the specified file.
/// This function creates a counter program account, then saves it to the specified file.
#[instrument(target = COMPONENT, name = "deploy-counter-account", skip_all, ret(level = "debug"))]
pub async fn deploy_counter_account(counter_account: &Account, rpc_url: &Url) -> Result<()> {
// Deploy counter account to the network using a genesis-aware RPC client.
Expand Down
4 changes: 2 additions & 2 deletions bin/network-monitor/src/faucet.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Faucet testing functionality.
//!
//! This module contains the logic for periodically testing faucet functionality
//! by requesting proof-of-work challenges, solving them, and submitting token requests.
//! This module contains the logic for periodically testing faucet functionality by requesting
//! proof-of-work challenges, solving them, and submitting token requests.

use std::time::Duration;

Expand Down
8 changes: 4 additions & 4 deletions bin/network-monitor/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Miden Network Monitor
//!
//! A monitor application for Miden network infrastructure that provides real-time status
//! monitoring and account deployment capabilities.
//! A monitor application for Miden network infrastructure that provides real-time status monitoring
//! and account deployment capabilities.

use anyhow::Result;
use clap::Parser;
Expand All @@ -28,8 +28,8 @@ pub const COMPONENT: &str = "miden-network-monitor";

/// Network Monitor main function.
///
/// This function parses command-line arguments and delegates to the appropriate
/// command handler. The monitor supports two main commands:
/// This function parses command-line arguments and delegates to the appropriate command handler.
/// The monitor supports two main commands:
/// - `start`: Runs the network monitoring service with web dashboard
/// - `deploy-account`: Creates and deploys Miden accounts to the network
#[tokio::main]
Expand Down
4 changes: 2 additions & 2 deletions bin/network-monitor/src/monitor/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ impl Tasks {

/// Gets the current Unix timestamp in seconds.
///
/// This function is infallible - if the system time is somehow before Unix epoch
/// (extremely unlikely), it returns 0.
/// This function is infallible - if the system time is somehow before Unix epoch (extremely
/// unlikely), it returns 0.
pub fn current_unix_timestamp_secs() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
Expand Down
14 changes: 7 additions & 7 deletions bin/network-monitor/src/remote_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ pub struct ProverTestDetails {

/// Runs a task that continuously tests remote prover functionality and updates a watch channel.
///
/// This function spawns a task that periodically sends mock request payloads to a remote prover
/// and measures the success/failure rate and performance metrics for proof generation.
/// This function spawns a task that periodically sends mock request payloads to a remote prover and
/// measures the success/failure rate and performance metrics for proof generation.
///
/// # Arguments
///
Expand Down Expand Up @@ -213,8 +213,8 @@ async fn test_remote_prover(

/// Converts a `tonic::Status` error to a JSON string with structured error information.
///
/// This function extracts the code, message, details, and metadata from a `tonic::Status`
/// error and serializes them into a JSON string for structured error reporting.
/// This function extracts the code, message, details, and metadata from a `tonic::Status` error and
/// serializes them into a JSON string for structured error reporting.
///
/// # Arguments
///
Expand Down Expand Up @@ -254,9 +254,9 @@ fn tonic_status_to_json(status: &tonic::Status) -> String {

/// Generates a mock transaction for testing remote prover functionality.
///
/// This function creates a mock transaction using `MockChainBuilder` similar to what's done
/// in the remote prover tests. The transaction is generated once and can be reused for
/// multiple proof test calls.
/// This function creates a mock transaction using `MockChainBuilder` similar to what's done in the
/// remote prover tests. The transaction is generated once and can be reused for multiple proof test
/// calls.
pub async fn generate_mock_transaction() -> anyhow::Result<TransactionInputs> {
let mut mock_chain_builder = MockChainBuilder::new();

Expand Down
20 changes: 10 additions & 10 deletions bin/network-monitor/src/status.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Network monitor status checker.
//!
//! This module contains the logic for checking the status of network services.
//! Individual status checker tasks send updates via watch channels to the web server.
//! This module contains the logic for checking the status of network services. Individual status
//! checker tasks send updates via watch channels to the web server.

use std::time::Duration;

Expand Down Expand Up @@ -132,8 +132,8 @@ pub struct StoreStatusDetails {

/// Details of a block producer service.
///
/// This struct contains the details of a block producer service, which is a union of the details
/// of the block producer service.
/// This struct contains the details of a block producer service, which is a union of the details of
/// the block producer service.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BlockProducerStatusDetails {
pub version: String,
Expand All @@ -155,8 +155,8 @@ pub struct MempoolStatusDetails {

/// Details of a remote prover service.
///
/// This struct contains the details of a remote prover service, which is a union of the details
/// of the remote prover service.
/// This struct contains the details of a remote prover service, which is a union of the details of
/// the remote prover service.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RemoteProverStatusDetails {
pub url: String,
Expand Down Expand Up @@ -267,8 +267,8 @@ impl From<RpcStatus> for RpcStatusDetails {

/// Runs a task that continuously checks RPC status and updates a watch channel.
///
/// This function spawns a task that periodically checks the RPC service status
/// and sends updates through a watch channel.
/// This function spawns a task that periodically checks the RPC service status and sends updates
/// through a watch channel.
///
/// # Arguments
///
Expand Down Expand Up @@ -357,8 +357,8 @@ pub(crate) async fn check_rpc_status(

/// Runs a task that continuously checks remote prover status and updates a watch channel.
///
/// This function spawns a task that periodically checks a remote prover service status
/// and sends updates through a watch channel.
/// This function spawns a task that periodically checks a remote prover service status and sends
/// updates through a watch channel.
///
/// # Arguments
///
Expand Down
4 changes: 2 additions & 2 deletions bin/remote-prover/src/api/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ impl std::str::FromStr for ProofType {

/// The prover for the remote prover.
///
/// This enum is used to store the prover for the remote prover.
/// Only one prover is enabled at a time.
/// This enum is used to store the prover for the remote prover. Only one prover is enabled at a
/// time.
enum Prover {
Transaction(Mutex<LocalTransactionProver>),
Batch(Mutex<LocalBatchProver>),
Expand Down
20 changes: 10 additions & 10 deletions bin/remote-prover/src/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ static RATE_LIMITER: LazyLock<Rate> = LazyLock::new(|| Rate::new(Duration::from_
// REQUEST QUEUE
// ================================================================================================

/// Request queue holds the list of requests that are waiting to be processed by the workers and
/// the time they were enqueued.
/// It is used to keep track of the order of the requests to then assign them to the workers.
/// Request queue holds the list of requests that are waiting to be processed by the workers and the
/// time they were enqueued. It is used to keep track of the order of the requests to then assign
/// them to the workers.
pub struct RequestQueue {
queue: RwLock<VecDeque<(Uuid, Instant)>>,
}
Expand Down Expand Up @@ -299,8 +299,8 @@ static QUEUE: LazyLock<RequestQueue> = LazyLock::new(RequestQueue::new);

/// Pingora `RequestHeader` injector for OpenTelemetry trace context propagation.
///
/// This allows the proxy to inject trace context into headers that will be forwarded
/// to worker nodes, enabling proper parent-child trace relationships.
/// This allows the proxy to inject trace context into headers that will be forwarded to worker
/// nodes, enabling proper parent-child trace relationships.
struct PingoraHeaderInjector<'a>(&'a mut pingora::http::RequestHeader);

impl opentelemetry::propagation::Injector for PingoraHeaderInjector<'_> {
Expand All @@ -321,8 +321,8 @@ impl opentelemetry::propagation::Injector for PingoraHeaderInjector<'_> {
/// Custom context for the request/response lifecycle
///
/// We use this context to keep track of the number of tries for a request, the unique ID for the
/// request, the worker that will process the request, a span that will be used for traces along
/// the transaction execution, and a timer to track how long the request took.
/// request, the worker that will process the request, a span that will be used for traces along the
/// transaction execution, and a timer to track how long the request took.
#[derive(Debug)]
pub struct RequestContext {
/// Number of tries for the request
Expand Down Expand Up @@ -362,9 +362,9 @@ impl RequestContext {

/// Wrapper around the load balancer that implements the [`ProxyHttp`] trait
///
/// This wrapper is used to implement the [`ProxyHttp`] trait for [`Arc<LoadBalancer>`].
/// This is necessary because we want to share the load balancer between the proxy server and the
/// health check background service.
/// This wrapper is used to implement the [`ProxyHttp`] trait for [`Arc<LoadBalancer>`]. This is
/// necessary because we want to share the load balancer between the proxy server and the health
/// check background service.
#[derive(Debug)]
pub struct LoadBalancer(pub Arc<LoadBalancerState>);

Expand Down
6 changes: 3 additions & 3 deletions bin/remote-prover/src/proxy/update_workers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ pub(crate) struct LoadBalancerUpdateService {
server_opts: HttpServerOptions,
}

/// Manually implement Debug for `LoadBalancerUpdateService`.
/// [`HttpServerOptions`] does not implement Debug, so we cannot derive Debug for
/// [`LoadBalancerUpdateService`], which is needed for the tracing instrumentation.
/// Manually implement Debug for `LoadBalancerUpdateService`. [`HttpServerOptions`] does not
/// implement Debug, so we cannot derive Debug for [`LoadBalancerUpdateService`], which is needed
/// for the tracing instrumentation.
impl fmt::Debug for LoadBalancerUpdateService {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("LBUpdaterService")
Expand Down
22 changes: 10 additions & 12 deletions bin/remote-prover/src/proxy/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ static WORKER_VERSION_REQUIREMENT: LazyLock<VersionReq> = LazyLock::new(|| {

/// A worker used for processing of requests.
///
/// The worker is used to process requests.
/// It has a backend, a status client, a health status, and a version.
/// The backend is used to send requests to the worker.
/// The status client is used to check the status of the worker.
/// The health status is used to determine if the worker is healthy or unhealthy.
/// The version is used to check if the worker is compatible with the proxy.
/// The `is_available` is used to determine if the worker is available to process requests.
/// The `connection_timeout` is used to set the timeout for the connection to the worker.
/// The `total_timeout` is used to set the timeout for the total request.
/// The worker is used to process requests. It has a backend, a status client, a health status, and
/// a version. The backend is used to send requests to the worker. The status client is used to
/// check the status of the worker. The health status is used to determine if the worker is healthy
/// or unhealthy. The version is used to check if the worker is compatible with the proxy. The
/// `is_available` is used to determine if the worker is available to process requests. The
/// `connection_timeout` is used to set the timeout for the connection to the worker. The
/// `total_timeout` is used to set the timeout for the total request.
#[derive(Debug, Clone)]
pub struct Worker {
backend: Backend,
Expand All @@ -63,9 +61,9 @@ pub struct Worker {

/// The health status of a worker.
///
/// A worker can be either healthy or unhealthy.
/// If the worker is unhealthy, it will have a number of failed attempts.
/// The number of failed attempts is incremented each time the worker is unhealthy.
/// A worker can be either healthy or unhealthy. If the worker is unhealthy, it will have a number
/// of failed attempts. The number of failed attempts is incremented each time the worker is
/// unhealthy.
#[derive(Debug, Clone, PartialEq, Serialize)]
pub enum WorkerHealthStatus {
/// The worker is healthy.
Expand Down
8 changes: 4 additions & 4 deletions bin/remote-prover/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ fn build_grpc_trailers(

/// Write a protobuf message as a gRPC response to a Pingora session
///
/// This helper function takes a protobuf message and writes it to a Pingora session
/// in the proper gRPC format, handling message encoding, headers, and trailers.
/// This helper function takes a protobuf message and writes it to a Pingora session in the proper
/// gRPC format, handling message encoding, headers, and trailers.
pub async fn write_grpc_response_to_session<T>(
session: &mut Session,
message: T,
Expand Down Expand Up @@ -99,8 +99,8 @@ where

/// Write a gRPC error response to a Pingora session
///
/// This helper function creates a proper gRPC error response with the specified
/// status code and error message.
/// This helper function creates a proper gRPC error response with the specified status code and
/// error message.
pub async fn write_grpc_error_to_session(
session: &mut Session,
grpc_status: Code,
Expand Down
8 changes: 4 additions & 4 deletions bin/stress-test/src/seeding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ pub async fn seed_store(

/// Generates batches of transactions to be inserted into the store.
///
/// The first transaction in each batch sends assets from the faucet to 255 accounts.
/// The rest of the transactions consume the notes created by the faucet in the previous block.
/// The first transaction in each batch sends assets from the faucet to 255 accounts. The rest of
/// the transactions consume the notes created by the faucet in the previous block.
async fn generate_blocks(
num_accounts: usize,
public_accounts_percentage: u8,
Expand Down Expand Up @@ -430,8 +430,8 @@ fn create_consume_note_tx(
.unwrap()
}

/// Creates a transaction from the faucet that creates the given output notes.
/// Updates the faucet account to increase the issuance slot and it's nonce.
/// Creates a transaction from the faucet that creates the given output notes. Updates the faucet
/// account to increase the issuance slot and it's nonce.
fn create_emit_note_tx(
block_ref: &BlockHeader,
faucet: &mut Account,
Expand Down
4 changes: 2 additions & 2 deletions bin/stress-test/src/store/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Duration;

/// Prints a summary of the benchmark results, including the average and various percentile
/// request latencies to help diagnose performance outliers.
/// Prints a summary of the benchmark results, including the average and various percentile request
/// latencies to help diagnose performance outliers.
pub fn print_summary(timers_accumulator: &[Duration]) {
let avg_time = timers_accumulator.iter().sum::<Duration>() / timers_accumulator.len() as u32;
println!("Average request latency: {avg_time:?}");
Expand Down
Loading