-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add getBlockTime rpc api #7130
Add getBlockTime rpc api #7130
Conversation
f0547c3
to
0a95bbb
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.
Thanks, plumbing looks great. Sneak in a cli/
command for this too? solana get-block-time <SLOT>
?
Codecov Report
@@ Coverage Diff @@
## master #7130 +/- ##
========================================
- Coverage 72% 69.8% -2.3%
========================================
Files 230 230
Lines 49393 51123 +1730
========================================
+ Hits 35576 35697 +121
- Misses 13817 15426 +1609 |
0a95bbb
to
49dfa0a
Compare
@mvines , do you mind taking a look at the changes I made to PohConfig::default and genesis::main? |
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.
There was some really unfortunate rounding due to use of
Duration::from_millis()
on our particular clock defaults (which meant I could never getslot_duration = 400ms
from slots_per_year).
What duration where you getting? Just curious
Since we are stashing a Duration anyway, I saw no reason not to use
Duration::from_micros()
.
It feels a little weird to be using such a small unit (micro seconds) on the solana-genesis command-line, wdyt about keeping --target-tick-duration as ms
and converting to μs
internally
384ms (1000/64 rounds to 6, instead of 6.25)
👌 |
663d0f6
to
2d8096d
Compare
aef9b66
to
bd94448
Compare
* Add getBlockTime rpc api * Add getBlockTime to docs * Fix duration rounding for common tick/slot durations; add slot duration calculation * Expose slots_per_year * Use genesis values instead of clock defaults to calculate block offset * Add get-block-time cli subcommand * Fix test_rent: decrease magic number usage (cherry picked from commit 58c144e)
Problem
It's strongly desired by some users to have a network-controlled best effort timestamp associated with the production time of each block.
Solana does not offer any RPC apis that return this information.
Summary of Changes
Toward #7115 (Steps 1 & part of 2)