Skip to content

Refactor ShufflingCache #8653

Description

@twoeths

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

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions