Skip to content

Commit

Permalink
PR review changes
Browse files Browse the repository at this point in the history
Signed-off-by: Sasha Bogicevic <[email protected]>
  • Loading branch information
v0d1ch committed Sep 5, 2024
1 parent bcf1fdd commit 4fd36c2
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 64 deletions.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@ onOpenNetworkReqTx env ledger st ttl tx =
-- Spec: wait L̂ ◦ tx ≠ ⊥
waitApplyTx $ \newLocalUTxO ->
(cause (ClientEffect $ ServerOutput.TxValid headId tx) <>) $
-- Spec: T̂ ← T̂ ⋃ {tx}
-- L̂ ← L̂ ◦ tx

-- Spec: T̂ ← T̂ ⋃ {tx}
-- L̂ ← L̂ ◦ tx
newState TransactionAppliedToLocalUTxO{tx, newLocalUTxO}
Expand Down Expand Up @@ -415,8 +412,6 @@ onOpenNetworkReqSn env ledger st otherParty sv sn requestedTxIds mDecommitTx =
requireReqSn $
-- Spec: wait ŝ = ̅S.s
waitNoSnapshotInFlight $
-- Spec: wait v = v̂

-- Spec: wait v = v̂
waitOnSnapshotVersion $
requireApplicableDecommitTx $ \(activeUTxO, mUtxoToDecommit) ->
Expand Down
5 changes: 0 additions & 5 deletions hydra-plutus/scripts/mDeposit.plutus

This file was deleted.

