diff --git a/.dockerignore b/.dockerignore
index 36451011..8c6bdbde 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,5 +1,4 @@
target
Dockerfile
.dockerignore
-.git
.gitignore
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 68186c23..0692b1ec 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -37,6 +37,11 @@ jobs:
uses: actions/checkout@v4
with:
ref: "stable"
+ fetch-depth: 0
+
+ - name: Log commit hash
+ run: |
+ echo "Releasing commit: $(git rev-parse HEAD)"
- name: Cache Cargo registry
uses: actions/cache@v3
@@ -107,6 +112,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: "stable"
+ fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
@@ -141,6 +147,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: "stable"
+ fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
diff --git a/bin/pbs.rs b/bin/pbs.rs
index 1514cf10..cb47ceb6 100644
--- a/bin/pbs.rs
+++ b/bin/pbs.rs
@@ -18,8 +18,8 @@ async fn main() -> Result<()> {
let pbs_config = load_pbs_config().await?;
+ PbsService::init_metrics(pbs_config.chain)?;
let state = PbsState::new(pbs_config);
- PbsService::init_metrics()?;
let server = PbsService::run::<_, DefaultBuilderApi>(state);
tokio::select! {
diff --git a/bin/src/lib.rs b/bin/src/lib.rs
index e4f566b2..c280d2a1 100644
--- a/bin/src/lib.rs
+++ b/bin/src/lib.rs
@@ -11,6 +11,7 @@ pub mod prelude {
},
pbs::{BuilderEvent, BuilderEventClient, OnBuilderApiEvent},
signer::{BlsPublicKey, BlsSignature, EcdsaPublicKey, EcdsaSignature},
+ types::Chain,
utils::{
initialize_pbs_tracing_log, initialize_tracing_log, utcnow_ms, utcnow_ns, utcnow_sec,
utcnow_us,
diff --git a/crates/common/build.rs b/crates/common/build.rs
new file mode 100644
index 00000000..9bd10ecb
--- /dev/null
+++ b/crates/common/build.rs
@@ -0,0 +1,7 @@
+use std::process::Command;
+
+fn main() {
+ let output = Command::new("git").args(["rev-parse", "HEAD"]).output().unwrap();
+ let git_hash = String::from_utf8(output.stdout).unwrap();
+ println!("cargo:rustc-env=GIT_HASH={git_hash}");
+}
diff --git a/crates/common/src/constants.rs b/crates/common/src/constants.rs
index 44b17e1a..d03904b3 100644
--- a/crates/common/src/constants.rs
+++ b/crates/common/src/constants.rs
@@ -2,3 +2,4 @@ pub const APPLICATION_BUILDER_DOMAIN: [u8; 4] = [0, 0, 0, 1];
pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = [0; 32];
pub const COMMIT_BOOST_DOMAIN: [u8; 4] = [109, 109, 111, 67];
pub const COMMIT_BOOST_VERSION: &str = env!("CARGO_PKG_VERSION");
+pub const COMMIT_BOOST_COMMIT: &str = env!("GIT_HASH");
diff --git a/crates/common/src/types.rs b/crates/common/src/types.rs
index f6b5efd1..71656178 100644
--- a/crates/common/src/types.rs
+++ b/crates/common/src/types.rs
@@ -28,6 +28,15 @@ pub enum Chain {
pub type ForkVersion = [u8; 4];
+impl std::fmt::Display for Chain {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match self {
+ Self::Mainnet | Self::Holesky | Self::Sepolia | Self::Helder => write!(f, "{self:?}"),
+ Self::Custom { .. } => write!(f, "Custom"),
+ }
+ }
+}
+
impl std::fmt::Debug for Chain {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
diff --git a/crates/metrics/src/provider.rs b/crates/metrics/src/provider.rs
index 97b2d063..b1cd242a 100644
--- a/crates/metrics/src/provider.rs
+++ b/crates/metrics/src/provider.rs
@@ -7,28 +7,33 @@ use axum::{
response::{IntoResponse, Response},
routing::get,
};
-use cb_common::config::ModuleMetricsConfig;
+use cb_common::{
+ config::ModuleMetricsConfig,
+ constants::{COMMIT_BOOST_COMMIT, COMMIT_BOOST_VERSION},
+ types::Chain,
+};
use eyre::bail;
-use prometheus::{Encoder, Registry, TextEncoder};
+use prometheus::{Encoder, IntGauge, Opts, Registry, TextEncoder};
use tokio::net::TcpListener;
use tracing::{error, info, trace, warn};
pub struct MetricsProvider {
+ network: Chain,
config: ModuleMetricsConfig,
registry: Registry,
}
impl MetricsProvider {
- pub fn new(config: ModuleMetricsConfig, registry: Registry) -> Self {
- MetricsProvider { config, registry }
+ pub fn new(network: Chain, config: ModuleMetricsConfig, registry: Registry) -> Self {
+ MetricsProvider { network, config, registry }
}
- pub fn from_registry(registry: Registry) -> eyre::Result