forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 293
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
gregcusack
merged 2 commits into
anza-xyz:master
from
gregcusack:rm-node-instance-from-pull-requests
Aug 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,7 +419,14 @@ 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, | ||
) { | ||
let has_min_stake_for_gossip = | ||
|pubkey: &Pubkey| stakes.get(pubkey).copied().unwrap_or_default() >= MIN_STAKE_FOR_GOSSIP; | ||
|
||
values.retain(|value| { | ||
match value.data { | ||
CrdsData::ContactInfo(_) => true, | ||
|
@@ -438,10 +445,13 @@ fn retain_staked(values: &mut Vec<CrdsValue>, stakes: &HashMap<Pubkey, u64>) { | |
| CrdsData::LegacyVersion(_) | ||
| CrdsData::DuplicateShred(_, _) | ||
| CrdsData::RestartHeaviestFork(_) | ||
| CrdsData::RestartLastVotedForkSlots(_) | ||
| CrdsData::NodeInstance(_) => { | ||
let stake = stakes.get(&value.pubkey()).copied(); | ||
stake.unwrap_or_default() >= MIN_STAKE_FOR_GOSSIP | ||
| CrdsData::RestartLastVotedForkSlots(_) => has_min_stake_for_gossip(&value.pubkey()), | ||
CrdsData::NodeInstance(_) => { | ||
if drop_unstaked_node_instance { | ||
has_min_stake_for_gossip(&value.pubkey()) | ||
} else { | ||
true | ||
} | ||
} | ||
} | ||
}) | ||
|
@@ -1646,7 +1656,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, false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for someone reading this code later, it is not clear what each of these retain_staked(data, stakes, /*drop_unstaked_node_instance:*/ false); |
||
!data.is_empty() | ||
}) | ||
} | ||
|
@@ -2138,7 +2148,7 @@ impl ClusterInfo { | |
}; | ||
if self.require_stake_for_gossip(stakes) { | ||
for resp in &mut pull_responses { | ||
retain_staked(resp, stakes); | ||
retain_staked(resp, stakes, true); | ||
} | ||
} | ||
let (responses, scores): (Vec<_>, Vec<_>) = addrs | ||
|
@@ -2544,9 +2554,9 @@ impl ClusterInfo { | |
} | ||
} | ||
if self.require_stake_for_gossip(stakes) { | ||
retain_staked(&mut pull_responses, stakes); | ||
retain_staked(&mut pull_responses, stakes, false); | ||
for (_, data) in &mut push_messages { | ||
retain_staked(data, stakes); | ||
retain_staked(data, stakes, false); | ||
} | ||
push_messages.retain(|(_, data)| !data.is_empty()); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can leave this part as is, but add an extra branch before line 437: