Skip to content

Commit

Permalink
stops pushing LegacyContactInfo updates over gossip (#4368)
Browse files Browse the repository at this point in the history
We no longer use LegacyContactInfo and don't need to push updates over
gossip.
  • Loading branch information
behzadnouri authored Jan 13, 2025
1 parent f8e5b16 commit 6b88a9c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
24 changes: 7 additions & 17 deletions gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:?}");
}
}

Expand Down Expand Up @@ -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),
]
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions gossip/src/contact_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SocketAddr>, // udp
other: &Option<SocketAddr>, // quic: udp + QUIC_PORT_OFFSET
Expand Down
13 changes: 6 additions & 7 deletions gossip/src/legacy_contact_info.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -169,6 +167,7 @@ impl LegacyContactInfo {
}
}

#[cfg(test)]
impl TryFrom<&ContactInfo> for LegacyContactInfo {
type Error = Error;

Expand Down

0 comments on commit 6b88a9c

Please sign in to comment.