-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
Problem
The UTxO RPC ChainPoint proto message defines a timestamp field (field 4, uint64, milliseconds), but it is never populated by mkChainPointMsg. It always defaults to 0.
This affects all RPC responses that include a ledgerTip, specifically readParams and readUtxos. The test at Cardano.Testnet.Test.Rpc.Query (line 102) documents this:
pparamsResponse ^. U5c.ledgerTip . U5c.timestamp === 0 -- not possible to implement at this momentProposed solution
The information needed to compute the timestamp is available via existing local state queries. The RPC handler methods (readParamsMethod, readUtxosMethod) already call executeLocalStateQueryExpr — two additional queries can be added to the same expression:
querySystemStart→SystemStart(chain genesisUTCTime)queryEraHistory→EraHistory(era boundaries and slot lengths)
With those, the conversion is:
import Cardano.Api (getProgress, EraHistory)
import Cardano.Slotting.Time (fromRelativeTime, SystemStart)
slotToUTCTime :: SystemStart -> EraHistory -> SlotNo -> Either PastHorizonException UTCTime
slotToUTCTime systemStart eraHistory slotNo = do
(relTime, _slotLen) <- getProgress slotNo eraHistory
pure $ fromRelativeTime systemStart relTimeThe resulting UTCTime then needs to be converted to POSIX milliseconds (Word64) for the proto field.
Changes required
Cardano.Rpc.Server.Internal.UtxoRpc.Query— addquerySystemStartandqueryEraHistoryto theexecuteLocalStateQueryExprblocks inreadParamsMethodandreadUtxosMethod; compute the timestamp and pass it tomkChainPointMsgCardano.Rpc.Server.Internal.UtxoRpc.Type— updatemkChainPointMsgsignature to accept the computed timestamp (orSystemStart+EraHistory) and set theU5c.timestampfieldCardano.Testnet.Test.Rpc.Query(incardano-node) — update the assertion on line 102 to check the actual expected timestamp instead of0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels