From 7717a699a08b065c18a19aee9d3f1fe8b090bb5c Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Wed, 30 Oct 2024 11:39:29 -0400 Subject: [PATCH] Update supplemental datum script to use findDatum --- .../PlutusScripts/SupplementalDatum.hs | 18 ++++++++++-------- cardano-testnet/src/Testnet/Defaults.hs | 3 ++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts/SupplementalDatum.hs b/bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts/SupplementalDatum.hs index 817d0642b8b..34a0ddc7151 100644 --- a/bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts/SupplementalDatum.hs +++ b/bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts/SupplementalDatum.hs @@ -36,9 +36,8 @@ import PlutusTx.Prelude as Tx hiding (Semigroup (..), (.), (<$>)) import Prelude as Haskell (String, (.), (<$>)) import PlutusTx import qualified Data.ByteString.Short as SBS -import qualified PlutusLedgerApi.V1.Scripts as V1 +import qualified PlutusLedgerApi.V3.Contexts as V3 import qualified PlutusLedgerApi.V3 as V3 -import qualified PlutusTx.AssocMap as PlutusTx import qualified PlutusTx.Builtins as PlutusTx import qualified PlutusTx.Prelude as PlutusTx @@ -53,15 +52,18 @@ script = mkPlutusBenchScript scriptName (toScriptInAnyLang (PlutusScript PlutusS {-# INLINABLE typedValidator #-} typedValidator :: V3.ScriptContext -> Bool typedValidator scriptContext = - PlutusTx.elem supplementalDatum datums + PlutusTx.isJust (V3.findDatum supplementalDatumHash txInfo) where txInfo = V3.scriptContextTxInfo scriptContext - datumMap = V3.txInfoData txInfo - datums = PlutusTx.elems datumMap -{-# INLINABLE supplementalDatum #-} -supplementalDatum :: V1.Datum -supplementalDatum = V1.Datum (PlutusTx.mkI 1) +{- On chain we are dealing with raw bytes. You can generate the datum hash from the cli via: +> cardano-cli transaction hash-script-data --script-data-value 1 +> ee155ace9c40292074cb6aff8c9ccdd273c81648ff1149ef36bcea6ebb8a3e25 +However this result is hex encoded. Therefore we have to convert to decimal notation and then use `integerToByteString` to convert to bytes. + -} +{-# INLINABLE supplementalDatumHash #-} +supplementalDatumHash :: V3.DatumHash +supplementalDatumHash = V3.DatumHash $ PlutusTx.integerToByteString PlutusTx.BigEndian 0 107688188478553082748947992068553556338831975613033640413719911361848497815077 untypedValidator :: BuiltinData -> BuiltinUnit untypedValidator ctx = diff --git a/cardano-testnet/src/Testnet/Defaults.hs b/cardano-testnet/src/Testnet/Defaults.hs index 71181f098ad..fc8beba1cfd 100644 --- a/cardano-testnet/src/Testnet/Defaults.hs +++ b/cardano-testnet/src/Testnet/Defaults.hs @@ -545,8 +545,9 @@ plutusV3Script :: Text plutusV3Script = "{ \"type\": \"PlutusScriptV3\", \"description\": \"\", \"cborHex\": \"46450101002499\" }" +-- | Created via: cabal run plutus-scripts-bench -- print SupplementalDatum -o supplemental-datum.plutus plutusV3SupplementalDatumScript :: Text plutusV3SupplementalDatumScript = - "{ \"type\": \"PlutusScriptV3\", \"description\": \"\", \"cborHex\": \"590e59590e560100003233223322323232323232323232323232323232253353010300e35353232325335333573466e1d200000201501413232323232333222123330010040030023232325335333573466e1d200000201d01c1323232323232323232323232323232323333333333332333233233222222222222222212333333333333333300101101000f00e00d00c00b00a00900800700600500400300230013574202860026ae8404cc0948c8c8c94cd4ccd5cd19b87480000080cc0c84cc8848cc00400c008c074d5d080098029aba135744002260589201035054310035573c0046aae74004dd5000998128009aba101123232325335333573466e1d200000203203113232333322221233330010050040030023232325335333573466e1d2000002037036133221233001003002302e357420026605e4646464a66a666ae68cdc3a4000004076074264244600400660646ae8400454cd4ccd5cd19b87480080080ec0e84c8ccc888488ccc00401401000cdd69aba1002375a6ae84004dd69aba1357440026ae880044c0d12401035054310035573c0046aae74004dd50009aba135744002260609201035054310035573c0046aae74004dd51aba1003300735742004646464a66a666ae68cdc3a400000406e06c224440062a66a666ae68cdc3a400400406e06c264244460020086eb8d5d08008a99a999ab9a3370e900200101b81b099091118010021aba1001130304901035054310035573c0046aae74004dd51aba10013302c75c6ae84d5d10009aba200135744002260569201035054310035573c0046aae74004dd50009bad3574201e60026ae84038c008c009d69981180a9aba100c33302702475a6ae8402cc8c8c94cd4ccd5cd19b87480000080c00bc4cc8848cc00400c008c8c8c94cd4ccd5cd19b87480000080cc0c84cc8848cc00400c008cc09dd69aba10013026357426ae880044c0b1241035054310035573c0046aae74004dd51aba10013232325335333573466e1d20000020330321332212330010030023302775a6ae84004c098d5d09aba20011302c491035054310035573c0046aae74004dd51aba13574400226052921035054310035573c0046aae74004dd51aba100a3302375c6ae84024ccc09c8c8c8c94cd4ccd5cd19b87480000080c40c04c84888888c01401cdd71aba100115335333573466e1d200200203103013212222223002007301b357420022a66a666ae68cdc3a40080040620602642444444600600e60506ae8400454cd4ccd5cd19b87480180080c40c04cc884888888cc01802001cdd69aba10013019357426ae8800454cd4ccd5cd19b87480200080c40c04c84888888c00401cc068d5d08008a99a999ab9a3370e9005001018818099910911111198020040039bad3574200260306ae84d5d1000898152481035054310035573c0046aae74004dd500080f9aba10083300201f3574200e6eb8d5d080319981380b198138111191919299a999ab9a3370e9000001018818089110010a99a999ab9a3370e9001001018818089110008a99a999ab9a3370e900200101881808911001898152481035054310035573c0046aae74004dd50009aba1005330230143574200860026ae8400cc004d5d09aba2003302475a604aeb8d5d10009aba2001357440026ae88004d5d10009aba2001357440026ae88004d5d10009aba2001357440026ae88004d5d10009aba200113016491035054310035573c0046aae74004dd51aba10063574200a646464a66a666ae68cdc3a400000403a0382642444444600a00e6eb8d5d08008a99a999ab9a3370e900100100e80e0999109111111980100400398039aba10013301500f357426ae8800454cd4ccd5cd19b87480100080740704c84888888c00c01cc050d5d08008a99a999ab9a3370e900300100e80e099910911111198030040039bad35742002600a6ae84d5d10008a99a999ab9a3370e900400100e80e0990911111180080398031aba100115335333573466e1d200a00201d01c13322122222233004008007375a6ae84004c010d5d09aba2001130164901035054310035573c0046aae74004dd51aba13574400a4646464a66a666ae68cdc3a400000403a038264666444246660020080060046eb4d5d0801180a9aba10013232325335333573466e1d20000020210201323332221222222233300300a0090083301a017357420046ae84004cc069d71aba1357440026ae8800454cd4ccd5cd19b87480080080840804cc8848888888cc01c024020cc064058d5d0800991919299a999ab9a3370e90000010120118999109198008018011bad357420026eb4d5d09aba20011301d491035054310035573c0046aae74004dd51aba1357440022a66a666ae68cdc3a4008004042040266442444444466004012010666036030eb4d5d08009980cbae357426ae8800454cd4ccd5cd19b87480180080840804c848888888c010020cc064058d5d08008a99a999ab9a3370e900400101081009919199991110911111119998008058050048041980d80c1aba10033301901a3574200466603a034eb4d5d08009a991919299a999ab9a3370e90000010130128998119bad357420026eb4d5d09aba20011301f4901035054310035573c0046aae74004dd51aba135744002446602a0040026ae88004d5d10008a99a999ab9a3370e90050010108100999109111111198028048041980c80b1aba10013232325335333573466e1d200000202402313301c75c6ae840044c075241035054310035573c0046aae74004dd51aba1357440022a66a666ae68cdc3a401800404204022444444400c26034921035054310035573c0046aae74004dd51aba1357440026ae880044c059241035054310035573c0046aae74004dd50009191919299a999ab9a3370e900000100e00d899910911111111111980280680618099aba10013301475a6ae84d5d10008a99a999ab9a3370e900100100e00d899910911111111111980100680618099aba10013301475a6ae84d5d10008a9919a999ab9a3370e900200180e80e0999109111111111119805006806180a1aba10023001357426ae8800854cd4ccd5cd19b874801800c0740704c8ccc888488888888888ccc018038034030c054d5d080198011aba1001375a6ae84d5d10009aba200215335333573466e1d200800301d01c133221222222222223300700d00c3014357420046eb4d5d09aba200215335333573466e1d200a00301d01c132122222222222300100c3014357420042a66a666ae68cdc3a401800603a038266442444444444446600601a01860286ae84008dd69aba1357440042a66a666ae68cdc3a401c00603a038266442444444444446601201a0186eb8d5d08011bae357426ae8800854cd4ccd5cd19b874804000c0740704cc88488888888888cc020034030dd71aba1002375a6ae84d5d10010a99a999ab9a3370e900900180e80e0999109111111111119805806806180a1aba10023014357426ae8800854cd4ccd5cd19b874805000c0740704c8488888888888c010030c050d5d08010980b2481035054310023232325335333573466e1d200000202001f13212223003004375c6ae8400454c8cd4ccd5cd19b874800800c0840804c84888c004010c004d5d08010a99a999ab9a3370e9002001810810099910911198010028021bae3574200460026ae84d5d10010980d2481035054310023232325335333573466e1d200000202402313212223003004301b357420022a66a666ae68cdc3a4004004048046224440042a66a666ae68cdc3a4008004048046224440022603a921035054310035573c0046aae74004dd50009aab9e00235573a0026ea8004d55cf0011aab9d00137540024646464a66a666ae68cdc3a40000040360342642444600600860246ae8400454cd4ccd5cd19b874800800806c0684c84888c008010c048d5d08008a99a999ab9a3370e900200100d80d099091118008021bae3574200226028921035054310035573c0046aae74004dd50009191919299a999ab9a3370e900000100d00c8999109198008018011bae357420026eb4d5d09aba200113013491035054310035573c0046aae74004dd50009aba20011300e491035054310035573c0046aae74004dd500091100191111111111111110030a4c260169201035054350030132225335333573466e1d20000010130121300c491035054330015335333573466e20005200001301213300333702900000119b81480000044c8cc8848cc00400c008cdc200180099b840020013300400200130122225335333573466e1d200000101201110021330030013370c00400240024646464a66a666ae68cdc3a400000402202020202a66a666ae68cdc3a40040040220202022260149201035054310035573c0046aae74004dd500091191919299a999ab9a3370e9000001008808089110010a99a999ab9a3370e90010010088080990911180180218029aba100115335333573466e1d2004002011010112220011300a4901035054310035573c0046aae74004dd50009191919299a999ab9a3370e90000010078070999109198008018011bae357420026eb4d5d09aba200113008491035054310035573c0046aae74004dd5000919118011bac001300e2233335573e0024020466a01e60086ae84008c00cd5d10010041191919299a999ab9a3370e900000100680609909118010019bae357420022a66a666ae68cdc3a400400401a01826424460020066eb8d5d0800898032481035054310035573c0046aae74004dd500091191919299a999ab9a3370e900100100680608910008a99a999ab9a3370e9000001006806099091180100198029aba1001130064901035054310035573c0046aae74004dd5000919319ab9c00100322322300237560026016446666aae7c00480348c8cd4034cc024c018d55ce80098029aab9e0013004357440066ae8400801448004c01c894cd40044020884cd4024d400888004c0100048848cc00400c008c014894cd4004400c8854cd4ccd5cd19baf4c01010100002006005100613004001122002122001122002122122330010040032323001001230022330020020011\" }" + "{ \"type\": \"PlutusScriptV3\", \"description\": \"\", \"cborHex\": \"590e72590e6f01000032323322332233223232323232323232323232323225335533535353232325335333573466e1d200000201301213232323232333222123330010040030023232325335333573466e1d200000201b01a1323232323232323232323232323232323333333333332333233233222222222222222212333333333333333300101101000f00e00d00c00b00a00900800700600500400300230013574202860026ae8404cc0948c8c8c94cd4ccd5cd19b87480000080c40c04cc8848cc00400c008c074d5d080098029aba135744002260589201035054310035573c0046aae74004dd5000998128009aba101123232325335333573466e1d200000203002f13232333322221233330010050040030023232325335333573466e1d2000002035034133221233001003002302e357420026605e4646464a66a666ae68cdc3a4000004072070264244600400660646ae8400454cd4ccd5cd19b87480080080e40e04c8ccc888488ccc00401401000cdd69aba1002375a6ae84004dd69aba1357440026ae880044c0d12401035054310035573c0046aae74004dd50009aba135744002260609201035054310035573c0046aae74004dd51aba1003300735742004646464a66a666ae68cdc3a400000406a068224440062a66a666ae68cdc3a400400406a068264244460020086eb8d5d08008a99a999ab9a3370e900200101a81a099091118010021aba1001130304901035054310035573c0046aae74004dd51aba10013302c75c6ae84d5d10009aba200135744002260569201035054310035573c0046aae74004dd50009bad3574201e60026ae84038c008c009d69981180a9aba100c33302702475a6ae8402cc8c8c94cd4ccd5cd19b87480000080b80b44cc8848cc00400c008c8c8c94cd4ccd5cd19b87480000080c40c04cc8848cc00400c008cc09dd69aba10013026357426ae880044c0b1241035054310035573c0046aae74004dd51aba10013232325335333573466e1d20000020310301332212330010030023302775a6ae84004c098d5d09aba20011302c491035054310035573c0046aae74004dd51aba13574400226052921035054310035573c0046aae74004dd51aba100a3302375c6ae84024ccc09c8c8c8c94cd4ccd5cd19b87480000080bc0b84c84888888c01401cdd71aba100115335333573466e1d200200202f02e13212222223002007301b357420022a66a666ae68cdc3a400800405e05c2642444444600600e60506ae8400454cd4ccd5cd19b87480180080bc0b84cc884888888cc01802001cdd69aba10013019357426ae8800454cd4ccd5cd19b87480200080bc0b84c84888888c00401cc068d5d08008a99a999ab9a3370e9005001017817099910911111198020040039bad3574200260306ae84d5d1000898152481035054310035573c0046aae74004dd500080f9aba10083300201f3574200e6eb8d5d080319981380b198138111191919299a999ab9a3370e9000001017817089110010a99a999ab9a3370e9001001017817089110008a99a999ab9a3370e900200101781708911001898152481035054310035573c0046aae74004dd50009aba1005330230143574200860026ae8400cc004d5d09aba2003302475a604aeb8d5d10009aba2001357440026ae88004d5d10009aba2001357440026ae88004d5d10009aba2001357440026ae88004d5d10009aba200113016491035054310035573c0046aae74004dd51aba10063574200a646464a66a666ae68cdc3a40000040360342642444444600a00e6eb8d5d08008a99a999ab9a3370e900100100d80d0999109111111980100400398039aba10013301500f357426ae8800454cd4ccd5cd19b874801000806c0684c84888888c00c01cc050d5d08008a99a999ab9a3370e900300100d80d099910911111198030040039bad35742002600a6ae84d5d10008a99a999ab9a3370e900400100d80d0990911111180080398031aba100115335333573466e1d200a00201b01a13322122222233004008007375a6ae84004c010d5d09aba2001130164901035054310035573c0046aae74004dd51aba13574400a4646464a66a666ae68cdc3a4000004036034264666444246660020080060046eb4d5d0801180a9aba10013232325335333573466e1d200000201f01e1323332221222222233300300a0090083301a017357420046ae84004cc069d71aba1357440026ae8800454cd4ccd5cd19b874800800807c0784cc8848888888cc01c024020cc064058d5d0800991919299a999ab9a3370e90000010110108999109198008018011bad357420026eb4d5d09aba20011301d491035054310035573c0046aae74004dd51aba1357440022a66a666ae68cdc3a400800403e03c266442444444466004012010666036030eb4d5d08009980cbae357426ae8800454cd4ccd5cd19b874801800807c0784c848888888c010020cc064058d5d08008a99a999ab9a3370e900400100f80f09919199991110911111119998008058050048041980d80c1aba10033301901a3574200466603a034eb4d5d08009a991919299a999ab9a3370e90000010120118998149bad357420026eb4d5d09aba20011301f4901035054310035573c0046aae74004dd51aba135744002446602a0040026ae88004d5d10008a99a999ab9a3370e900500100f80f0999109111111198028048041980c80b1aba10013232325335333573466e1d200000202202113301c75c6ae840044c075241035054310035573c0046aae74004dd51aba1357440022a66a666ae68cdc3a401800403e03c22444444400c26034921035054310035573c0046aae74004dd51aba1357440026ae880044c059241035054310035573c0046aae74004dd50009191919299a999ab9a3370e900000100d00c899910911111111111980280680618099aba10013301475a6ae84d5d10008a99a999ab9a3370e900100100d00c899910911111111111980100680618099aba10013301475a6ae84d5d10008a9919a999ab9a3370e900200180d80d0999109111111111119805006806180a1aba10023001357426ae8800854cd4ccd5cd19b874801800c06c0684c8ccc888488888888888ccc018038034030c054d5d080198011aba1001375a6ae84d5d10009aba200215335333573466e1d200800301b01a133221222222222223300700d00c3014357420046eb4d5d09aba200215335333573466e1d200a00301b01a132122222222222300100c3014357420042a66a666ae68cdc3a4018006036034266442444444444446600601a01860286ae84008dd69aba1357440042a66a666ae68cdc3a401c006036034266442444444444446601201a0186eb8d5d08011bae357426ae8800854cd4ccd5cd19b874804000c06c0684cc88488888888888cc020034030dd71aba1002375a6ae84d5d10010a99a999ab9a3370e900900180d80d0999109111111111119805806806180a1aba10023014357426ae8800854cd4ccd5cd19b874805000c06c0684c8488888888888c010030c050d5d08010980b2481035054310023232325335333573466e1d200000201e01d13212223003004375c6ae8400454c8cd4ccd5cd19b874800800c07c0784c84888c004010c004d5d08010a99a999ab9a3370e900200180f80f099910911198010028021bae3574200460026ae84d5d10010980d2481035054310023232325335333573466e1d200000202202113212223003004301b357420022a66a666ae68cdc3a4004004044042224440042a66a666ae68cdc3a4008004044042224440022603a921035054310035573c0046aae74004dd50009aab9e00235573a0026ea8004d55cf0011aab9d00137540024646464a66a666ae68cdc3a40000040320302642444600600860246ae8400454cd4ccd5cd19b87480080080640604c84888c008010c048d5d08008a99a999ab9a3370e900200100c80c099091118008021bae3574200226028921035054310035573c0046aae74004dd50009191919299a999ab9a3370e900000100c00b8999109198008018011bae357420026eb4d5d09aba200113013491035054310035573c0046aae74004dd50009aba20011300e491035054310035573c0046aae74004dd50009110019111111111111111180f0031080888078a4c26016921035054350030142225335333573466e1d20000010110101300c491035054330015335333573466e20005200001101013300333702900000119b81480000044c8cc8848cc00400c008cdc200180099b840020013300400200130132225335333573466e1d200000101000f10021330030013370c00400240024646464a66a666ae68cdc3a400000401e01c201c2a66a666ae68cdc3a400400401e01c201e260149201035054310035573c0046aae74004dd500091191919299a999ab9a3370e9000001007807089110010a99a999ab9a3370e90010010078070990911180180218029aba100115335333573466e1d200400200f00e112220011300a4901035054310035573c0046aae74004dd50009191919299a999ab9a3370e90000010068060999109198008018011bae357420026eb4d5d09aba200113008491035054310035573c0046aae74004dd5000919118011bac001300f2233335573e002401c466a01a60086ae84008c00cd5d10010041191919299a999ab9a3370e900000100580509909118010019bae357420022a66a666ae68cdc3a400400401601426424460020066eb8d5d0800898032481035054310035573c0046aae74004dd500091191919299a999ab9a3370e90010010058050a8070a99a999ab9a3370e90000010058050980798029aba1001130064901035054310035573c0046aae74004dd5000919319ab9c00100322322300237560026018446666aae7c004802c8c8cd402ccc03cc018d55ce80098029aab9e0013004357440066ae8400801448004c020894cd40045401c884d4008894cd4ccd5cd19b8f488120ee155ace9c40292074cb6aff8c9ccdd273c81648ff1149ef36bcea6ebb8a3e25000020080071300c001130060031220021220011220021221223300100400321223002003112200122123300100300223230010012300223300200200101\" }"