Skip to content

Commit

Permalink
fix: make sure shuffling is calculated when querying next epoch propo…
Browse files Browse the repository at this point in the history
…sers (#7156)

* feat: make getBeaconProposersNextEpoch async to await for shuffling calculation

* fix: build error in getBeaconProposersNextEpoch

* fix: failed unit test

* refactor: use tuyen suggestion to await for shuffling keeping state-transition sync
  • Loading branch information
matthewkeil authored Oct 14, 2024
1 parent d37bdb0 commit 2a7f7e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,8 @@ export function getValidatorApi(
break;

case stateEpoch + 1:
// make sure shuffling is calculated and ready for next call to calculate nextProposers
await chain.shufflingCache.get(state.epochCtx.nextEpoch, state.epochCtx.nextDecisionRoot);
// Requesting duties for next epoch is allowed since they can be predicted with high probabilities.
// @see `epochCtx.getBeaconProposersNextEpoch` JSDocs for rationale.
indexes = state.epochCtx.getBeaconProposersNextEpoch();
Expand Down
2 changes: 1 addition & 1 deletion packages/state-transition/src/cache/epochCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ export class EpochCache {
getBeaconProposersNextEpoch(): ValidatorIndex[] {
if (!this.proposersNextEpoch.computed) {
const indexes = computeProposers(
this.config.getForkSeqAtEpoch(this.epoch + 1),
this.config.getForkSeqAtEpoch(this.nextEpoch),
this.proposersNextEpoch.seed,
this.getShufflingAtEpoch(this.nextEpoch),
this.effectiveBalanceIncrements
Expand Down

0 comments on commit 2a7f7e6

Please sign in to comment.