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

v2.2: stop unstaked nodes from pushing EpochSlots into the cluster (backport of #5141) #5286

Merged
merged 1 commit into from
Mar 21, 2025

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Mar 14, 2025

Problem

  • EpochSlots is 70% of gossip traffic
  • Unstaked nodes do not need to send it

Summary of Changes

  • Prevent them from sending the message

Fixes #
Partially #5034


This is an automatic backport of pull request #5141 done by [Mergify](https://mergify.com).

* stop unstaked nodes from pushing EpochSlots into the cluster
* reload own stake on every epoch in case I become staked
* use epoch specs to reduce contention for bank forks

---------

Co-authored-by: Alex Pyattaev <[email protected]>

Big thanks to Behzad for code suggestions.

(cherry picked from commit 145d562)
@mergify mergify bot requested a review from a team as a code owner March 14, 2025 07:38
@alexpyattaev
Copy link

alexpyattaev commented Mar 14, 2025

According to @kobi-lizard epoch slots bandwidth cost over 1M$ daily on MNB.
According to my estimate it is more like 20K$ daily. The truth is probabaly somewhere in between.

Copy link

@t-nelson t-nelson left a comment

Choose a reason for hiding this comment

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

not sure why these nits weren't caught in master review. don't change them here. prefer to keep bp as close to 1:1 with master as feasible

break;
}
let mut epoch_specs = EpochSpecs::from(bank_forks.clone());
while !exit.load(Ordering::Relaxed) {

Choose a reason for hiding this comment

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

in the future, please avoid superfluous refactors like this for changes that are intended for backport. they can go into master as a followup

Choose a reason for hiding this comment

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

Sure thing!

.current_epoch_staked_nodes()
.get(&node_id)
.cloned()
.unwrap_or_default();

Choose a reason for hiding this comment

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

avoid smearing over potential unexpected error scenarios with dubious generics (Default is a bug). this would have been more obvious as

let maybe_my_stake = epoch_specs
    .current_epoch_staked_nodes()
    .get(&node_id)
    .cloned();
match maybe_my_stake {
    Some(my_stake) if my_stake > 0 => {
        ...process
    }
    () => {
        ...drain
    }
}

Choose a reason for hiding this comment

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

Arguably, unwrap_or(0) would work even better here. Agree that default can do surprising things. Should we add recommendations to avoid using default() where reasonable?

@@ -100,12 +98,25 @@ impl ClusterSlotsService {
lowest_slot_elapsed.stop();
let mut process_cluster_slots_updates_elapsed =
Measure::start("process_cluster_slots_updates_elapsed");

Choose a reason for hiding this comment

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

avoid superfluous cosmetics

@t-nelson
Copy link

@alessandrod are you willing to sme this one?

@alexpyattaev alexpyattaev merged commit ee3d50d into v2.2 Mar 21, 2025
46 checks passed
@alexpyattaev alexpyattaev deleted the mergify/bp/v2.2/pr-5141 branch March 21, 2025 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants