Skip to content

Commit

Permalink
Allow committing reference scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch authored and Sasha Bogicevic committed Apr 17, 2024
1 parent d2959d6 commit 1a1db19
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
12 changes: 0 additions & 12 deletions hydra-node/src/Hydra/Chain/Direct/State.hs
Expand Up @@ -368,9 +368,7 @@ commit' ::
commit' ctx headId spendableUTxO utxoToCommit blueprintTx = do
pid <- headIdToPolicyId headId ?> InvalidHeadId{headId}
(i, o) <- ownInitial pid ?> CannotFindOwnInitial{knownUTxO = spendableUTxO}
-- FIXME: not all outputs in utxoToCommit are necessarily commited, they could also be reference inputs to the blueprintTx
rejectByronAddress utxoToCommit
rejectReferenceScripts utxoToCommit
rejectMoreThanMainnetLimit networkId utxoToCommit
pure $ commitTx networkId scriptRegistry headId ownParty utxoToCommit blueprintTx (i, o, vkh)
where
Expand All @@ -392,16 +390,6 @@ rejectByronAddress u = do
(TxOut ShelleyAddressInEra{} _ _ _) ->
Right ()

rejectReferenceScripts :: UTxO -> Either (PostTxError Tx) ()
rejectReferenceScripts u =
when (any hasReferenceScript u) $
Left CannotCommitReferenceScript
where
hasReferenceScript out =
case txOutReferenceScript out of
ReferenceScript{} -> True
ReferenceScriptNone -> False

-- Rejects outputs with more than 'maxMainnetLovelace' lovelace on mainnet
-- NOTE: Remove this limit once we have more experiments on mainnet.
rejectMoreThanMainnetLimit :: NetworkId -> UTxO -> Either (PostTxError Tx) ()
Expand Down
10 changes: 0 additions & 10 deletions hydra-node/test/Hydra/Chain/Direct/StateSpec.hs
Expand Up @@ -274,16 +274,6 @@ spec = parallel $ do
Left UnsupportedLegacyOutput{} -> property True
_ -> property False

prop "reject committing outputs with reference scripts" $
monadicST $ do
hctx <- pickBlind $ genHydraContext maximumNumberOfParties
(ctx, stInitial@InitialState{headId}) <- pickBlind $ genStInitial hctx
utxo <- pick $ genUTxO1 genTxOutWithReferenceScript
pure $
case commit ctx headId (getKnownUTxO stInitial) utxo of
Left CannotCommitReferenceScript{} -> property True
_ -> property False

prop "reject Commits with more than maxMainnetLovelace Lovelace" $
monadicST $ do
hctx <- pickBlind $ genHydraContext maximumNumberOfParties
Expand Down

0 comments on commit 1a1db19

Please sign in to comment.