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

Remove self-profiles from incoming gossip #3946

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Discard incoming gossips with either the same address or id as the current node
- Add /v1/account-votes-all endpoint to return the list of proposals a user has voted for
- Remove /v1/account-votes-count endpoint
- Validate server id is the expected one during gRPC handshake
Expand Down
14 changes: 14 additions & 0 deletions jormungandr/src/topology/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@ impl P2pTopology {
let peer = Profile::from_gossip(gossip);
let peer_id = NodeId(peer.id());
tracing::trace!(addr = %peer.address(), %peer_id, "received peer from incoming gossip");

// We do not support hosting multiple nodes at the same address at the moment.
// One problem with it is that routing new connections is a non-trivial task,
// plus we can rely on this to easily remove self_profile from incoming gossips.
// Such occurrences are usually the result of a restart of a node.
if peer.address() == self.topology.self_profile().address()
|| peer.id() == self.topology.self_profile().id()
{
tracing::warn!(
"gossip peer is using the address or id of the current node, ignoring..."
);
continue;
}

if self.topology.add_peer(peer) {
self.quarantine.record_new_gossip(&peer_id);
self.stats_counter
Expand Down