Skip to content

Commit 221eaa8

Browse files
committed
Included the hash in plutus script translation
1 parent 0d20d71 commit 221eaa8

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

cabal.project

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ source-repository-package
2424
-- !WARNING!:
2525
-- MAKE SURE THIS POINTS TO A COMMIT IN `MAlonzo-code` BEFORE MERGE!
2626
subdir: generated
27-
--sha256: sha256-by921yC1MaZI58kyrtEGGKqmt9jMnVsPLfQtP4raJPw=
28-
tag: be51adff014214c15fed718d396bb8a6d955f9e1
27+
--sha256: sha256-/YE/qwup2ijMB7bo5eWyBIM+gXZ3Z1g0NZyNSfRwoPY=
28+
tag: 93041ddbf659e0dbc1981d73fecb439b0209d484
2929

3030
-- NOTE: If you would like to update the above, look for the `MAlonzo-code`
3131
-- branch in the `formal-ledger-specifications` repo and copy the SHA of

libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/ExecSpecRule/Conway/Utxow.hs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ module Test.Cardano.Ledger.Conformance.ExecSpecRule.Conway.Utxow () where
1414

1515
import Cardano.Ledger.Conway (ConwayEra)
1616
import Cardano.Ledger.Conway.TxCert (ConwayTxCert)
17+
import Cardano.Ledger.Conway.UTxO (getConwayWitsVKeyNeeded)
18+
import Cardano.Ledger.Core (EraTx (..))
19+
import Cardano.Ledger.Shelley.LedgerState (UTxOState (..))
1720
import Data.Bifunctor (Bifunctor (..))
1821
import qualified Data.Text as T
22+
import Lens.Micro ((^.))
1923
import qualified Lib as Agda
2024
import qualified Prettyprinter as PP
2125
import Test.Cardano.Ledger.Conformance (
@@ -41,6 +45,7 @@ import Test.Cardano.Ledger.Constrained.Conway (
4145
)
4246
import qualified Test.Cardano.Ledger.Generic.PrettyCore as PP
4347
import Test.Cardano.Ledger.Shelley.Utils (runSTS)
48+
import Test.Cardano.Ledger.TreeDiff (showExpr)
4449

4550
instance
4651
( IsConwayUniv fn
@@ -69,6 +74,12 @@ instance
6974
in
7075
PP.vcat
7176
[ "UTXOW"
77+
, "Impl:"
78+
, "witsVKeyNeeded"
79+
, PP.ppString . showExpr $
80+
getConwayWitsVKeyNeeded @ConwayEra (utxosUtxo st) (sig ^. bodyTxL)
81+
, "witsVKeyHashes"
82+
, "Spec:"
7283
, PP.ppString result
7384
, mempty
7485
, "UTXO"

libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/Orphans.hs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,18 @@ instance NFData LEnv
149149
instance ToExpr a => ToExpr (HSSet a)
150150

151151
instance ToExpr Credential where
152-
toExpr (KeyHashObj h) = App "KeyHashObj" [agdaHashToExpr 28 h, toExpr h]
153-
toExpr (ScriptObj h) = App "ScriptObj" [agdaHashToExpr 28 h, toExpr h]
152+
toExpr (KeyHashObj h) =
153+
App
154+
"KeyHashObj"
155+
[ agdaHashToExpr standardAddrHashSize h
156+
, toExpr h
157+
]
158+
toExpr (ScriptObj h) =
159+
App
160+
"ScriptObj"
161+
[ agdaHashToExpr standardAddrHashSize h
162+
, toExpr h
163+
]
154164

155165
instance (ToExpr k, ToExpr v) => ToExpr (HSMap k v)
156166

libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/SpecTranslate/Conway/Base.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ instance
245245
type SpecRep (AlonzoScript era) = Agda.Script
246246

247247
toSpecRep (TimelockScript s) = Left <$> toSpecRep s
248-
toSpecRep (PlutusScript _) = pure $ Right ()
248+
toSpecRep (PlutusScript s) = Right . (,()) <$> toSpecRep s
249249

250250
instance
251251
( EraTxOut era

libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/Utils.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ module Test.Cardano.Ledger.Conformance.Utils where
66

77
import Cardano.Crypto.Hash (ByteString, Hash, HashAlgorithm, hashFromBytes, hashToBytes, sizeHash)
88
import Cardano.Crypto.Util (bytesToNatural, naturalToBytes)
9-
import Cardano.Ledger.Hashes (HASH)
9+
import Cardano.Ledger.Hashes (ADDRHASH, HASH)
1010
import qualified Data.ByteString.Base16 as B16
1111
import Data.Data (Proxy (..))
1212
import Test.Cardano.Ledger.TreeDiff (Expr, ToExpr (..))
1313

1414
standardHashSize :: Int
1515
standardHashSize = fromIntegral . sizeHash $ Proxy @HASH
1616

17+
standardAddrHashSize :: Int
18+
standardAddrHashSize = fromIntegral . sizeHash $ Proxy @ADDRHASH
19+
1720
agdaHashToBytes :: Int -> Integer -> ByteString
1821
agdaHashToBytes hs = B16.encode . naturalToBytes hs . fromInteger
1922

0 commit comments

Comments
 (0)