-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Correct Bank timestamp drift every slot #12737
Correct Bank timestamp drift every slot #12737
Conversation
Codecov Report
@@ Coverage Diff @@
## master #12737 +/- ##
========================================
Coverage 81.9% 81.9%
========================================
Files 359 360 +1
Lines 84547 84686 +139
========================================
+ Hits 69277 69412 +135
- Misses 15270 15274 +4 |
0261ec7
to
aa966f3
Compare
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.
Looks about right
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.
Pretty simple, I like it
Pull request has been modified.
Oh #12742 💔 |
b86110c
to
7562c87
Compare
7562c87
to
d46a6e5
Compare
* Move timestamp helper to sdk * Add Bank method for getting timestamp estimate * Return sysvar info from Bank::clock * Add feature-gated timestamp correction * Rename unix_timestamp method to be more descriptive * Review comments * Add timestamp metric (cherry picked from commit b028c47) # Conflicts: # runtime/src/feature_set.rs
* Move timestamp helper to sdk * Add Bank method for getting timestamp estimate * Return sysvar info from Bank::clock * Add feature-gated timestamp correction * Rename unix_timestamp method to be more descriptive * Review comments * Add timestamp metric (cherry picked from commit b028c47) # Conflicts: # runtime/src/feature_set.rs
* Move timestamp helper to sdk * Add Bank method for getting timestamp estimate * Return sysvar info from Bank::clock * Add feature-gated timestamp correction * Rename unix_timestamp method to be more descriptive * Review comments * Add timestamp metric (cherry picked from commit b028c47) # Conflicts: # runtime/src/feature_set.rs Co-authored-by: Tyera Eulberg <[email protected]>
Problem
The timestamp returned by
Bank::unix_timestamp()
ends up in the clock sysvar and is used to assess time-based stake account lockouts. However it's based on a theoretical slots-per-second instead of reality, so it's quite inaccurate. This will pose a problem for lockups, since the accounts will not register as lockup-free on (or anytime near) the date the lockup is set to expire.Block times are estimated using a validator timestamp oracle; this data provides an opportunity to align the bank timestamp more closely with real-world time.
Summary of Changes
Bank::update_clock
to set the Clock sysvar timestamp to the stake-weighted timestamp estimate if it is greater than the unix_timestamp from genesis; feature-gatedThis adds 50us to each
Bank::new_from_parent()
, which was not distinguishable in confirmation-time or other metrics on a testnet under moderate TPS load.Fixes #9874
Toward #10093 (but requires some additional handling to update Bank::slots_per_year)