IntersectMBO / IntersectMBO/cardano-ledger
Use separate serialization/types for ledger queries
- Dominant language
- Haskell
- Stars
- 295
- Forks
- 179
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 29
Description
The Local State Query mini-protocol supports a variety of messages involving types from Ledger (see [here](https://github.com/IntersectMBO/ouroboros-consensus/blob/27178aa06ba934da8d19445240c8878852197857/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs#L111) 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`: https://github.com/IntersectMBO/ouroboros-consensus/pull/95 and https://github.com/CardanoSolutions/ogmios/issues/314
- Ledger made changes to the `PoolDistr` type and serialization: https://github.com/IntersectMBO/cardano-ledger/pull/4324 and https://github.com/IntersectMBO/ouroboros-consensus/pull/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)
Contributor guide
Assessment
This issue has not been assessed yet.