Skip to content

Commit

Permalink
removes fallback on legacy versions in ClusterInfo::get_node_version (#…
Browse files Browse the repository at this point in the history
…3565)

New ContactInfo is propagated on all clusters and is sufficient to
lookup a node's version. CrdsData for legacy versions are deprecated and
should no longer be used.
  • Loading branch information
behzadnouri authored Nov 11, 2024
1 parent 683ca1b commit c54dd21
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 54 deletions.
12 changes: 0 additions & 12 deletions gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,18 +1068,6 @@ impl ClusterInfo {
.get::<&ContactInfo>(*pubkey)
.map(ContactInfo::version)
.cloned()
.or_else(|| {
gossip_crds
.get::<&Version>(*pubkey)
.map(|entry| entry.version.clone())
.or_else(|| {
gossip_crds
.get::<&crds_data::LegacyVersion>(*pubkey)
.map(|entry| entry.version.clone())
.map(solana_version::LegacyVersion2::from)
})
.map(solana_version::Version::from)
})
}

fn check_socket_addr_space<E>(&self, addr: &Result<SocketAddr, E>) -> bool {
Expand Down
2 changes: 0 additions & 2 deletions gossip/src/cluster_info_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ pub struct GossipStats {
pub(crate) filter_crds_values_dropped_values: Counter,
pub(crate) filter_pull_response: Counter,
pub(crate) generate_pull_responses: Counter,
pub(crate) get_accounts_hash: Counter,
pub(crate) get_epoch_duration_no_working_bank: Counter,
pub(crate) get_votes: Counter,
pub(crate) get_votes_count: Counter,
Expand Down Expand Up @@ -206,7 +205,6 @@ pub(crate) fn submit_gossip_stats(
("push_vote_read", stats.push_vote_read.clear(), i64),
("get_votes", stats.get_votes.clear(), i64),
("get_votes_count", stats.get_votes_count.clear(), i64),
("get_accounts_hash", stats.get_accounts_hash.clear(), i64),
("all_tvu_peers", stats.all_tvu_peers.clear(), i64),
("tvu_peers", stats.tvu_peers.clear(), i64),
(
Expand Down
4 changes: 2 additions & 2 deletions gossip/src/crds_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl<'de> Deserialize<'de> for Vote {
pub(crate) struct LegacyVersion {
from: Pubkey,
wallclock: u64,
pub(crate) version: solana_version::LegacyVersion1,
version: solana_version::LegacyVersion1,
}

impl Sanitize for LegacyVersion {
Expand All @@ -390,7 +390,7 @@ impl Sanitize for LegacyVersion {
pub(crate) struct Version {
from: Pubkey,
wallclock: u64,
pub(crate) version: solana_version::LegacyVersion2,
version: solana_version::LegacyVersion2,
}

impl Sanitize for Version {
Expand Down
8 changes: 1 addition & 7 deletions gossip/src/crds_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use {
crate::{
contact_info::ContactInfo,
crds::VersionedCrdsValue,
crds_data::{CrdsData, LegacyVersion, LowestSlot, SnapshotHashes, Version},
crds_data::{CrdsData, LowestSlot, SnapshotHashes},
crds_value::{CrdsValue, CrdsValueLabel},
},
indexmap::IndexMap,
Expand Down Expand Up @@ -52,9 +52,7 @@ impl_crds_entry!(VersionedCrdsValue, |entry| entry);

// Lookup by Pubkey.
impl_crds_entry!(ContactInfo, CrdsData::ContactInfo(node), node);
impl_crds_entry!(LegacyVersion, CrdsData::LegacyVersion(version), version);
impl_crds_entry!(LowestSlot, CrdsData::LowestSlot(_, slot), slot);
impl_crds_entry!(Version, CrdsData::Version(version), version);
impl_crds_entry!(
SnapshotHashes,
CrdsData::SnapshotHashes(snapshot_hashes),
Expand Down Expand Up @@ -107,10 +105,6 @@ mod tests {
CrdsData::LowestSlot(_, slot) => {
assert_eq!(crds.get::<&LowestSlot>(key), Some(slot))
}
CrdsData::Version(version) => assert_eq!(crds.get::<&Version>(key), Some(version)),
CrdsData::LegacyVersion(version) => {
assert_eq!(crds.get::<&LegacyVersion>(key), Some(version))
}
CrdsData::SnapshotHashes(hash) => {
assert_eq!(crds.get::<&SnapshotHashes>(key), Some(hash))
}
Expand Down
18 changes: 0 additions & 18 deletions version/src/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ pub struct LegacyVersion2 {
pub feature_set: u32, // first 4 bytes of the FeatureSet identifier
}

impl From<LegacyVersion1> for LegacyVersion2 {
fn from(legacy_version: LegacyVersion1) -> Self {
Self {
major: legacy_version.major,
minor: legacy_version.minor,
patch: legacy_version.patch,
commit: legacy_version.commit,
feature_set: 0,
}
}
}

impl Default for LegacyVersion2 {
fn default() -> Self {
let feature_set =
Expand All @@ -53,12 +41,6 @@ impl Default for LegacyVersion2 {
}
}

impl fmt::Display for LegacyVersion2 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}.{}.{}", self.major, self.minor, self.patch,)
}
}

impl fmt::Debug for LegacyVersion2 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
Expand Down
13 changes: 0 additions & 13 deletions version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,6 @@ fn compute_commit(sha1: Option<&'static str>) -> Option<u32> {
u32::from_str_radix(sha1?.get(..8)?, /*radix:*/ 16).ok()
}

impl From<LegacyVersion2> for Version {
fn from(version: LegacyVersion2) -> Self {
Self {
major: version.major,
minor: version.minor,
patch: version.patch,
commit: version.commit.unwrap_or_default(),
feature_set: version.feature_set,
client: Version::default().client,
}
}
}

impl Default for Version {
fn default() -> Self {
let feature_set =
Expand Down

0 comments on commit c54dd21

Please sign in to comment.