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

Mismatched handshake #12690

Merged
merged 1 commit into from
Jan 11, 2025
Merged

Mismatched handshake #12690

merged 1 commit into from
Jan 11, 2025

Conversation

mkamonMdt
Copy link
Contributor

The detailed description of the problem is available at #12364

@mkamonMdt mkamonMdt force-pushed the mismatched_handshake branch from 18692df to 049021a Compare January 9, 2025 16:02
@mkamonMdt mkamonMdt marked this pull request as ready for review January 9, 2025 16:03
@mkamonMdt mkamonMdt requested a review from a team as a code owner January 9, 2025 16:03
@mkamonMdt mkamonMdt requested a review from akhi3030 January 9, 2025 16:03
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 76.19048% with 5 lines in your changes missing coverage. Please review.

Project coverage is 70.65%. Comparing base (445ee6f) to head (06a2e78).
Report is 23 commits behind head on master.

Files with missing lines Patch % Lines
...hain/network/src/peer_manager/network_state/mod.rs 73.68% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12690      +/-   ##
==========================================
+ Coverage   70.53%   70.65%   +0.12%     
==========================================
  Files         847      848       +1     
  Lines      172839   173802     +963     
  Branches   172839   173802     +963     
==========================================
+ Hits       121904   122806     +902     
- Misses      45833    45871      +38     
- Partials     5102     5125      +23     
Flag Coverage Δ
backward-compatibility 0.16% <0.00%> (-0.01%) ⬇️
db-migration 0.16% <0.00%> (-0.01%) ⬇️
genesis-check 1.36% <0.00%> (-0.01%) ⬇️
linux 69.21% <76.19%> (+<0.01%) ⬆️
linux-nightly 70.26% <76.19%> (+0.14%) ⬆️
pytests 1.66% <0.00%> (-0.01%) ⬇️
sanity-checks 1.47% <0.00%> (-0.01%) ⬇️
unittests 70.48% <76.19%> (+0.12%) ⬆️
upgradability 0.20% <0.00%> (-0.01%) ⬇️

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.

@akhi3030
Copy link
Collaborator

akhi3030 commented Jan 9, 2025

@saketh-are maybe you can help review.

@akhi3030 akhi3030 requested a review from saketh-are January 9, 2025 18:10
@saketh-are
Copy link
Collaborator

@mkamonMdt thank you for looking into this. I think you are correct that peer_id as currently defined should not be used here:

peer_info: PeerInfo { id: peer_id, addr: Some(request.addr), account_id: None },

However, there are other consumers of peer_id in the same function which make use of it correctly.

I think what should be done here is to add a new argument msg_author to the receive_routed_message function. msg.msg.author can be passed there.

At the same time, we can rename the peer_id argument to something like prev_hop to clarify its definition and prevent future mistakes like this one.

During routing of StateRequestPart the PeerInfo used was taken from
connection (prev_hop) instead of actual message author (msg_author).
That results in malformed PeerInfo that is coposed of prev_hop-party
ID and the original msg_author's address.
@mkamonMdt mkamonMdt force-pushed the mismatched_handshake branch from 049021a to 06a2e78 Compare January 10, 2025 19:50
@@ -1029,7 +1030,8 @@ impl PeerActor {
Self::receive_routed_message(
&clock,
&network_state,
peer_id,
msg.msg.author,
peer_id.clone(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is a bit confusing, why do we need a .clone() now if we did not before?

@saketh-are saketh-are added this pull request to the merge queue Jan 11, 2025
Merged via the queue into near:master with commit cbef830 Jan 11, 2025
26 of 28 checks passed
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.

3 participants