Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ToJSON/FromJSON Tx with cbor encoding #1240

Merged
merged 27 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
52e9c48
Remove AlonzoTx JSON instances
locallycompact Jan 10, 2024
9a372e1
Regenerate golden json files
locallycompact Jan 10, 2024
d6d4bf8
Remove Transaction from json schemas
locallycompact Jan 10, 2024
88b5a3e
Remove and fix JSON tests for cardano Tx
ch1bo Jan 10, 2024
b1cdf58
Rename RawTransaction to Transaction
abailly Jan 10, 2024
4d447a4
Add txId to TxValid and TxInvalid server outputs
locallycompact Jan 10, 2024
e368c72
Restructure server outputs in api.yaml to make it testable
ch1bo Jan 10, 2024
6da5139
Remove TextEnvelopeTransaction from schema
locallycompact Jan 12, 2024
42db3c9
Change TransactionEnvelope to Transaction and only use Transaction type.
locallycompact Jan 15, 2024
b936f43
Encode and decode txId
locallycompact Jan 15, 2024
aa87c0b
Remove tx-output parameter
locallycompact Jan 15, 2024
1f63ace
Regenerate golden files
locallycompact Jan 15, 2024
4e4ab0a
Remove redundant tests
locallycompact Jan 15, 2024
077dc54
LogFilterSpec: remove
locallycompact Jan 15, 2024
9204be7
bench: Use toJSON
locallycompact Jan 15, 2024
bdf23f5
Remove tx-output from API docs
locallycompact Jan 17, 2024
2f14186
ServerOutput: remove redundant pattern match
locallycompact Jan 17, 2024
f67db3a
Remove redundant configurability test
locallycompact Jan 17, 2024
eab9fca
ToJSON Tx: add "type" field
locallycompact Jan 17, 2024
81311f9
Remove redundant imports
locallycompact Jan 17, 2024
b407d07
Replace "Tx BabbageEra.json" with "ReasonablySized (Tx BabbageEra).json"
locallycompact Jan 17, 2024
7970d75
treefmt
locallycompact Jan 18, 2024
8b33782
Add test for same TxId as TxBody after decoding
locallycompact Jan 19, 2024
330eca1
Transaction schema: require type and description
locallycompact Jan 23, 2024
f5caab7
Restore golden files that did not need to change
locallycompact Jan 23, 2024
7c261a4
CHANGELOG: Start section 0.16.0
locallycompact Jan 23, 2024
a682340
docs: remove mention of CBOR
locallycompact Jan 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ As a minor extension, we also keep a semantic version for the `UNRELEASED`
changes.


## [0.16.0] - UNRELEASED

- **BREAKING** Transaction serialization on hydra-node api and persisted data changed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: bump the hydra-node binary (in the cabal file) to this version.


## [0.15.0] - 2024-01-18

- Tested with `cardano-node 8.7.3` and `cardano-cli 8.17.0.0`.
Expand Down
3 changes: 1 addition & 2 deletions docs/core-concepts/behavior.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Not pictured is the `CommandFailed` output, which is implicit emitted whenever a
There are some options for API clients to control the server outputs. Server outputs are controlled using the following query parameters:

+ `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.
+ `tx-output=cbor` -> Outputs transaction fields encoded as CBOR instead of default JSON.
+ `snapshot-utxo=no` -> In case of a `SnapshotConfirmed` message the `utxo` field in the inner `Snapshot` will be omitted.

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

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`.

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`.
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`.
8 changes: 4 additions & 4 deletions hydra-cluster/bench/Bench/EndToEnd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Data.Scientific (Scientific)
import Data.Set ((\\))
import Data.Set qualified as Set
import Data.Time (UTCTime (UTCTime), utctDayTime)
import Hydra.Cardano.Api (Tx, TxId, UTxO, getVerificationKey, serialiseToTextEnvelope, signTx)
import Hydra.Cardano.Api (Tx, TxId, UTxO, getVerificationKey, signTx)
import Hydra.Cluster.Faucet (FaucetLog, publishHydraScriptsAs, seedFromFaucet)
import Hydra.Cluster.Fixture (Actor (Faucet))
import Hydra.Cluster.Scenarios (
Expand Down Expand Up @@ -329,7 +329,7 @@ newTx registry client tx = do
, invalidAt = Nothing
, confirmedAt = Nothing
}
send client $ input "NewTx" ["transaction" .= serialiseToTextEnvelope Nothing tx]
send client $ input "NewTx" ["transaction" .= toJSON tx]

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

maybeTxInvalid v = do
guard (v ^? key "tag" == Just "TxInvalid")
v
^? key "transaction" . key "id" . to fromJSON >>= \case
^? key "transaction" . key "txId" . to fromJSON >>= \case
Error _ -> Nothing
Success tx ->
TxInvalid tx <$> v ^? key "validationError" . key "reason" . _String
Expand Down
1 change: 0 additions & 1 deletion hydra-cluster/hydra-cluster.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ test-suite tests
Test.Hydra.Cluster.CardanoCliSpec
Test.Hydra.Cluster.FaucetSpec
Test.Hydra.Cluster.MithrilSpec
Test.LogFilterSpec
Test.OfflineChainSpec

build-depends:
Expand Down
5 changes: 2 additions & 3 deletions hydra-cluster/src/Hydra/Cluster/Scenarios.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import Hydra.Cardano.Api (
mkVkAddress,
selectLovelace,
signTx,
toLedgerTx,
toScriptData,
writeFileTextEnvelope,
pattern ReferenceScriptNone,
Expand Down Expand Up @@ -525,12 +524,12 @@ canSubmitTransactionThroughAPI tracer workDir node hydraScriptsTxId =
Left e -> failure $ show e
Right body -> do
let unsignedTx = makeSignedTransaction [] body
let unsignedRequest = toJSON $ toLedgerTx unsignedTx
let unsignedRequest = toJSON unsignedTx
sendRequest hydraNodeId unsignedRequest
`shouldThrow` expectErrorStatus 400 (Just "MissingVKeyWitnessesUTXOW")

let signedTx = signTx cardanoBobSk unsignedTx
let signedRequest = toJSON $ toLedgerTx signedTx
let signedRequest = toJSON signedTx
(sendRequest hydraNodeId signedRequest <&> responseBody)
`shouldReturn` TransactionSubmitted
where
Expand Down
47 changes: 0 additions & 47 deletions hydra-cluster/test/Test/LogFilterSpec.hs

This file was deleted.

Loading