Use separate serialization/types for ledger queries
amesgen opened this issue · 0 comments
amesgen commented
The Local State Query mini-protocol supports a variety of messages involving types from Ledger (see here for the definition).
Currently, serialization of queries uses the {Enc,Dec,To,From}CBOR
instances provided by ledger.
These ledger queries have to be backwards-compatible across node releases; only the serialization is allowed to vary (gated behind the NodeToClient version). However, it is currently easy to make mistakes here:
- Ledger made changes to the serialization of
PParams
: IntersectMBO/ouroboros-consensus#95 and CardanoSolutions/ogmios#314 - Ledger made changes to the
PoolDistr
type and serialization: #4324 and IntersectMBO/ouroboros-consensus#1142
Both cases are currently handled by vendoring old Ledger code in Consensus. While this works, it is not ideal, rather, quoting @lehins:
There are three things that need to be done to solve this properly IMHO:
- Separate types for queries, so that we don't get into situation like above where we can't roundtrip the result of the query because the type was expanded with new information
- Separate type class that supports serialization versioning parameterized on NoteToClient protocol version.
- CDDL specification for all types and versions (#4396)