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

Fix EpochCommittees returning stake tables out of order #2514

Merged
merged 3 commits into from
Jan 30, 2025

Conversation

ss-es
Copy link
Contributor

@ss-es ss-es commented Jan 30, 2025

This PR:

Fixes an issue where EpochCommittees was previously returning stake tables out of order. We now store (and prefer) the vector passed to EpochCommittees::new_stake without modification, and only retain a BTreeMap for lookup.

This PR does not:

Key places to review:

@@ -126,10 +126,16 @@ struct Committee {
/// leader but without voting rights.
eligible_leaders: Vec<StakeTableEntry<PubKey>>,

/// TODO: add comment
/// Stake table
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a comment explaining why we need these vectors

indexed_stake_table: BTreeMap<PubKey, StakeTableEntry<PubKey>>,

/// TODO: comment
/// DA members indexed by public key, for efficient lookup.
indexed_da_members: BTreeMap<PubKey, StakeTableEntry<PubKey>>,
Copy link
Member

Choose a reason for hiding this comment

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

Nit: maybe make the value here usize index into stake_table and da_members, so we only have a single source of truth for the actual contents of the stake table entry?

Copy link
Member

Choose a reason for hiding this comment

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

Also consider BTreeMap -> HashMap so it is more clear that nothing is actually ordered by keys?

@ss-es ss-es enabled auto-merge (squash) January 30, 2025 23:03
@ss-es ss-es merged commit 0f75108 into main Jan 30, 2025
22 checks passed
@ss-es ss-es deleted the ss/fix-membership-order branch January 30, 2025 23:10
github-actions bot pushed a commit that referenced this pull request Jan 30, 2025
Copy link
Contributor

Successfully created backport PR for release-labrador:

ss-es added a commit that referenced this pull request Jan 30, 2025
…les out of order (#2515)

Fix `EpochCommittees` returning stake tables out of order (#2514)

(cherry picked from commit 0f75108)

Co-authored-by: ss-es <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants