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
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
use futures_util::FutureExt;
use hyper_util::rt::TokioIo;
use parking_lot::Mutex;
use rbuilder::{
live_builder::{
block_output::bidding_service_interface::{
BiddingService, BlockSealInterfaceForSlotBidder,
LandedBlockInfo as RealLandedBlockInfo, RelaySet, ScrapedRelayBlockBidWithStats,
SlotBidder, SlotBlockId,
},
process_killer::ProcessKiller,
use rbuilder::live_builder::{
block_output::bidding_service_interface::{
BiddingService, BlockSealInterfaceForSlotBidder, LandedBlockInfo as RealLandedBlockInfo,
RelaySet, ScrapedRelayBlockBidWithStats, SlotBidder, SlotBlockId,
},
utils::build_info::Version,
process_killer::ProcessKiller,
};
use rbuilder_utils::build_info::Version;
use std::{
collections::HashMap,
path::PathBuf,
Expand Down
47 changes: 2 additions & 45 deletions crates/rbuilder-operator/src/build_info.rs
Original file line number Diff line number Diff line change
@@ -1,45 +1,2 @@
// The file has been placed there by the build script.

mod internal {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

use internal::{
BUILT_TIME_UTC, CI_PLATFORM, FEATURES, GIT_COMMIT_HASH_SHORT, GIT_HEAD_REF, PROFILE,
RUSTC_VERSION,
};
use rbuilder::utils::build_info::Version;

pub fn print_version_info() {
println!(
"commit: {}",
GIT_COMMIT_HASH_SHORT.unwrap_or_default()
);
println!("branch: {}", GIT_HEAD_REF.unwrap_or_default());
println!("build_platform: {:?}", CI_PLATFORM.unwrap_or_default());
println!("build_time: {BUILT_TIME_UTC}");
println!("features: {FEATURES:?}");
println!("profile: {PROFILE}");
println!("rustc: {RUSTC_VERSION}");
}

pub fn rbuilder_version() -> Version {
let git_commit = {
let mut commit = String::new();
if let Some(hash) = GIT_COMMIT_HASH_SHORT {
commit.push_str(hash);
}
if commit.is_empty() {
commit.push_str("unknown");
}
commit
};

let git_ref = GIT_HEAD_REF.unwrap_or("unknown").to_string();

Version {
git_commit,
git_ref,
build_time_utc: BUILT_TIME_UTC.to_string(),
}
}
use rbuilder_utils::define_version_module;
define_version_module!(rbuilder_version);
2 changes: 1 addition & 1 deletion crates/rbuilder-operator/src/flashbots_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ use rbuilder::{
LiveBuilder,
},
provider::StateProviderFactory,
utils::build_info::Version,
};
use rbuilder_config::EnvOrValue;
use rbuilder_utils::build_info::Version;
use serde::Deserialize;
use serde_with::serde_as;
use time::OffsetDateTime;
Expand Down
3 changes: 2 additions & 1 deletion crates/rbuilder-operator/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use prometheus::{
};
use rbuilder::{
telemetry::{exponential_buckets_range, REGISTRY},
utils::{self, build_info::Version},
utils::{self},
};
use rbuilder_utils::build_info::Version;
use rbuilder_utils::clickhouse::Quantities;

register_metrics! {
Expand Down
67 changes: 67 additions & 0 deletions crates/rbuilder-utils/src/build_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//! Macro to generate functions to get git information from the current build.
//! Everything is based on the data generated by the built crate.
//! This has to be a macro and not a function since it's referencing a dynamically build mod create by built.
//! Top use add:
//! built::write_built_file().expect("Failed to acquire build-time information"); on the main in build.rs and then call the macro like:
//! define_version_module!(rbuilder_version);

#[derive(Debug)]
pub struct Version {
/// 8 digits commit. if modified "-dirty" is appended
pub git_commit: String,
/// Git ref if available (eg:"refs/heads/more-comments")
pub git_ref: String,
pub build_time_utc: String,
}

#[macro_export]
macro_rules! define_version_module {
($version_fn_name:ident) => {
mod internal {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

use internal::{
BUILT_TIME_UTC, FEATURES, GIT_COMMIT_HASH_SHORT, GIT_DIRTY, GIT_HEAD_REF, GIT_VERSION,
PROFILE, RUSTC_VERSION,
};
use rbuilder_utils::build_info::Version;

pub fn print_version_info() {
println!("version: {}", GIT_VERSION.unwrap_or_default());
println!("commit: {}", GIT_COMMIT_HASH_SHORT.unwrap_or_default());
println!("dirty: {}", GIT_DIRTY.unwrap_or_default());
println!("branch: {}", GIT_HEAD_REF.unwrap_or_default());
println!("build_time: {BUILT_TIME_UTC}");
println!("rustc: {RUSTC_VERSION}");
println!("features: {FEATURES:?}");
println!("profile: {PROFILE}");
}

pub fn $version_fn_name() -> Version {
let git_commit = {
let mut commit = String::new();
if let Some(hash) = GIT_COMMIT_HASH_SHORT {
commit.push_str(hash);
}
if let Some(dirty) = GIT_DIRTY {
if dirty {
commit.push_str("-dirty");
}
}
if commit.is_empty() {
commit.push_str("unknown");
}
commit
};

let git_ref = GIT_HEAD_REF.unwrap_or("unknown").to_string();

Version {
git_commit,
git_ref,
build_time_utc: BUILT_TIME_UTC.to_string(),
}
}
};
}
1 change: 1 addition & 0 deletions crates/rbuilder-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod backoff;
pub mod build_info;
pub mod clickhouse;
pub mod format;
pub mod metrics;
Expand Down
1 change: 1 addition & 0 deletions crates/rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ build = "build.rs"
[dependencies]
rbuilder-primitives.workspace = true
rbuilder-config.workspace = true
rbuilder-utils.workspace = true

serde = { workspace = true }
derive_more = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion crates/rbuilder/src/live_builder/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use clap::Parser;
use rbuilder_config::load_toml_config;
use rbuilder_utils::build_info::Version;
use serde::de::DeserializeOwned;
use std::{
fmt::Debug,
Expand All @@ -22,7 +23,7 @@ use crate::{
},
provider::StateProviderFactory,
telemetry,
utils::{bls::generate_random_bls_address, build_info::Version},
utils::bls::generate_random_bls_address,
};

use super::{base_config::BaseConfig, LiveBuilder};
Expand Down
2 changes: 1 addition & 1 deletion crates/rbuilder/src/live_builder/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ impl LiveBuilderConfig for Config {
Ok(live_builder.with_builders(builders))
}

fn version_for_telemetry(&self) -> crate::utils::build_info::Version {
fn version_for_telemetry(&self) -> rbuilder_utils::build_info::Version {
rbuilder_version()
}

Expand Down
3 changes: 2 additions & 1 deletion crates/rbuilder/src/telemetry/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use crate::{
building::BuiltBlockTrace,
live_builder::block_list_provider::{blocklist_hash, BlockList},
utils::{build_info::Version, duration_ms},
utils::duration_ms,
};
use alloy_consensus::constants::GWEI_TO_WEI;
use alloy_primitives::{utils::Unit, U256};
Expand All @@ -25,6 +25,7 @@ use prometheus::{
IntGaugeVec, Opts, Registry,
};
use rbuilder_primitives::mev_boost::MevBoostRelayID;
use rbuilder_utils::build_info::Version;
use std::time::Duration;
use time::OffsetDateTime;
use tracing::error;
Expand Down
12 changes: 5 additions & 7 deletions crates/rbuilder/src/telemetry/servers/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
//!
//! Full server may expose metrics that could leak information when running tdx.

use rbuilder_utils::build_info::Version;
use std::net::SocketAddr;
use time::OffsetDateTime;
use warp::{Filter, Rejection, Reply};

use crate::{
telemetry::{
metrics::{gather_prometheus_metrics, set_version},
BUILDER_BALANCE, CURRENT_BLOCK, MAX_FRESH_GAUGE_AGE, ORDERPOOL_BUNDLES, ORDERPOOL_TXS,
ORDERPOOL_TXS_SIZE, REGISTRY,
},
utils::build_info::Version,
use crate::telemetry::{
metrics::{gather_prometheus_metrics, set_version},
BUILDER_BALANCE, CURRENT_BLOCK, MAX_FRESH_GAUGE_AGE, ORDERPOOL_BUNDLES, ORDERPOOL_TXS,
ORDERPOOL_TXS_SIZE, REGISTRY,
};

pub async fn spawn(addr: SocketAddr, version: Version) -> eyre::Result<()> {
Expand Down
59 changes: 2 additions & 57 deletions crates/rbuilder/src/utils/build_info.rs
Original file line number Diff line number Diff line change
@@ -1,57 +1,2 @@
//! Functions to get git information from the current build.
//! Everything is based on the data generated by crates/rbuilder/build.rs (included as a [build-dependencies] con cargo.toml) and left on
//! a file called built.rs on the output dir.
mod internal {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

use internal::{
BUILT_TIME_UTC, FEATURES, GIT_COMMIT_HASH_SHORT, GIT_DIRTY, GIT_HEAD_REF, GIT_VERSION, PROFILE,
RUSTC_VERSION,
};

pub fn print_version_info() {
println!("version: {}", GIT_VERSION.unwrap_or_default());
println!("commit: {}", GIT_COMMIT_HASH_SHORT.unwrap_or_default());
println!("dirty: {}", GIT_DIRTY.unwrap_or_default());
println!("branch: {}", GIT_HEAD_REF.unwrap_or_default());
println!("build_time: {BUILT_TIME_UTC}");
println!("rustc: {RUSTC_VERSION}");
println!("features: {FEATURES:?}");
println!("profile: {PROFILE}");
}

#[derive(Debug)]
pub struct Version {
/// 8 digits commit. if modified "-dirty" is appended
pub git_commit: String,
/// Git ref if available (eg:"refs/heads/more-comments")
pub git_ref: String,
pub build_time_utc: String,
}

pub fn rbuilder_version() -> Version {
let git_commit = {
let mut commit = String::new();
if let Some(hash) = GIT_COMMIT_HASH_SHORT {
commit.push_str(hash);
}
if let Some(dirty) = GIT_DIRTY {
if dirty {
commit.push_str("-dirty");
}
}
if commit.is_empty() {
commit.push_str("unknown");
}
commit
};

let git_ref = GIT_HEAD_REF.unwrap_or("unknown").to_string();

Version {
git_commit,
git_ref,
build_time_utc: BUILT_TIME_UTC.to_string(),
}
}
use rbuilder_utils::define_version_module;
define_version_module!(rbuilder_version);
Loading