Skip to content

Commit a51b424

Browse files
chore: send bundle hashes instead of uuid to fake relay (#771)
1 parent c6e5106 commit a51b424

File tree

4 files changed

+32
-27
lines changed

4 files changed

+32
-27
lines changed

crates/rbuilder-primitives/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,13 @@ impl Order {
11511151
}
11521152
}
11531153

1154+
pub fn external_bundle_hash(&self) -> Option<B256> {
1155+
match self {
1156+
Order::Bundle(b) => b.external_hash,
1157+
_ => None,
1158+
}
1159+
}
1160+
11541161
pub fn is_tx(&self) -> bool {
11551162
matches!(self, Order::Tx(_))
11561163
}

crates/rbuilder-primitives/src/mev_boost/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::OrderId;
2-
use alloy_primitives::{Address, Bytes, U256};
2+
use alloy_primitives::{Address, Bytes, B256, U256};
33
use alloy_rpc_types_beacon::{
44
relay::BidTrace, requests::ExecutionRequestsV4, BlsPublicKey, BlsSignature,
55
};
@@ -200,6 +200,7 @@ pub struct BloxrouteRegionalEndpoint {
200200
pub struct BidMetadata {
201201
pub value: BidValueMetadata,
202202
pub order_ids: Vec<OrderId>,
203+
pub bundle_hashes: Vec<B256>,
203204
}
204205

205206
#[derive(Clone, Copy, Default, Debug)]

crates/rbuilder/src/live_builder/block_output/relay_submit.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ async fn run_submit_to_relays_job(
202202
coinbase_reward: block.trace.coinbase_reward,
203203
top_competitor_bid: block.trace.seen_competition_bid,
204204
},
205-
order_ids: executed_orders.map(|o| o.id()).collect(),
205+
order_ids: executed_orders.clone().map(|o| o.id()).collect(),
206+
bundle_hashes: executed_orders
207+
.filter_map(|o| o.external_bundle_hash())
208+
.collect(),
206209
};
207210

208211
let latency = block.trace.orders_sealed_at - block.trace.orders_closed_at;

crates/rbuilder/src/mev_boost/mod.rs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use alloy_primitives::{utils::parse_ether, Address, BlockHash, U256};
33
use alloy_rpc_types_beacon::BlsPublicKey;
44
use flate2::{write::GzEncoder, Compression};
55
use governor::{DefaultDirectRateLimiter, Quota, RateLimiter};
6-
use itertools::Itertools;
76
use rbuilder_primitives::mev_boost::{
87
HeaderSubmissionOptimisticV3, KnownRelay, MevBoostRelayID, RelayMode,
98
SubmitBlockRequestNoBlobs, SubmitBlockRequestWithMetadata, ValidatorRegistration,
@@ -749,35 +748,29 @@ impl RelayClient {
749748
if let Some(top_competitor_bid) = metadata.value.top_competitor_bid {
750749
builder = builder.header(TOP_BID_HEADER, top_competitor_bid.to_string());
751750
}
752-
if !metadata.order_ids.is_empty() {
753-
const MAX_BUNDLE_IDS: usize = 150;
754-
let bundle_ids: Vec<_> = metadata
755-
.order_ids
751+
752+
const MAX_BUNDLE_HASHES: usize = 150;
753+
if !metadata.bundle_hashes.is_empty() {
754+
let bundle_hashes: Vec<_> = metadata
755+
.bundle_hashes
756756
.iter()
757-
.filter_map(|order| match order {
758-
rbuilder_primitives::OrderId::Tx(_fixed_bytes) => None,
759-
rbuilder_primitives::OrderId::Bundle(uuid) => Some(uuid),
760-
rbuilder_primitives::OrderId::ShareBundle(_fixed_bytes) => None,
761-
})
757+
.take(MAX_BUNDLE_HASHES)
758+
.map(|h| format!("{h:?}"))
762759
.collect();
763-
let total_bundles = bundle_ids.len();
764-
let mut bundle_ids = bundle_ids
765-
.iter()
766-
.take(MAX_BUNDLE_IDS)
767-
.map(|uuid| format!("{uuid:?}"));
768-
let bundle_ids = if total_bundles > MAX_BUNDLE_IDS {
769-
bundle_ids.join(",") + ",CAPPED"
760+
761+
let bundle_hashes = if bundle_hashes.len() > MAX_BUNDLE_HASHES {
762+
bundle_hashes.join(",") + ",CAPPED"
770763
} else {
771-
bundle_ids.join(",")
764+
bundle_hashes.join(",")
772765
};
773-
builder = builder.header(BUNDLE_HASHES_HEADER, bundle_ids);
774-
775-
let sent_at = std::time::SystemTime::now()
776-
.duration_since(std::time::UNIX_EPOCH)
777-
.unwrap_or_default()
778-
.as_secs_f64();
779-
builder = builder.header("X-BuilderNet-SentAt", sent_at.to_string());
766+
builder = builder.header(BUNDLE_HASHES_HEADER, bundle_hashes);
780767
}
768+
769+
let sent_at = std::time::SystemTime::now()
770+
.duration_since(std::time::UNIX_EPOCH)
771+
.unwrap_or_default()
772+
.as_secs_f64();
773+
builder = builder.header("X-BuilderNet-SentAt", sent_at.to_string());
781774
}
782775

783776
let response = builder
@@ -1260,6 +1253,7 @@ mod tests {
12601253
top_competitor_bid: None,
12611254
},
12621255
order_ids: vec![],
1256+
bundle_hashes: vec![],
12631257
},
12641258
};
12651259
let registration = ValidatorSlotData {

0 commit comments

Comments
 (0)