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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions chain/network/src/peer/peer_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -978,11 +978,12 @@ impl PeerActor {
async fn receive_routed_message(
clock: &time::Clock,
network_state: &Arc<NetworkState>,
peer_id: PeerId,
msg_author: PeerId,
prev_hop: PeerId,
msg_hash: CryptoHash,
body: RoutedMessageBody,
) -> Result<Option<RoutedMessageBody>, ReasonForBan> {
Ok(network_state.receive_routed_message(clock, peer_id, msg_hash, body).await)
Ok(network_state.receive_routed_message(clock, msg_author, prev_hop, msg_hash, body).await)
}

fn receive_message(
Expand Down Expand Up @@ -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?

msg_hash,
msg.msg.body,
)
Expand Down
25 changes: 19 additions & 6 deletions chain/network/src/peer_manager/network_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,13 +623,21 @@ impl NetworkState {
debug_assert!(msg.allow_sending_to_self());
let this = self.clone();
let clock = clock.clone();
let peer_id = self.config.node_id();
let my_peer_id = self.config.node_id();
let msg = self.sign_message(
&clock,
RawRoutedMessage { target: PeerIdOrHash::PeerId(peer_id.clone()), body: msg },
RawRoutedMessage { target: PeerIdOrHash::PeerId(my_peer_id.clone()), body: msg },
);
actix::spawn(async move {
this.receive_routed_message(&clock, peer_id, msg.hash(), msg.msg.body).await;
let hash = msg.hash();
this.receive_routed_message(
&clock,
msg.msg.author.clone(),
my_peer_id,
hash,
msg.msg.body,
)
.await;
});
return true;
}
Expand Down Expand Up @@ -701,7 +709,8 @@ impl NetworkState {
pub async fn receive_routed_message(
self: &Arc<Self>,
clock: &time::Clock,
peer_id: PeerId,
msg_author: PeerId,
prev_hop: PeerId,
msg_hash: CryptoHash,
body: RoutedMessageBody,
) -> Option<RoutedMessageBody> {
Expand All @@ -718,7 +727,7 @@ impl NetworkState {
None
}
RoutedMessageBody::BlockApproval(approval) => {
self.client.send_async(BlockApproval(approval, peer_id)).await.ok();
self.client.send_async(BlockApproval(approval, prev_hop)).await.ok();
None
}
RoutedMessageBody::ForwardTx(transaction) => {
Expand Down Expand Up @@ -779,7 +788,11 @@ impl NetworkState {
}
RoutedMessageBody::StatePartRequest(request) => {
self.peer_manager_adapter.send(Tier3Request {
peer_info: PeerInfo { id: peer_id, addr: Some(request.addr), account_id: None },
peer_info: PeerInfo {
id: msg_author,
addr: Some(request.addr),
account_id: None,
},
body: Tier3RequestBody::StatePart(StatePartRequestBody {
shard_id: request.shard_id,
sync_hash: request.sync_hash,
Expand Down
Loading