Skip to content

Commit 262bb7a

Browse files
committed
PBS: Log auction participants with bid value and delta at INFO level
1 parent ed4747c commit 262bb7a

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

crates/pbs/src/mev_boost/get_header.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use futures::future::join_all;
2727
use parking_lot::RwLock;
2828
use reqwest::{StatusCode, header::USER_AGENT};
2929
use tokio::time::sleep;
30-
use tracing::{Instrument, debug, error, warn};
30+
use tracing::{Instrument, debug, error, info, warn};
3131
use tree_hash::TreeHash;
3232
use url::Url;
3333

@@ -119,7 +119,8 @@ pub async fn get_header<S: BuilderApiState>(
119119
}
120120

121121
let results = join_all(handles).await;
122-
let mut relay_bids = Vec::with_capacity(relays.len());
122+
let mut relay_bids: Vec<(&str, GetHeaderResponse)> = Vec::with_capacity(relays.len());
123+
let mut best_value = U256::ZERO;
123124
for (i, res) in results.into_iter().enumerate() {
124125
let relay_id = relays[i].id.as_str();
125126

@@ -131,15 +132,34 @@ pub async fn get_header<S: BuilderApiState>(
131132
.unwrap_or_default();
132133
RELAY_HEADER_VALUE.with_label_values(&[relay_id]).set(value_gwei);
133134

134-
relay_bids.push(res)
135+
best_value = best_value.max(*res.data.message.value());
136+
relay_bids.push((relay_id, res))
135137
}
136138
Ok(_) => {}
137139
Err(err) if err.is_timeout() => error!(err = "Timed Out", relay_id),
138140
Err(err) => error!(%err, relay_id),
139141
}
140142
}
141143

142-
let max_bid = relay_bids.into_iter().max_by_key(|bid| *bid.value());
144+
// Log auction participants and pick the winner
145+
let mut max_bid = None;
146+
for (relay_id, bid) in relay_bids {
147+
let value = *bid.value();
148+
let delta = best_value.saturating_sub(value);
149+
let selected = value == best_value;
150+
info!(
151+
relay_id,
152+
value = %value,
153+
value_eth = format_ether(value),
154+
value_delta = %delta,
155+
selected,
156+
block_hash = %bid.block_hash(),
157+
"Auction participant"
158+
);
159+
if selected && max_bid.is_none() {
160+
max_bid = Some(bid);
161+
}
162+
}
143163

144164
Ok(max_bid)
145165
}

0 commit comments

Comments
 (0)