-
Notifications
You must be signed in to change notification settings - Fork 624
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
fix(state sync): handle expected_peer_id correctly #12267
fix(state sync): handle expected_peer_id correctly #12267
Conversation
if request | ||
.peer_id | ||
.as_ref() | ||
.is_some_and(|expecting_peer_id| expecting_peer_id == &peer_id) |
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.
The heart of this change is essentially replacing this is_some_and
with is_none_or
. However, is_none_or is still unstable in rust version 1.81.0 so I had to reorganize things a bit.
} | ||
|
||
let Some(request) = self.pending_requests.get(&key) else { | ||
tracing::debug!(target: "sync", "Received {:?} expecting {:?}", key, self.pending_requests.keys()); |
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.
Think it should be OK to debug log all the pending keys since the limit is fairly low (10).
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12267 +/- ##
==========================================
+ Coverage 71.65% 71.66% +0.01%
==========================================
Files 836 836
Lines 167176 167177 +1
Branches 167176 167177 +1
==========================================
+ Hits 119788 119813 +25
+ Misses 42163 42135 -28
- Partials 5225 5229 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Another mistake of mine that is almost the same as the other Option bug :)
If the expected sender is not specified, we should accept a response from any peer. We don't specify an expected sender for state parts, so this bug meant that state sync was ignoring all parts received from peers.
#12247 adds tests which cover this code and detect this problem.