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

Commit

Permalink
Reduce max snapshot hashes to stay under MTU
Browse files Browse the repository at this point in the history
(cherry picked from commit 2a5605d)
  • Loading branch information
mvines committed Feb 29, 2020
1 parent 2bc735b commit db949b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 12 additions & 1 deletion core/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ const MAX_GOSSIP_TRAFFIC: usize = 128_000_000 / PACKET_DATA_SIZE;
const NUM_BITS_PER_BYTE: u64 = 8;
const MIN_SIZE_TO_COMPRESS_GZIP: u64 = 64;

/// Keep the number of snapshot hashes a node publishes under MAX_PROTOCOL_PAYLOAD_SIZE
pub const MAX_SNAPSHOT_HASHES: usize = 16;

#[derive(Debug, PartialEq, Eq)]
pub enum ClusterInfoError {
NoPeers,
Expand Down Expand Up @@ -441,6 +444,14 @@ impl ClusterInfo {
}

pub fn push_snapshot_hashes(&mut self, snapshot_hashes: Vec<(Slot, Hash)>) {
if snapshot_hashes.len() > MAX_SNAPSHOT_HASHES {
warn!(
"snapshot_hashes too large, ignored: {}",
snapshot_hashes.len()
);
return;
}

let now = timestamp();
let entry = CrdsValue::new_signed(
CrdsData::SnapshotHash(SnapshotHash::new(self.id(), snapshot_hashes, now)),
Expand Down Expand Up @@ -1056,7 +1067,7 @@ impl ClusterInfo {
}

/// Splits a Vec of CrdsValues into a nested Vec, trying to make sure that
/// each Vec is no larger than `PROTOCOL_PAYLOAD_SIZE`
/// each Vec is no larger than `MAX_PROTOCOL_PAYLOAD_SIZE`
/// Note: some messages cannot be contained within that size so in the worst case this returns
/// N nested Vecs with 1 item each.
fn split_gossip_messages(msgs: Vec<CrdsValue>) -> Vec<Vec<CrdsValue>> {
Expand Down
4 changes: 1 addition & 3 deletions core/src/snapshot_packager_service.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::cluster_info::ClusterInfo;
use crate::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES};
use solana_ledger::{
snapshot_package::SnapshotPackageReceiver, snapshot_utils::archive_snapshot_package,
};
Expand All @@ -16,8 +16,6 @@ pub struct SnapshotPackagerService {
t_snapshot_packager: JoinHandle<()>,
}

const MAX_SNAPSHOT_HASHES: usize = 24;

impl SnapshotPackagerService {
pub fn new(
snapshot_package_receiver: SnapshotPackageReceiver,
Expand Down

0 comments on commit db949b4

Please sign in to comment.