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
9 changes: 1 addition & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,13 @@ install-network-monitor: ## Installs network monitor binary

# --- docker --------------------------------------------------------------------------------------

.PHONY: compose-genesis
compose-genesis: ## Wipes node volumes and creates a fresh genesis block
docker compose $(COMPOSE_FILES) down --volumes --remove-orphans
docker volume rm -f miden-node_node-data
docker compose $(COMPOSE_FILES) --profile genesis run --rm genesis-store
docker compose $(COMPOSE_FILES) --profile genesis rm -f

.PHONY: compose-up
compose-up: ## Starts all node components, telemetry, and monitor via docker compose
docker compose $(COMPOSE_FILES) up -d

.PHONY: compose-down
compose-down: ## Stops and removes all containers via docker compose
docker compose $(COMPOSE_FILES) down
docker compose $(COMPOSE_FILES) down --remove-orphans

.PHONY: compose-logs
compose-logs: ## Follows logs for all components via docker compose
Expand Down
10 changes: 5 additions & 5 deletions bin/network-monitor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ miden-network-monitor --help
# Common usage examples
miden-network-monitor start --port 8080 --rpc.listen http://localhost:50051
miden-network-monitor start --remote-prover-urls http://prover1.com:50052,http://prover2.com:50053
miden-network-monitor start --faucet-url http://localhost:8080 --enable-otel
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 miden-network-monitor start --faucet-url http://localhost:8080
```

**Available Options:**
Expand All @@ -41,7 +41,6 @@ miden-network-monitor start --faucet-url http://localhost:8080 --enable-otel
- `--request-timeout`: Timeout for outgoing requests (default: `10s`)
- `--stale-chain-tip-threshold`: Maximum time without a chain tip update before marking RPC as unhealthy (default: `1m`)
- `--port, -p`: Web server port (default: `3000`)
- `--enable-otel`: Enable OpenTelemetry tracing
- `--counter-increment-interval`: Interval at which to send the increment counter transaction (default: `30s`)
- `--counter-pending-unhealthy-threshold`: Mark the Network Transactions card unhealthy when the gap between expected and observed counter values stays above this for several consecutive polls (default: `5`)
- `--counter-latency-timeout`: Maximum time to wait for a counter update after submitting a transaction (default: `2m`)
Expand All @@ -66,7 +65,6 @@ If command-line arguments are not provided, the application falls back to enviro
- `MIDEN_MONITOR_REQUEST_TIMEOUT`: Timeout for outgoing requests
- `MIDEN_MONITOR_STALE_CHAIN_TIP_THRESHOLD`: Maximum time without a chain tip update before marking RPC as unhealthy
- `MIDEN_MONITOR_PORT`: Web server port
- `MIDEN_MONITOR_ENABLE_OTEL`: Enable OpenTelemetry tracing
- `MIDEN_MONITOR_COUNTER_INCREMENT_INTERVAL`: Interval at which to send the increment counter transaction
- `MIDEN_MONITOR_COUNTER_PENDING_UNHEALTHY_THRESHOLD`: Mark the Network Transactions card unhealthy when the gap between expected and observed counter values stays above this for several consecutive polls
- `MIDEN_MONITOR_COUNTER_LATENCY_TIMEOUT`: Maximum time to wait for a counter update after submitting a transaction
Expand Down Expand Up @@ -122,8 +120,7 @@ miden-network-monitor start \
--remote-prover-test-interval 2m \
--faucet-test-interval 2m \
--status-check-interval 3s \
--port 8080 \
--enable-otel
--port 8080

# Get help
miden-network-monitor --help
Expand All @@ -144,6 +141,9 @@ miden-network-monitor start

Once running, the monitor will be available at `http://localhost:3000` (or the configured port).

OpenTelemetry tracing is enabled automatically when `OTEL_EXPORTER_OTLP_ENDPOINT` or
`OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` is set.

## Currently Supported Monitor

The monitor application provides real-time status monitoring for the following Miden network components:
Expand Down
7 changes: 2 additions & 5 deletions bin/network-monitor/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ use crate::monitor::tasks::Tasks;
pub async fn start_monitor(config: MonitorConfig) -> Result<()> {
info!("Loaded configuration: {:?}", config);

let _otel_guard = if config.enable_otel {
miden_node_utils::logging::setup_tracing(OpenTelemetry::Enabled)?
} else {
miden_node_utils::logging::setup_tracing(OpenTelemetry::Disabled)?
};
let _otel_guard =
miden_node_utils::logging::setup_tracing(OpenTelemetry::from_env().with_name("monitor"))?;

let mut tasks = Tasks::new();

Expand Down
10 changes: 0 additions & 10 deletions bin/network-monitor/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,6 @@ pub struct MonitorConfig {
)]
pub port: u16,

