Skip to content

Commit 8b3a54a

Browse files
Arnaud Baillych1bo
Arnaud Bailly
andcommitted
Apply suggestions from code review
Co-authored-by: Sebastian Nagel <[email protected]>
1 parent 56b0d56 commit 8b3a54a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

docs/adr/2023-12-06_029-use-cbor-for-tx.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ slug: 30
33
title: |
44
30. Use CBOR in external representation of Cardano transactions
55
authors: [abailly]
6-
tags: []
6+
tags: [Proposed]
77
---
88

99
## Status
@@ -12,7 +12,7 @@ Proposed
1212

1313
## Context
1414

15-
* The [Hydra.Ledger.Cardano](https://github.com/input-output-hk/hydra/blob/b2dc5a0da4988631bd2c1e94b66ba6217d5db595/hydra-node/src/Hydra/Ledger/Cardano.hs#L127] module provides `ToJSON/FromJSON` instances for [Alonzo.Tx](https://github.com/input-output-hk/hydra/blob/b2dc5a0da4988631bd2c1e94b66ba6217d5db595/hydra-node/src/Hydra/Ledger/Cardano/Json.hs#L361)
15+
* The [Hydra.Ledger.Cardano](https://github.com/input-output-hk/hydra/blob/b2dc5a0da4988631bd2c1e94b66ba6217d5db595/hydra-node/src/Hydra/Ledger/Cardano.hs#L127) module provides `ToJSON/FromJSON` instances for `Tx` and [AlonzoTx](https://github.com/input-output-hk/hydra/blob/b2dc5a0da4988631bd2c1e94b66ba6217d5db595/hydra-node/src/Hydra/Ledger/Cardano/Json.hs#L361)
1616
* We have specified this format as part of [Hydra API](https://github.com/input-output-hk/hydra/blob/b2dc5a0da4988631bd2c1e94b66ba6217d5db595/hydra-node/json-schemas/api.yaml#L1473)
1717
* These instances appear in a few places as part of Hydra API:
1818
* In the [ServerOutput](https://github.com/input-output-hk/hydra/blob/b2dc5a0da4988631bd2c1e94b66ba6217d5db595/hydra-node/src/Hydra/API/ServerOutput.hs#L51) sent by the node to clients
@@ -36,14 +36,16 @@ Proposed
3636
* Drop support of "structured" JSON encoding of transactions in log messages, external APIs, and local storage of a node state
3737
* Require JSON encoding for transactions that consists in:
3838
* A `cborHex` string field containing the base16 CBOR-encoded transaction
39-
* An optional `txId` string field containing the base16 encoding of the Blake2b256 hash of the transaction's bytes
39+
* An optional `txId` string field containing the Cardano transaction id, i.e. the base16 encoded Blake2b256 hash of the transaction body bytes
4040
* When present, the `txId` MUST be consistent with the `cborHex`. This will be guaranteed for data produced by Hydra, but input data (eg. through a `NewTx` message) that does not respect this constraint will be rejected
4141

4242
## Consequences
4343

44-
* By providing a `txId` field alongside the CBOR encoding, we still allow clients to observe the lifecycle of a transaction inside a Head as it gets validated and confirmed without requiring from them to be able to decode the CBOR body and compute the txId themselves
44+
* This is a breaking change and client applications must decode the full transaction CBOR before accessing any part of it
45+
- Hydra clients like `hydraw`, `hydra-auction`, `hydra-pay`, `hydra-poll` and hydra-chess` need to be updated
46+
* By providing a `txId` field alongside the CBOR encoding, we still allow clients to observe the lifecycle of a transaction inside a Head as it gets validated and confirmed without requiring from them to be able to decode the CBOR body and compute the `txId` themselves
4547
* This is particularly important for monitoring which usually does not care about the details of transactions
4648
* We should point users to existing tools for decoding transactions' content in a human-readable format as this can be useful for troubleshooting:
47-
* `cardano-cli transaction view --tx-file <path to tx enveloppe file>` is one example
49+
* `cardano-cli transaction view --tx-file <path to tx envelope file>` is one example
4850
* We need to _version_ the data that's persisted and exchanged, e.g the Head state and network messages, in order to ensure nodes can either gracefully migrate stored data or detect explicitly versions inconsistency
4951
* We should use the [cardanonical](https://github.com/CardanoSolutions/cardanonical) schemas should the need arise to represent transaction in JSON again

0 commit comments

Comments
 (0)