Skip to content

Commit 560a7bf

Browse files
Merge pull request #1240 from input-output-hk/lc/cbor
Replace ToJSON/FromJSON Tx with cbor encoding
2 parents 148a0c3 + a682340 commit 560a7bf

25 files changed

+16888
-48696
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ As a minor extension, we also keep a semantic version for the `UNRELEASED`
99
changes.
1010

1111

12+
## [0.16.0] - UNRELEASED
13+
14+
- **BREAKING** Transaction serialization on hydra-node api and persisted data changed.
15+
1216
## [0.15.0] - 2024-01-18
1317

1418
- Tested with `cardano-node 8.7.3` and `cardano-cli 8.17.0.0`.

docs/core-concepts/behavior.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Not pictured is the `CommandFailed` output, which is implicit emitted whenever a
1919
There are some options for API clients to control the server outputs. Server outputs are controlled using the following query parameters:
2020

2121
+ `history=no` -> Prevents historical outputs display. All server outputs are recorded and when a client re-connects these outputs are replayed unless `history=no` query param is used.
22-
+ `tx-output=cbor` -> Outputs transaction fields encoded as CBOR instead of default JSON.
2322
+ `snapshot-utxo=no` -> In case of a `SnapshotConfirmed` message the `utxo` field in the inner `Snapshot` will be omitted.
2423

2524
## Replay of past server outputs
@@ -28,4 +27,4 @@ When a `hydra-node` restarts, by default it will load its history from persisten
2827

2928
Clients can optionally decide to skip history outputs and receive only the `Greetings` and following ones. In order to do that they can use query param `history=no`.
3029

31-
For example if the client wants to connect to a local `hydra-node` and doesn't want to view the server history but also wants to have the transactions encoded as CBOR (base16) and prevent utxo display in `SnapshotConfirmed` messages, they would connect using default port `4001` and the full path `ws://localhost:4001/?history=no&tx-output=cbor`.
30+
For example if the client wants to connect to a local `hydra-node` and doesn't want to view the server history and prevent utxo display in `SnapshotConfirmed` messages, they would connect using default port `4001` and the full path `ws://localhost:4001/?history=no`.

hydra-cluster/bench/Bench/EndToEnd.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import Data.Scientific (Scientific)
2828
import Data.Set ((\\))
2929
import Data.Set qualified as Set
3030
import Data.Time (UTCTime (UTCTime), utctDayTime)
31-
import Hydra.Cardano.Api (Tx, TxId, UTxO, getVerificationKey, serialiseToTextEnvelope, signTx)
31+
import Hydra.Cardano.Api (Tx, TxId, UTxO, getVerificationKey, signTx)
3232
import Hydra.Cluster.Faucet (FaucetLog, publishHydraScriptsAs, seedFromFaucet)
3333
import Hydra.Cluster.Fixture (Actor (Faucet))
3434
import Hydra.Cluster.Scenarios (
@@ -329,7 +329,7 @@ newTx registry client tx = do
329329
, invalidAt = Nothing
330330
, confirmedAt = Nothing
331331
}
332-
send client $ input "NewTx" ["transaction" .= serialiseToTextEnvelope Nothing tx]
332+
send client $ input "NewTx" ["transaction" .= toJSON tx]
333333

334334
data WaitResult
335335
= TxInvalid {transactionId :: TxId, reason :: Text}
@@ -396,14 +396,14 @@ waitForAllConfirmations n1 Registry{processedTxs} allIds = do
396396
maybeTxValid v = do
397397
guard (v ^? key "tag" == Just "TxValid")
398398
v
399-
^? key "transaction" . key "id" . to fromJSON >>= \case
399+
^? key "transaction" . key "txId" . to fromJSON >>= \case
400400
Error _ -> Nothing
401401
Success txid -> pure $ TxValid txid
402402

403403
maybeTxInvalid v = do
404404
guard (v ^? key "tag" == Just "TxInvalid")
405405
v
406-
^? key "transaction" . key "id" . to fromJSON >>= \case
406+
^? key "transaction" . key "txId" . to fromJSON >>= \case
407407
Error _ -> Nothing
408408
Success tx ->
409409
TxInvalid tx <$> v ^? key "validationError" . key "reason" . _String

hydra-cluster/hydra-cluster.cabal

-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ test-suite tests
157157
Test.Hydra.Cluster.CardanoCliSpec
158158
Test.Hydra.Cluster.FaucetSpec
159159
Test.Hydra.Cluster.MithrilSpec
160-
Test.LogFilterSpec
161160
Test.OfflineChainSpec
162161

163162
build-depends:

hydra-cluster/src/Hydra/Cluster/Scenarios.hs

+2-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import Hydra.Cardano.Api (
4848
mkVkAddress,
4949
selectLovelace,
5050
signTx,
51-
toLedgerTx,
5251
toScriptData,
5352
writeFileTextEnvelope,
5453
pattern ReferenceScriptNone,
@@ -525,12 +524,12 @@ canSubmitTransactionThroughAPI tracer workDir node hydraScriptsTxId =
525524
Left e -> failure $ show e
526525
Right body -> do
527526
let unsignedTx = makeSignedTransaction [] body
528-
let unsignedRequest = toJSON $ toLedgerTx unsignedTx
527+
let unsignedRequest = toJSON unsignedTx
529528
sendRequest hydraNodeId unsignedRequest
530529
`shouldThrow` expectErrorStatus 400 (Just "MissingVKeyWitnessesUTXOW")
531530

532531
let signedTx = signTx cardanoBobSk unsignedTx
533-
let signedRequest = toJSON $ toLedgerTx signedTx
532+
let signedRequest = toJSON signedTx
534533
(sendRequest hydraNodeId signedRequest <&> responseBody)
535534
`shouldReturn` TransactionSubmitted
536535
where

hydra-cluster/test/Test/LogFilterSpec.hs

-47
This file was deleted.

0 commit comments

Comments
 (0)