Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 2a5605d

Browse files
committed
Reduce max snapshot hashes to stay under MTU
1 parent b4362cc commit 2a5605d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

core/src/cluster_info.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ const MAX_GOSSIP_TRAFFIC: usize = 128_000_000 / PACKET_DATA_SIZE;
8484
const NUM_BITS_PER_BYTE: u64 = 8;
8585
const MIN_SIZE_TO_COMPRESS_GZIP: u64 = 64;
8686

87+
/// Keep the number of snapshot hashes a node publishes under MAX_PROTOCOL_PAYLOAD_SIZE
88+
pub const MAX_SNAPSHOT_HASHES: usize = 16;
89+
8790
#[derive(Debug, PartialEq, Eq)]
8891
pub enum ClusterInfoError {
8992
NoPeers,
@@ -441,6 +444,14 @@ impl ClusterInfo {
441444
}
442445

443446
pub fn push_snapshot_hashes(&mut self, snapshot_hashes: Vec<(Slot, Hash)>) {
447+
if snapshot_hashes.len() > MAX_SNAPSHOT_HASHES {
448+
warn!(
449+
"snapshot_hashes too large, ignored: {}",
450+
snapshot_hashes.len()
451+
);
452+
return;
453+
}
454+
444455
let now = timestamp();
445456
let entry = CrdsValue::new_signed(
446457
CrdsData::SnapshotHash(SnapshotHash::new(self.id(), snapshot_hashes, now)),
@@ -1059,7 +1070,7 @@ impl ClusterInfo {
10591070
}
10601071

10611072
/// Splits a Vec of CrdsValues into a nested Vec, trying to make sure that
1062-
/// each Vec is no larger than `PROTOCOL_PAYLOAD_SIZE`
1073+
/// each Vec is no larger than `MAX_PROTOCOL_PAYLOAD_SIZE`
10631074
/// Note: some messages cannot be contained within that size so in the worst case this returns
10641075
/// N nested Vecs with 1 item each.
10651076
fn split_gossip_messages(msgs: Vec<CrdsValue>) -> Vec<Vec<CrdsValue>> {

core/src/snapshot_packager_service.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::cluster_info::ClusterInfo;
1+
use crate::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES};
22
use solana_ledger::{
33
snapshot_package::SnapshotPackageReceiver, snapshot_utils::archive_snapshot_package,
44
};
@@ -16,8 +16,6 @@ pub struct SnapshotPackagerService {
1616
t_snapshot_packager: JoinHandle<()>,
1717
}
1818

19-
const MAX_SNAPSHOT_HASHES: usize = 24;
20-
2119
impl SnapshotPackagerService {
2220
pub fn new(
2321
snapshot_package_receiver: SnapshotPackageReceiver,

0 commit comments

Comments
 (0)