Skip to content
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

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

saketh-are
Copy link
Collaborator

@saketh-are saketh-are commented Oct 19, 2024

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.

if request
.peer_id
.as_ref()
.is_some_and(|expecting_peer_id| expecting_peer_id == &peer_id)
Copy link
Collaborator Author

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());
Copy link
Collaborator Author

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).

Copy link

codecov bot commented Oct 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.

Project coverage is 71.66%. Comparing base (7ce9e95) to head (31b0adc).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
chain/client/src/sync/state/network.rs 0.00% 11 Missing ⚠️
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     
Flag Coverage Δ
backward-compatibility 0.16% <0.00%> (ø)
db-migration 0.16% <0.00%> (ø)
genesis-check 1.25% <0.00%> (?)
integration-tests 38.88% <0.00%> (-0.01%) ⬇️
linux 71.31% <0.00%> (+0.01%) ⬆️
linux-nightly 71.23% <0.00%> (-0.02%) ⬇️
macos 54.34% <0.00%> (+<0.01%) ⬆️
pytests 1.57% <0.00%> (+0.19%) ⬆️
sanity-checks 1.37% <0.00%> (-0.01%) ⬇️
unittests 65.43% <0.00%> (+<0.01%) ⬆️
upgradability 0.21% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@saketh-are saketh-are marked this pull request as ready for review October 19, 2024 19:29
@saketh-are saketh-are requested a review from a team as a code owner October 19, 2024 19:29
Copy link
Contributor

@robin-near robin-near left a 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 :)

@saketh-are saketh-are added this pull request to the merge queue Oct 21, 2024
Merged via the queue into near:master with commit b1f6185 Oct 21, 2024
28 of 30 checks passed
@saketh-are saketh-are deleted the fix-state-sync-expected-peer-id branch October 21, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants