chore: index proposer preferences by slot first - #9312
Merged
nflaig merged 2 commits intoApr 30, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the SeenProposerPreferences class by reordering its internal map structure to use Slot as the primary key instead of RootHex. This change simplifies the prune method, allowing it to iterate directly over slots and remove outdated entries in a single pass. A review comment suggests optimizing the prune method further by using .keys() instead of .entries() to reduce memory overhead during iteration.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
nflaig
approved these changes
Apr 30, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #9312 +/- ##
=========================================
Coverage 52.59% 52.59%
=========================================
Files 848 848
Lines 61087 61087
Branches 4504 4504
=========================================
Hits 32126 32126
Misses 28897 28897
Partials 64 64 🚀 New features to boost your workflow:
|
Member
|
🎉 This PR is included in v1.43.0 🎉 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
As suggested by @twoeths in #9303, the current map nesting in
SeenProposerPreferences(Map<dependentRoot, Map<slot, validatorIndex>>) makes pruning inefficient — it requires iterating through every dependent root and checking each slot individually.Description
Swaps the map nesting to
Map<slot, Map<dependentRoot, validatorIndex>>so that pruning can delete entire slot entries directly from the outer map. No changes to the public API;isKnown,add, andpruneall retain their existing signatures and behavior.Closes #9309
AI Assistance Disclosure
Used Claude to discuss the approach and review the implementation.