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
7 changes: 7 additions & 0 deletions crates/rbuilder-primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,13 @@ impl Order {
}
}

pub fn external_bundle_hash(&self) -> Option<B256> {
match self {
Order::Bundle(b) => b.external_hash,
_ => None,
}
}

pub fn is_tx(&self) -> bool {
matches!(self, Order::Tx(_))
}
Expand Down
3 changes: 2 additions & 1 deletion crates/rbuilder-primitives/src/mev_boost/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::OrderId;
use alloy_primitives::{Address, Bytes, U256};
use alloy_primitives::{Address, Bytes, B256, U256};
use alloy_rpc_types_beacon::{
relay::BidTrace, requests::ExecutionRequestsV4, BlsPublicKey, BlsSignature,
};
Expand Down Expand Up @@ -200,6 +200,7 @@ pub struct BloxrouteRegionalEndpoint {
pub struct BidMetadata {
pub value: BidValueMetadata,
pub order_ids: Vec<OrderId>,
pub bundle_hashes: Vec<B256>,
}

#[derive(Clone, Copy, Default, Debug)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ async fn run_submit_to_relays_job(
coinbase_reward: block.trace.coinbase_reward,
top_competitor_bid: block.trace.seen_competition_bid,
},
order_ids: executed_orders.map(|o| o.id()).collect(),
order_ids: executed_orders.clone().map(|o| o.id()).collect(),
bundle_hashes: executed_orders
.filter_map(|o| o.external_bundle_hash())
.collect(),
};

let latency = block.trace.orders_sealed_at - block.trace.orders_closed_at;
Expand Down
44 changes: 19 additions & 25 deletions crates/rbuilder/src/mev_boost/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use alloy_primitives::{utils::parse_ether, Address, BlockHash, U256};
use alloy_rpc_types_beacon::BlsPublicKey;
use flate2::{write::GzEncoder, Compression};
use governor::{DefaultDirectRateLimiter, Quota, RateLimiter};
use itertools::Itertools;
use rbuilder_primitives::mev_boost::{
HeaderSubmissionOptimisticV3, KnownRelay, MevBoostRelayID, RelayMode,
SubmitBlockRequestNoBlobs, SubmitBlockRequestWithMetadata, ValidatorRegistration,
Expand Down Expand Up @@ -749,35 +748,29 @@ impl RelayClient {
if let Some(top_competitor_bid) = metadata.value.top_competitor_bid {
builder = builder.header(TOP_BID_HEADER, top_competitor_bid.to_string());
}
if !metadata.order_ids.is_empty() {
const MAX_BUNDLE_IDS: usize = 150;
let bundle_ids: Vec<_> = metadata
.order_ids

const MAX_BUNDLE_HASHES: usize = 150;
if !metadata.bundle_hashes.is_empty() {
let bundle_hashes: Vec<_> = metadata
.bundle_hashes
.iter()
.filter_map(|order| match order {
rbuilder_primitives::OrderId::Tx(_fixed_bytes) => None,
rbuilder_primitives::OrderId::Bundle(uuid) => Some(uuid),
rbuilder_primitives::OrderId::ShareBundle(_fixed_bytes) => None,
})
.take(MAX_BUNDLE_HASHES)
.map(|h| format!("{h:?}"))
.collect();
let total_bundles = bundle_ids.len();
let mut bundle_ids = bundle_ids
.iter()
.take(MAX_BUNDLE_IDS)
.map(|uuid| format!("{uuid:?}"));
let bundle_ids = if total_bundles > MAX_BUNDLE_IDS {
bundle_ids.join(",") + ",CAPPED"

let bundle_hashes = if bundle_hashes.len() > MAX_BUNDLE_HASHES {
bundle_hashes.join(",") + ",CAPPED"
} else {
bundle_ids.join(",")
bundle_hashes.join(",")
};
builder = builder.header(BUNDLE_HASHES_HEADER, bundle_ids);

let sent_at = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap_or_default()
.as_secs_f64();
builder = builder.header("X-BuilderNet-SentAt", sent_at.to_string());
builder = builder.header(BUNDLE_HASHES_HEADER, bundle_hashes);
}

let sent_at = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap_or_default()
.as_secs_f64();
builder = builder.header("X-BuilderNet-SentAt", sent_at.to_string());
}

let response = builder
Expand Down Expand Up @@ -1260,6 +1253,7 @@ mod tests {
top_competitor_bid: None,
},
order_ids: vec![],
bundle_hashes: vec![],
},
};
let registration = ValidatorSlotData {
Expand Down
Loading