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 moment
Proposed 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 genesis UTCTime)
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 relTime
The resulting UTCTime then needs to be converted to POSIX milliseconds (Word64) for the proto field.
Changes required
Cardano.Rpc.Server.Internal.UtxoRpc.Query — add querySystemStart and queryEraHistory to the executeLocalStateQueryExpr blocks in readParamsMethod and readUtxosMethod; compute the timestamp and pass it to mkChainPointMsg
Cardano.Rpc.Server.Internal.UtxoRpc.Type — update mkChainPointMsg signature to accept the computed timestamp (or SystemStart + EraHistory) and set the U5c.timestamp field
Cardano.Testnet.Test.Rpc.Query (in cardano-node) — update the assertion on line 102 to check the actual expected timestamp instead of 0
Problem
The UTxO RPC
ChainPointproto message defines atimestampfield (field 4,uint64, milliseconds), but it is never populated bymkChainPointMsg. It always defaults to0.This affects all RPC responses that include a
ledgerTip, specificallyreadParamsandreadUtxos. The test atCardano.Testnet.Test.Rpc.Query(line 102) documents this:Proposed solution
The information needed to compute the timestamp is available via existing local state queries. The RPC handler methods (
readParamsMethod,readUtxosMethod) already callexecuteLocalStateQueryExpr— 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:
The resulting
UTCTimethen 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