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

Computing proposers is not cached #4039

Closed
wemeetagain opened this issue May 19, 2022 · 2 comments
Closed

Computing proposers is not cached #4039

wemeetagain opened this issue May 19, 2022 · 2 comments
Labels
prio-high Resolve issues as soon as possible.

Comments

@wemeetagain
Copy link
Member

@dapplion this won't cache though, and on every request to get next proposers, the this.proposersNextEpoch.computed check here will always return false, and the if branch check always run.

You can confirm this by running the application, and trigger the end point multiple times, the if branch will always run.

I noticed this while working on the implementation and I think the reason why this is the case is how the chain.getHeadStateAtCurrentEpoch here works, but I did not go ahead with caching when I realised that the request to the endpoint itself was actually pretty fast and no need to even cache.

Originally posted by @dadepo in #3782 (comment)

@dadepo
Copy link
Contributor

dadepo commented May 19, 2022

Locally with the code modified as follows:

  getBeaconProposersNextEpoch(): ValidatorIndex[] {
    if (!this.proposersNextEpoch.computed) {
      console.log("should only console once. Current epoch is: " + this.epoch);
      const indexes = computeProposers(
        this.proposersNextEpoch.seed,
        this.nextShuffling,
        this.effectiveBalanceIncrements
      );
      this.proposersNextEpoch = {computed: true, indexes};
    }

    return this.proposersNextEpoch.indexes;
  }

At current epoch of 94955, making repeated requests for proposers at 94956, the console:

May-19 16:34:06.001[]                 info: Synced - slot: 3038570 - head: 3038570 0x1879…e5c1 - finalized: 0x2b30…d099:94953 - peers: 10
should only console once. Current epoch is: 94955
May-19 16:34:18.001[]                 info: Synced - slot: 3038571 - head: 3038571 0x3517…6ea6 - finalized: 0x2b30…d099:94953 - peers: 9
should only console once. Current epoch is: 94955
should only console once. Current epoch is: 94955
should only console once. Current epoch is: 94955

@dapplion dapplion added the prio-high Resolve issues as soon as possible. label May 20, 2022
@philknows philknows added this to the Sprint July 15 milestone Jun 29, 2022
@philknows philknows removed this from the Sprint: July 15, 2022 milestone Jul 1, 2022
@dapplion
Copy link
Contributor

dapplion commented Dec 24, 2022

I tested this feature and was unable to request duties for the next epoch since this function throws for any slot ahead of the clock

await waitForSlot(startSlot); // Must never request for a future slot > currentSlot

@dadepo How were you able to test the feature? That check has always been there

Caching works fine, adding manually a console.log I can see that next proposers is computed only once for repeated calls through that epoch. So closing the issue

Repository owner moved this from Todo to Done in Lodestar Sprint Planning Dec 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prio-high Resolve issues as soon as possible.
Projects
Status: Done
Development

No branches or pull requests

4 participants