lodestar icon indicating copy to clipboard operation
lodestar copied to clipboard

Refactor ShufflingCache

Open twoeths opened this issue 1 month ago • 1 comments

Problem description

as in #8650 we will not have a full beacon state at typescript anymore so the ShufflingCache.build() function will not work

current implementation:

/**
   * Queue asynchronous build for an EpochShuffling, triggered from state-transition
   */
  build(epoch: number, decisionRoot: string, state: BeaconStateAllForks, activeIndices: Uint32Array): void {
    this.insertPromise(epoch, decisionRoot);
    /**
     * TODO: (@matthewkeil) This will get replaced by a proper build queue and a worker to do calculations
     * on a NICE thread
     */
    const timer = this.metrics?.shufflingCache.shufflingCalculationTime.startTimer({source: "build"});
    computeEpochShufflingAsync(state, activeIndices, epoch)
      .then((shuffling) => {
        this.set(shuffling, decisionRoot);
      })
      .catch((err) =>
        this.logger?.error(`error building shuffling for epoch ${epoch} at decisionRoot ${decisionRoot}`, {}, err)
      )
      .finally(() => {
        timer?.();
      });

also the lazy build() does not work after fulu since we add proposerLookahead to EpochCache

Solution description

  • remove build() method
  • after every epoch transition, add a Shuffling to this cache
  • revert #6938 since it's not helpful anymore postfulu and it prevents #8650

Additional context

No response

twoeths avatar Dec 02 '25 08:12 twoeths

can i take this up?

guha-rahul avatar Dec 10 '25 09:12 guha-rahul