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
159 changes: 152 additions & 7 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ ethereum_ssz = "0.8.3"
ssz_types = "0.10.1"
tree_hash = "0.9.1"
tree_hash_derive = "0.9.1"

# Build-time version info
vergen = { version = "9", features = ["build", "rustc"] }
vergen-git2 = "9"
4 changes: 4 additions & 0 deletions bin/ethlambda/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ hex.workspace = true

ethereum-types.workspace = true
clap.workspace = true

[build-dependencies]
vergen.workspace = true
vergen-git2.workspace = true
17 changes: 17 additions & 0 deletions bin/ethlambda/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use vergen::{Emitter, RustcBuilder};
use vergen_git2::Git2Builder;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let git2 = Git2Builder::default().branch(true).sha(true).build()?;
let rustc = RustcBuilder::default()
.semver(true)
.host_triple(true)
.build()?;

Emitter::default()
.add_instructions(&rustc)?
.add_instructions(&git2)?
.emit()?;

Ok(())
}
7 changes: 7 additions & 0 deletions bin/ethlambda/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mod version;

use std::{
collections::{BTreeMap, HashMap},
net::{IpAddr, SocketAddr},
Expand Down Expand Up @@ -27,6 +29,7 @@ const ASCII_ART: &str = r#"
"#;

#[derive(Debug, clap::Parser)]
#[command(name = "ethlambda", author = "LambdaClass", version = version::CLIENT_VERSION, about = "ethlambda consensus client")]
struct CliOptions {
#[arg(long)]
custom_network_config_dir: PathBuf,
Expand All @@ -53,6 +56,10 @@ async fn main() {

let options = CliOptions::parse();

// Set node info metrics
ethlambda_blockchain::metrics::set_node_info("ethlambda", version::CLIENT_VERSION);
ethlambda_blockchain::metrics::set_node_start_time();

let metrics_socket = SocketAddr::new(options.metrics_address, options.metrics_port);
let node_p2p_key = read_hex_file_bytes(&options.node_key);
let p2p_socket = SocketAddr::new(IpAddr::from([0, 0, 0, 0]), options.gossipsub_port);
Expand Down
15 changes: 15 additions & 0 deletions bin/ethlambda/src/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// Client version string with git info.
/// Format: ethlambda/v0.1.0-main-892ad575.../x86_64-unknown-linux-gnu/rustc-v1.85.0
pub const CLIENT_VERSION: &str = concat!(
env!("CARGO_PKG_NAME"),
"/v",
env!("CARGO_PKG_VERSION"),
"-",
env!("VERGEN_GIT_BRANCH"),
"-",
env!("VERGEN_GIT_SHA"),
"/",
env!("VERGEN_RUSTC_HOST_TRIPLE"),
"/rustc-v",
env!("VERGEN_RUSTC_SEMVER")
);
2 changes: 1 addition & 1 deletion crates/blockchain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use tokio::sync::mpsc;
use tracing::{error, info, warn};

pub mod key_manager;
mod metrics;
pub mod metrics;
pub mod store;

/// Messages sent from the blockchain to the P2P layer for publishing.
Expand Down
29 changes: 29 additions & 0 deletions crates/blockchain/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,32 @@ pub fn update_safe_target_slot(slot: u64) {
});
LEAN_SAFE_TARGET_SLOT.set(slot.try_into().unwrap());
}

pub fn set_node_info(name: &str, version: &str) {
static LEAN_NODE_INFO: std::sync::LazyLock<prometheus::IntGaugeVec> =
std::sync::LazyLock::new(|| {
prometheus::register_int_gauge_vec!(
"lean_node_info",
"Node information (always 1)",
&["name", "version"]
)
.unwrap()
});
LEAN_NODE_INFO.with_label_values(&[name, version]).set(1);
}

pub fn set_node_start_time() {
static LEAN_NODE_START_TIME_SECONDS: std::sync::LazyLock<prometheus::IntGauge> =
std::sync::LazyLock::new(|| {
prometheus::register_int_gauge!(
"lean_node_start_time_seconds",
"Timestamp when node started"
)
.unwrap()
});
let timestamp = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_secs();
LEAN_NODE_START_TIME_SECONDS.set(timestamp as i64);
}
Loading