Skip to content

Commit c54dd21

Browse files
authored
removes fallback on legacy versions in ClusterInfo::get_node_version (anza-xyz#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.
1 parent 683ca1b commit c54dd21

File tree

6 files changed

+3
-54
lines changed

6 files changed

+3
-54
lines changed

gossip/src/cluster_info.rs

-12
Original file line numberDiff line numberDiff line change
@@ -1068,18 +1068,6 @@ impl ClusterInfo {
10681068
.get::<&ContactInfo>(*pubkey)
10691069
.map(ContactInfo::version)
10701070
.cloned()
1071-
.or_else(|| {
1072-
gossip_crds
1073-
.get::<&Version>(*pubkey)
1074-
.map(|entry| entry.version.clone())
1075-
.or_else(|| {
1076-
gossip_crds
1077-
.get::<&crds_data::LegacyVersion>(*pubkey)
1078-
.map(|entry| entry.version.clone())
1079-
.map(solana_version::LegacyVersion2::from)
1080-
})
1081-
.map(solana_version::Version::from)
1082-
})
10831071
}
10841072

10851073
fn check_socket_addr_space<E>(&self, addr: &Result<SocketAddr, E>) -> bool {

gossip/src/cluster_info_metrics.rs

-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ pub struct GossipStats {
9999
pub(crate) filter_crds_values_dropped_values: Counter,
100100
pub(crate) filter_pull_response: Counter,
101101
pub(crate) generate_pull_responses: Counter,
102-
pub(crate) get_accounts_hash: Counter,
103102
pub(crate) get_epoch_duration_no_working_bank: Counter,
104103
pub(crate) get_votes: Counter,
105104
pub(crate) get_votes_count: Counter,
@@ -206,7 +205,6 @@ pub(crate) fn submit_gossip_stats(
206205
("push_vote_read", stats.push_vote_read.clear(), i64),
207206
("get_votes", stats.get_votes.clear(), i64),
208207
("get_votes_count", stats.get_votes_count.clear(), i64),
209-
("get_accounts_hash", stats.get_accounts_hash.clear(), i64),
210208
("all_tvu_peers", stats.all_tvu_peers.clear(), i64),
211209
("tvu_peers", stats.tvu_peers.clear(), i64),
212210
(

gossip/src/crds_data.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl<'de> Deserialize<'de> for Vote {
374374
pub(crate) struct LegacyVersion {
375375
from: Pubkey,
376376
wallclock: u64,
377-
pub(crate) version: solana_version::LegacyVersion1,
377+
version: solana_version::LegacyVersion1,
378378
}
379379

380380
impl Sanitize for LegacyVersion {
@@ -390,7 +390,7 @@ impl Sanitize for LegacyVersion {
390390
pub(crate) struct Version {
391391
from: Pubkey,
392392
wallclock: u64,
393-
pub(crate) version: solana_version::LegacyVersion2,
393+
version: solana_version::LegacyVersion2,
394394
}
395395

396396
impl Sanitize for Version {

gossip/src/crds_entry.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use {
22
crate::{
33
contact_info::ContactInfo,
44
crds::VersionedCrdsValue,
5-
crds_data::{CrdsData, LegacyVersion, LowestSlot, SnapshotHashes, Version},
5+
crds_data::{CrdsData, LowestSlot, SnapshotHashes},
66
crds_value::{CrdsValue, CrdsValueLabel},
77
},
88
indexmap::IndexMap,
@@ -52,9 +52,7 @@ impl_crds_entry!(VersionedCrdsValue, |entry| entry);
5252

5353
// Lookup by Pubkey.
5454
impl_crds_entry!(ContactInfo, CrdsData::ContactInfo(node), node);
55-
impl_crds_entry!(LegacyVersion, CrdsData::LegacyVersion(version), version);
5655
impl_crds_entry!(LowestSlot, CrdsData::LowestSlot(_, slot), slot);
57-
impl_crds_entry!(Version, CrdsData::Version(version), version);
5856
impl_crds_entry!(
5957
SnapshotHashes,
6058
CrdsData::SnapshotHashes(snapshot_hashes),
@@ -107,10 +105,6 @@ mod tests {
107105
CrdsData::LowestSlot(_, slot) => {
108106
assert_eq!(crds.get::<&LowestSlot>(key), Some(slot))
109107
}
110-
CrdsData::Version(version) => assert_eq!(crds.get::<&Version>(key), Some(version)),
111-
CrdsData::LegacyVersion(version) => {
112-
assert_eq!(crds.get::<&LegacyVersion>(key), Some(version))
113-
}
114108
CrdsData::SnapshotHashes(hash) => {
115109
assert_eq!(crds.get::<&SnapshotHashes>(key), Some(hash))
116110
}

version/src/legacy.rs

-18
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@ pub struct LegacyVersion2 {
2727
pub feature_set: u32, // first 4 bytes of the FeatureSet identifier
2828
}
2929

30-
impl From<LegacyVersion1> for LegacyVersion2 {
31-
fn from(legacy_version: LegacyVersion1) -> Self {
32-
Self {
33-
major: legacy_version.major,
34-
minor: legacy_version.minor,
35-
patch: legacy_version.patch,
36-
commit: legacy_version.commit,
37-
feature_set: 0,
38-
}
39-
}
40-
}
41-
4230
impl Default for LegacyVersion2 {
4331
fn default() -> Self {
4432
let feature_set =
@@ -53,12 +41,6 @@ impl Default for LegacyVersion2 {
5341
}
5442
}
5543

56-
impl fmt::Display for LegacyVersion2 {
57-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58-
write!(f, "{}.{}.{}", self.major, self.minor, self.patch,)
59-
}
60-
}
61-
6244
impl fmt::Debug for LegacyVersion2 {
6345
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
6446
write!(

version/src/lib.rs

-13
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,6 @@ fn compute_commit(sha1: Option<&'static str>) -> Option<u32> {
5353
u32::from_str_radix(sha1?.get(..8)?, /*radix:*/ 16).ok()
5454
}
5555

56-
impl From<LegacyVersion2> for Version {
57-
fn from(version: LegacyVersion2) -> Self {
58-
Self {
59-
major: version.major,
60-
minor: version.minor,
61-
patch: version.patch,
62-
commit: version.commit.unwrap_or_default(),
63-
feature_set: version.feature_set,
64-
client: Version::default().client,
65-
}
66-
}
67-
}
68-
6956
impl Default for Version {
7057
fn default() -> Self {
7158
let feature_set =

0 commit comments

Comments
 (0)