From 0bd0cc62165d2a15563c9f472cde36679fec9e01 Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Thu, 9 Jan 2025 13:59:40 -0600 Subject: [PATCH] stops pushing LegacyContactInfo updates over gossip We no longer use LegacyContactInfo and don't need to push updates over gossip. --- gossip/src/cluster_info.rs | 24 +++++++----------------- gossip/src/contact_info.rs | 1 + gossip/src/legacy_contact_info.rs | 13 ++++++------- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/gossip/src/cluster_info.rs b/gossip/src/cluster_info.rs index 8a21e9fab7e749..7c6b8501bbee52 100644 --- a/gossip/src/cluster_info.rs +++ b/gossip/src/cluster_info.rs @@ -34,7 +34,6 @@ use { duplicate_shred::DuplicateShred, epoch_slots::EpochSlots, gossip_error::GossipError, - legacy_contact_info::LegacyContactInfo, ping_pong::Pong, protocol::{ split_gossip_messages, Ping, PingCache, Protocol, PruneData, @@ -284,18 +283,12 @@ impl ClusterInfo { // TODO kill insert_info, only used by tests pub fn insert_info(&self, node: ContactInfo) { - let entries: Vec<_> = [ - LegacyContactInfo::try_from(&node) - .map(CrdsData::LegacyContactInfo) - .expect("Operator must spin up node with valid contact-info"), - CrdsData::ContactInfo(node), - ] - .into_iter() - .map(|entry| CrdsValue::new(entry, &self.keypair())) - .collect(); - let mut gossip_crds = self.gossip.crds.write().unwrap(); - for entry in entries { - let _ = gossip_crds.insert(entry, timestamp(), GossipRoute::LocalMessage); + let entry = CrdsValue::new(CrdsData::ContactInfo(node), &self.keypair()); + if let Err(err) = { + let mut gossip_crds = self.gossip.crds.write().unwrap(); + gossip_crds.insert(entry, timestamp(), GossipRoute::LocalMessage) + } { + error!("ClusterInfo.insert_info: {err:?}"); } } @@ -1184,9 +1177,6 @@ impl ClusterInfo { node.clone() }; let entries: Vec<_> = [ - LegacyContactInfo::try_from(&node) - .map(CrdsData::LegacyContactInfo) - .expect("Operator must spin up node with valid contact-info"), CrdsData::ContactInfo(node), CrdsData::NodeInstance(instance), ] @@ -1829,7 +1819,7 @@ impl ClusterInfo { score }; let score = match response.data() { - CrdsData::LegacyContactInfo(_) | CrdsData::ContactInfo(_) => 2 * score, + CrdsData::ContactInfo(_) => 2 * score, _ => score, }; ((addr, response), score) diff --git a/gossip/src/contact_info.rs b/gossip/src/contact_info.rs index e7a8015d8b95cb..26f11a771b6136 100644 --- a/gossip/src/contact_info.rs +++ b/gossip/src/contact_info.rs @@ -615,6 +615,7 @@ fn sanitize_entries(addrs: &[IpAddr], sockets: &[SocketEntry]) -> Result<(), Err } // Verifies that the other socket is at QUIC_PORT_OFFSET from the first one. +#[cfg(test)] pub(crate) fn sanitize_quic_offset( socket: &Option, // udp other: &Option, // quic: udp + QUIC_PORT_OFFSET diff --git a/gossip/src/legacy_contact_info.rs b/gossip/src/legacy_contact_info.rs index edd042acda897a..165b72314c00a0 100644 --- a/gossip/src/legacy_contact_info.rs +++ b/gossip/src/legacy_contact_info.rs @@ -1,12 +1,10 @@ #[cfg(test)] -use crate::contact_info::{get_quic_socket, sanitize_socket}; +use crate::contact_info::{ + get_quic_socket, sanitize_quic_offset, sanitize_socket, ContactInfo, Error, Protocol, + SOCKET_ADDR_UNSPECIFIED, +}; use { - crate::{ - contact_info::{ - sanitize_quic_offset, ContactInfo, Error, Protocol, SOCKET_ADDR_UNSPECIFIED, - }, - crds_data::MAX_WALLCLOCK, - }, + crate::crds_data::MAX_WALLCLOCK, solana_pubkey::Pubkey, solana_sanitize::{Sanitize, SanitizeError}, solana_streamer::socket::SocketAddrSpace, @@ -169,6 +167,7 @@ impl LegacyContactInfo { } } +#[cfg(test)] impl TryFrom<&ContactInfo> for LegacyContactInfo { type Error = Error;