Skip to content

Commit

Permalink
Add deadline information
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed Oct 14, 2024
1 parent 114a9cb commit fed456a
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 555 deletions.

Large diffs are not rendered by default.

237 changes: 179 additions & 58 deletions hydra-node/golden/ServerOutput/CommitRecorded.json
Original file line number Diff line number Diff line change
@@ -1,121 +1,242 @@
{
"samples": [
{
"headId": "a310bc2d25324513509751f4bb3fc64c",
"pendingDeposit": "4f64b4e501caa23c9868dfa77e9c6ee13f36969ecce3c0e5b018f10c6175146e",
"deadline": "1864-05-09T12:43:39.421430191425Z",
"headId": "68595f07802a421aa17be13e73dbdd9d",
"pendingDeposit": "a558c7a694517116ce06e5375bc253b7557e7acef6248082932fda63ef0bd77b",
"tag": "CommitRecorded",
"utxoToCommit": {
"1da0dda3c32c4188cf2df93fe03d79bcfbcb23dfd3bb2d9fef70e2cc1920623c#95": {
"address": "addr_test1vzehkwgdc93pf4tjdql86vctp5ddnhgnettcjnwrf22pumq8ru47t",
"2f49e79a9a8b7450962948ff0ffdb9c9420897651c471913786c4e1f92d0a72a#87": {
"address": "EqGAuA8vHnPDeqbWGxyPcLX9YD8ut1pUibNcwwbKZQAoUExgLTRqPpefb44LFFW4agxCag4X4h18cPxjSQ987JER9gunoFUiZ2zKjnPqhLEfRtBJMR4qY9B",
"datum": null,
"datumhash": "cb10ea9ced49987dc85a81309d778fb2796a9364cf611835e7f02b975fc25512",
"inlineDatum": null,
"inlineDatumRaw": null,
"inlineDatum": {
"bytes": ""
},
"inlineDatumRaw": "40",
"inlineDatumhash": "39df024ac52722fe8ae4c1a8740e4c5624a38c3820e504a059aae8728421f8bd",
"referenceScript": null,
"value": {
"3e90ca095d09c8bb04e8624109d8f8fbbdd27c0ea33bf66bfd3e3bdd": {
"ad28596723f573b811731b64832247512ff2d4dee2fb188638cea5dbcffc3c": 4166921036024893347
},
"lovelace": 1
}
},
"35ef95a478e2d352118109ce8d4a7b45ab7f460590d6ec2420638e4e7a0b43c1#86": {
"address": "addr_test1yq4tdvz9y9pfnz62eh4d5ysvf64xrhsnxgesgld67z075skdhgqqnewsmlm4jzmg8tyrrdqp0uw7zfkxzrz8plpd56fs8fef4a",
"datum": null,
"inlineDatum": {
"int": -3
},
"inlineDatumRaw": "22",
"inlineDatumhash": "95c3003a78585e0db8c9496f6deef4de0ff000994b8534cd66d4fe96bb21ddd3",
"referenceScript": {
"script": {
"cborHex": "8200581c0e7348ec87874ba5575511441ecf51682824821fff97427d1c5c146f",
"cborHex": "484701000022200101",
"description": "",
"type": "SimpleScript"
"type": "PlutusScriptV1"
},
"scriptLanguage": "SimpleScriptLanguage"
"scriptLanguage": "PlutusScriptLanguage PlutusScriptV1"
},
"value": {
"105a8f1bb56444cacc86378c95421aceeb326b0fb7743e493eb82fd5": {
"e2617282dec669eeb94cd323ebc20643a7e3b0dde5a3b5f8a9cb0e1e": 2
"8f461954fe2f18fee1dca233f358907e643ff839ed1f995e4bf325e3": {
"cb61fe9ce2458e7d4e8ece6719a9eee0cd1a6dee": 5529673388420696061,
"f96e0464324b3f08595b": 2
},
"66a2c11d762fe8e6e84a92878fd61a1fc944d600f2b4e1ee7c86cfa0": {
"f5b2d8bafb5e9fbd": 5474725707454191587
"cdc4b664504b61069f85b3aa795aa687b09423a8f2f925ec3d559a20": {
"847b69": 2
},
"lovelace": 1
"lovelace": 4926645793686556066
}
},
"3dec6e0f8ab16b95b7773d9f4b1e8ae59f40073552ffb989dc11b440f323d832#69": {
"address": "addr_test1qqyfep92ncd0002qt3gnxpcycd4kcunrk3r0kzmshl0r67ae335p9qhv86m7sgjz3fpcnvf5rnt2cllra87mcmsu0ejq73cpcq",
"3e928f973bb42c4460e61f9312deb353f5da31392c04676f700a85f1482866b9#98": {
"address": "addr_test1qzkvpzjdjhpcl6kdxsj39s0jg2ackqew5ssjtqqfvc8725v6cdmcnumz38q78cqr6gstty0hrpqlp363wd8tqpeaqumqypdyr8",
"datum": null,
"datumhash": "dd390e6fb883784d7cbffc39169956ad88baa269be5b925410d30603229d7185",
"datumhash": null,
"inlineDatum": null,
"inlineDatumRaw": null,
"referenceScript": {
"script": {
"cborHex": "8200581c21f442aebd65b497718e97c1cf64adcefb14f4a8c3530b152a9c3982",
"cborHex": "46450100002261",
"description": "",
"type": "SimpleScript"
"type": "PlutusScriptV2"
},
"scriptLanguage": "SimpleScriptLanguage"
"scriptLanguage": "PlutusScriptLanguage PlutusScriptV2"
},
"value": {
"8f461954fe2f18fee1dca233f358907e643ff839ed1f995e4bf325e3": {
"fb3abff7b436c54b7bcb7c9353fe931900518149e7c7941b38ed": 1
"2d725128406dc832eb74c4709aca0512499b3c7b17e00d7cb2e6d1b1": {
"27033b77c6": 7088478949785575952,
"7340b60da6f0ff93cdc9d37c4e87c7": 314982647972728306
},
"lovelace": 1
}
},
"8f1b3d6858bbc533dc34ecb72cb22d433325f4a43cbe18a6e8530d3ac1d91fd1#97": {
"address": "addr1vxg2kk38zscl853v7x39cwyezk8lqtew6e8htwexh9xkqfs2wpqha",
"9574a8926e32d8ac24540f74b48859a9e9345a096d21802d93d3b417d68944cf#42": {
"address": "addr1qx8m4xr7edxa23wc7ag6hjcrylha3ulsu3lznpame5y6c7q07n5yecpdwwe9gr26a34r77lgpwlpyqswpp3gttwr4uhsc8620y",
"datum": null,
"datumhash": null,
"inlineDatum": null,
"inlineDatumRaw": null,
"referenceScript": {
"script": {
"cborHex": "820180",
"cborHex": "8202818201848201818200581c26ea8a0d6509e3d7f471123a1b0dc3a6a843079c3cb121da165f4da98200581c8e698aec477571d81f19f7281bb6c4766dc48512e5e3ed6bb726f4478202838200581cec216502686d9a47b084d83d54f897137ed0d1f220a9e1af1b7621ff8200581cea423c09d4b9de047c0a27abe6cd05a40d75ce604de0f9d86c9ce80d8200581c6e757d239d4f088bd6e8e83fa8f307ea64a1e22fa64df46c07a9cc648202828200581c176b40c47c7df9f0e452055f8258f2837e8fe973153deb2f6b7468508200581ccfd715fe660733c5be0d3fc95c86785fff8c0899453530745697f134",
"description": "",
"type": "SimpleScript"
},
"scriptLanguage": "SimpleScriptLanguage"
},
"value": {
"abfbdeaa53ab44dfb357a6ce3e22e6d5a6a3b057c838138ad9d1e06a": {
"0a6c2e7ce96e0f504b04a415061b9ea3": 1
"105a8f1bb56444cacc86378c95421aceeb326b0fb7743e493eb82fd5": {
"da2722d8b49c98874b9eafdb59786667b2a0a4743993": 6805035914308588488
},
"724c2e0e0ac7f8c4afa4fa18038fb76e8573f7af644d7bbc88f9e393": {
"32": 1,
"ee991184f582811b6ae5530395b117879ad15414b3963d9cf91e6c": 8934491785691888450
},
"lovelace": 227856113935439342
"lovelace": 5245046578922861563
}
},
"9db584394f7811fc9604dd13b688e864be207fe9d2335334a1abd522916500cb#65": {
"address": "addr1z87fzxxyhv89h3udpnn63auvsmknfgw8h2sa2nj7pccyjzwje7h2m7dzcwjh8f3dx64lwt9haqsdxa7s32naasjdhj3sqz9aw7",
"ba877f246f3fc6b43faf49494562e255c3b9bd37ba54d31e499f2250ebbb1b22#79": {
"address": "addr_test1xqhvxw5x2x3fzzflld0d6wxh0ep92xvh3qjx6e045kd2r206j48rsckpcf5d8t78az6gfv0lc8p4hk7ge07fwlnw2d6qz2evg5",
"datum": null,
"inlineDatum": {
"bytes": "e543"
},
"inlineDatumRaw": "42e543",
"inlineDatumhash": "6042a3d658c0c75e356db89fb69b9e565062e83ac6de36f6cee2f6cc61ce5586",
"datumhash": null,
"inlineDatum": null,
"inlineDatumRaw": null,
"referenceScript": {
"script": {
"cborHex": "8200581cc5dcc6e2c90dab246c5127d1d520ccefc2f9a48f1f213c14ea79e2bb",
"cborHex": "484701000022200101",
"description": "",
"type": "SimpleScript"
"type": "PlutusScriptV2"
},
"scriptLanguage": "SimpleScriptLanguage"
"scriptLanguage": "PlutusScriptLanguage PlutusScriptV2"
},
"value": {
"467f58932b54910584a0e8ea25a225e06a14530b2e96e938c53a3f22": {
"43be3dde54050eb926cafdf2f35be9a9bf8e0d": 4796155671044796811,
"6ffb821096fb40b39dff5c3da0c0ebdcb646c7e6e73bef0117aa": 2
},
"b0c53e2bf180858da4b64eb5598c5615bba7d723d2b604a83b7f9165": {
"84227d5b262ea367a37a5bb8cf5c1df317082ad1af47a0b5f9d1071b968217": 2
"cae0629479deea101b11c2fc2556327dd705b1b5d9a80b8c30673fe1": {
"096d2a6f13c765ffc51832e20d": 2
},
"lovelace": 8258311493319174747
"lovelace": 468764666243078712
}
},
"fdbbd3610eb109f74c9f353c86d4aeafdc9f836091580b73f4cef12f366dffbb#96": {
"address": "addr1qyhfs7a6mvqg928ujduydtj26mrh6g9tm78da35q03w6ch6p6nx3grpkwzqdu5z0a2jh69n3e2adqqa76u5lkm33ssaquklpmr",
"bad5ae8bf9b1d6adc5be11ae170cc7001aaad70d242f41bcdfdce0e21afe753d#44": {
"address": "addr1z9lf2lp6lwhdzs5uzy6cctxgv7m2ns49fkhrwfuq4ek7t709gkpxw6kk9yxnsdndpt3r3pcs6v0jz3yhvp0kh6erxngsmsfcej",
"datum": null,
"inlineDatum": {
"int": 3
"list": [
{
"map": []
},
{
"map": [
{
"k": {
"int": 2
},
"v": {
"int": -4
}
},
{
"k": {
"map": [
{
"k": {
"bytes": "6363ba"
},
"v": {
"int": -2
}
},
{
"k": {
"bytes": "135f30"
},
"v": {
"bytes": "070913"
}
},
{
"k": {
"bytes": "ecf0"
},
"v": {
"bytes": "7c"
}
}
]
},
"v": {
"map": [
{
"k": {
"int": 4
},
"v": {
"bytes": "fb"
}
},
{
"k": {
"int": 0
},
"v": {
"bytes": "aa5f"
}
}
]
}
}
]
},
{
"int": -3
},
{
"list": [
{
"constructor": 1,
"fields": [
{
"int": 4
},
{
"bytes": "6f8796"
},
{
"bytes": "d76c"
},
{
"bytes": ""
},
{
"int": 5
}
]
}
]
},
{
"bytes": "cb"
}
]
},
"inlineDatumRaw": "9fa0a20223a3436363ba2143135f304307091342ecf0417ca20441fb0042aa5f229fd87a9f04436f879642d76c4005ffff41cbff",
"inlineDatumhash": "f6f122d4dbeb95e127118acadfcfa82ebbe8d5b6b51a6556915a074cc4f35cdd",
"referenceScript": {
"script": {
"cborHex": "82041a004b9d8f",
"description": "",
"type": "SimpleScript"
},
"scriptLanguage": "SimpleScriptLanguage"
},
"inlineDatumRaw": "03",
"inlineDatumhash": "e88bd757ad5b9bedf372d8d3f0cf6c962a469db61a265f6418e1ffed86da29ec",
"referenceScript": null,
"value": {
"245d5a7a06fe18358242e81281cd5ba9e6abe4efc54e7b659f25abae": {
"34": 1,
"3eb620367fee3857be367297e059a9509770": 3
"3bb3488685ba2f7c6bbf441c470f4aa2207d7ebe6da370c9a3a3ae93": {
"b0fb19cef89a441c47f8f6820b406bfcb1a5283774f982f2ad8609b2a9564bc8": 2
},
"aba763f6ea5f4ed49795829c4773dd4dc7ec9dcc3ee376f0d80dbeed": {
"30": 1
"8f461954fe2f18fee1dca233f358907e643ff839ed1f995e4bf325e3": {
"f744ee": 1
},
"lovelace": 1
"lovelace": 8050092423291003290
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions hydra-node/json-schemas/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@ components:
- headId
- utxoToCommit
- pendingDeposit
- deadline
- seq
- timestamp
properties:
Expand All @@ -1364,6 +1365,8 @@ components:
$ref: "api.yaml#/components/schemas/UTxO"
pendingDeposit:
type: string
deadline:
$ref: "api.yaml#/components/schemas/UTCTime"
seq:
$ref: "api.yaml#/components/schemas/SequenceNumber"
timestamp:
Expand Down
4 changes: 2 additions & 2 deletions hydra-node/src/Hydra/API/ServerOutput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ data ServerOutput tx
| DecommitRequested {headId :: HeadId, decommitTx :: tx, utxoToDecommit :: UTxOType tx}
| DecommitInvalid {headId :: HeadId, decommitTx :: tx, decommitInvalidReason :: DecommitInvalidReason tx}
| DecommitApproved {headId :: HeadId, decommitTxId :: TxIdType tx, utxoToDecommit :: UTxOType tx}
| CommitRecorded {headId :: HeadId, utxoToCommit :: UTxOType tx, pendingDeposit :: TxIdType tx}
| CommitRecorded {headId :: HeadId, utxoToCommit :: UTxOType tx, pendingDeposit :: TxIdType tx, deadline :: UTCTime}
| CommitApproved {headId :: HeadId, utxoToCommit :: UTxOType tx}
| DecommitFinalized {headId :: HeadId, decommitTxId :: TxIdType tx}
| CommitFinalized {headId :: HeadId, theDeposit :: TxIdType tx}
Expand Down Expand Up @@ -197,7 +197,7 @@ instance (ArbitraryIsTx tx, IsChainState tx) => Arbitrary (ServerOutput tx) wher
IgnoredHeadInitializing{} -> []
DecommitRequested headId txid u -> DecommitRequested headId txid <$> shrink u
DecommitInvalid{} -> []
CommitRecorded headId u txId -> CommitRecorded headId <$> shrink u <*> shrink txId
CommitRecorded headId u txId d -> CommitRecorded headId <$> shrink u <*> shrink txId <*> shrink d
CommitApproved headId u -> CommitApproved headId <$> shrink u
DecommitApproved headId txid u -> DecommitApproved headId txid <$> shrink u
CommitRecovered headId u rid -> CommitRecovered headId <$> shrink u <*> shrink rid
Expand Down
4 changes: 2 additions & 2 deletions hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -941,12 +941,12 @@ onOpenChainDepositTx ::
-- | Deposit deadline
UTCTime ->
Outcome tx
onOpenChainDepositTx headId env st deposited depositTxId _deadline =
onOpenChainDepositTx headId env st deposited depositTxId deadline =
-- TODO: We should check for deadline and only request snapshots that have deadline further in the future so
-- we don't end up with a snapshot that is already outdated.
waitOnUnresolvedDecommit $
newState CommitRecorded{pendingDeposits = Map.singleton depositTxId deposited, newLocalUTxO = localUTxO <> deposited}
<> cause (ClientEffect $ ServerOutput.CommitRecorded{headId, utxoToCommit = deposited, pendingDeposit = depositTxId})
<> cause (ClientEffect $ ServerOutput.CommitRecorded{headId, utxoToCommit = deposited, pendingDeposit = depositTxId, deadline})
<> if not snapshotInFlight && isLeader parameters party nextSn
then
cause (NetworkEffect $ ReqSn version nextSn (txId <$> localTxs) Nothing (Just deposited))
Expand Down
Loading

0 comments on commit fed456a

Please sign in to comment.