This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
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.
Problem
Users have no way to know when a Solana block was produced in real-world time.
Validators are now including intermittent timestamps in their votes, but JSON RPC is not using that data to return an estimated block time.
Summary of Changes
Adds blocktree apis to return real block time data. The get_block_time method does the following:
Only rooted slots have static block times.
If the requested block is right after genesis, uses slot 0 as the base slot. Else if the requested block is after one or more
TIMESTAMP_SLOT_INTERVAL
s, uses as base slot the most recentTIMESTAMP_SLOT_INTERVAL
or (if that slot is not seen/rooted on the fork) the oldest subsequent slot. (If there are not "enough" slots between the base slot and the requested block, uses the previousTIMESTAMP_SLOT_INTERVAL
or oldest subsequent slot as the base slot. See Research PoS implementations #3 for what constitutes enough.)The number of slots to check is set in
TIMESTAMP_SLOT_RANGE
, and currently set to 5 slots. This is pretty arbitrary. This setting gives validators 2sec-worth of slots to get their timestamp in. This seems fairly luxurious, but if votes are taking multiple slots to process on the cluster, this might need to be tuned.Fixes #7115