@@ -16,7 +16,7 @@ use tracing::{debug, info};
16
16
use url:: Url ;
17
17
18
18
use super :: { load_optional_env_var, PbsConfig , RelayConfig , MUX_PATH_ENV } ;
19
- use crate :: { pbs:: RelayClient , types:: Chain } ;
19
+ use crate :: { config :: remove_duplicate_keys , pbs:: RelayClient , types:: Chain } ;
20
20
21
21
#[ derive( Debug , Deserialize , Serialize ) ]
22
22
pub struct PbsMuxes {
@@ -164,7 +164,7 @@ impl MuxKeysLoader {
164
164
chain : Chain ,
165
165
rpc_url : Option < Url > ,
166
166
) -> eyre:: Result < Vec < BlsPublicKey > > {
167
- match self {
167
+ let keys = match self {
168
168
Self :: File ( config_path) => {
169
169
// First try loading from env
170
170
let path: PathBuf = load_optional_env_var ( & get_mux_env ( mux_id) )
@@ -192,7 +192,11 @@ impl MuxKeysLoader {
192
192
}
193
193
NORegistry :: SSV => fetch_ssv_pubkeys ( chain, U256 :: from ( * node_operator_id) ) . await ,
194
194
} ,
195
- }
195
+ } ?;
196
+
197
+ // Remove duplicates
198
+ let deduped_keys = remove_duplicate_keys ( keys) ;
199
+ Ok ( deduped_keys)
196
200
}
197
201
}
198
202
@@ -281,8 +285,6 @@ async fn fetch_lido_registry_keys(
281
285
}
282
286
283
287
ensure ! ( keys. len( ) == total_keys as usize , "expected {total_keys} keys, got {}" , keys. len( ) ) ;
284
- let unique = keys. iter ( ) . collect :: < HashSet < _ > > ( ) ;
285
- ensure ! ( unique. len( ) == keys. len( ) , "found duplicate keys in registry" ) ;
286
288
287
289
Ok ( keys)
288
290
}
@@ -330,9 +332,6 @@ async fn fetch_ssv_pubkeys(
330
332
}
331
333
}
332
334
333
- let unique = pubkeys. iter ( ) . collect :: < HashSet < _ > > ( ) ;
334
- ensure ! ( unique. len( ) == pubkeys. len( ) , "found duplicate keys in registry" ) ;
335
-
336
335
Ok ( pubkeys)
337
336
}
338
337
0 commit comments