From 3ea6a012543920fb8f282a211cc80f9bb343e46e Mon Sep 17 00:00:00 2001 From: Brooks Prumo Date: Mon, 27 Sep 2021 19:29:08 -0500 Subject: [PATCH] Only gossip snapshot hashes for full snapshots (#20271) --- core/src/snapshot_packager_service.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/core/src/snapshot_packager_service.rs b/core/src/snapshot_packager_service.rs index 81483c9f4e..821b735ce9 100644 --- a/core/src/snapshot_packager_service.rs +++ b/core/src/snapshot_packager_service.rs @@ -1,7 +1,9 @@ use solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES}; use solana_runtime::{ - snapshot_archive_info::SnapshotArchiveInfoGetter, snapshot_config::SnapshotConfig, - snapshot_package::PendingSnapshotPackage, snapshot_utils, + snapshot_archive_info::SnapshotArchiveInfoGetter, + snapshot_config::SnapshotConfig, + snapshot_package::{PendingSnapshotPackage, SnapshotType}, + snapshot_utils, }; use solana_sdk::{clock::Slot, hash::Hash}; use std::{ @@ -58,11 +60,15 @@ impl SnapshotPackagerService { ) .expect("failed to archive snapshot package"); - hashes.push((snapshot_package.slot(), *snapshot_package.hash())); - while hashes.len() > MAX_SNAPSHOT_HASHES { - hashes.remove(0); + // NOTE: For backwards compatibility with version <=1.7, only _full_ snapshots + // can have their hashes pushed out to the cluster. + if snapshot_package.snapshot_type == SnapshotType::FullSnapshot { + hashes.push((snapshot_package.slot(), *snapshot_package.hash())); + while hashes.len() > MAX_SNAPSHOT_HASHES { + hashes.remove(0); + } + cluster_info.push_snapshot_hashes(hashes.clone()); } - cluster_info.push_snapshot_hashes(hashes.clone()); } }) .unwrap();