ogmios
ogmios copied to clipboard
Time Interpreter / Slotting Arithmetic
Describe your idea, in simple words.
The local-state-query protocol provides a GetInterpreter
query which returns an interface for running various queries regarding time and slotting arithmetic on Cardano. Behind the scene, the interpreter is constructed from a list of epoch summaries objects, which are also transferred over the wire. This is also how Ogmios currently provides support for this query (called eraSummaries
in Ogmios).
While already useful, it does not however provide the full power of the internal TimeInterpreter
abstraction from ouroboros-network. This abstraction is used to perform queries for converting times to slot, epochs and the like. It is not possible to transfer such abstraction over the wire, but, it may possible to turn it into a mini-protocol and offer a simple query/response pattern to clients.
Note that, these could be supported via both WebSocket and plain HTTP?
Why is it a good idea?
There's a lot of pitfalls and rooms for error in the time interpretation of the chain. Since a lot of this intelligence has already been put into the Haskell TimeInterpreter
, providing support for it via Ogmios could be extremely useful for those looking into slot arithmetic, especially across eras. In particular, the following queries are currently available from the TimeInterpreter
:
Query | Description / Effects |
---|---|
wallclockToSlot | Translate a UTC (relative) time to an absolute slot number |
slotToWallclock | Convert an absolute slot number to a UTC (relative) time |
slotToEpoch | Convert an absolute slot number to an epoch number and slot number within this epoch |
epochToSlot | Translate an epoch number to the absolute slot number of the first slot of that epoch |
epochToSize | Get the size (in slots) of a given epoch |
Are you willing to work on it yourself?
Yes.