Skip to content

Commit 1608fc3

Browse files
MauroToscanouri-99IAvecillaJuArce
authored
v0.9.1 (#1232)
Co-authored-by: Uriel Mihura <[email protected]> Co-authored-by: IAvecilla <[email protected]> Co-authored-by: Julian Arce <[email protected]>
1 parent 7679154 commit 1608fc3

File tree

11 files changed

+1495
-585
lines changed

11 files changed

+1495
-585
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ OS := $(shell uname -s)
66
CONFIG_FILE?=config-files/config.yaml
77
AGG_CONFIG_FILE?=config-files/config-aggregator.yaml
88

9-
OPERATOR_VERSION=v0.9.0
9+
OPERATOR_VERSION=v0.9.1
1010

1111
ifeq ($(OS),Linux)
1212
BUILD_ALL_FFI = $(MAKE) build_all_ffi_linux

batcher/Cargo.lock

Lines changed: 147 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

batcher/aligned-batcher/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ bincode = "1.3.3"
3131
aligned-sdk = { path = "../aligned-sdk" }
3232
ciborium = "=0.2.2"
3333
priority-queue = "2.1.0"
34+
35+
once_cell = "1.20.2"
36+
warp = "0.3.7"
37+
prometheus = { version = "0.13.4", features = ["process"] }

batcher/aligned-batcher/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ mod config;
3737
mod connection;
3838
mod eth;
3939
pub mod gnark;
40+
pub mod metrics;
4041
pub mod risc_zero;
4142
pub mod s3;
4243
pub mod sp1;
@@ -212,6 +213,7 @@ impl Batcher {
212213

213214
// Let's spawn the handling of each connection in a separate task.
214215
while let Ok((stream, addr)) = listener.accept().await {
216+
metrics::OPEN_CONNECTIONS.inc();
215217
let batcher = self.clone();
216218
tokio::spawn(batcher.handle_connection(stream, addr));
217219
}
@@ -294,6 +296,7 @@ impl Batcher {
294296
Ok(_) => info!("{} disconnected", &addr),
295297
}
296298

299+
metrics::OPEN_CONNECTIONS.dec();
297300
Ok(())
298301
}
299302

@@ -313,6 +316,7 @@ impl Batcher {
313316
};
314317
let msg_nonce = client_msg.verification_data.nonce;
315318
debug!("Received message with nonce: {msg_nonce:?}",);
319+
metrics::RECEIVED_PROOFS.inc();
316320

317321
// * ---------------------------------------------------*
318322
// * Perform validations over the message *
@@ -1012,6 +1016,8 @@ impl Batcher {
10121016

10131017
let proof_submitters = finalized_batch.iter().map(|entry| entry.sender).collect();
10141018

1019+
metrics::GAS_PRICE_USED_ON_LATEST_BATCH.set(gas_price.as_u64() as i64);
1020+
10151021
match self
10161022
.create_new_task(
10171023
*batch_merkle_root,
@@ -1023,6 +1029,7 @@ impl Batcher {
10231029
{
10241030
Ok(_) => {
10251031
info!("Batch verification task created on Aligned contract");
1032+
metrics::SENT_BATCHES.inc();
10261033
Ok(())
10271034
}
10281035
Err(e) => {
@@ -1031,6 +1038,7 @@ impl Batcher {
10311038
e
10321039
);
10331040

1041+
metrics::REVERTED_BATCHES.inc();
10341042
Err(e)
10351043
}
10361044
}

batcher/aligned-batcher/src/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use std::sync::Arc;
55
use clap::Parser;
66
use env_logger::Env;
77

8+
use aligned_batcher::metrics;
89
use aligned_batcher::{types::errors::BatcherError, Batcher};
10+
use warp::Filter;
911

1012
/// Batcher main flow:
1113
/// There are two main tasks spawned: `listen_connections` and `listen_new_blocks`
@@ -38,6 +40,14 @@ async fn main() -> Result<(), BatcherError> {
3840

3941
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
4042

43+
// Endpoint for Prometheus
44+
metrics::init_variables();
45+
let metrics_route = warp::path!("metrics").and_then(metrics::metrics_handler);
46+
println!("Starting Batcher metrics on port 9093");
47+
tokio::task::spawn(async move {
48+
warp::serve(metrics_route).run(([0, 0, 0, 0], 9093)).await;
49+
}); //TODO read from config
50+
4151
let batcher = Batcher::new(cli.config).await;
4252
let batcher = Arc::new(batcher);
4353

@@ -53,6 +63,8 @@ async fn main() -> Result<(), BatcherError> {
5363
}
5464
});
5565

66+
metrics::batcher_started();
67+
5668
batcher.listen_connections(&addr).await?;
5769

5870
Ok(())

0 commit comments

Comments
 (0)