Skip to content

chore: index proposer preferences by slot first - #9312

Merged
nflaig merged 2 commits into
ChainSafe:unstablefrom
markolazic01:refactor/index-proposer-preferences-by-slot
Apr 30, 2026
Merged

chore: index proposer preferences by slot first#9312
nflaig merged 2 commits into
ChainSafe:unstablefrom
markolazic01:refactor/index-proposer-preferences-by-slot

Conversation

@markolazic01

Copy link
Copy Markdown
Contributor

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, and prune all retain their existing signatures and behavior.

Closes #9309

AI Assistance Disclosure

Used Claude to discuss the approach and review the implementation.

@markolazic01
markolazic01 requested a review from a team as a code owner April 30, 2026 12:15

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread packages/beacon-node/src/chain/seenCache/seenProposerPreferences.ts Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

@nflaig nflaig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, thanks @markolazic01 for fixing this

@nflaig
nflaig merged commit 9f5db5b into ChainSafe:unstable Apr 30, 2026
19 checks passed
@codecov

codecov Bot commented Apr 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.59%. Comparing base (87cbe69) to head (fa68f3a).
⚠️ Report is 2 commits behind head on unstable.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wemeetagain

Copy link
Copy Markdown
Member

🎉 This PR is included in v1.43.0 🎉

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.

index proposer preferences by slot first

3 participants