From a371ce86bd5e2eb6bb5a17bb2a6020e0e366978b Mon Sep 17 00:00:00 2001 From: Nina Date: Wed, 22 Apr 2026 11:02:20 +0100 Subject: [PATCH 1/2] fix --- crates/common/src/config/mux.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/common/src/config/mux.rs b/crates/common/src/config/mux.rs index afd3075c..c9b9fda9 100644 --- a/crates/common/src/config/mux.rs +++ b/crates/common/src/config/mux.rs @@ -476,12 +476,17 @@ async fn fetch_ssv_pubkeys_from_public_api( page += 1; if fetched < MAX_PER_PAGE { - ensure!( - pubkeys.len() == response.pagination.total, - "expected {} keys, got {}", - response.pagination.total, - pubkeys.len() - ); + // Past-end page (fetched == 0) returns pagination.total == 0 from the SSV + // public API; only assert the total when the page actually carried + // data. + if fetched > 0 { + ensure!( + pubkeys.len() == response.pagination.total, + "expected {} keys, got {}", + response.pagination.total, + pubkeys.len() + ); + } break; } } From 19894f6e3a1ac58f80d5d3c3ee3fb3f676daf287 Mon Sep 17 00:00:00 2001 From: Nina Date: Wed, 22 Apr 2026 15:10:56 +0100 Subject: [PATCH 2/2] check expected number of keys --- crates/common/src/config/mux.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/crates/common/src/config/mux.rs b/crates/common/src/config/mux.rs index c9b9fda9..8a9dab73 100644 --- a/crates/common/src/config/mux.rs +++ b/crates/common/src/config/mux.rs @@ -461,6 +461,7 @@ async fn fetch_ssv_pubkeys_from_public_api( let mut pubkeys: Vec = vec![]; let mut page = 1; + let mut expected_total: Option = None; loop { let route = format!( @@ -470,26 +471,22 @@ async fn fetch_ssv_pubkeys_from_public_api( let response = request_ssv_pubkeys_from_public_api(url, http_timeout).await?; let fetched = response.validators.len(); + if expected_total.is_none() && fetched > 0 { + expected_total = Some(response.pagination.total); + } pubkeys.extend( response.validators.into_iter().map(|v| v.pubkey).collect::>(), ); page += 1; if fetched < MAX_PER_PAGE { - // Past-end page (fetched == 0) returns pagination.total == 0 from the SSV - // public API; only assert the total when the page actually carried - // data. - if fetched > 0 { - ensure!( - pubkeys.len() == response.pagination.total, - "expected {} keys, got {}", - response.pagination.total, - pubkeys.len() - ); - } break; } } + if let Some(expected) = expected_total { + ensure!(pubkeys.len() == expected, "expected {expected} keys, got {}", pubkeys.len()); + } + Ok(pubkeys) }