From c45c9dc562f26d5a858afdf9dee70fdbeaa00f4c Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 10 Oct 2023 11:52:53 -0400 Subject: [PATCH] v1.17: Stops pushing legacy snapshot hashes to crds (backport of #33576) (#33581) (cherry picked from commit c588f25eca9b0277aea9f524aacfc35552a01b4b) Co-authored-by: Brooks --- core/src/snapshot_packager_service.rs | 18 ++-------- .../snapshot_gossip_manager.rs | 36 +------------------ 2 files changed, 4 insertions(+), 50 deletions(-) diff --git a/core/src/snapshot_packager_service.rs b/core/src/snapshot_packager_service.rs index 4c90a8bd18d793..6d81e2b5402039 100644 --- a/core/src/snapshot_packager_service.rs +++ b/core/src/snapshot_packager_service.rs @@ -2,7 +2,7 @@ mod snapshot_gossip_manager; use { crossbeam_channel::{Receiver, Sender}, snapshot_gossip_manager::SnapshotGossipManager, - solana_gossip::cluster_info::{ClusterInfo, MAX_LEGACY_SNAPSHOT_HASHES}, + solana_gossip::cluster_info::ClusterInfo, solana_measure::measure_us, solana_perf::thread::renice_this_thread, solana_runtime::{ @@ -39,25 +39,13 @@ impl SnapshotPackagerService { snapshot_config: SnapshotConfig, enable_gossip_push: bool, ) -> Self { - let max_full_snapshot_hashes = std::cmp::min( - MAX_LEGACY_SNAPSHOT_HASHES, - snapshot_config - .maximum_full_snapshot_archives_to_retain - .get(), - ); - let t_snapshot_packager = Builder::new() .name("solSnapshotPkgr".to_string()) .spawn(move || { info!("SnapshotPackagerService has started"); renice_this_thread(snapshot_config.packager_thread_niceness_adj).unwrap(); - let mut snapshot_gossip_manager = enable_gossip_push.then(|| { - SnapshotGossipManager::new( - cluster_info, - max_full_snapshot_hashes, - starting_snapshot_hashes, - ) - }); + let mut snapshot_gossip_manager = enable_gossip_push + .then(|| SnapshotGossipManager::new(cluster_info, starting_snapshot_hashes)); loop { if exit.load(Ordering::Relaxed) { diff --git a/core/src/snapshot_packager_service/snapshot_gossip_manager.rs b/core/src/snapshot_packager_service/snapshot_gossip_manager.rs index a2d7239b3197ae..d4ab9863642e09 100644 --- a/core/src/snapshot_packager_service/snapshot_gossip_manager.rs +++ b/core/src/snapshot_packager_service/snapshot_gossip_manager.rs @@ -4,7 +4,7 @@ use { snapshot_hash::{ FullSnapshotHash, IncrementalSnapshotHash, SnapshotHash, StartingSnapshotHashes, }, - snapshot_package::{retain_max_n_elements, SnapshotKind}, + snapshot_package::SnapshotKind, }, solana_sdk::{clock::Slot, hash::Hash}, std::sync::Arc, @@ -14,8 +14,6 @@ use { pub struct SnapshotGossipManager { cluster_info: Arc, latest_snapshot_hashes: Option, - max_legacy_full_snapshot_hashes: usize, - legacy_full_snapshot_hashes: Vec, } impl SnapshotGossipManager { @@ -24,14 +22,11 @@ impl SnapshotGossipManager { #[must_use] pub fn new( cluster_info: Arc, - max_legacy_full_snapshot_hashes: usize, starting_snapshot_hashes: Option, ) -> Self { let mut this = SnapshotGossipManager { cluster_info, latest_snapshot_hashes: None, - max_legacy_full_snapshot_hashes, - legacy_full_snapshot_hashes: Vec::default(), }; if let Some(starting_snapshot_hashes) = starting_snapshot_hashes { this.push_starting_snapshot_hashes(starting_snapshot_hashes); @@ -49,10 +44,6 @@ impl SnapshotGossipManager { ); } self.push_latest_snapshot_hashes_to_cluster(); - - // Handle legacy snapshot hashes here too - // Once LegacySnapshotHashes are removed from CRDS, also remove them here - self.push_legacy_full_snapshot_hash(starting_snapshot_hashes.full); } /// Push new snapshot hash to the cluster via CRDS @@ -78,10 +69,6 @@ impl SnapshotGossipManager { fn push_full_snapshot_hash(&mut self, full_snapshot_hash: FullSnapshotHash) { self.update_latest_full_snapshot_hash(full_snapshot_hash); self.push_latest_snapshot_hashes_to_cluster(); - - // Handle legacy snapshot hashes here too - // Once LegacySnapshotHashes are removed from CRDS, also remove them here - self.push_legacy_full_snapshot_hash(full_snapshot_hash); } /// Push new incremental snapshot hash to the cluster via CRDS @@ -146,22 +133,6 @@ impl SnapshotGossipManager { and a new error case has been added that has not been handled here.", ); } - - /// Add `full_snapshot_hash` to the vector of full snapshot hashes, then push that vector to - /// the cluster via CRDS. - fn push_legacy_full_snapshot_hash(&mut self, full_snapshot_hash: FullSnapshotHash) { - self.legacy_full_snapshot_hashes.push(full_snapshot_hash); - - retain_max_n_elements( - &mut self.legacy_full_snapshot_hashes, - self.max_legacy_full_snapshot_hashes, - ); - - self.cluster_info - .push_legacy_snapshot_hashes(clone_hashes_for_crds( - self.legacy_full_snapshot_hashes.as_slice(), - )); - } } #[derive(Debug, Copy, Clone, Eq, PartialEq)] @@ -191,8 +162,3 @@ impl AsSnapshotHash for IncrementalSnapshotHash { &self.0 } } - -/// Clones and maps snapshot hashes into what CRDS expects -fn clone_hashes_for_crds(hashes: &[impl AsSnapshotHash]) -> Vec<(Slot, Hash)> { - hashes.iter().map(AsSnapshotHash::clone_for_crds).collect() -}