Skip to content

Commit

Permalink
ignores pubkey in Protocol::PruneMessage (solana-labs#29280)
Browse files Browse the repository at this point in the history
  • Loading branch information
behzadnouri authored Dec 15, 2022
1 parent 50ad039 commit 78a04ed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
17 changes: 7 additions & 10 deletions gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1800,30 +1800,27 @@ impl ClusterInfo {
.unwrap()
}

fn handle_batch_prune_messages(&self, messages: Vec<(Pubkey, PruneData)>) {
fn handle_batch_prune_messages(&self, messages: Vec<PruneData>) {
let _st = ScopedTimer::from(&self.stats.handle_batch_prune_messages_time);
if messages.is_empty() {
return;
}
self.stats
.prune_message_count
.add_relaxed(messages.len() as u64);
self.stats.prune_message_len.add_relaxed(
messages
.iter()
.map(|(_, data)| data.prunes.len() as u64)
.sum(),
);
self.stats
.prune_message_len
.add_relaxed(messages.iter().map(|data| data.prunes.len() as u64).sum());
let mut prune_message_timeout = 0;
let mut bad_prune_destination = 0;
let self_pubkey = self.id();
{
let _st = ScopedTimer::from(&self.stats.process_prune);
let now = timestamp();
for (from, data) in messages {
for data in messages {
match self.gossip.process_prune_msg(
&self_pubkey,
&from,
&data.pubkey,
&data.destination,
&data.prunes,
data.wallclock,
Expand Down Expand Up @@ -2423,7 +2420,7 @@ impl ClusterInfo {
check_duplicate_instance(&data)?;
push_messages.push((from, data));
}
Protocol::PruneMessage(from, data) => prune_messages.push((from, data)),
Protocol::PruneMessage(_from, data) => prune_messages.push(data),
Protocol::PingMessage(ping) => ping_messages.push((from_addr, ping)),
Protocol::PongMessage(pong) => pong_messages.push((from_addr, pong)),
}
Expand Down
8 changes: 3 additions & 5 deletions gossip/src/crds_gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,9 @@ impl CrdsGossip {
wallclock: u64,
now: u64,
) -> Result<(), CrdsGossipError> {
let expired = now > wallclock + self.push.prune_timeout;
if expired {
return Err(CrdsGossipError::PruneMessageTimeout);
}
if self_pubkey == destination {
if now > wallclock.saturating_add(self.push.prune_timeout) {
Err(CrdsGossipError::PruneMessageTimeout)
} else if self_pubkey == destination {
self.push.process_prune_msg(self_pubkey, peer, origin);
Ok(())
} else {
Expand Down
7 changes: 6 additions & 1 deletion gossip/src/crds_gossip_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,12 @@ impl CrdsGossipPush {
}

/// Add the `from` to the peer's filter of nodes.
pub fn process_prune_msg(&self, self_pubkey: &Pubkey, peer: &Pubkey, origins: &[Pubkey]) {
pub(crate) fn process_prune_msg(
&self,
self_pubkey: &Pubkey,
peer: &Pubkey,
origins: &[Pubkey],
) {
if let Some(filter) = self.active_set.read().unwrap().get(peer) {
for origin in origins {
if origin != self_pubkey {
Expand Down

0 comments on commit 78a04ed

Please sign in to comment.