Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dedup relay endpoints in boost and builder configs #244

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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: 6 additions & 1 deletion mev-boost-rs/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use serde::Deserialize;
use std::{future::Future, net::Ipv4Addr, pin::Pin, task::Poll};
use tokio::task::{JoinError, JoinHandle};
use tracing::{info, warn};
use std::collections::HashSet;

#[derive(Debug, Deserialize)]
pub struct Config {
Expand All @@ -37,8 +38,12 @@ pub struct Service {
impl Service {
pub fn from(network: Network, config: Config) -> Self {
let relays = parse_relay_endpoints(&config.relays);
let mut relayset: HashSet<RelayEndpoint> = HashSet::new();
for relay in relays.into_iter(){
relayset.insert(relay);
}

Self { host: config.host, port: config.port, relays, network, config }
Self { host: config.host, port: config.port, relays: Vec::from_iter(relayset), network, config }
}

/// Spawns a new [`RelayMux`] and [`BlindedBlockProviderServer`] task
Expand Down
11 changes: 8 additions & 3 deletions mev-build-rs/src/auctioneer/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use mev_rs::{
relay::parse_relay_endpoints,
signing::sign_builder_message,
types::{block_submission, BidTrace, SignedBidSubmission},
BlindedBlockRelayer, Relay,
BlindedBlockRelayer, Relay, RelayEndpoint,
};
use reth::{
api::{EngineTypes, PayloadBuilderAttributes},
Expand Down Expand Up @@ -155,8 +155,13 @@ impl<
context: Arc<Context>,
genesis_time: u64,
) -> Self {
let relays =
parse_relay_endpoints(&config.relays).into_iter().map(Relay::from).collect::<Vec<_>>();
let relays = parse_relay_endpoints(&config.relays);
let mut relayset: HashSet<RelayEndpoint> = HashSet::new();
g11tech marked this conversation as resolved.
Show resolved Hide resolved
g11tech marked this conversation as resolved.
Show resolved Hide resolved
for relay in relays.into_iter(){
relayset.insert(relay);
}

let relays = relayset.into_iter().map(Relay::from).collect::<Vec<_>>();

config.public_key = config.secret_key.public_key();

Expand Down
15 changes: 15 additions & 0 deletions mev-rs/src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ impl TryFrom<Url> for RelayEndpoint {
}
}

impl hash::Hash for RelayEndpoint {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
g11tech marked this conversation as resolved.
Show resolved Hide resolved
self.public_key.hash(state);
}
}

impl cmp::PartialEq for RelayEndpoint {
fn eq(&self, other: &Self) -> bool {
self.public_key == other.public_key
}
}

impl cmp::Eq for RelayEndpoint {}
g11tech marked this conversation as resolved.
Show resolved Hide resolved


impl fmt::Debug for RelayEndpoint {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
f.write_str(self.url.as_str())
Expand Down
Loading