Skip to content

Commit

Permalink
Fix json schema errors
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed Oct 4, 2024
1 parent 5139946 commit 44f4da7
Show file tree
Hide file tree
Showing 9 changed files with 5,904 additions and 4,855 deletions.
7,362 changes: 4,021 additions & 3,341 deletions hydra-node/golden/ReasonablySized (ServerOutput (Tx ConwayEra)).json

Large diffs are not rendered by default.

54 changes: 37 additions & 17 deletions hydra-node/golden/ReasonablySized (ServerOutput SimpleTx).json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
},
{
"headId": "00010406050008050703040407010701",
"recoveredTxId": 0,
"recoveredUTxO": [],
"tag": "CommitRecovered"
},
Expand Down Expand Up @@ -396,11 +397,12 @@
},
{
"headId": "07000102030306030705020600050407",
"recoveredTxId": 1,
"recoveredUTxO": [
-5,
1,
4,
5
-6,
-1,
2,
4
],
"tag": "CommitRecovered"
},
Expand Down Expand Up @@ -664,8 +666,9 @@
},
{
"headId": "01030802000808000606010102010706",
"recoveredTxId": 5,
"recoveredUTxO": [
-3,
4,
5
],
"tag": "CommitRecovered"
Expand Down Expand Up @@ -1077,7 +1080,11 @@
},
{
"headId": "04010801080402030703030703030603",
"recoveredUTxO": [],
"recoveredTxId": 1,
"recoveredUTxO": [
3,
6
],
"tag": "CommitRecovered"
},
{
Expand Down Expand Up @@ -1218,14 +1225,21 @@
},
{
"headId": "03050307000000040001020602000202",
"recoveredUTxO": [],
"recoveredTxId": 6,
"recoveredUTxO": [
-5,
1
],
"tag": "CommitRecovered"
},
{
"headId": "04010600050603060803010801080708",
"recoveredTxId": -5,
"recoveredUTxO": [
-5,
3
-2,
-1,
0,
5
],
"tag": "CommitRecovered"
},
Expand Down Expand Up @@ -1297,6 +1311,7 @@
},
{
"headId": "08020102050306060001030607080106",
"recoveredTxId": 3,
"recoveredUTxO": [],
"tag": "CommitRecovered"
},
Expand Down Expand Up @@ -2929,10 +2944,11 @@
},
{
"headId": "01040202060208020004020101080304",
"recoveredTxId": 0,
"recoveredUTxO": [
-3,
0,
3
-4,
2,
5
],
"tag": "CommitRecovered"
},
Expand Down Expand Up @@ -3059,7 +3075,14 @@
},
{
"headId": "02030000080303040201040004080208",
"recoveredUTxO": [],
"recoveredTxId": -2,
"recoveredUTxO": [
-5,
-1,
2,
5,
6
],
"tag": "CommitRecovered"
},
{
Expand Down Expand Up @@ -3156,11 +3179,8 @@
},
{
"headId": "00060804060003070301080308060705",
"recoveredTxId": -6,
"recoveredUTxO": [
-6,
-4,
-3,
-2,
0
],
"tag": "CommitRecovered"
Expand Down
3,239 changes: 1,800 additions & 1,439 deletions hydra-node/golden/ReasonablySized (TimedServerOutput (Tx ConwayEra)).json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions hydra-node/json-schemas/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,7 @@ components:
type: string
enum: ["Recover"]
recoverTxId:
type: object
$ref: "api.yaml#/components/schemas/TxId"
type: string
Decommit:
title: Decommit
description: |
Expand Down Expand Up @@ -1350,6 +1349,7 @@ components:
- tag
- headId
- recoveredUTxO
- recoveredTxId
- seq
- timestamp
properties:
Expand All @@ -1360,6 +1360,8 @@ components:
$ref: "api.yaml#/components/schemas/HeadId"
recoveredUTxO:
$ref: "api.yaml#/components/schemas/UTxO"
recoveredTxId:
type: string
seq:
$ref: "api.yaml#/components/schemas/SequenceNumber"
timestamp:
Expand Down Expand Up @@ -1732,11 +1734,9 @@ components:
headId:
$ref: "api.yaml#/components/schemas/HeadId"
recoverTxId:
$ref: "api.yaml#/components/schemas/TxIn"
type: string
utxoToDeposit:
oneOf:
- type: "null"
- $ref: "api.yaml#/components/schemas/UTxO"
$ref: "api.yaml#/components/schemas/UTxO"
deadline:
$ref: "api.yaml#/components/schemas/ChainSlot"
- title: IncrementTx
Expand Down Expand Up @@ -1764,7 +1764,7 @@ components:
depositScriptUTxO:
$ref: "api.yaml#/components/schemas/UTxO"
depositTxId:
$ref: "api.yaml#/components/schemas/TxId"
type: string
- title: DecrementTx
type: object
additionalProperties: false
Expand Down
62 changes: 34 additions & 28 deletions hydra-node/json-schemas/logs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,24 @@ definitions:
newVersion:
$ref: "api.yaml#/components/schemas/SnapshotVersion"
depositTxId:
$ref: "api.yaml#/components/schemas/TxId"
type: string
- title: "CommitRecovered"
additionalProperties: false
required:
- tag
- recoveredUTxO
- newLocalUTxO
- recoveredTxId
properties:
tag:
type: string
enum: ["CommitRecovered"]
recoveredUTxO:
$ref: "api.yaml#/components/schemas/UTxO"
newLocalUTxO:
$ref: "api.yaml#/components/schemas/UTxO"
recoveredTxId:
type: string
- title: "DecommitRecorded"
additionalProperties: false
required:
Expand Down Expand Up @@ -2029,8 +2046,10 @@ definitions:
required:
- tag
- headId
- utxo
- deposited
- depositTxId
- deadline
- depositScriptUTxO
description: >-
The deposit transaction locking some UTxO to a deposit script.
properties:
Expand All @@ -2039,17 +2058,22 @@ definitions:
enum: ["OnDepositTx"]
headId:
$ref: "api.yaml#/components/schemas/HeadId"
utxo:
$ref: "api.yaml#/components/schemas/UTxO"
deposited:
$ref: "api.yaml#/components/schemas/UTxO"
depositTxId:
type: string
deadline:
$ref: "api.yaml#/components/schemas/UTCTime"
depositScriptUTxO:
$ref: "api.yaml#/components/schemas/UTxO"
- title: OnRecoverTx
type: object
additionalProperties: false
required:
- tag
- headId
- recoveredUTxO
- recoveredTxId
description: >-
The recover transaction unlocking the deposited UTxO.
properties:
Expand All @@ -2060,14 +2084,16 @@ definitions:
$ref: "api.yaml#/components/schemas/HeadId"
recoveredUTxO:
$ref: "api.yaml#/components/schemas/UTxO"
recoveredTxId:
type: string
- title: OnIncrementTx
type: object
additionalProperties: false
required:
- tag
- headId
- committedUTxO
- depositScriptUTxO
- newVersion
- depositTxId
description: >-
The increment transaction adding some UTxO from L1 into the Head.
properties:
Expand All @@ -2078,10 +2104,8 @@ definitions:
$ref: "api.yaml#/components/schemas/HeadId"
newVersion:
$ref: "api.yaml#/components/schemas/SnapshotVersion"
committedUTxO:
$ref: "api.yaml#/components/schemas/UTxO"
depositScriptUTxO:
$ref: "api.yaml#/components/schemas/UTxO"
depositTxId:
type: string
- title: OnCommitTx
type: object
additionalProperties: false
Expand Down Expand Up @@ -2115,24 +2139,6 @@ definitions:
enum: ["OnAbortTx"]
headId:
$ref: "api.yaml#/components/schemas/HeadId"
- title: OnDepositTx
type: object
additionalProperties: false
required:
- tag
- headId
- utxo
- deposited
properties:
tag:
type: string
enum: ["OnDepositTx"]
headId:
$ref: "api.yaml#/components/schemas/HeadId"
utxo:
$ref: "api.yaml#/components/schemas/UTxO"
deposited:
$ref: "api.yaml#/components/schemas/UTxO"
- title: OnIncrementTx
type: object
additionalProperties: false
Expand Down
9 changes: 0 additions & 9 deletions hydra-node/src/Hydra/Chain/Direct/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,6 @@ commit' ctx headId spendableUTxO commitBlueprintTx = do
hasMatchingPT pid val =
selectAsset val (AssetId pid (AssetName (serialiseToRawBytes vkh))) == 1

incrementalCommit ::
ChainContext ->
HeadId ->
-- | Spendable 'UTxO'
UTxO ->
CommitBlueprintTx Tx ->
Either (PostTxError Tx) Tx
incrementalCommit = error "not implemented yet"

rejectByronAddress :: UTxO -> Either (PostTxError Tx) ()
rejectByronAddress u = do
forM_ u $ \case
Expand Down
10 changes: 1 addition & 9 deletions hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -320,17 +320,9 @@ onOpenNetworkReqTx ::
onOpenNetworkReqTx env ledger st ttl tx =
-- Keep track of transactions by-id
(newState TransactionReceived{tx} <>) $
-- Spec: wait L̂ ◦ tx ≠ ⊥
-- Spec: wait L̂ ◦ tx ≠ ⊥

-- Spec: wait L̂ ◦ tx ≠ ⊥
waitApplyTx $ \newLocalUTxO ->
(cause (ClientEffect $ ServerOutput.TxValid headId tx) <>) $
-- Spec: T̂ ← T̂ ⋃ {tx}
-- Spec: T̂ ← T̂ ⋃ {tx}
-- L̂ ← L̂ ◦ tx
-- L̂ ← L̂ ◦ tx

-- Spec: T̂ ← T̂ ⋃ {tx}
-- L̂ ← L̂ ◦ tx
newState TransactionAppliedToLocalUTxO{tx, newLocalUTxO}
Expand Down Expand Up @@ -685,7 +677,7 @@ onOpenNetworkAckSn Environment{party} openState otherParty snapshotSignature sn
else outcome

maybePostIncrementTx snapshot@Snapshot{utxoToCommit} signatures outcome =
case find (\(_, (utxoToDeposit, _, _)) -> Just utxoToDeposit == utxoToCommit) (Map.assocs pendingDeposits) of
case find (\(_, (depositedUTxO, _, _)) -> Just depositedUTxO == utxoToCommit) (Map.assocs pendingDeposits) of
Just (depositTxId, (commitUTxOFromState, depositScriptUTxO, _)) ->
outcome
<> causes
Expand Down
6 changes: 3 additions & 3 deletions hydra-node/src/Hydra/HeadLogic/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ instance (ArbitraryIsTx tx, Arbitrary (ChainStateType tx)) => Arbitrary (OpenSta
<*> arbitrary
<*> arbitrary

-- | Pending deposits are a map from the deposit input to the triple of UTxO is
-- the one user wants to deposit, deposit script UTxO to be spent in the
-- increment transaction and the deadline
-- | Pending deposits are a map from the deposit input to the triple of: UTxO
-- the user wants to deposit, deposit script UTxO to be spent in the
-- increment transaction and a deadline
type PendingDeposits tx = Map (TxIdType tx) (UTxOType tx, UTxOType tx, UTCTime)

-- | Off-chain state of the Coordinated Head protocol.
Expand Down
3 changes: 1 addition & 2 deletions hydra-plutus/src/Hydra/Contract/Head.hs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ checkDecrement ctx openBefore redeemer =
&& mustBeSignedByParticipant ctx prevHeadId
where
checkSnapshotSignature =
-- TODO: introduce emptyHash instead of hashTxOuts [] ?
verifySnapshotSignature nextParties (nextHeadId, prevVersion, snapshotNumber, nextUtxoHash, hashTxOuts [], decommitUtxoHash) signature
verifySnapshotSignature nextParties (nextHeadId, prevVersion, snapshotNumber, nextUtxoHash, emptyHash, decommitUtxoHash) signature

mustDecreaseValue =
traceIfFalse $(errorCode HeadValueIsNotPreserved) $
Expand Down

0 comments on commit 44f4da7

Please sign in to comment.