-
Notifications
You must be signed in to change notification settings - Fork 231
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
VC: Hardening and optimizing time handling. #4743
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e17a785
Fix durationToNextSlot() and durationToNextEpoch() to work not only a…
cheatfate 6beb537
Refactor validator logging.
cheatfate b21adc9
Fix doppelganger detection should not start at pre-genesis time.
cheatfate 17336cd
Address review comments part 1.
cheatfate 5740df5
Address review comments.
cheatfate 5be531a
Fix condition issue for near genesis waiting loop.
cheatfate 447332f
Address review comments.
cheatfate aa4a00d
Address review comments 2.
cheatfate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
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.
Ideally we would remove
durationToNextSlot
andfromNow
- both of these are compound operations that mix "current time" from the global clock with "time arithmetic" which leads to problems and confusion in code that uses them, since getting the "current time" generally should only be done in a controlled way:await
boundariestherefore:
fromNow
,durationToNext*
etcnow
consistently when the current time is needed as the only function that accesses the global clockdurationFrom(a, b: BeaconTime): tuple[future: bool, dur: Duration]
as is done infromNow
bn
andvc
to use the above functionsfromNow
becomesslot.start_beacon_time().durationFrom(clock.now())
durationToNextSlot
becomeslet now = clock.now(); saturate((now.slotOrZero() + 1).start_beacon_time().durationFrom(now))
more or less (slotOrZero
is incorrect for pre-genesis - it needs to return duration to genesis for any time before genesis)BeaconTime
and do the saturation if need be, but these helpers should never access the clock itselfdurationFrom
can be added for slot vs time etc to make it less verbosedurationFrom
can also bedurationTo
or some other name or shape - doesn't matter which direction it goes in, but sinceDuration
is undefined for negative values, we need to return a tuple - we also sometimes need to know that genesis hasn't happened yet, so we don't always want to saturate.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.
Proposed solution do not support negative Slot values which is happened when you are running before genesis. So it become impossible to provide such UX experience like it was done now. Because its impossible to supply negative Slot values it is very hard to find proper argument value for
durationFrom/durationTo
. Its whydurationToNextSlot
looks the most appropriate name for the procedure which is able to calculate duration to next slot which is either before or after genesis.