-
Notifications
You must be signed in to change notification settings - Fork 168
chore(l1): replace unjustified panics with proper error propagation #6147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
951c521
72cc379
5511f8c
678f973
f340d9d
fb212fb
17891ee
cbdbce5
47e601a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ use tokio::{ | |
| sync::mpsc::{Sender, error::TrySendError}, | ||
| task::yield_now, | ||
| }; | ||
| use tracing::{debug, trace}; | ||
| use tracing::{debug, trace, warn}; | ||
|
|
||
| /// This struct stores the metadata we need when we request a node | ||
| #[derive(Debug, Clone)] | ||
|
|
@@ -449,7 +449,19 @@ async fn zip_requeue_node_responses_score_peer( | |
| } | ||
|
|
||
| if request.requests.len() < nodes_size { | ||
| panic!("The node responded with more data than us!"); | ||
| warn!( | ||
| peer = ?request.peer_id, | ||
| requested = request.requests.len(), | ||
| received = nodes_size, | ||
| "Peer responded with more trie nodes than requested" | ||
| ); | ||
| *failed_downloads += 1; | ||
| peer_handler | ||
| .peer_table | ||
| .record_failure(&request.peer_id) | ||
| .await?; | ||
| download_queue.extend(request.requests); | ||
| return Ok(None); | ||
|
Comment on lines
451
to
+464
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drops extra peer data In If you want to ignore the response, consider explicitly documenting that extra nodes are discarded by design (and ensure the peer is disconnected/penalized enough to prevent repeated churn), or alternatively keep the first Prompt To Fix With AIThis is a comment left during a code review.
Path: crates/networking/p2p/sync/storage_healing.rs
Line: 443:456
Comment:
**Drops extra peer data**
In `zip_requeue_node_responses_score_peer`, when `nodes_size > request.requests.len()` you treat it as a peer failure and requeue the original requests, but you silently drop the *extra* trie nodes that were already received (`trie_nodes.nodes`), even though they may contain useful nodes for other pending requests. If this situation can occur due to a peer bug/misalbehavior (or message framing issues), this code will now reliably discard those bytes and redo requests, potentially causing repeated download loops.
If you want to ignore the response, consider explicitly documenting that extra nodes are discarded by design (and ensure the peer is disconnected/penalized enough to prevent repeated churn), or alternatively keep the first `request.requests.len()` nodes and process those while penalizing the peer for the overflow.
How can I resolve this? If you propose a fix, please make it concise.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The behavior goes against spec, a node exhibiting this behavior is malfunctioning. The peer is in fact penalized. |
||
| } | ||
|
|
||
| if let Ok(nodes) = request | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Adding a blanket
From<std::io::Error>toNetworkErrormeans anyio::Errorfrom any source in a function returningResult<_, NetworkError>will silently becomeUdpSocketError. Currentlystart_networkonly has the one UDP bind site, but this could be misleading if the function grows. A scoped.map_err()at the call site would be more precise:and drop the
#[from]on the variant.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in cbdbce5