Skip to content

Conversation

@guha-rahul
Copy link
Contributor

@guha-rahul guha-rahul commented Dec 10, 2025

Motivation

  • When lodestar-z happens, BeaconStateAllForks will be a blocker and The build() method in ShufflingCache depends on it.
  • Post-Fulu proposer lookahead is stored in BeaconState, requiring shufflings synchronously during epoch transitions—making the async build() pattern no longer viable.

Description

  • Remove build() method from IShufflingCache interface and ShufflingCache class
  • Add set() to IShufflingCache interface to add shufflings
  • Remove asyncShufflingCalculation

Closes #8653

AI Assistance Disclosure

  • External Contributors: I have read the contributor guidelines and disclosed my usage of AI below.
    use claude to understand how ShufflingCache avoids recomputation

@guha-rahul guha-rahul requested a review from a team as a code owner December 10, 2025 22:50
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @guha-rahul, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the shuffling calculation mechanism by removing the asynchronous build() method and the asyncShufflingCalculation flag. This change is motivated by upcoming lodestar-z compatibility issues with BeaconStateAllForks and the need for synchronous shuffling calculations for proposer lookahead in the post-Fulu era. The IShufflingCache interface has been updated to reflect these changes, now providing a set() method for directly adding shufflings.

Highlights

  • Removal of Asynchronous Shuffling: The build() method and the asyncShufflingCalculation flag have been removed, shifting shuffling computations to a synchronous model to align with new requirements.
  • IShufflingCache Interface Update: The build() method in the IShufflingCache interface has been replaced with a set() method, allowing direct addition of EpochShuffling objects to the cache.
  • BeaconStateAllForks Compatibility: The changes address a future blocker related to BeaconStateAllForks and lodestar-z by removing the dependency of the build() method on it.
  • Post-Fulu Requirements: This refactor ensures that proposer lookahead, which requires synchronous shuffling post-Fulu, is correctly handled within the system.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 effectively refactors the shuffling calculation by removing the asynchronous build() method and the asyncShufflingCalculation option. This change simplifies the codebase by enforcing synchronous shuffling calculation, which is a necessary step for upcoming features like post-Fulu proposer lookahead. The changes are consistent across all modified files, including interfaces, implementations, and tests. The IShufflingCache interface is updated to use a set() method, and the implementation in ShufflingCache correctly makes this method public. The epoch processing logic in EpochCache and EpochTransitionCache is also cleaned up by removing the now-obsolete async path. Overall, this is a solid refactoring. I have a couple of minor suggestions to improve code clarity and documentation.

}
});

// Trigger async build of shuffling for epoch after next (nextShuffling post epoch transition)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This comment is misleading as the asynchronous shuffling build logic has been removed in this pull request. It should be removed to avoid confusion for future developers.

Comment on lines 54 to 56
/**
* Queue asynchronous build for an EpochShuffling
* Add an EpochShuffling to the ShufflingCache.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The comment for the set method in the IShufflingCache interface could be more descriptive. The implementation in ShufflingCache also handles resolving promises if they exist. Reflecting this behavior in the interface documentation would improve clarity for developers using this interface.

Suggested change
/**
* Queue asynchronous build for an EpochShuffling
* Add an EpochShuffling to the ShufflingCache.
*/
/**
* Add an EpochShuffling to the ShufflingCache. If a promise for the shuffling is present it will
* resolve the promise with the built shuffling.
*/

wemeetagain
wemeetagain previously approved these changes Dec 11, 2025
Copy link
Member

@wemeetagain wemeetagain left a comment

Choose a reason for hiding this comment

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

generally lgtm

Copy link
Contributor

@twoeths twoeths left a comment

Choose a reason for hiding this comment

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

this PR misses the context of #6938:

in the end it'd be more about reverting #6938, and we should deploy on a feature group to make sure there is no regression
also would like @matthewkeil to have a close look to make sure we don't miss anything

@matthewkeil
Copy link
Member

this PR misses the context of #6938:

in the end it'd be more about reverting #6938, and we should deploy on a feature group to make sure there is no regression also would like @matthewkeil to have a close look to make sure we don't miss anything

@twoeths It looks like you covered changes that will get reverted from #6938. The gist Rahul will be that there should be no shuffling cache on the epochCtx anymore. I think if you remove that from the EpochCache and follow all the codepaths that break from the change you will find most of the other hanging references not mentioned above.

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.

Refactor ShufflingCache

4 participants