/// Whether to enable OpenTelemetry.
#[arg(
long = "enable-otel",
env = "MIDEN_MONITOR_ENABLE_OTEL",
action = clap::ArgAction::SetTrue,
default_value_t = false,
help = "Whether to enable OpenTelemetry"
)]
pub enable_otel: bool,

/// Whether to disable the network transaction service checks (enabled by default). The network
/// transaction service is a network account with a counter deployed at startup and incremented
/// by sending a transaction to it.
Expand Down
15 changes: 9 additions & 6 deletions bin/node/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod store;

use clap::Subcommand;
pub use lifecycle::{BootstrapCommand, MigrateCommand};
use miden_node_utils::logging::OpenTelemetry;
pub use modes::{FullNodeCommand, SequencerCommand};

const ENV_DATA_DIRECTORY: &str = "MIDEN_NODE_DATA_DIRECTORY";
Expand Down Expand Up @@ -51,13 +52,15 @@ pub enum Command {
}

impl Command {
pub(crate) fn open_telemetry(&self) -> miden_node_utils::logging::OpenTelemetry {
pub(crate) fn open_telemetry(&self) -> OpenTelemetry {
match self {
Command::Sequencer(command) => command.runtime.open_telemetry(),
Command::Full(command) => command.runtime.open_telemetry(),
Command::Bootstrap(_) | Command::Migrate(_) => {
miden_node_utils::logging::OpenTelemetry::Disabled
},
Command::Sequencer(_) => OpenTelemetry::from_env()
.with_name("node")
.with_attribute("miden.node.role", "sequencer"),
Command::Full(_) => OpenTelemetry::from_env()
.with_name("node")
.with_attribute("miden.node.role", "full"),
Command::Bootstrap(_) | Command::Migrate(_) => OpenTelemetry::Disabled,
}
}

Expand Down
21 changes: 0 additions & 21 deletions bin/node/src/commands/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::path::PathBuf;

use miden_node_store::DatabaseOptions;
use miden_node_utils::clap::{GrpcOptionsExternal, StorageOptions};
use miden_node_utils::logging::OpenTelemetry;

use super::ENV_DATA_DIRECTORY;
use super::rpc::RpcOptions;
Expand All @@ -18,31 +17,11 @@ pub struct RuntimeOptions {
#[arg(long, env = ENV_DATA_DIRECTORY, value_name = "DIR")]
pub data_directory: PathBuf,

/// Enables the exporting of traces for OpenTelemetry.
///
/// This can be further configured using environment variables as defined in the official
/// OpenTelemetry documentation. See our operator manual for further details.
#[arg(
long = "enable-otel",
default_value_t = false,
env = "MIDEN_NODE_ENABLE_OTEL",
value_name = "BOOL"
)]
pub enable_otel: bool,

#[command(flatten)]
pub rpc: RpcOptions,
}

