Skip to content

Commit 3a68581

Browse files
committed
test: trace beacon e2e convergence stalls
1 parent d5a1bdd commit 3a68581

5 files changed

Lines changed: 72 additions & 18 deletions

File tree

bin/ream/src/main.rs

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,30 +1490,53 @@ mod tests {
14901490
peer_count_value(peer_count, "connected")
14911491
}
14921492

1493-
fn peer_count_total(peer_count: &serde_json::Value) -> u64 {
1494-
peer_count_value(peer_count, "connected")
1495-
+ peer_count_value(peer_count, "connecting")
1496-
+ peer_count_value(peer_count, "disconnected")
1497-
+ peer_count_value(peer_count, "disconnecting")
1493+
fn peer_count_debug_row(
1494+
http_port: u16,
1495+
peer_count: &serde_json::Value,
1496+
) -> (u16, u64, u64, u64, u64) {
1497+
(
1498+
http_port,
1499+
peer_count_connected(peer_count),
1500+
peer_count_value(peer_count, "connecting"),
1501+
peer_count_value(peer_count, "disconnected"),
1502+
peer_count_value(peer_count, "disconnecting"),
1503+
)
14981504
}
14991505

15001506
async fn wait_for_connected_beacon_peer(
15011507
http_ports: &[u16],
15021508
) -> Result<Vec<serde_json::Value>, Vec<serde_json::Value>> {
15031509
let start = Instant::now();
15041510
let timeout_duration = Duration::from_secs(60);
1511+
let required_ready_polls = 3;
1512+
let mut ready_polls = 0;
15051513
loop {
15061514
let mut peer_counts = Vec::new();
15071515
for http_port in http_ports {
15081516
peer_counts.push(wait_for_beacon_json(*http_port, "/eth/v1/node/peer_count").await);
15091517
}
15101518

1511-
let every_node_knows_a_peer =
1512-
peer_counts.iter().all(|count| peer_count_total(count) > 0);
1513-
let any_node_connected = peer_counts
1519+
let every_node_connected = peer_counts
1520+
.iter()
1521+
.all(|count| peer_count_connected(count) > 0);
1522+
let peer_count_summary = http_ports
15141523
.iter()
1515-
.any(|count| peer_count_connected(count) > 0);
1516-
if every_node_knows_a_peer && any_node_connected {
1524+
.copied()
1525+
.zip(peer_counts.iter())
1526+
.map(|(http_port, count)| peer_count_debug_row(http_port, count))
1527+
.collect::<Vec<_>>();
1528+
info!(
1529+
ready_polls,
1530+
required_ready_polls,
1531+
?peer_count_summary,
1532+
"beacon e2e peer readiness poll"
1533+
);
1534+
if every_node_connected {
1535+
ready_polls += 1;
1536+
} else {
1537+
ready_polls = 0;
1538+
}
1539+
if ready_polls >= required_ready_polls {
15171540
return Ok(peer_counts);
15181541
}
15191542

@@ -2318,7 +2341,7 @@ mod tests {
23182341
assert!(
23192342
peer_counts
23202343
.iter()
2321-
.any(|count| peer_count_connected(count) > 0),
2344+
.all(|count| peer_count_connected(count) > 0),
23222345
"beacon nodes did not report a connected peer: {peer_counts:?}"
23232346
);
23242347
}
@@ -2565,7 +2588,7 @@ mod tests {
25652588
assert!(
25662589
peer_counts
25672590
.iter()
2568-
.any(|count| peer_count_connected(count) > 0),
2591+
.all(|count| peer_count_connected(count) > 0),
25692592
"beacon nodes did not report a connected peer: {peer_counts:?}"
25702593
);
25712594
info!(

crates/networking/manager/src/gossipsub/validate/beacon_block.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,19 @@ pub async fn validate_beacon_block(
160160
}
161161
}
162162
None => {
163+
let local_highest_slot = store
164+
.db
165+
.slot_index_provider()
166+
.get_highest_slot()?
167+
.unwrap_or_default();
163168
// [IGNORE] The block's parent (defined by block.parent_root) has been seen.
164-
return Ok(ValidationResult::Ignore(
165-
"Parent block not found".to_string(),
166-
));
169+
return Ok(ValidationResult::Ignore(format!(
170+
"Parent block not found: slot={}, root={}, parent_root={}, local_highest_slot={}",
171+
block.message.slot,
172+
block.message.block_root(),
173+
block.message.parent_root,
174+
local_highest_slot
175+
)));
167176
}
168177
}
169178

crates/networking/syncer/src/block_range/block_cache.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ impl BlockCache {
145145
MAX_BLOCKS_PER_REQUEST
146146
}
147147

148+
pub fn initial_slot(&self) -> u64 {
149+
self.initial_slot
150+
}
151+
152+
pub fn next_start_slot(&self) -> u64 {
153+
self.next_start_slot
154+
}
155+
148156
pub fn push_retry_range(&mut self, range: Range) {
149157
self.block_ranges_to_retry.push(range);
150158
}

crates/networking/syncer/src/block_range/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,14 @@ impl BlockRangeSyncer {
120120

121121
let data_to_fetch = block_cache.data_to_fetch(finalized_slot);
122122
info!(
123-
"Forward sync status: Downloaded Blocks {}, Downloaded Blobs {}/{}, Stage {data_to_fetch}",
123+
"Forward sync status: Downloaded Blocks {}, Downloaded Blobs {}/{}, Finalized Slot {}, Initial Slot {}, Next Start Slot {}, Stage {data_to_fetch}, {}",
124124
block_cache.block_count(),
125125
block_cache.downloaded_blob_count(),
126126
block_cache.blob_count(),
127+
finalized_slot,
128+
block_cache.initial_slot(),
129+
block_cache.next_start_slot(),
130+
self.peer_manager.peer_counts(),
127131
);
128132

129133
match data_to_fetch {

crates/networking/syncer/src/block_range/peer_manager.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,20 @@ impl PeerManager {
9595
.filter(|peer_info| matches!(peer_info.peer_status, PeerStatus::Idle))
9696
.count();
9797
let downloading_peers = total_peers - idle_peers;
98+
let mut finalized_epochs = HashMap::new();
99+
for peer in self.peers.values() {
100+
let finalized_epoch = peer
101+
.peer
102+
.status
103+
.as_ref()
104+
.map(|status| status.finalized_epoch);
105+
*finalized_epochs.entry(finalized_epoch).or_insert(0) += 1;
106+
}
98107

99108
format!(
100-
"Total Peers: {total_peers}, Idle: {idle_peers}, Downloading: {downloading_peers}, Banned: {}",
101-
self.banned_peers.len()
109+
"Total Peers: {total_peers}, Idle: {idle_peers}, Downloading: {downloading_peers}, Banned: {}, Finalized Epochs: {:?}",
110+
self.banned_peers.len(),
111+
finalized_epochs
102112
)
103113
}
104114

0 commit comments

Comments
 (0)