4 changes: 2 additions & 2 deletions hydra-plutus/scripts/vDeposit.plutus
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "PlutusScriptV2",
"description": "hydra-vDeposit-0.18.1-42-gfdb9d672a",
"cborHex": "590ac5590ac20100003233322232332232323232323232323232323232323322323232323232323232323232323232323232322225335333222353007006322225335006101f2153535355005222222222222005220022233553335002213300b4910344303400333573466e2400401808808c4c07124103443033001301c491034430330013300a49010344303500333573466e3cdc9181199a8078019aa8039111111111110051b92302b3028302f004022021102113500122002225335001101a1335738004032646464a666ae68cdc3a400000422440042a666ae68cdc3a400400426424460020066eb4d5d08008980a80b1aab9e00235573a0026ea8008c8c8c94ccd5cd19b87480000084cc8848cc00400c008c8c8c94ccd5cd19b87480000084c8c8c8c8c8c8c8c8c8c8cccccccccccc88888888888848cccccccccccc00403403002c02802402001c01801401000c008cc064070d5d08059980c80e1aba100a3301901f3574201266604aeb94090d5d0804199812bae50243574200e660320366ae84018ccc094081d69aba10053232325333573466e1d20000021332212330010030023232325333573466e1d20000021332212330010030023301e75a6ae84004c074d5d09aba20011302802935573c0046aae74004dd51aba10013232325333573466e1d20000021332212330010030023301e75a6ae84004c074d5d09aba20011302802935573c0046aae74004dd51aba1357440022604a04c6aae78008d55ce8009baa3574200866032eb8d5d080199981280d00b1aba100233302575c02c6ae84004c078d5d09aba2001357440026ae88004d5d10009aba2001357440026ae88004d5d10009aba2001357440026ae880044c060064d55cf0011aab9d00137546ae84004c034d5d09aba20011301501635573c0046aae74004dd5000880e89809248103505435003223232325333573466e1d200000213233322212333001004003002375c6ae84008dd69aba10013006357426ae88004d5d10008980980a1aab9e00235573a0026ea8004c0148c8c8c94ccd5cd19b87480000084cc8848cc00400c008c034d5d08009bae357426ae880044c04804cd55cf0011aab9d00137540026605044244a666ae68cdc480124000204e2a66a002204e44266a05000466a600c2400266e04011200200112001200123232325333573466e1d2000002101415333573466e1d200200210151300f01035573c0046aae74004dd5000911919192999ab9a3370e9000001089110010a999ab9a3370e90010010990911180180218029aba100115333573466e1d2004002112220011300f01035573c0046aae74004dd5000919118011bac00130252233335573e0024046466a04460086ae84008c00cd5d100100811919192999ab9a3370e90000010990911118018029bae357420022a666ae68cdc3a400400426424444600200a600e6ae8400454ccd5cd19b87480100084c848888c008014c028d5d08008a999ab9a3370e900300109909111180200298029aba10011300c00d35573c0046aae74004dd500091919192999ab9a3370e900000109909111111180280418049aba100115333573466e1d20020021321222222230070083009357420022a666ae68cdc3a400800426644244444446600c01201060126ae84004dd71aba1357440022a666ae68cdc3a400c0042664424444444660040120106eb8d5d08009bae357426ae8800454ccd5cd19b87480200084cc8848888888cc004024020dd71aba1001375a6ae84d5d10008a999ab9a3370e90050010891111110020a999ab9a3370e9006001089111111001898058061aab9e00235573a0026ea80048c8c8c94ccd5cd19b87480000084cc8848cc00400c008c014d5d080098039aba135744002260140166aae78008d55ce8009baa00123232325333573466e1d20000021332212330010030023005357420026eb4d5d09aba20011300900a35573c0046aae74004dd500091919192999ab9a3370e900000109bae35742002260100126aae78008d55ce8009baa0013223232325333573466e1d200000213232333322221233330010050040030023232325333573466e1d2000002133221233001003002300c35742002660140166ae84d5d1000898068071aab9e00235573a0026ea8d5d0801999806bae500c35742004646464a666ae68cdc3a4000004224440062a666ae68cdc3a4004004264244460020086eb8d5d08008a999ab9a3370e9002001099091118010021aba10011300d00e35573c0046aae74004dd51aba10013300775c6ae84d5d10009aba200135744002260100126aae78008d55ce8009baa001223232325333573466e1d2002002112200115333573466e1d20000021321223002003300535742002260100126aae78008d55ce8009baa00123232325333573466e1d200000213212230020033005357420022a666ae68cdc3a400400426466644424466600200a0080066eb4d5d08011bad357420026eb4d5d09aba2001357440022600c00e6aae78008d55ce8009baa00123232325333573466e1d20000021321223002003375c6ae8400454ccd5cd19b87480080084c8488c00400cdd71aba10011300500635573c0046aae74004dd5000919319ab9c0010054901035054310013300175ceb488c88c008dd5800980d111999aab9f001201823233501833221233001003002300635573a002600a6aae78004c010d5d10019aba1002005120011220021220013014225335001100b221337146eccd40088888cdd2a400066ae80d401088cdd2a400066ae80c02c008cd5d019806119a800919ba548000cd5d018068009bb10102223374a900119aba0375000666ae80dd400119aba037500026ec4048004dd880719aba033300b75266016ea48dd400080199aba05333500213374a90001bb100c213374a900219aba0001376201a4266e9520023357406ea4004dd880699aba03300a7520026ec4030c0100048cd40048cdd2a400066ae80dd48009bb100523374a900119aba037520026ec4014894cd400484cdd2a400066ae80c00c004dd8802899ba548008dd8802111911ba6300200130132253350011376400a4426a0044466ae80cdd8180400118038009803001a4c601e44a66a002260046006018442a66a0022004442600c600e00a601c44a66a0022016442a66a002200644266a01c6600e008004600c002601a444a66a0042002442a66a006200864442a666a6602200a0042a006266a01e0046601000e0022a006266a0180046600a002006601844a66a00220064426a0044466e28004c01800d22010035003222001350022220023500122200333230010012212323330022300222230030042300222230020042300222230010042353300400400335003001122223330042533500113350060070072215335001133500800300922153233353300d00500315001133300800333500b00500c002150011333006002233500b00500100122253350011335008335008003002300600932221533353300d00600215003133300800233500b0060050011500313350083350080030023006001222532335002130014988854c8ccd4cc03801c00c540044c011261500113330070022300633500c0070010012335009300333500900400a30070021220021221223300100400332223500222350022235005223500222533353300b00600215333573466e1c014004403854ccd5cd19b89005001100c100d13300b00600213300b006002225333573466e3c008004401454ccd5cd19b91002001100310041222003122200212220012323001001230022330020020011"
"description": "hydra-vDeposit-0.18.1-27-g5d6d4b00e",
"cborHex": "590ae4590ae10100003233322232332232323232323232323232323232323322323232323232323232323232323232323232222533533322253353232325333573466e1d2000002112200215333573466e1d20020021321223001003375a6ae840044c05c060d55cf0011aab9d001375400a20326442a6a6a6aa00444444444444400a440044466aa666a00442660109210344303400333573466e24004d401c88800807807c4c061241034430330013018491034430330013300749010344303500333573466e3cdc9180f99a8058019aa8021111111111110051b9230273024302b3500622200101e01d101d1350012200222533500110191335738004030646464a666ae68cdc3a4000004264646464a666ae68cdc3a4000004264666444246660020080060046eb8d5d08011bad35742002600a6ae84d5d10009aba20011301801935573c0046aae74004dd51aba1002300b23232325333573466e1d20000021332212330010030023013357420026eb8d5d09aba20011301801935573c0046aae74004dd50008980a00a9aab9e00235573a0026ea800cc8c8c94ccd5cd19b87480000084cc8848cc00400c008c8c8c94ccd5cd19b87480000084c8c8c8c8c8c8c8c8c8c8cccccccccccc88888888888848cccccccccccc00403403002c02802402001c01801401000c008cc06006cd5d08059980c00d9aba100a3301801e35742012666048eb9408cd5d08041998123ae50233574200e660300346ae84018ccc09007dd69aba10053232325333573466e1d20000021332212330010030023232325333573466e1d20000021332212330010030023301d75a6ae84004c070d5d09aba20011302702835573c0046aae74004dd51aba10013232325333573466e1d20000021332212330010030023301d75a6ae84004c070d5d09aba20011302702835573c0046aae74004dd51aba1357440022604804a6aae78008d55ce8009baa3574200866030eb8d5d080199981200c80a9aba100233302475c02a6ae84004c074d5d09aba2001357440026ae88004d5d10009aba2001357440026ae88004d5d10009aba2001357440026ae880044c05c060d55cf0011aab9d00137546ae84004c030d5d09aba20011301401535573c0046aae74004dd5000880e09808a481035054350033028221225333573466e240092000102715335001102722133502800233530061200133702008900100089000900091919192999ab9a3370e9000001080a0a999ab9a3370e9001001080a898078081aab9e00235573a0026ea800488c8c8c94ccd5cd19b87480000084488800854ccd5cd19b87480080084c84888c00c010c014d5d08008a999ab9a3370e900200108911000898078081aab9e00235573a0026ea80048c88c008dd60009812911999aab9f0012023233502230043574200460066ae880080408c8c8c94ccd5cd19b87480000084c848888c00c014dd71aba100115333573466e1d20020021321222230010053007357420022a666ae68cdc3a400800426424444600400a60146ae8400454ccd5cd19b87480180084c848888c010014c014d5d0800898060069aab9e00235573a0026ea80048c8c8c94ccd5cd19b87480000084c848888888c014020c024d5d08008a999ab9a3370e900100109909111111180380418049aba100115333573466e1d20040021332212222222330060090083009357420026eb8d5d09aba200115333573466e1d2006002133221222222233002009008375c6ae84004dd71aba1357440022a666ae68cdc3a40100042664424444444660020120106eb8d5d08009bad357426ae8800454ccd5cd19b874802800844888888801054ccd5cd19b874803000844888888800c4c02c030d55cf0011aab9d00137540024646464a666ae68cdc3a4000004266442466002006004600a6ae84004c01cd5d09aba20011300a00b35573c0046aae74004dd500091919192999ab9a3370e900000109991091980080180118029aba1001375a6ae84d5d1000898048051aab9e00235573a0026ea80048c8c8c94ccd5cd19b87480000084dd71aba10011300800935573c0046aae74004dd50009911919192999ab9a3370e900000109919199991110919998008028020018011919192999ab9a3370e900000109991091980080180118061aba10013300a00b357426ae880044c034038d55cf0011aab9d00137546ae8400cccc035d728061aba10023232325333573466e1d20000021122200315333573466e1d200200213212223001004375c6ae8400454ccd5cd19b87480100084c84888c008010d5d0800898068071aab9e00235573a0026ea8d5d080099803bae357426ae88004d5d10009aba20011300800935573c0046aae74004dd5000911919192999ab9a3370e900100108910008a999ab9a3370e9000001099091180100198029aba10011300800935573c0046aae74004dd500091919192999ab9a3370e9000001099091180100198029aba100115333573466e1d2002002132333222122333001005004003375a6ae84008dd69aba1001375a6ae84d5d10009aba20011300600735573c0046aae74004dd500091919192999ab9a3370e900000109909118010019bae357420022a666ae68cdc3a400400426424460020066eb8d5d0800898028031aab9e00235573a0026ea80048c98cd5ce000802a481035054310013300175ceb488c88c008dd5800980d111999aab9f001201823233501833221233001003002300635573a002600a6aae78004c010d5d10019aba1002005120011220021220013014225335001100b221337146eccd40088888cdd2a400066ae80d401088cdd2a400066ae80c02c008cd5d019806119a800919ba548000cd5d018068009bb10102223374a900119aba0375000666ae80dd400119aba037500026ec4048004dd880719aba033300b75266016ea48dd400080199aba05333500213374a90001bb100c213374a900219aba0001376201a4266e9520023357406ea4004dd880699aba03300a7520026ec4030c0100048cd40048cdd2a400066ae80dd48009bb100523374a900119aba037520026ec4014894cd400484cdd2a400066ae80c00c004dd8802899ba548008dd8802111911ba6300200130132253350011376400a4426a0044466ae80cdd8180400118038009803001a4c601e44a66a002260046006018442a66a0022004442600c600e00a601c44a66a0022016442a66a002200644266a01c6600e008004600c002601a444a66a0042002442a66a006200864442a666a6602200a0042a006266a01e0046601000e0022a006266a0180046600a002006601844a66a00220064426a0044466e28004c01800d22010035003222001350022220023500122200333230010012212323330022300222230030042300222230020042300222230010042353300400400335003001122223330042533500113350060070072215335001133500800300922153233353300d00500315001133300800333500b00500c002150011333006002233500b00500100122253350011335008335008003002300600932221533353300d00600215003133300800233500b0060050011500313350083350080030023006001222532335002130014988854c8ccd4cc03801c00c540044c011261500113330070022300633500c0070010012335009300333500900400a30070021220021221223300100400332223500222350022235005223500222533353300b00600215333573466e1c014004403854ccd5cd19b89005001100c100d13300b00600213300b006002225333573466e3c008004401454ccd5cd19b91002001100310041222003122200212220012323001001230022330020020011"
}
16 changes: 10 additions & 6 deletions hydra-plutus/src/Hydra/Contract/Deposit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,27 @@ data DepositRedeemer
PlutusTx.unstableMakeIsData ''DepositRedeemer

