Skip to content

manager: Incorrect address score updates for PeerIdMismatch negotiation errors #492

@lexnv

Description

@lexnv

A PeerIdMismatch mismatch error implies:

  • (I) The local node can establish a socket connection to the given IP address
  • (II) Negotiation of protocols fails because the provided encryption key corresponds to a different PeerID

The first (I) step increments the score of the address by 100 points:

/// Update the address on a connection established.
fn update_address_on_connection_established(&mut self, peer: PeerId, endpoint: &Endpoint) {
// The connection can be inbound or outbound.
// For the inbound connection type, in most cases, the remote peer dialed
// with an ephemeral port which it might not be listening on.
// Therefore, we only insert the address into the store if we're the dialer.
if endpoint.is_listener() {
return;
}
let mut peers = self.peers.write();
let record = AddressRecord::new(
&peer,
endpoint.address().clone(),
scores::CONNECTION_ESTABLISHED,
);
let context = peers.entry(peer).or_default();
context.addresses.insert(record);
}

The second step (II) decrements the score of the address by 100 points:

// Update the address on a dial failure.
fn update_address_on_dial_failure(&mut self, address: Multiaddr, error: &DialError) {
let mut peers = self.peers.write();
let score = AddressStore::error_score(error);

This effectively leaves the score of the invalid IP address unmodified.

The downstream effect of this is that the IP address will be retried in the future, effectively wasting resources.

Discovered during:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions