Skip to content

Commit

Permalink
feat: make getBeaconProposersNextEpoch async to await for shuffling c…
Browse files Browse the repository at this point in the history
…alculation
  • Loading branch information
matthewkeil committed Oct 12, 2024
1 parent d37bdb0 commit dc7038c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ export function getValidatorApi(
case stateEpoch + 1:
// 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();
indexes = await state.epochCtx.getBeaconProposersNextEpoch();
break;

case stateEpoch - 1: {
Expand Down
4 changes: 2 additions & 2 deletions packages/state-transition/src/cache/epochCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -918,12 +918,12 @@ export class EpochCache {
* balances are sampled to adjust the probability of the next selection (32 per epoch on average). So to invalidate
* the prediction the effective of one of those 32 samples should change and change the random_byte inequality.
*/
getBeaconProposersNextEpoch(): ValidatorIndex[] {
async getBeaconProposersNextEpoch(): Promise<ValidatorIndex[]> {
if (!this.proposersNextEpoch.computed) {
const indexes = computeProposers(
this.config.getForkSeqAtEpoch(this.epoch + 1),
this.proposersNextEpoch.seed,
this.getShufflingAtEpoch(this.nextEpoch),
await this.shufflingCache?.get(this.nextEpoch, this.nextDecisionRoot);
this.effectiveBalanceIncrements
);
this.proposersNextEpoch = {computed: true, indexes};
Expand Down

0 comments on commit dc7038c

Please sign in to comment.