From 91d8d9586d40cc373efd81dc1482419be1f363ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joosep=20J=C3=A4=C3=A4ger?= Date: Tue, 1 Oct 2024 15:43:45 +0300 Subject: [PATCH] Improved hashing in conformance testing --- cabal.project | 4 +- .../Cardano/Ledger/Conformance/Orphans.hs | 6 +++ .../Conformance/SpecTranslate/Conway/Base.hs | 38 ++++++++++--------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/cabal.project b/cabal.project index 714de50cb86..25eeb0addb1 100644 --- a/cabal.project +++ b/cabal.project @@ -24,8 +24,8 @@ source-repository-package -- !WARNING!: -- MAKE SURE THIS POINTS TO A COMMIT IN `MAlonzo-code` BEFORE MERGE! subdir: generated - tag: 0b0b1f4eddb718b704824dcdc86abb8ce815deb2 - --sha256: sha256-+bpsxn1hPGZqJ0rwZmUaPlOJuRj0RzLj1rulldUqk/E= + tag: d5c32e238236e6e2a3941551b4512e117e399271 + --sha256: sha256-bi4+bXqi8n2BQM4+9uwwaDsm3nblg15Cj+9IvNGTkPI= -- NOTE: If you would like to update the above, look for the `MAlonzo-code` -- branch in the `formal-ledger-specifications` repo and copy the SHA of -- the commit you need. The `MAlonzo-code` branch functions like an alternative diff --git a/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/Orphans.hs b/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/Orphans.hs index 7438415b4c0..ab980df7b3d 100644 --- a/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/Orphans.hs +++ b/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/Orphans.hs @@ -60,6 +60,8 @@ instance NFData BootstrapAddr instance NFData Timelock +instance NFData HashedTimelock + instance NFData UTxOState instance NFData Vote @@ -186,6 +188,8 @@ instance ToExpr BootstrapAddr instance ToExpr Timelock +instance ToExpr HashedTimelock + instance ToExpr TxBody instance ToExpr Tag @@ -277,6 +281,8 @@ instance FixupSpecRep BootstrapAddr instance FixupSpecRep Timelock +instance FixupSpecRep HashedTimelock + instance FixupSpecRep UTxOState instance FixupSpecRep Credential diff --git a/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/SpecTranslate/Conway/Base.hs b/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/SpecTranslate/Conway/Base.hs index 4d1e205cfc1..92e71258dff 100644 --- a/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/SpecTranslate/Conway/Base.hs +++ b/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/SpecTranslate/Conway/Base.hs @@ -217,23 +217,25 @@ instance ) => SpecTranslate ctx (Timelock era) where - type SpecRep (Timelock era) = Agda.Timelock - - toSpecRep = - \case - RequireSignature kh -> - Agda.RequireSig <$> toSpecRep kh - RequireAllOf ss -> do - tls <- traverse toSpecRep ss - pure . Agda.RequireAllOf $ toList tls - RequireAnyOf ss -> do - tls <- traverse toSpecRep ss - pure . Agda.RequireAnyOf $ toList tls - RequireMOf m ss -> do - tls <- traverse toSpecRep ss - pure . Agda.RequireMOf (toInteger m) $ toList tls - RequireTimeExpire slot -> Agda.RequireTimeExpire <$> toSpecRep slot - RequireTimeStart slot -> Agda.RequireTimeStart <$> toSpecRep slot + type SpecRep (Timelock era) = Agda.HashedTimelock + + toSpecRep tl = Agda.HashedTimelock <$> timelockToSpecRep tl <*> undefined + where + timelockToSpecRep x = + case x of + RequireSignature kh -> + Agda.RequireSig <$> toSpecRep kh + RequireAllOf ss -> do + tls <- traverse timelockToSpecRep ss + pure . Agda.RequireAllOf $ toList tls + RequireAnyOf ss -> do + tls <- traverse timelockToSpecRep ss + pure . Agda.RequireAnyOf $ toList tls + RequireMOf m ss -> do + tls <- traverse timelockToSpecRep ss + pure . Agda.RequireMOf (toInteger m) $ toList tls + RequireTimeExpire slot -> Agda.RequireTimeExpire <$> toSpecRep slot + RequireTimeStart slot -> Agda.RequireTimeStart <$> toSpecRep slot instance ( AlonzoEraScript era @@ -261,7 +263,7 @@ instance instance ( EraTxOut era , SpecRep (Value era) ~ Agda.Coin - , SpecRep (Script era) ~ Either Agda.Timelock () + , Script era ~ AlonzoScript era , SpecTranslate ctx (Value era) , SpecTranslate ctx (Script era) ) =>