@@ -5,11 +5,11 @@ use std::{
55} ;
66
77use alloy:: rpc:: types:: beacon:: BlsPublicKey ;
8- use eyre:: { bail, ensure, eyre , Context } ;
8+ use eyre:: { bail, ensure, Context } ;
99use serde:: { Deserialize , Serialize } ;
1010
1111use super :: { load_optional_env_var, PbsConfig , RelayConfig , MUX_PATH_ENV } ;
12- use crate :: pbs:: { RelayClient , RelayEntry } ;
12+ use crate :: pbs:: RelayClient ;
1313
1414#[ derive( Debug , Deserialize , Serialize ) ]
1515pub struct PbsMuxes {
@@ -29,7 +29,6 @@ impl PbsMuxes {
2929 pub fn validate_and_fill (
3030 self ,
3131 default_pbs : & PbsConfig ,
32- default_relays : & [ RelayConfig ] ,
3332 ) -> eyre:: Result < HashMap < BlsPublicKey , RuntimeMuxConfig > > {
3433 let mut muxes = self . muxes ;
3534
@@ -61,33 +60,8 @@ impl PbsMuxes {
6160 ) ;
6261
6362 let mut relay_clients = Vec :: with_capacity ( mux. relays . len ( ) ) ;
64- for partial_relay in mux. relays . into_iter ( ) {
65- // create a new config overriding only the missing fields
66- let partial_id = partial_relay. id ( ) ?;
67- // assume that there is always a relay defined in the default config. If this
68- // becomes too much of a burden, we can change this to allow defining relays
69- // that are exclusively used by a mux
70- let default_relay = default_relays
71- . iter ( )
72- . find ( |r| r. id ( ) == partial_id)
73- . ok_or_else ( || eyre ! ( "default relay config not found for: {}" , partial_id) ) ?;
74-
75- let full_config = RelayConfig {
76- id : Some ( partial_id. to_string ( ) ) ,
77- entry : partial_relay. entry . unwrap_or ( default_relay. entry . clone ( ) ) ,
78- headers : partial_relay. headers . or ( default_relay. headers . clone ( ) ) ,
79- enable_timing_games : partial_relay
80- . enable_timing_games
81- . unwrap_or ( default_relay. enable_timing_games ) ,
82- target_first_request_ms : partial_relay
83- . target_first_request_ms
84- . or ( default_relay. target_first_request_ms ) ,
85- frequency_get_header_ms : partial_relay
86- . frequency_get_header_ms
87- . or ( default_relay. frequency_get_header_ms ) ,
88- } ;
89-
90- relay_clients. push ( RelayClient :: new ( full_config) ?) ;
63+ for config in mux. relays . into_iter ( ) {
64+ relay_clients. push ( RelayClient :: new ( config) ?) ;
9165 }
9266
9367 let config = PbsConfig {
@@ -117,7 +91,7 @@ pub struct MuxConfig {
11791 /// Identifier for this mux config
11892 pub id : String ,
11993 /// Relays to use for this mux config
120- pub relays : Vec < PartialRelayConfig > ,
94+ pub relays : Vec < RelayConfig > ,
12195 /// Which validator pubkeys to match against this mux config
12296 #[ serde( default ) ]
12397 pub validator_pubkeys : Vec < BlsPublicKey > ,
@@ -142,33 +116,6 @@ impl MuxConfig {
142116 }
143117}
144118
145- #[ derive( Debug , Clone , Deserialize , Serialize ) ]
146- /// A relay config with all optional fields. See [`RelayConfig`] for the
147- /// description of the fields.
148- pub struct PartialRelayConfig {
149- pub id : Option < String > ,
150- #[ serde( rename = "url" ) ]
151- pub entry : Option < RelayEntry > ,
152- pub headers : Option < HashMap < String , String > > ,
153- pub enable_timing_games : Option < bool > ,
154- pub target_first_request_ms : Option < u64 > ,
155- pub frequency_get_header_ms : Option < u64 > ,
156- }
157-
158- impl PartialRelayConfig {
159- pub fn id ( & self ) -> eyre:: Result < & str > {
160- match & self . id {
161- Some ( id) => Ok ( id. as_str ( ) ) ,
162- None => {
163- let entry = self . entry . as_ref ( ) . ok_or_else ( || {
164- eyre ! ( "relays in [[mux]] need to specifify either an `id` or a `url`" )
165- } ) ?;
166- Ok ( entry. id . as_str ( ) )
167- }
168- }
169- }
170- }
171-
172119#[ derive( Debug , Clone , Deserialize , Serialize ) ]
173120#[ serde( untagged) ]
174121pub enum MuxKeysLoader {
0 commit comments