-
-
Notifications
You must be signed in to change notification settings - Fork 318
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
fix: timeUntilNext calculation before genesis #7372
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## unstable #7372 +/- ##
=========================================
Coverage 48.76% 48.76%
=========================================
Files 601 601
Lines 40243 40243
Branches 2067 2067
=========================================
Hits 19626 19626
Misses 20579 20579
Partials 38 38 |
Performance Report✔️ no performance regression detected Full benchmark results
|
nflaig
approved these changes
Jan 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently
Clock.runEverySlot()
andClock.runEveryEpoch()
will run at odd timing during epoch 0 due to calculation oftimeUntilNext
before genesis being incorrect.Fixing the calculation ensures both functions will execute at t=0 in epoch 0.
Example 1
Suppose current time is 7 seconds before genesis, we want to sleep for 7 seconds before we run the next execution of per-slot and per-epoch task.
In current calculation, next per-slot execution will happen in 5s, which is still 2s before genesis. And next per-epoch execution will happen in 377s, which is 370s after genesis (or 10s into slot 30).
Example 2
Following the per-slot execution in the previous example, if we are at 2s before genesis, we want to sleep for 2s.
However current calculation wants us to sleep for 10s:
Example 3
Current time 864s (2.25 epoch) before genesis. We want next execution to be at t=-768 by waiting for 96s: