-
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
Add time since genesis to sysvar::clock #7289
Conversation
812c3cc
to
fb2349a
Compare
How do you intend to use this clock, and is Tyera's work in #7115 not good enough? We'll going from no clock to two clocks otherwise. |
I plan to use this clock for lockups that expire from some date vs. some number of epochs from genesis. The only reason I've decided not to calculate the epochs from when genesis ran (which is the same as this does) is because it'll be useful for vests later. Tyera's clock is different, can be used as a stake-weighted wallclock, and it appears in the ledger. This one is just genesis unixtimestamp + slots (already calculated for consumers). |
Codecov Report
@@ Coverage Diff @@
## master #7289 +/- ##
========================================
- Coverage 71.8% 64.3% -7.5%
========================================
Files 245 240 -5
Lines 54595 57157 +2562
========================================
- Hits 39215 36806 -2409
- Misses 15380 20351 +4971 |
Is there such a requirement? There's a 6 month expiration after launch, but technically, genesis could be idling a long time before launch. |
There's no concern about the timestamp here drifting if the cluster stalls for a time, or is reset? |
Drift should be okay. What's important is that all unlocking occurs at the same time. |
But why not use Tyera's clock? We're building this for an external need regardless |
The requirement comes and goes. It has most recently come again. Besides the network launch-based lockups, there are overlapping required holding periods. Stake lockups will have a semantic like: |
Where is Tyera's clock exposed to programs? What if big stakers want to collude and get out of their lockups? |
minimal concerns. we could allow custodian to change the lockups, too... |
It's not exposed yet but it could be.
Ok that sounds like a decent argument to not use "Tyera's clock"! Thanks |
The requirement needs to be in the SSOT before we move forward here. Please send me a direct message showing where that's coming from. |
Generally speaking, I like Solana-controlled date oracle accounts as the stopgap solution for all date issues. |
for stake lockups, I think there are only 2 reasonable options:
this PR makes 1) I'd have to define another "date oracle" field in StakeState to do 2) I'm starting to think that we don't need dropping lockup by time/date would also make genesis stakes more liquid/flexible. they could be split and withdrawn any time the custodian agrees CC @aeyakovenko |
@rob-solana @garious solana controlled oracle puts to much control on us and has legal implications. A best effort slot approximation is what we want. We should be adjusting hashes per slot every epoch automatically. |
@mvines this is ready for another once-over by you |
This comment has been minimized.
This comment has been minimized.
runtime/src/bank.rs
Outdated
/// computed unix_timestamp at this slot height | ||
pub fn unix_timestamp(&self) -> i64 { | ||
self.genesis_creation_time | ||
+ ((self.slot as u128 * self.ns_per_slot) / 1_000_000_000_000) as i64 |
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.
Sure you have the right amount of zeros there? At a glance, it looks like 3 too many.
The PR contents itself looks good to me! |
72d433e
to
1659d6f
Compare
Problem
no notion of wallclock available to programs
Summary of Changes
add simple, good enough unix_timestamp to bank, sysvar::clock, based
on genesis creation timestamp
Fixes #