-
Notifications
You must be signed in to change notification settings - Fork 136
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 back timestamp precondition #755
Conversation
My only concern is dealing with long forks and missed slot, which will inevitable cause the timestamp to run out of sync with the "real world" time, which might give the user/developer a wrong understanding of how to use this. |
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.
This looks good to me! Maybe we can add docs to timestamp
to let people know it’s virtualized on top of currentSlot
network.timestamp
globalSlot
->currentSlot
following internal discussion with @jasongitmailsatisfies
operatorTimestamp precondition RFC
network.timestamp
is implemented as a wrapper fornetwork.globalSlotSinceGenesis
, which means:network.timestamp.get()
, the global slot is fetched under the hood and converted to a timestamptimestamp.assertEquals()
ortimestamp.assertBetween()
, a precondition forglobalSlotSinceGenesis
is added under the hoodImplementation details
.getNetworkConstants()
on theMina
interface, which returns constants such as the genesis timestamp. This way, we can also use a reasonable mock value for local blockchain: the timestamp at whichLocalBlockchain
is instantiated.UInt64
to aUInt32
with two possible semantics: either assert that theUInt64
fits in 32 bits already, or clamp theUInt64
to the uint32 range, so that larger values just become the max uint32. For our conversion of timestamp ranges to slot ranges, clamping is appropriate: this enables users to specify a "definitely large enough" timestamp value as the upper bound and have it converted to the max uint32 which is a definitely large enough slot.Potential caveats
The fact that we implement one precondition on top of another means that the network doesn't know that
timestamp
was used and can't return an appropriate error. This is currently not an issue because the protocol returnsProtocol_state_precondition_unsatisfied
for all failing network preconditions, so it doesn't distinguish the exact case anyway.