Skip to content

Commit f856b78

Browse files
authored
feat: set additional bloxroute headers (#673)
## 📝 Summary Sets additional headers for bid submissions to bloxroute. By default, the bids are shared across regions. Setting `share=na` header restricts bloxroute submissions to be shared only within North America region. Builder value header allows to communicate to bloxroute full coinbase reward without having relay to simulate the block. ## ✅ I have completed the following steps: * [x] Run `make lint` * [x] Run `make test` * [ ] Added tests (if applicable)
1 parent 96bde39 commit f856b78

File tree

6 files changed

+58
-5
lines changed

6 files changed

+58
-5
lines changed

crates/rbuilder/src/bin/dummy-builder.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,15 @@ async fn main() -> eyre::Result<()> {
7070
let cancel = CancellationToken::new();
7171

7272
let flashbots_relay_url = "https://0xac6e77dfe25ecd6110b8e780608cce0dab71fdd5ebea22a16c0205200f2f8e2e3ad3b71d3499c54ad14d6c21b41a37ae@boost-relay.flashbots.net";
73-
let relay_client =
74-
RelayClient::from_url(flashbots_relay_url.parse()?, None, None, None, false, false);
73+
let relay_client = RelayClient::from_url(
74+
flashbots_relay_url.parse()?,
75+
None,
76+
None,
77+
None,
78+
false,
79+
false,
80+
false,
81+
);
7582
let relay = MevBoostRelaySlotInfoProvider::new(relay_client, "flashbots".to_string());
7683
let blocklist_provider = Arc::new(NullBlockListProvider::new());
7784
let payload_event = MevBoostSlotDataGenerator::new(

crates/rbuilder/src/integration/playground.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ impl Playground {
163163
None,
164164
false,
165165
false,
166+
false,
166167
);
167168

168169
let payload = client

crates/rbuilder/src/live_builder/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ impl L1Config {
248248
relay_config.authorization_header.clone(),
249249
relay_config.builder_id_header.clone(),
250250
relay_config.api_token_header.clone(),
251+
relay_config.is_bloxroute,
251252
relay_config
252253
.ask_for_filtering_validators
253254
.unwrap_or(DEFAULT_ASK_FOR_FILTERING_VALIDATORS),
@@ -763,6 +764,7 @@ lazy_static! {
763764
builder_id_header: None,
764765
api_token_header: None,
765766
adjustment_fee_payer: None,
767+
is_bloxroute: false,
766768
ask_for_filtering_validators: None,
767769
can_ignore_gas_limit: None,
768770
},
@@ -785,6 +787,7 @@ lazy_static! {
785787
builder_id_header: None,
786788
api_token_header: None,
787789
adjustment_fee_payer: None,
790+
is_bloxroute: false,
788791
ask_for_filtering_validators: None,
789792
can_ignore_gas_limit: None,
790793
},
@@ -807,6 +810,7 @@ lazy_static! {
807810
builder_id_header: None,
808811
api_token_header: None,
809812
adjustment_fee_payer: None,
813+
is_bloxroute: false,
810814
ask_for_filtering_validators: None,
811815
can_ignore_gas_limit: None,
812816
},
@@ -828,6 +832,7 @@ lazy_static! {
828832
builder_id_header: None,
829833
api_token_header: None,
830834
adjustment_fee_payer: None,
835+
is_bloxroute: false,
831836
ask_for_filtering_validators: None,
832837
can_ignore_gas_limit: None,
833838
},
@@ -850,6 +855,7 @@ lazy_static! {
850855
builder_id_header: None,
851856
api_token_header: None,
852857
adjustment_fee_payer: None,
858+
is_bloxroute: false,
853859
ask_for_filtering_validators: None,
854860
can_ignore_gas_limit: None,
855861
},

crates/rbuilder/src/mev_boost/mod.rs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ pub use sign_payload::*;
2828
const TOTAL_PAYMENT_HEADER: &str = "Total-Payment";
2929
const BUNDLE_HASHES_HEADER: &str = "Bundle-Hashes";
3030
const TOP_BID_HEADER: &str = "Top-Bid";
31+
const BLOXROUTE_SHARE_HEADER: &str = "share";
32+
const BLOXROUTE_BUILDER_VALUE_HEADER: &str = "builder-value";
3133

3234
const JSON_CONTENT_TYPE: &str = "application/json";
3335
const SSZ_CONTENT_TYPE: &str = "application/octet-stream";
@@ -119,6 +121,13 @@ impl KnownRelay {
119121
}
120122
.to_string()
121123
}
124+
125+
pub fn is_bloxroute(&self) -> bool {
126+
matches!(
127+
self,
128+
Self::BloxrouteMaxProfit | Self::BloxrouteEthical | Self::BloxrouteRegulated
129+
)
130+
}
122131
}
123132

124133
impl FromStr for KnownRelay {
@@ -151,6 +160,8 @@ pub struct RelayClient {
151160
authorization_header: Option<String>,
152161
builder_id_header: Option<String>,
153162
api_token_header: Option<String>,
163+
/// Flag indicating whether this is the bloxroute relay.
164+
is_bloxroute: bool,
154165
/// Adds "filtering=true" as query
155166
ask_for_filtering_validators: bool,
156167
/// If we submit a block with a different gas than the one the validator registered with in this relay the relay does not mind.
@@ -163,6 +174,7 @@ impl RelayClient {
163174
authorization_header: Option<String>,
164175
builder_id_header: Option<String>,
165176
api_token_header: Option<String>,
177+
is_bloxroute: bool,
166178
ask_for_filtering_validators: bool,
167179
can_ignore_gas_limit: bool,
168180
) -> Self {
@@ -172,13 +184,22 @@ impl RelayClient {
172184
authorization_header,
173185
builder_id_header,
174186
api_token_header,
187+
is_bloxroute,
175188
ask_for_filtering_validators,
176189
can_ignore_gas_limit,
177190
}
178191
}
179192

180193
pub fn from_known_relay(relay: KnownRelay) -> Self {
181-
Self::from_url(relay.url(), None, None, None, false, false)
194+
Self::from_url(
195+
relay.url(),
196+
None,
197+
None,
198+
None,
199+
relay.is_bloxroute(),
200+
false,
201+
false,
202+
)
182203
}
183204

184205
pub fn can_ignore_gas_limit(&self) -> bool {
@@ -538,6 +559,21 @@ impl RelayClient {
538559
.map_err(|e| SubmitBlockErr::RPCSerializationError(e.to_string()))?;
539560
}
540561

562+
// Set bloxroute specific headers.
563+
if self.is_bloxroute {
564+
headers.insert(BLOXROUTE_SHARE_HEADER, HeaderValue::from_static("na"));
565+
headers.insert(
566+
BLOXROUTE_BUILDER_VALUE_HEADER,
567+
submission_with_metadata
568+
.metadata
569+
.value
570+
.coinbase_reward
571+
.to_string()
572+
.parse()
573+
.map_err(|_| RelayError::InvalidHeader)?,
574+
);
575+
}
576+
541577
builder = builder.headers(headers).body(Body::from(body_data));
542578
if fake_relay {
543579
builder = builder.header(
@@ -838,7 +874,7 @@ mod tests {
838874
let mut generator = TestDataGenerator::default();
839875

840876
let relay_url = Url::from_str(&srv.endpoint()).unwrap();
841-
let relay = RelayClient::from_url(relay_url, None, None, None, false, false);
877+
let relay = RelayClient::from_url(relay_url, None, None, None, false, false, false);
842878
let submission = SubmitBlockRequest::Deneb(generator.create_deneb_submit_block_request());
843879
let sub_relay = SubmitBlockRequestWithMetadata {
844880
submission,

crates/rbuilder/src/primitives/mev_boost.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ pub struct RelayConfig {
6464
pub submit_config: Option<RelaySubmitConfig>,
6565
/// Deprecated field that is not used
6666
pub priority: Option<usize>,
67+
/// Set to `true` for bloxroute relays.
68+
#[serde(default)]
69+
pub is_bloxroute: bool,
6770
/// Adds "filtering=true" as query to the call relay/v1/builder/validators to get all validators (including those filtering OFAC)
6871
/// On 2025/06/24 (my birthday!) only supported by ultrasound.
6972
/// None -> false

crates/test-relay/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ async fn main() -> eyre::Result<()> {
102102

103103
let relay = {
104104
let url: Url = cli.relay.parse()?;
105-
let client = RelayClient::from_url(url, None, None, None, false, false);
105+
let client = RelayClient::from_url(url, None, None, None, false, false, false);
106106
MevBoostRelaySlotInfoProvider::new(client, "relay".to_string())
107107
};
108108

0 commit comments

Comments
 (0)