Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter out unstaked NodeInstance from sent PullRequests #2637

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,11 @@ impl Sanitize for Protocol {

// Retains only CRDS values associated with nodes with enough stake.
// (some crds types are exempted)
fn retain_staked(values: &mut Vec<CrdsValue>, stakes: &HashMap<Pubkey, u64>) {
fn retain_staked(
values: &mut Vec<CrdsValue>,
stakes: &HashMap<Pubkey, u64>,
drop_unstaked_node_instance: bool,
) {
values.retain(|value| {
match value.data {
CrdsData::ContactInfo(_) => true,
Expand All @@ -434,6 +438,7 @@ fn retain_staked(values: &mut Vec<CrdsValue>, stakes: &HashMap<Pubkey, u64>) {
// the various dashboards.
CrdsData::Version(_) => true,
CrdsData::AccountsHashes(_) => true,
CrdsData::NodeInstance(_) if !drop_unstaked_node_instance => true,
CrdsData::LowestSlot(_, _)
| CrdsData::LegacyVersion(_)
| CrdsData::DuplicateShred(_, _)
Expand Down Expand Up @@ -1646,7 +1651,7 @@ impl ClusterInfo {
.add_relaxed(num_nodes as u64);
if self.require_stake_for_gossip(stakes) {
push_messages.retain(|_, data| {
retain_staked(data, stakes);
retain_staked(data, stakes, /* drop_unstaked_node_instance */ false);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this also be true?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i purposefully left this false since I wanted to minimize crds table differences between nodes on this first PR. If we stop propagating staked NodeInstance via push, then the crds tables will differ more between the non upgraded nodes and the upgraded nodes. This will result in more unstaked NodeInstances getting sent from non upgraded to upgraded nodes in PullResponses. Which is the same issue we are trying to fix (although less extreme)

!data.is_empty()
})
}
Expand Down Expand Up @@ -2138,7 +2143,7 @@ impl ClusterInfo {
};
if self.require_stake_for_gossip(stakes) {
for resp in &mut pull_responses {
retain_staked(resp, stakes);
retain_staked(resp, stakes, /* drop_unstaked_node_instance */ true);
}
}
let (responses, scores): (Vec<_>, Vec<_>) = addrs
Expand Down Expand Up @@ -2544,9 +2549,13 @@ impl ClusterInfo {
}
}
if self.require_stake_for_gossip(stakes) {
retain_staked(&mut pull_responses, stakes);
retain_staked(
&mut pull_responses,
stakes,
/* drop_unstaked_node_instance */ false,
);
for (_, data) in &mut push_messages {
retain_staked(data, stakes);
retain_staked(data, stakes, /* drop_unstaked_node_instance */ false);
}
push_messages.retain(|(_, data)| !data.is_empty());
}
Expand Down