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
52 changes: 51 additions & 1 deletion crates/rbuilder-primitives/src/mev_boost/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub struct ValidatorSlotData {
pub regional_endpoints: Vec<BloxrouteRegionalEndpoint>,
/// (Titan) Validator preferences.
#[serde(default)]
pub preferences: Option<TitanValidatorPreferences>,
pub preferences: Option<ValidatorPreferences>,
}

/// Bloxroute validator RProxy details.
Expand All @@ -201,6 +201,36 @@ pub struct BloxrouteRegionalEndpoint {
pub websocket_endpoint: String,
}

/// Relay validator preferences.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Hash)]
#[serde(untagged)]
pub enum ValidatorPreferences {
Ultrasound(UltrasoundValidatorPreferences),
Titan(TitanValidatorPreferences),
}

impl ValidatorPreferences {
/// Returns [`TitanValidatorPreferences`] if the variant matches.
pub fn as_titan(&self) -> Option<&TitanValidatorPreferences> {
if let Self::Titan(preferences) = self {
Some(preferences)
} else {
None
}
}
}

/// Ultrasound validator preferences.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Hash)]
pub struct UltrasoundValidatorPreferences {
/// Indicator whether the validator is filtering. Values: "none", "ofac".
filtering: String,
/// Flag indicating whether the validator is integrated with MEV Protect.
is_mev_protect: bool,
/// Flag indicating whether the validator is integrated with Primev.
is_primev: bool,
}

/// Titan validator preferences.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)]
pub struct TitanValidatorPreferences {
Expand Down Expand Up @@ -292,6 +322,26 @@ mod tests {
}
}
"#,
r#"
{
"slot": "123",
"validator_index": "123",
"entry": {
"message": {
"fee_recipient": "0x0000000000000000000000000000000000000000",
"gas_limit": "60000000",
"timestamp": "123",
"pubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
"signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
"preferences": {
"filtering": "none",
"is_mev_protect": false,
"is_primev": false
}
}
"#,
];
for raw in registrations {
assert!(serde_json::from_str::<ValidatorSlotData>(raw).is_ok());
Expand Down
5 changes: 3 additions & 2 deletions crates/rbuilder/src/mev_boost/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use flate2::{write::GzEncoder, Compression};
use governor::{DefaultDirectRateLimiter, Quota, RateLimiter};
use rbuilder_primitives::mev_boost::{
KnownRelay, MevBoostRelayID, RelayMode, SubmitBlockRequestNoBlobs,
SubmitBlockRequestWithMetadata, SubmitHeaderRequestWithMetadata, ValidatorRegistration,
ValidatorSlotData, MEV_BOOST_SLOT_INFO_REQUEST_TIMEOUT,
SubmitBlockRequestWithMetadata, SubmitHeaderRequestWithMetadata, ValidatorPreferences,
ValidatorRegistration, ValidatorSlotData, MEV_BOOST_SLOT_INFO_REQUEST_TIMEOUT,
};
use reqwest::{
header::{HeaderMap, HeaderValue, AUTHORIZATION, CONTENT_ENCODING, CONTENT_TYPE},
Expand Down Expand Up @@ -691,6 +691,7 @@ impl RelayClient {
.filter(|r| {
r.preferences
.as_ref()
.and_then(ValidatorPreferences::as_titan)
.is_none_or(|p| !p.censoring || self.ask_for_filtering_validators)
})
.collect();
Expand Down
Loading