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

expand MissingRequiredDatums failure details #2342

Merged
merged 1 commit into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ data AlonzoPredFail era
= WrappedShelleyEraFailure !(UtxowPredicateFailure era)
| UnRedeemableScripts ![(ScriptPurpose (Crypto era), ScriptHash (Crypto era))]
| MissingRequiredDatums
!(Set (DataHash (Crypto era)))
!(Set (DataHash (Crypto era))) -- Set of missing data hashes
!(Set (DataHash (Crypto era))) -- Set of received data hashes
| PPViewHashesDontMatch
!(StrictMaybe (WitnessPPDataHash (Crypto era)))
-- ^ The PPHash in the TxBody
Expand Down Expand Up @@ -147,7 +148,7 @@ encodePredFail ::
Encode 'Open (AlonzoPredFail era)
encodePredFail (WrappedShelleyEraFailure x) = Sum WrappedShelleyEraFailure 0 !> E toCBOR x
encodePredFail (UnRedeemableScripts x) = Sum UnRedeemableScripts 1 !> To x
encodePredFail (MissingRequiredDatums x) = Sum MissingRequiredDatums 2 !> To x
encodePredFail (MissingRequiredDatums x y) = Sum MissingRequiredDatums 2 !> To x !> To y
encodePredFail (PPViewHashesDontMatch x y) = Sum PPViewHashesDontMatch 3 !> To x !> To y
encodePredFail (MissingRequiredSigners x) = Sum MissingRequiredSigners 4 !> To x
encodePredFail (UnspendableUTxONoDatumHash x) = Sum UnspendableUTxONoDatumHash 5 !> To x
Expand All @@ -172,7 +173,7 @@ decodePredFail ::
Decode 'Open (AlonzoPredFail era)
decodePredFail 0 = SumD WrappedShelleyEraFailure <! D fromCBOR
decodePredFail 1 = SumD UnRedeemableScripts <! From
decodePredFail 2 = SumD MissingRequiredDatums <! From
decodePredFail 2 = SumD MissingRequiredDatums <! From <! From
decodePredFail 3 = SumD PPViewHashesDontMatch <! From <! From
decodePredFail 4 = SumD MissingRequiredSigners <! From
decodePredFail 5 = SumD UnspendableUTxONoDatumHash <! From
Expand Down Expand Up @@ -270,7 +271,7 @@ alonzoStyleWitness = do
let txHashes = domain (unTxDats . txdats . wits $ tx)
inputHashes = Set.fromList utxoHashes
unmatchedInputHashes = eval (inputHashes ➖ txHashes)
Set.null unmatchedInputHashes ?! MissingRequiredDatums unmatchedInputHashes
Set.null unmatchedInputHashes ?! MissingRequiredDatums unmatchedInputHashes txHashes
{- ∀ sph ∈ scriptsNeeded utxo tx, checkScriptData tx utxo ph -}
let sphs :: [(ScriptPurpose (Crypto era), ScriptHash (Crypto era))]
sphs = scriptsNeeded utxo tx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ instance Mock c => Arbitrary (AlonzoPredFail (AlonzoEra c)) where
oneof
[ WrappedShelleyEraFailure <$> arbitrary,
UnRedeemableScripts <$> arbitrary,
MissingRequiredDatums <$> arbitrary,
MissingRequiredDatums <$> arbitrary <*> arbitrary,
PPViewHashesDontMatch <$> arbitrary <*> arbitrary
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,7 @@ alonzoUTXOWexamples =
( Left
[ [ MissingRequiredDatums
(Set.singleton $ hashData @A datumExample1)
mempty
]
]
),
Expand Down