Skip to content

Commit 2aa1d0e

Browse files
dicethedevMegaRedHandpablodeymo
authored
fix(p2p): warn when peer status is ahead (lambdaclass#432)
## 🗒️ Description / Motivation - Logs a warning when a peer’s status response reports a head slot higher than the local head. - Makes it easier for operators to identify when a node is behind its peers. - Completes the status-response observability requested in lambdaclass#211. ## What Changed - Updated `crates/net/p2p/src/req_resp/handlers.rs`. - Added a structured warning containing: - Peer ID - Peer head slot - Local head slot - Slot gap - The warning is emitted before range synchronization begins. ## Correctness / Behavior Guarantees - Status responses at or behind the local head do not produce a warning. - Existing `BlocksByRange` synchronization behavior is unchanged. - The change only adds observability and does not alter peer selection, request ranges, or block processing. ## Tests Added / Run - No new tests were added because this is a logging-only change. - Ran `cargo fmt --all -- --check` — clean. - P2P lint and unit tests were started, but interrupted while compiling RocksDB. - `git diff --check` — clean. ## Related Issues / PRs - Closes lambdaclass#211 - Related to lambdaclass#193 - Builds on lambdaclass#351 ## ✅ Verification Checklist - [x] Ran `make fmt` — clean - [x] Ran `make lint` (clippy with `-D warnings`) — clean - [x] Ran `cargo test --workspace --release` — all passing --------- Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com> Co-authored-by: Pablo Deymonnaz <pdeymon@fi.uba.ar>
1 parent 60a2567 commit 2aa1d0e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

crates/net/p2p/src/req_resp/handlers.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ async fn handle_status_response(server: &mut P2PServer, status: Status, peer: Pe
171171
return;
172172
}
173173
let gap = status.head.slot - our_head_slot;
174+
warn!(
175+
%peer,
176+
peer_head_slot = status.head.slot,
177+
local_head_slot = our_head_slot,
178+
slot_gap = gap,
179+
"Peer status head is ahead of local head"
180+
);
181+
174182
let start_slot = our_head_slot.saturating_add(1);
175183
let end_exclusive = start_slot.saturating_add(gap.min(MAX_SYNC_RANGE));
176184

0 commit comments

Comments
 (0)