impl RuntimeOptions {
pub fn open_telemetry(&self) -> OpenTelemetry {
if self.enable_otel {
OpenTelemetry::Enabled
} else {
OpenTelemetry::Disabled
}
}

pub(super) fn runtime_config(&self, store: &StoreOptions) -> RuntimeConfig {
RuntimeConfig {
data_directory: self.data_directory.clone(),
Expand Down
16 changes: 4 additions & 12 deletions bin/ntx-builder/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use std::time::Duration;
use anyhow::Context;
use clap::Parser;
use miden_node_utils::clap::duration_to_human_readable_string;
use miden_node_utils::logging::OpenTelemetry;
use tokio::net::TcpListener;
use tonic::metadata::AsciiMetadataValue;
use url::Url;

const ENV_ENABLE_OTEL: &str = "MIDEN_NODE_ENABLE_OTEL";
const ENV_DATA_DIRECTORY: &str = "MIDEN_NODE_DATA_DIRECTORY";
const ENV_LISTEN: &str = "MIDEN_NODE_NTX_BUILDER_LISTEN";
const ENV_RPC_URL: &str = "MIDEN_NODE_NTX_BUILDER_RPC_URL";
Expand Down Expand Up @@ -103,13 +103,6 @@ pub enum NtxBuilderCommand {
/// Directory for the ntx-builder's persistent database.
#[arg(long = "data-directory", env = ENV_DATA_DIRECTORY, value_name = "DIR")]
data_directory: PathBuf,

/// Enables the exporting of traces for OpenTelemetry.
///
/// This can be further configured using environment variables as defined in the official
/// OpenTelemetry documentation. See our operator manual for further details.
#[arg(long = "enable-otel", default_value_t = false, env = ENV_ENABLE_OTEL, value_name = "BOOL")]
enable_otel: bool,
},

/// Bootstraps the ntx-builder database with the genesis block fetched from the node RPC.
Expand Down Expand Up @@ -164,7 +157,6 @@ impl NtxBuilderCommand {
max_tx_cycles,
sqlite_connection_pool_size,
data_directory,
enable_otel: _,
} = self
else {
unreachable!("start is only called for the Start variant")
Expand Down Expand Up @@ -197,11 +189,11 @@ impl NtxBuilderCommand {
.context("failed while running ntx builder component")
}

pub fn is_open_telemetry_enabled(&self) -> bool {
pub fn open_telemetry(&self) -> OpenTelemetry {
match self {
Self::Start { enable_otel, .. } => *enable_otel,
Self::Start { .. } => OpenTelemetry::from_env().with_name("ntx-builder"),
// Bootstrap is a one-shot command and does not set up a tracing pipeline.
Self::Bootstrap { .. } => false,
Self::Bootstrap { .. } => OpenTelemetry::Disabled,
}
}
}
Expand Down
10 changes: 1 addition & 9 deletions bin/ntx-builder/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
use clap::Parser;
use miden_node_utils::logging::OpenTelemetry;

mod commands;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let command = commands::NtxBuilderCommand::parse();

let otel = if command.is_open_telemetry_enabled() {
OpenTelemetry::Enabled
} else {
OpenTelemetry::Disabled
};

let _otel_guard = miden_node_utils::logging::setup_tracing(otel)?;
let _otel_guard = miden_node_utils::logging::setup_tracing(command.open_telemetry())?;

command.handle().await
}
8 changes: 4 additions & 4 deletions bin/remote-prover/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use anyhow::Context;
use clap::Parser;
use miden_node_utils::logging::{OpenTelemetry, setup_tracing};
use tracing::info;

mod server;
Expand All @@ -9,11 +8,12 @@ const COMPONENT: &str = "miden-prover";

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let _otel_guard = setup_tracing(OpenTelemetry::Enabled)?;
let server = server::Server::parse();

let _otel_guard = miden_node_utils::logging::setup_tracing(server.open_telemetry())?;
info!(target: COMPONENT, "Tracing initialized");

let (handle, _port) =
server::Server::parse().spawn().await.context("failed to spawn server")?;
let (handle, _port) = server.spawn().await.context("failed to spawn server")?;

handle.await.context("proof server panicked").flatten()
}
7 changes: 7 additions & 0 deletions bin/remote-prover/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use anyhow::Context;
use miden_node_proto::generated::remote_prover::api_server::ApiServer;
use miden_node_proto::generated::remote_prover::worker_status_api_server::WorkerStatusApiServer;
use miden_node_utils::cors::cors_for_grpc_web_layer;
use miden_node_utils::logging::OpenTelemetry;
use miden_node_utils::panic::catch_panic_layer_fn;
use miden_node_utils::tracing::grpc::grpc_trace_fn;
use proof_kind::ProofKind;
Expand Down Expand Up @@ -47,6 +48,12 @@ pub struct Server {
}

impl Server {
pub fn open_telemetry(&self) -> OpenTelemetry {
OpenTelemetry::from_env()
.with_name("remote-prover")
.with_attribute("miden.prover.kind", self.kind.as_str())
}

/// Spawns the prover server, returning its handle and the port it is listening on.
pub async fn spawn(&self) -> anyhow::Result<(JoinHandle<anyhow::Result<()>>, u16)> {
let listener = TcpListener::bind(format!("0.0.0.0:{}", self.port))
Expand Down
16 changes: 11 additions & 5 deletions bin/remote-prover/src/server/proof_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ pub enum ProofKind {
Block,
}

impl ProofKind {
pub const fn as_str(self) -> &'static str {
match self {
ProofKind::Transaction => "transaction",
ProofKind::Batch => "batch",
ProofKind::Block => "block",
}
}
}

impl From<proto::ProofType> for ProofKind {
fn from(value: proto::ProofType) -> Self {
match value {
Expand All @@ -20,11 +30,7 @@ impl From<proto::ProofType> for ProofKind {

impl std::fmt::Display for ProofKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ProofKind::Transaction => write!(f, "transaction"),
ProofKind::Batch => write!(f, "batch"),
ProofKind::Block => write!(f, "block"),
}
f.write_str(self.as_str())
}
}

Expand Down
15 changes: 4 additions & 11 deletions bin/validator/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::path::PathBuf;

use clap::Parser;
use miden_node_utils::clap::GrpcOptionsInternal;
use miden_node_utils::logging::OpenTelemetry;
use miden_protocol::crypto::dsa::ecdsa_k256_keccak::SigningKey;
use miden_protocol::utils::serde::Deserializable;
use miden_validator::ValidatorSigner;
Expand All @@ -14,7 +15,6 @@ const ENV_DATA_DIRECTORY: &str = "MIDEN_NODE_DATA_DIRECTORY";
const ENV_LISTEN: &str = "MIDEN_NODE_VALIDATOR_LISTEN";
const ENV_KEY: &str = "MIDEN_NODE_VALIDATOR_KEY";
const ENV_KMS_KEY_ID: &str = "MIDEN_NODE_VALIDATOR_KMS_KEY_ID";
const ENV_ENABLE_OTEL: &str = "MIDEN_NODE_ENABLE_OTEL";
const ENV_GENESIS_CONFIG_FILE: &str = "MIDEN_NODE_VALIDATOR_GENESIS_CONFIG_FILE";
const ENV_SQLITE_CONNECTION_POOL_SIZE: &str = "MIDEN_NODE_VALIDATOR_SQLITE_CONNECTION_POOL_SIZE";

Expand Down Expand Up @@ -65,13 +65,6 @@ pub enum ValidatorCommand {
#[arg(long = "listen", env = ENV_LISTEN, value_name = "LISTEN")]
listen: std::net::SocketAddr,

/// Enables the exporting of traces for OpenTelemetry.
///
/// This can be further configured using environment variables as defined in the official
/// OpenTelemetry documentation. See our operator manual for further details.
#[arg(long = "enable-otel", default_value_t = false, env = ENV_ENABLE_OTEL, value_name = "BOOL")]
enable_otel: bool,

#[command(flatten)]
grpc_options: GrpcOptionsInternal,

Expand Down Expand Up @@ -173,10 +166,10 @@ impl ValidatorCommand {
}
}

pub fn is_open_telemetry_enabled(&self) -> bool {
pub fn open_telemetry(&self) -> OpenTelemetry {
match self {
Self::Start { enable_otel, .. } => *enable_otel,
Self::Bootstrap { .. } => false,
Self::Start { .. } => OpenTelemetry::from_env().with_name("validator"),
Self::Bootstrap { .. } => OpenTelemetry::Disabled,
}
}
}
Expand Down
10 changes: 1 addition & 9 deletions bin/validator/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use clap::Parser;
use miden_node_utils::logging::OpenTelemetry;

mod commands;

// MAIN
Expand All @@ -10,13 +8,7 @@ mod commands;
async fn main() -> anyhow::Result<()> {
let command = commands::ValidatorCommand::parse();

let otel = if command.is_open_telemetry_enabled() {
OpenTelemetry::Enabled
} else {
OpenTelemetry::Disabled
};

let _otel_guard = miden_node_utils::logging::setup_tracing(otel)?;
let _otel_guard = miden_node_utils::logging::setup_tracing(command.open_telemetry())?;

command.handle().await
}
6 changes: 1 addition & 5 deletions compose/monitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ services:
- miden-network-monitor
- start
environment:
- MIDEN_MONITOR_RPC_URL=http://localhost:57291
- MIDEN_MONITOR_RPC_URL=http://sequencer:57291
- MIDEN_MONITOR_PORT=3001
- MIDEN_MONITOR_NETWORK_NAME=Localhost
- MIDEN_MONITOR_DISABLE_NTX_SERVICE=true
- MIDEN_MONITOR_ENABLE_OTEL=true
- OTEL_EXPORTER_OTLP_ENDPOINT=http://tempo:4317
- OTEL_SERVICE_NAME=monitor
extra_hosts:
- "localhost:host-gateway"
ports:
- "3001:3001"
Loading
Loading