-
-
Notifications
You must be signed in to change notification settings - Fork 319
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
Proposal for reorganizing shuffling code #6386
Comments
yes I strongly support the idea because having shuffling inside both EpochCache and ShufflingCache is not great. Some more contexts:
|
@matthewkeil this approach sounds good to me |
update: we don't need epoch shuffling for the above apis as long as we cache previous/current/next active validator indices
|
Problem description
Currently we are calculating the shuffling for the next epoch during the state transition of the current epoch.
https://github.com/ChainSafe/lodestar/blob/00dfa63413e9b2a57dbaea70ac7151ef134b0c05/packages/state-transition/src/cache/epochCache.ts#L513-517
This takes about a second.
We propose to offload that work to idle time not on critical path during epoch transition which should shrink the transition duration by about a second.
The
nextShuffling
is not necessary for epoch transition but is useful for calculating the next epoch proposers and sync committee duties so pre-computation is still recommended but it just doesnt need to be on critical path.Solution description
Currently the shuffling code is housed in
state-transition
and the shuffling results are available, on theEpochCache
. We propose to move that all to theShufflingCache
in `beacon-node.This will facilitate a couple of things. We will still have access to the results for service via API, the current consumers of the
nextShuffling
and the shuffling results can be passed into the state-transition pre-computed. It will also open up the ability to do the shuffling on a separate thread or async in main thread idle times.As a result of moving the shuffling to beacon-node the
getBeaconProposersNextEpoch
and similar getters would also need to be moved out of state-transition as they rely on the nextShuffling that will only be available in beacon-node after a period of time (so they cannot be precomputed until the nextShuffling is finished).I am looking either moving those onto the ShufflingCache but that feels like mixing of concerns so potentially I will create a
PrecomputationCache
or similar to house that type of convenience information that gets served by the API.Additional context
What are everyones thoughts on the approach and process?
Step 1) refactor code to move shuffling fully out of
state-transition
and intobeacon-node
. This will not change epoch transition times but will set the groundwork for the next stepsStep 2) create async processing code to move shuffling off critical path
Step 3) potentially create worker for precomputation tasks and implement with napi-nice to make sure kernel scheduling prioritizes main, network and bls threads
The text was updated successfully, but these errors were encountered: