Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ OS := $(shell uname -s)
CONFIG_FILE?=config-files/config.yaml
AGG_CONFIG_FILE?=config-files/config-aggregator.yaml

OPERATOR_VERSION=v0.9.0
OPERATOR_VERSION=v0.9.1

ifeq ($(OS),Linux)
BUILD_ALL_FFI = $(MAKE) build_all_ffi_linux
Expand Down
152 changes: 147 additions & 5 deletions batcher/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 batcher/aligned-batcher/Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,3 +31,7 @@ bincode = "1.3.3"
aligned-sdk = { path = "../aligned-sdk" }
ciborium = "=0.2.2"
priority-queue = "2.1.0"

once_cell = "1.20.2"
warp = "0.3.7"
prometheus = { version = "0.13.4", features = ["process"] }
8 changes: 8 additions & 0 deletions batcher/aligned-batcher/src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,6 +37,7 @@ mod config;
mod connection;
mod eth;
pub mod gnark;
pub mod metrics;
pub mod risc_zero;
pub mod s3;
pub mod sp1;
Expand DownExpand Up@@ -212,6 +213,7 @@ impl Batcher {

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

metrics::OPEN_CONNECTIONS.dec();
Ok(())
}

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

// * ---------------------------------------------------*
// * Perform validations over the message *
Expand DownExpand Up@@ -1012,6 +1016,8 @@ impl Batcher {

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

metrics::GAS_PRICE_USED_ON_LATEST_BATCH.set(gas_price.as_u64() as i64);

match self
.create_new_task(
*batch_merkle_root,
Expand All@@ -1023,6 +1029,7 @@ impl Batcher {
{
Ok(_) => {
info!("Batch verification task created on Aligned contract");
metrics::SENT_BATCHES.inc();
Ok(())
}
Err(e) => {
Expand All@@ -1031,6 +1038,7 @@ impl Batcher {
e
);

metrics::REVERTED_BATCHES.inc();
Err(e)
}
}
Expand Down
12 changes: 12 additions & 0 deletions batcher/aligned-batcher/src/main.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,9 @@ use std::sync::Arc;
use clap::Parser;
use env_logger::Env;

use aligned_batcher::metrics;
use aligned_batcher::{types::errors::BatcherError, Batcher};
use warp::Filter;

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

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

// Endpoint for Prometheus
metrics::init_variables();
let metrics_route = warp::path!("metrics").and_then(metrics::metrics_handler);
println!("Starting Batcher metrics on port 9093");
tokio::task::spawn(async move {
warp::serve(metrics_route).run(([0, 0, 0, 0], 9093)).await;
}); //TODO read from config

let batcher = Batcher::new(cli.config).await;
let batcher = Arc::new(batcher);

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

metrics::batcher_started();

batcher.listen_connections(&addr).await?;

Ok(())
Expand Down
Loading