-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Why
Users repeatedly have asked for a reliable API reference of the LocalStateQuery protocol available on the Node-to-Client (N2C) socket of the cardano-node.
The cardano-node implements this API through the ouroboros-network, ouroboros-consensus and cardano-ledger components, where the resulting protocol is comprised by messages and their binary CBOR encodings from these three components.
There are multiple clients/servers with varying completeness of this API:
- cardano-api
- ogmios
- pallas
- gouroboros and dingo
- ouroboros-miniprotocols-ts (even contains
.cddlfiles).
Implementing them resulted in users asking for this in multiple issues scattered across repositories:
- [FEAT] - Provide CDDL specs for ledger state queries IntersectMBO/ouroboros-consensus#439 (links to reverse engineering)
- CDDL specs for ledger state queries IntersectMBO/cardano-ledger#4396
- Clarity on ledger state queries IntersectMBO/ouroboros-consensus#246
- Write a CDDL spec for LocalStateQuery and LocalTxSubmission IntersectMBO/ouroboros-consensus#1370 (good comments on approach)
- Comprehensive information about Cardano wire protocol IntersectMBO/ouroboros-network#5049
- [FR] - Provide comprehensive CDDL grammar for local tx-submission protocol IntersectMBO/cardano-node#5139 (asks about tx submission, but good comments on why)
- Document serialisation used by Cardano IntersectMBO/ouroboros-consensus#7
This is a meta-issue to collect these issues and tackle them in course of the cardano-blueprint initiative. On top of these issues, there has been also repeated questions on communication channels about this API.
What
An API reference for the N2C protocols, especially the LocalStateQuery should be:
- human readable to discover available functionality
- machine readable to test and ensure consistency with implementations
- easy to maintain
Concretely this means we need:
- A high-level API description like in ogmios
- An explanation of the protocol (acquiring, querying, ...) with messages defined as
CDDL - A definite list of all queries available
- can be searched
- can be linked to
- Each query holds an explanation (to answer questions like these)
- Each query and its possible responses are defined as a
CDDL- Can be used to encoder/decoder implementations
- Notable implementations like
pallas,gouroborosanddingohave test suites to check conformance
- The API definition is automatically checked against the
cardano-nodereference implementation- Contributors to
ouroboros-network,ouroboros-consensusandcardano-ledgerget notified about inconsistencies
- Contributors to
- The API definition is versioned, such that
- it is clear which API is available in a given
cardano-nodeversion (or any of other client/server implementations) - modifications of the API can be done freely before releasing components
- it is clear which API is available in a given
How
As also discussed in this and this issue, the concrete API is a combination of the ouroboros-network protocol, that delegates handling of a list of queries defined by ouroboros-consensus, which in turn often relies on cardano-ledger to provide the actual query results.
Current situation
-
ouroboros-networkdefines a CDDL forlocalStateQueryMessagein local-state-query.cddl- This is using
query = anyandresult = anyplaceholders
- This is using
-
ouroboros-consensusdoes not define a CDDL ledger queries, there is this PR though: Refine the CDDL spec of theLocalStateQuerymini-protocol IntersectMBO/ouroboros-network#5074, where (shelley era) query messages are defined in data instance BlockQuery and encoding/decoding is provided byencodeShelleyQueryandencodeShelleyResult.- Depending on the
resulttype, thecardano-ledgeris involved in providing the response. - Consensus "native" results are not explicitly covered by a CDDL
- Depending on the
-
cardano-ledgergenerates a composite CDDL for theconwayera using cuddle into conway.cddl (with "huddle" source here)- It is not always clear which schema is used, e.g. the
UTxOresult ofGetUTxOByTxInquery (needs to know how the Haskell typeUTxOis mapped to CBOR) - This does not hold everything needed to describe query results, e.g.
PParamsseems not to be covered
- It is not always clear which schema is used, e.g. the
Concrete solution idea
Create a binary, CDDL-based equivalence of the ledger state query documentation of ogmios:
- Written in markdown
- Rendered and hosted as static website
- Enumerates all queries and explains them
- references
.cddlfiles (see below) - (optional) includes examples / test data
- references
- Create individual
.cddlfiles for each query/result- References the relevant rules from
cardano-ledger'sconway.cddl - Using CDDL module extension
- Add tests to
ouroboros-consensusthat test eachQuery- This requires the individual query
.cddlfiles to be composed withconway.cddl
- This requires the individual query
- References the relevant rules from
- Provide instructions to do similar tests for client implementations
- (optional) Show how to generate arbitrary CBOR with cuddle to test client-side decoders
- Create a full, composite
.cddlof the overall protocol- Can be used to explain all messages received on the wire
- Enumerates all possible
queryandresultcombinations - Is based on
ouroboros-network'slocal-state-query.cddl- (optional) Update ouroboros-network tests to use this composite cddl?
- This may also require to be composed with
conway.cddl - Using CDDL module extension
Steps
- Create an example local state query API description and CDDL #29
- Validate example with
cardano-nodecomponents - Validate example with
pallasorgouroborosclients - Create full API description and CDDLs
TBD
- Latest version and era is sufficient for a first pass?
Sub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
Status