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(external_address): limit some of the incoming error from... #2640

Open
wants to merge 1 commit into
base: rc-2024.12.1-hotfix5
Choose a base branch
from
Open
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
16 changes: 10 additions & 6 deletions ant-networking/src/event/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,19 @@ impl SwarmDriver {
// giving time for ConnectionEstablished to be hopefully processed.
// And since we don't do anything critical with this event, the order and time of processing is
// not critical.
if self.should_we_log_incoming_connection_error(connection_id, &send_back_addr) {
if self.is_incoming_connection_error_valid(connection_id, &send_back_addr) {
error!("IncomingConnectionError from local_addr:?{local_addr:?}, send_back_addr {send_back_addr:?} on {connection_id:?} with error {error:?}");

// This is best approximation that we can do to prevent harmless errors from affecting the external
// address health.
if let Some(external_addr_manager) = self.external_address_manager.as_mut() {
external_addr_manager
.on_incoming_connection_error(local_addr.clone(), &mut self.swarm);
}
} else {
debug!("IncomingConnectionError from local_addr:?{local_addr:?}, send_back_addr {send_back_addr:?} on {connection_id:?} with error {error:?}");
}
if let Some(external_addr_manager) = self.external_address_manager.as_mut() {
external_addr_manager
.on_incoming_connection_error(local_addr.clone(), &mut self.swarm);
}

let _ = self.live_connected_peers.remove(&connection_id);
self.record_connection_metrics();
}
Expand Down Expand Up @@ -787,7 +791,7 @@ impl SwarmDriver {
}

// Do not log IncomingConnectionError if the ConnectionId is adjacent to an already established connection.
fn should_we_log_incoming_connection_error(&self, id: ConnectionId, addr: &Multiaddr) -> bool {
fn is_incoming_connection_error_valid(&self, id: ConnectionId, addr: &Multiaddr) -> bool {
let Ok(id) = format!("{id}").parse::<usize>() else {
return true;
};
Expand Down
Loading