Skip to content
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

feat: debug too many shuffling promises #7251

Merged
merged 13 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/prepareNextSlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class PrepareNextSlotScheduler {
// the slot 0 of next epoch will likely use this Previous Root Checkpoint state for state transition so we transfer cache here
// the resulting state with cache will be cached in Checkpoint State Cache which is used for the upcoming block processing
// for other slots dontTransferCached=true because we don't run state transition on this state
{dontTransferCache: !isEpochTransition},
{dontTransferCache: !isEpochTransition, asyncShufflingCalculation: true},
matthewkeil marked this conversation as resolved.
Show resolved Hide resolved
RegenCaller.precomputeEpoch
);

Expand Down
4 changes: 4 additions & 0 deletions packages/beacon-node/src/chain/regen/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export enum RegenFnName {

export type StateCloneOpts = {
matthewkeil marked this conversation as resolved.
Show resolved Hide resolved
dontTransferCache: boolean;
/**
* Do not queue shuffling calculation async. Forces sync JIT calculation in afterProcessEpoch
*/
asyncShufflingCalculation?: boolean;
};

export interface IStateRegenerator extends IStateRegeneratorInternal {
Expand Down
11 changes: 7 additions & 4 deletions packages/state-transition/src/cache/epochCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,13 @@ export class EpochCache {
this.shufflingCache
.get(epochAfterUpcoming, this.nextDecisionRoot)
.then((shuffling) => {
if (!shuffling) {
throw new Error("EpochShuffling not returned from get in afterProcessEpoch");
}
this.nextShuffling = shuffling;
this.nextShuffling = shuffling
matthewkeil marked this conversation as resolved.
Show resolved Hide resolved
? shuffling
: // biome-ignore lint/style/noNonNullAssertion: object must be defined to be in this branch of the conditional
this.shufflingCache!.getSync(epochAfterUpcoming, this.nextDecisionRoot, {
state,
activeIndices: this.nextActiveIndices,
});
})
.catch((err) => {
this.shufflingCache?.logger?.error(
matthewkeil marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export type EpochTransitionCacheOpts = {
* Assert progressive balances the same to EpochTransitionCache
*/
assertCorrectProgressiveBalances?: boolean;
/**
* Do not queue shuffling calculation async. Forces sync JIT calculation in afterProcessEpoch
*/
asyncShufflingCalculation?: boolean;
};

/**
Expand Down Expand Up @@ -376,7 +380,10 @@ export function beforeProcessEpoch(
for (let i = 0; i < nextEpochShufflingActiveIndicesLength; i++) {
nextShufflingActiveIndices[i] = nextEpochShufflingActiveValidatorIndices[i];
}
state.epochCtx.shufflingCache?.build(epochAfterNext, nextShufflingDecisionRoot, state, nextShufflingActiveIndices);

if (opts?.asyncShufflingCalculation) {
state.epochCtx.shufflingCache?.build(epochAfterNext, nextShufflingDecisionRoot, state, nextShufflingActiveIndices);
}
matthewkeil marked this conversation as resolved.
Show resolved Hide resolved

if (totalActiveStakeByIncrement < 1) {
totalActiveStakeByIncrement = 1;
Expand Down
Loading