Skip to content

Commit a6ebe67

Browse files
authored
feat(relay): support validator preferences in registrations (#817)
## 📝 Summary Support validator preferences in relay registrations. ## ✅ I have completed the following steps: * [x] Run `make lint` * [x] Run `make test` * [ ] Added tests (if applicable)
1 parent 9a82891 commit a6ebe67

File tree

3 files changed

+100
-6
lines changed

3 files changed

+100
-6
lines changed

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

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ pub struct ValidatorSlotData {
181181
/// (Bloxroute) Collection of regional endpoints validator is connected to.
182182
#[serde(default)]
183183
pub regional_endpoints: Vec<BloxrouteRegionalEndpoint>,
184+
/// (Titan) Validator preferences.
185+
#[serde(default)]
186+
pub preferences: Option<TitanValidatorPreferences>,
184187
}
185188

186189
/// Bloxroute validator RProxy details.
@@ -198,6 +201,13 @@ pub struct BloxrouteRegionalEndpoint {
198201
pub websocket_endpoint: String,
199202
}
200203

204+
/// Titan validator preferences.
205+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)]
206+
pub struct TitanValidatorPreferences {
207+
/// Flag indicating whether the validator is censoring.
208+
pub censoring: bool,
209+
}
210+
201211
#[derive(Clone, Debug)]
202212
pub struct BidMetadata {
203213
pub sequence: u64,
@@ -217,3 +227,74 @@ pub struct SubmitBlockRequestWithMetadata {
217227
pub submission: SubmitBlockRequest,
218228
pub metadata: BidMetadata,
219229
}
230+
231+
#[cfg(test)]
232+
mod tests {
233+
use super::*;
234+
235+
#[test]
236+
fn validator_slot_data_ser_deser() {
237+
let registrations = [
238+
r#"
239+
{
240+
"slot": "123",
241+
"validator_index": "123",
242+
"entry": {
243+
"message": {
244+
"fee_recipient": "0x0000000000000000000000000000000000000000",
245+
"gas_limit": "60000000",
246+
"timestamp": "123",
247+
"pubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
248+
},
249+
"signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
250+
}
251+
}
252+
"#,
253+
r#"
254+
{
255+
"slot": "123",
256+
"validator_index": "123",
257+
"entry": {
258+
"message": {
259+
"fee_recipient": "0x0000000000000000000000000000000000000000",
260+
"gas_limit": "60000000",
261+
"timestamp": "123",
262+
"pubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
263+
},
264+
"signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
265+
},
266+
"regional_endpoints": [
267+
{
268+
"name": "",
269+
"region": "",
270+
"http_endpoint": "http://0.0.0.0",
271+
"grpc_endpoint": "grpc://0.0.0.0",
272+
"websocket_endpoint": "ws://0.0.0.0"
273+
}
274+
]
275+
}
276+
"#,
277+
r#"
278+
{
279+
"slot": "123",
280+
"validator_index": "123",
281+
"entry": {
282+
"message": {
283+
"fee_recipient": "0x0000000000000000000000000000000000000000",
284+
"gas_limit": "60000000",
285+
"timestamp": "123",
286+
"pubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
287+
},
288+
"signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
289+
},
290+
"preferences": {
291+
"censoring": false
292+
}
293+
}
294+
"#,
295+
];
296+
for raw in registrations {
297+
assert!(serde_json::from_str::<ValidatorSlotData>(raw).is_ok());
298+
}
299+
}
300+
}

crates/rbuilder/src/live_builder/payload_events/relay_epoch_cache.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ mod test {
237237
validator_index: 1,
238238
slot: 2,
239239
regional_endpoints: Vec::new(),
240+
preferences: None,
240241
},
241242
adjustment_fee_payer: None,
242243
}

crates/rbuilder/src/mev_boost/mod.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ pub struct RelayConfig {
102102
/// Flag indicating whether the builder should only submit to rproxy endpoinds if available.
103103
#[serde(default)]
104104
pub bloxroute_rproxy_only: bool,
105-
/// Adds "filtering=true" as query to the call relay/v1/builder/validators to get all validators (including those filtering OFAC)
106-
/// On 2025/06/24 (my birthday!) only supported by ultrasound.
107-
/// None -> false
105+
/// Retrieves registrations for all validators, including filtering ones.
106+
/// For ultrasound relay, the behavior is to add `filtering=true` as a query parameter.
107+
/// For titan relay if the value is not set, the registrations will be filtered by `censoring=false` by default.
108+
/// If the value is set to `true`, `censoring=true` validators would be included.
108109
pub ask_for_filtering_validators: Option<bool>,
109110
/// If we submit a block with a different gas than the one the validator registered with in this relay the relay does not mind.
110111
/// None -> false
@@ -674,15 +675,25 @@ impl RelayClient {
674675
let mut headers = HeaderMap::new();
675676
self.add_auth_headers(&mut headers)
676677
.map_err(|_| RelayError::InvalidHeader)?;
677-
let validators = req
678+
let registrations = req
678679
.headers(headers)
679680
.send()
680681
.await?
681682
.json::<RelayResponse<Vec<ValidatorSlotData>>>()
682683
.await?;
683684

684-
match validators {
685-
RelayResponse::Ok(validators) => Ok(validators),
685+
match registrations {
686+
RelayResponse::Ok(registrations) => {
687+
let registrations = registrations
688+
.into_iter()
689+
.filter(|r| {
690+
r.preferences
691+
.as_ref()
692+
.is_none_or(|p| !p.censoring || self.ask_for_filtering_validators)
693+
})
694+
.collect();
695+
Ok(registrations)
696+
}
686697
RelayResponse::Error(error) => Err(RelayError::RelayError(error)),
687698
}
688699
}
@@ -1314,6 +1325,7 @@ mod tests {
13141325
signature: Default::default(),
13151326
},
13161327
regional_endpoints: Vec::new(),
1328+
preferences: None,
13171329
};
13181330
relay
13191331
.submit_block(&sub_relay, &registration, true, true, false, false)

0 commit comments

Comments
 (0)