-- | Deposit datum containing HeadId, deadline and a list of deposits.
type DepositDatum = (CurrencySymbol, POSIXTime, [Commit])
newtype DepositDatum
= DepositDatum (CurrencySymbol, POSIXTime, [Commit])

PlutusTx.unstableMakeIsData ''DepositDatum

-- | v_deposit validator checks
--
-- * Claim redeemer -> no checks are needed
-- * Claim redeemer -> more checks will be added
--
-- * Recover redeemer
-- * The deadline HAS BEEN reached.
-- * The hash of locked outputs are mathing the tx outputs.
-- * The deadline has been reached.
-- * The hash of recovered outputs are matching the deposited outputs.
validator :: DepositDatum -> DepositRedeemer -> ScriptContext -> Bool
validator (_headId, dl, deposits) r ctx =
validator depositDatum r ctx =
case r of
Claim -> True
Claim -> False
Recover m ->
afterDeadline
&& recoverOutputs m
where
DepositDatum (_headId, dl, deposits) = depositDatum
recoverOutputs m =
traceIfFalse $(errorCode IncorrectDepositHash) $
hashOfOutputs m == hashPreSerializedCommits deposits
Expand Down
8 changes: 4 additions & 4 deletions hydra-tx/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Hydra.Prelude
import Cardano.Api.UTxO (UTxO)
import Cardano.Api.UTxO qualified as UTxO
import Data.Aeson (eitherDecodeFileStrict)
import Hydra.Contract.Deposit (DepositDatum)
import Hydra.Contract.Deposit (DepositDatum (..))
import Hydra.Tx.Deposit (depositTx)
import Hydra.Tx.Recover (recoverTx)
import Hydra.Tx.Utils (extractInlineDatumFromTxOut)
Expand All @@ -23,7 +23,7 @@ main = do
let depositTransaction = depositTx networkId headId utxo depositDeadline
writeFileLBS outFile $ textEnvelopeToJSON Nothing depositTransaction
putStrLn $ "Wrote deposit transaction to " <> outFile
Recover RecoverOptions{networkId, headId, outFile, recoverTxIn, utxoFilePath, depositDeadline, recoverSlotNo} -> do
Recover RecoverOptions{networkId, outFile, recoverTxIn, utxoFilePath, recoverSlotNo} -> do
eitherDecodeFileStrict utxoFilePath >>= \case
Left err -> die $ "failed to parse provided UTXO file! " <> err
Right (utxo :: UTxO) -> do
Expand All @@ -32,8 +32,8 @@ main = do
Just depositedTxOut -> do
case extractInlineDatumFromTxOut @DepositDatum depositedTxOut of
Nothing -> die "failed to extract DepositDatum from recover UTxO"
Just (_, _, depositted) -> do
Just (DepositDatum (headCS, datumDepositDeadline, deposited)) -> do
let recoverTransaction =
recoverTx networkId headId recoverTxIn depositted depositDeadline recoverSlotNo
recoverTx networkId headCS recoverTxIn deposited datumDepositDeadline recoverSlotNo
writeFileLBS outFile $ textEnvelopeToJSON Nothing recoverTransaction
putStrLn $ "Wrote deposit transaction to " <> outFile
Loading

0 comments on commit 4fd36c2

Please sign in to comment.