Skip to content
This repository was archived by the owner on Oct 2, 2025. It is now read-only.

Commit e9a18f2

Browse files
authored
Merge pull request #9 from flashbots/bidder-version
New bidding service version metric.
2 parents 4f74e27 + 081734a commit e9a18f2

File tree

4 files changed

+55
-9
lines changed

4 files changed

+55
-9
lines changed

src/bidding_service_wrapper/bidding_service.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/// Mapping of build_info::Version
2+
#[allow(clippy::derive_partial_eq_without_eq)]
3+
#[derive(Clone, PartialEq, ::prost::Message)]
4+
pub struct BidderVersionInfo {
5+
#[prost(string, tag = "1")]
6+
pub git_commit: ::prost::alloc::string::String,
7+
#[prost(string, tag = "2")]
8+
pub git_ref: ::prost::alloc::string::String,
9+
#[prost(string, tag = "3")]
10+
pub build_time_utc: ::prost::alloc::string::String,
11+
}
112
#[allow(clippy::derive_partial_eq_without_eq)]
213
#[derive(Clone, PartialEq, ::prost::Message)]
314
pub struct Empty {}
@@ -190,10 +201,11 @@ pub mod bidding_service_client {
190201
self
191202
}
192203
/// Call after connection before calling anything. This will really create the BiddingService on the server side.
204+
/// Returns the version info for the server side.
193205
pub async fn initialize(
194206
&mut self,
195207
request: impl tonic::IntoRequest<super::LandedBlocksParams>,
196-
) -> Result<tonic::Response<super::Empty>, tonic::Status> {
208+
) -> Result<tonic::Response<super::BidderVersionInfo>, tonic::Status> {
197209
self.inner
198210
.ready()
199211
.await
@@ -358,10 +370,11 @@ pub mod bidding_service_server {
358370
#[async_trait]
359371
pub trait BiddingService: Send + Sync + 'static {
360372
/// Call after connection before calling anything. This will really create the BiddingService on the server side.
373+
/// Returns the version info for the server side.
361374
async fn initialize(
362375
&self,
363376
request: tonic::Request<super::LandedBlocksParams>,
364-
) -> Result<tonic::Response<super::Empty>, tonic::Status>;
377+
) -> Result<tonic::Response<super::BidderVersionInfo>, tonic::Status>;
365378
/// Server streaming response type for the CreateSlotBidder method.
366379
type CreateSlotBidderStream: futures_core::Stream<
367380
Item = Result<super::Callback, tonic::Status>,
@@ -476,7 +489,7 @@ pub mod bidding_service_server {
476489
T: BiddingService,
477490
> tonic::server::UnaryService<super::LandedBlocksParams>
478491
for InitializeSvc<T> {
479-
type Response = super::Empty;
492+
type Response = super::BidderVersionInfo;
480493
type Future = BoxFuture<
481494
tonic::Response<Self::Response>,
482495
tonic::Status,

src/bidding_service_wrapper/client/bidding_service_client_adapter.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use alloy_primitives::U256;
2-
use rbuilder::live_builder::block_output::bidding::interfaces::{
3-
BiddingServiceWinControl, LandedBlockInfo as RealLandedBlockInfo,
2+
use rbuilder::{
3+
live_builder::block_output::bidding::interfaces::{
4+
BiddingServiceWinControl, LandedBlockInfo as RealLandedBlockInfo,
5+
},
6+
utils::build_info::Version,
47
};
58
use std::{
69
path::PathBuf,
@@ -19,6 +22,7 @@ use crate::{
1922
MustWinBlockParams, NewBlockParams, UpdateNewBidParams,
2023
},
2124
block_descriptor_bidding::traits::{Bid, BidMaker, BiddingService, BlockId, SlotBidder},
25+
metrics::set_bidding_service_version,
2226
};
2327

2428
use super::slot_bidder_client::SlotBidderClient;
@@ -102,10 +106,16 @@ impl BiddingServiceClientAdapter {
102106
.map(real2rpc_landed_block_info)
103107
.collect(),
104108
};
105-
client
109+
let bidding_service_version = client
106110
.initialize(init_params)
107111
.await
108112
.map_err(|_| Error::InitFailed)?;
113+
let bidding_service_version = bidding_service_version.into_inner();
114+
set_bidding_service_version(Version {
115+
git_commit: bidding_service_version.git_commit,
116+
git_ref: bidding_service_version.git_ref,
117+
build_time_utc: bidding_service_version.build_time_utc,
118+
});
109119
let (commands_sender, mut rx) = mpsc::unbounded_channel::<BiddingServiceClientCommand>();
110120
// Spawn a task to execute received futures
111121
tokio::spawn(async move {

src/bidding_service_wrapper/proto/bidding_service.proto

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ package bidding_service;
1414
service BiddingService {
1515

1616
// Call after connection before calling anything. This will really create the BiddingService on the server side.
17-
rpc Initialize(LandedBlocksParams) returns (Empty);
17+
// Returns the version info for the server side.
18+
rpc Initialize(LandedBlocksParams) returns (BidderVersionInfo);
1819

1920
// BiddingService
2021
rpc CreateSlotBidder(CreateSlotBidderParams) returns (stream Callback);
@@ -36,6 +37,13 @@ service BiddingService {
3637
// uint64 block + uint64 slot should be something like BidderId
3738

3839

40+
// Mapping of build_info::Version
41+
message BidderVersionInfo {
42+
string git_commit = 1;
43+
string git_ref = 2;
44+
string build_time_utc = 3;
45+
}
46+
3947
message Empty {
4048
}
4149

src/metrics.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use ctor::ctor;
22
use lazy_static::lazy_static;
33
use metrics_macros::register_metrics;
4-
use prometheus::{IntCounter, IntCounterVec, Opts};
5-
use rbuilder::telemetry::REGISTRY;
4+
use prometheus::{IntCounter, IntCounterVec, IntGaugeVec, Opts};
5+
use rbuilder::{telemetry::REGISTRY, utils::build_info::Version};
66

77
register_metrics! {
88
pub static BLOCK_API_ERRORS: IntCounterVec = IntCounterVec::new(
@@ -17,6 +17,11 @@ register_metrics! {
1717
)
1818
.unwrap();
1919

20+
pub static BIDDING_SERVICE_VERSION: IntGaugeVec = IntGaugeVec::new(
21+
Opts::new("bidding_service_version", "Version of the bidding service"),
22+
&["git", "git_ref", "build_time_utc"]
23+
)
24+
.unwrap();
2025
}
2126

2227
pub fn inc_blocks_api_errors() {
@@ -26,3 +31,13 @@ pub fn inc_blocks_api_errors() {
2631
pub fn inc_non_0_competition_bids() {
2732
NON_0_COMPETITION_BIDS.inc();
2833
}
34+
35+
pub(super) fn set_bidding_service_version(version: Version) {
36+
BIDDING_SERVICE_VERSION
37+
.with_label_values(&[
38+
&version.git_commit,
39+
&version.git_ref,
40+
&version.build_time_utc,
41+
])
42+
.set(1);
43+
}

0 commit comments

Comments
 (0)