From 83877389685c3006460774ad6a5231a1f71c05cc Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Thu, 23 Jun 2022 11:25:32 -0500 Subject: [PATCH 1/2] Add minting context test shell script. This checks that the mint field in the ScriptContxt is equivalent to the mint field in our redeemer --- cardano-api/src/Cardano/Api.hs | 2 + cardano-api/src/Cardano/Api/Fees.hs | 10 +- .../Cardano/CLI/Shelley/Run/Transaction.hs | 2 - .../script-context-equivalance-test.sh | 198 ++++++++++++++++++ .../script-mint-context-equivalance-test.sh | 145 +++++++++++++ .../v2/context-equivalence-test.plutus | 5 + .../minting-context-equivalance-test.plutus | 5 + 7 files changed, 360 insertions(+), 7 deletions(-) create mode 100755 scripts/babbage/script-context-equivalance-test.sh create mode 100755 scripts/babbage/script-mint-context-equivalance-test.sh create mode 100644 scripts/plutus/scripts/v2/context-equivalence-test.plutus create mode 100644 scripts/plutus/scripts/v2/minting-context-equivalance-test.plutus diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index 99a04d76fee..0691232f96a 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -237,6 +237,7 @@ module Cardano.Api ( -- ** Fee calculation transactionFee, + toLedgerEpochInfo, estimateTransactionFee, evaluateTransactionFee, estimateTransactionKeyWitnessCount, @@ -578,6 +579,7 @@ module Cardano.Api ( -- *** Local state query LocalStateQueryClient(..), QueryInMode(..), + SystemStart(..), QueryInEra(..), QueryInShelleyBasedEra(..), QueryUTxOFilter(..), diff --git a/cardano-api/src/Cardano/Api/Fees.hs b/cardano-api/src/Cardano/Api/Fees.hs index 7a8485ce4d0..9363a3a83b9 100644 --- a/cardano-api/src/Cardano/Api/Fees.hs +++ b/cardano-api/src/Cardano/Api/Fees.hs @@ -14,7 +14,6 @@ -- | Fee calculation -- module Cardano.Api.Fees ( - -- * Transaction fees transactionFee, estimateTransactionFee, @@ -40,6 +39,7 @@ module Cardano.Api.Fees ( -- * Internal helpers mapTxScriptWitnesses, + toLedgerEpochInfo, ) where import Prelude @@ -578,10 +578,6 @@ evaluateTransactionExecutionUnits _eraInMode systemstart history pparams utxo tx of Left err -> Left (TransactionValidityTranslationError err) Right exmap -> Right (fromLedgerScriptExUnitsMap exmap) - toLedgerEpochInfo :: EraHistory mode -> EpochInfo (Either Text.Text) - toLedgerEpochInfo (EraHistory _ interpreter) = - hoistEpochInfo (first (Text.pack . show) . runExcept) $ - Consensus.interpreterToEpochInfo interpreter toAlonzoCostModelsArray :: Map AnyPlutusScriptVersion CostModel @@ -637,6 +633,10 @@ evaluateTransactionExecutionUnits _eraInMode systemstart history pparams utxo tx obtainHasFieldConstraint CollateralInAlonzoEra f = f obtainHasFieldConstraint CollateralInBabbageEra f = f +toLedgerEpochInfo :: EraHistory mode -> EpochInfo (Either Text.Text) +toLedgerEpochInfo (EraHistory _ interpreter) = + hoistEpochInfo (first (Text.pack . show) . runExcept) $ + Consensus.interpreterToEpochInfo interpreter -- ---------------------------------------------------------------------------- -- Transaction balance diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs index 56fa122d572..817cc0c57ce 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs @@ -43,10 +43,8 @@ import Ouroboros.Consensus.Shelley.Eras (StandardAllegra, StandardCryp --TODO: do this nicely via the API too: import qualified Cardano.Binary as CBOR - --TODO: following import needed for orphan Eq Script instance import Cardano.Ledger.Shelley.Scripts () -import Cardano.Ledger.ShelleyMA.TxBody () import Cardano.CLI.Environment (EnvSocketError, readEnvSocketPath, renderEnvSocketError) import Cardano.CLI.Run.Friendly (friendlyTxBS, friendlyTxBodyBS) diff --git a/scripts/babbage/script-context-equivalance-test.sh b/scripts/babbage/script-context-equivalance-test.sh new file mode 100755 index 00000000000..0fd9357e62c --- /dev/null +++ b/scripts/babbage/script-context-equivalance-test.sh @@ -0,0 +1,198 @@ +#!/usr/bin/env bash + +# Unofficial bash strict mode. +# See: http://redsymbol.net/articles/unofficial-bash-strict-mode/ +set -e +set -o pipefail + +export WORK="${WORK:-example/work}" +export BASE="${BASE:-.}" +export CARDANO_CLI="${CARDANO_CLI:-cardano-cli}" +export CARDANO_NODE_SOCKET_PATH="${CARDANO_NODE_SOCKET_PATH:-example/main.sock}" +export TESTNET_MAGIC="${TESTNET_MAGIC:-42}" +export UTXO_VKEY="${UTXO_VKEY:-example/utxo-keys/utxo1.vkey}" +export UTXO_SKEY="${UTXO_SKEY:-example/utxo-keys/utxo1.skey}" +export RESULT_FILE="${RESULT_FILE:-$WORK/result.out}" + +mkdir -p "$WORK" + +echo "Socket path: $CARDANO_NODE_SOCKET_PATH" +echo "Socket path: $(pwd)" + +ls -al "$CARDANO_NODE_SOCKET_PATH" + +# NB: This plutus script uses a "typed" redeemer and "typed" datum. +plutusscriptinuse="$BASE/scripts/plutus/scripts/v2/context-equivalence-test.plutus" +# This datum hash is the hash of the typed 42 +scriptdatumhash="fcaa61fb85676101d9e3398a484674e71c45c3fd41b492682f3b0054f4cf3273" +datumfilepath="$BASE/scripts/plutus/data/typed-42.datum" +redeemerfilepath="$BASE/scripts/plutus/data/script-context.redeemer" +certifyingscript="scripts/plutus/scripts/v2/stake-script.plutus" + +# Create certificate +cardano-cli stake-address registration-certificate \ + --stake-script-file "$certifyingscript" \ + --out-file "$WORK/script.regcert" + +# Step 1: Create a tx output with a datum hash at the script address. In order for a tx output to be locked +# by a plutus script, it must have a datahash. We also need collateral tx inputs so we split the utxo +# in order to accommodate this. + + +plutusscriptaddr=$($CARDANO_CLI address build --payment-script-file "$plutusscriptinuse" --testnet-magic "$TESTNET_MAGIC") +readonlyaddress=addr_test1vz3t3f2kgy2re66tnhgxc4t8jgylw2cqfnxdwlrq9agfmtstxxkm5 + +mkdir -p "$WORK" + +utxoaddr=$($CARDANO_CLI address build --testnet-magic "$TESTNET_MAGIC" --payment-verification-key-file "$UTXO_VKEY") + +$CARDANO_CLI query utxo --address "$utxoaddr" --cardano-mode --testnet-magic "$TESTNET_MAGIC" --out-file $WORK/utxo-1.json +cat $WORK/utxo-1.json + +txin=$(jq -r 'keys[]' $WORK/utxo-1.json) +lovelaceattxin=$(jq -r ".[\"$txin\"].value.lovelace" $WORK/utxo-1.json) +lovelaceattxindiv6=$(expr $lovelaceattxin / 6) + +$CARDANO_CLI query protocol-parameters --testnet-magic "$TESTNET_MAGIC" --out-file $WORK/pparams.json + +$CARDANO_CLI transaction build \ + --babbage-era \ + --cardano-mode \ + --testnet-magic "$TESTNET_MAGIC" \ + --change-address "$utxoaddr" \ + --tx-in "$txin" \ + --tx-out "$readonlyaddress+$lovelaceattxindiv6" \ + --tx-out "$plutusscriptaddr+$lovelaceattxindiv6" \ + --tx-out-datum-hash "$scriptdatumhash" \ + --tx-out "$utxoaddr+$lovelaceattxindiv6" \ + --protocol-params-file "$WORK/pparams.json" \ + --out-file "$WORK/create-datum-output.body" + +$CARDANO_CLI transaction sign \ + --tx-body-file $WORK/create-datum-output.body \ + --testnet-magic "$TESTNET_MAGIC" \ + --signing-key-file $UTXO_SKEY \ + --out-file $WORK/create-datum-output.tx + +# SUBMIT +$CARDANO_CLI transaction submit --tx-file $WORK/create-datum-output.tx --testnet-magic "$TESTNET_MAGIC" +echo "Pausing for 5 seconds..." +sleep 5 + +# Step 2 +# After "locking" the tx output at the script address, we can now can attempt to spend +# the "locked" tx output below. + +$CARDANO_CLI query utxo --address $plutusscriptaddr --testnet-magic "$TESTNET_MAGIC" --out-file $WORK/plutusutxo.json + +plutusutxotxin=$(jq -r 'keys[]' $WORK/plutusutxo.json) + +$CARDANO_CLI query utxo --address $utxoaddr --cardano-mode --testnet-magic "$TESTNET_MAGIC" --out-file $WORK/utxo-2.json +cat $WORK/utxo-2.json +txinCollateral=$(jq -r 'keys[0]' $WORK/utxo-2.json) + + +dummyaddress=addr_test1vpqgspvmh6m2m5pwangvdg499srfzre2dd96qq57nlnw6yctpasy4 + +lovelaceatplutusscriptaddr=$(jq -r ".[\"$plutusutxotxin\"].value.lovelace" $WORK/plutusutxo.json) + +#Get read only reference input +$CARDANO_CLI query utxo --address "$readonlyaddress" --cardano-mode \ + --testnet-magic "$TESTNET_MAGIC" --out-file $WORK/read-only-ref-input-utxo.json +readonlyrefinput=$(jq -r 'keys[0]' $WORK/read-only-ref-input-utxo.json) + + + +# We need to generate a dummy redeemer in order to create a txbody from which we can generate +# a tx and then derive the correct redeemer. +create-script-context --plutus-v2 --out-file "$WORK/script-context.redeemer" + +correctredeemer="$WORK/script-context.redeemer" + +echo "Constructing dummy tx..." + +# Create dummy certificate +certifyingscript="scripts/plutus/scripts/v2/stake-script.plutus" +cardano-cli stake-address registration-certificate \ + --stake-script-file "$certifyingscript" \ + --out-file "$WORK/script.regcert" + +requiredsignerhash=$(cardano-cli address key-hash --payment-verification-key-file ${UTXO_VKEY}) + +# DUMMY TX! We generate the actual redeemer from this! +# --certificate-file "$WORK/script.regcert" \ +redeemerfilepath="$BASE/scripts/plutus/data/42.redeemer" +$CARDANO_CLI transaction build \ + --babbage-era \ + --cardano-mode \ + --testnet-magic "$TESTNET_MAGIC" \ + --script-invalid \ + --change-address "$utxoaddr" \ + --invalid-before 1 \ + --invalid-hereafter 400 \ + --certificate-file "$WORK/script.regcert" \ + --read-only-tx-in-reference "$readonlyrefinput" \ + --tx-in "$plutusutxotxin" \ + --tx-in-collateral "$txinCollateral" \ + --tx-out "$dummyaddress+10000000" \ + --tx-in-script-file "$plutusscriptinuse" \ + --tx-in-datum-file "$datumfilepath" \ + --protocol-params-file "$WORK/pparams.json" \ + --tx-in-redeemer-file "$redeemerfilepath" \ + --required-signer-hash "$requiredsignerhash" \ + --out-file $WORK/test-alonzo.body + +$CARDANO_CLI transaction sign \ + --tx-body-file $WORK/test-alonzo.body \ + --testnet-magic "$TESTNET_MAGIC" \ + --signing-key-file "${UTXO_SKEY}" \ + --out-file $WORK/test-alonzo.tx + +# Generate the "real" redeeemer! + +create-script-context \ + --generate-tx "$WORK/test-alonzo.tx" \ + --plutus-v2 \ + --out-file "$WORK/script-context.redeemer" \ + --cardano-mode \ + --testnet-magic 42 \ + +echo "Constructing real tx..." +# REAL TX! + +$CARDANO_CLI transaction build \ + --babbage-era \ + --cardano-mode \ + --testnet-magic "$TESTNET_MAGIC" \ + --script-valid \ + --invalid-before 1 \ + --invalid-hereafter 400 \ + --change-address "$utxoaddr" \ + --certificate-file "$WORK/script.regcert" \ + --read-only-tx-in-reference "$readonlyrefinput" \ + --tx-in "$plutusutxotxin" \ + --tx-in-collateral "$txinCollateral" \ + --tx-out "$dummyaddress+10000000" \ + --tx-in-script-file "$plutusscriptinuse" \ + --tx-in-datum-file "$datumfilepath" \ + --protocol-params-file "$WORK/pparams.json" \ + --tx-in-redeemer-file "$correctredeemer" \ + --required-signer-hash "$requiredsignerhash" \ + --out-file $WORK/test-alonzo-final.body + +$CARDANO_CLI transaction sign \ + --tx-body-file $WORK/test-alonzo-final.body \ + --testnet-magic "$TESTNET_MAGIC" \ + --signing-key-file "${UTXO_SKEY}" \ + --out-file $WORK/alonzo.tx + +# SUBMIT $WORK/alonzo.tx containing the correct redeemer + +echo "Submit the tx with plutus script and wait 5 seconds..." +$CARDANO_CLI transaction submit --tx-file $WORK/alonzo.tx --testnet-magic "$TESTNET_MAGIC" +sleep 5 +echo "" +echo "Querying UTxO at $dummyaddress. If there is ADA at the address the Plutus script successfully executed!" +echo "" +$CARDANO_CLI query utxo --address "$dummyaddress" --testnet-magic "$TESTNET_MAGIC" \ + | tee "$RESULT_FILE" diff --git a/scripts/babbage/script-mint-context-equivalance-test.sh b/scripts/babbage/script-mint-context-equivalance-test.sh new file mode 100755 index 00000000000..4e2d8475c7e --- /dev/null +++ b/scripts/babbage/script-mint-context-equivalance-test.sh @@ -0,0 +1,145 @@ +#!/usr/bin/env bash + +# Unofficial bash strict mode. +# See: http://redsymbol.net/articles/unofficial-bash-strict-mode/ +set -e +set -o pipefail + +export WORK="${WORK:-example/work}" +export BASE="${BASE:-.}" +export CARDANO_CLI="${CARDANO_CLI:-cardano-cli}" +export CARDANO_NODE_SOCKET_PATH="${CARDANO_NODE_SOCKET_PATH:-example/main.sock}" +export TESTNET_MAGIC="${TESTNET_MAGIC:-42}" +export UTXO_VKEY="${UTXO_VKEY:-example/utxo-keys/utxo1.vkey}" +export UTXO_SKEY="${UTXO_SKEY:-example/utxo-keys/utxo1.skey}" +export RESULT_FILE="${RESULT_FILE:-$WORK/result.out}" + +mkdir -p "$WORK" + +echo "Socket path: $CARDANO_NODE_SOCKET_PATH" +echo "Socket path: $(pwd)" + +ls -al "$CARDANO_NODE_SOCKET_PATH" + +# NB: This plutus script uses a "typed" redeemer and "typed" datum. +plutusscriptinuse="$BASE/scripts/plutus/scripts/v2/minting-context-equivalance-test.plutus" +policyid=$(cardano-cli transaction policyid --script-file $plutusscriptinuse) +redeemerfilepath="$BASE/scripts/plutus/data/script-context.redeemer" + +mkdir -p "$WORK" + +utxoaddr=$($CARDANO_CLI address build --testnet-magic "$TESTNET_MAGIC" --payment-verification-key-file "$UTXO_VKEY") + +$CARDANO_CLI query utxo --address "$utxoaddr" --cardano-mode --testnet-magic "$TESTNET_MAGIC" --out-file $WORK/utxo-1.json +cat $WORK/utxo-1.json + +txin=$(jq -r 'keys[]' $WORK/utxo-1.json) +lovelaceattxin=$(jq -r ".[\"$txin\"].value.lovelace" $WORK/utxo-1.json) +lovelaceattxindiv6=$(expr $lovelaceattxin / 6) + +$CARDANO_CLI query protocol-parameters --testnet-magic "$TESTNET_MAGIC" --out-file $WORK/pparams.json + +$CARDANO_CLI transaction build \ + --babbage-era \ + --cardano-mode \ + --testnet-magic "$TESTNET_MAGIC" \ + --change-address "$utxoaddr" \ + --tx-in "$txin" \ + --tx-out "$utxoaddr+$lovelaceattxindiv6" \ + --protocol-params-file "$WORK/pparams.json" \ + --out-file "$WORK/create-datum-output.body" + +$CARDANO_CLI transaction sign \ + --tx-body-file $WORK/create-datum-output.body \ + --testnet-magic "$TESTNET_MAGIC" \ + --signing-key-file $UTXO_SKEY \ + --out-file $WORK/create-datum-output.tx + +# SUBMIT +$CARDANO_CLI transaction submit --tx-file $WORK/create-datum-output.tx --testnet-magic "$TESTNET_MAGIC" +echo "Pausing for 5 seconds..." +sleep 5 + + +$CARDANO_CLI query utxo --address $utxoaddr --cardano-mode --testnet-magic "$TESTNET_MAGIC" --out-file $WORK/utxo-2.json +cat $WORK/utxo-2.json +txinCollateral=$(jq -r 'keys[0]' $WORK/utxo-2.json) +txinfunding1=$(jq -r 'keys[1]' $WORK/utxo-2.json) + + +dummyaddress=addr_test1vpqgspvmh6m2m5pwangvdg499srfzre2dd96qq57nlnw6yctpasy4 + + +# We need to generate a dummy redeemer in order to create a txbody from which we can generate +# a tx and then derive the correct redeemer. +create-script-context --plutus-v2 --out-file "$WORK/script-context.redeemer" + +correctredeemer="$WORK/script-context.redeemer" + +echo "Constructing dummy tx..." + +# DUMMY TX! We generate the actual redeemer from this! +redeemerfilepath="$BASE/scripts/plutus/data/42.redeemer" +$CARDANO_CLI transaction build \ + --babbage-era \ + --cardano-mode \ + --testnet-magic "$TESTNET_MAGIC" \ + --script-invalid \ + --change-address "$utxoaddr" \ + --tx-in-collateral "$txinCollateral" \ + --tx-in "$txinfunding1" \ + --mint "5 $policyid.4D696C6C6172436F696E" \ + --mint-script-file "$plutusscriptinuse" \ + --mint-redeemer-file "$correctredeemer" \ + --tx-out "$dummyaddress+2000000 + 5 $policyid.4D696C6C6172436F696E" \ + --protocol-params-file "$WORK/pparams.json" \ + --out-file $WORK/test-alonzo.body + +$CARDANO_CLI transaction sign \ + --tx-body-file $WORK/test-alonzo.body \ + --testnet-magic "$TESTNET_MAGIC" \ + --signing-key-file "${UTXO_SKEY}" \ + --out-file $WORK/test-alonzo.tx + +# Generate the "real" redeeemer! + +create-script-context \ + --generate-tx "$WORK/test-alonzo.tx" \ + --plutus-v2 \ + --out-file "$WORK/script-context.redeemer" \ + --cardano-mode \ + --testnet-magic 42 \ + +echo "Constructing real tx..." +# REAL TX! + +$CARDANO_CLI transaction build \ + --babbage-era \ + --cardano-mode \ + --testnet-magic "$TESTNET_MAGIC" \ + --change-address "$utxoaddr" \ + --tx-in-collateral "$txinCollateral" \ + --tx-in "$txinfunding1" \ + --mint "5 $policyid.4D696C6C6172436F696E" \ + --mint-script-file "$plutusscriptinuse" \ + --mint-redeemer-file "$correctredeemer" \ + --tx-out "$dummyaddress+2000000 + 5 $policyid.4D696C6C6172436F696E" \ + --protocol-params-file "$WORK/pparams.json" \ + --out-file $WORK/test-alonzo-final.body + +$CARDANO_CLI transaction sign \ + --tx-body-file $WORK/test-alonzo-final.body \ + --testnet-magic "$TESTNET_MAGIC" \ + --signing-key-file "${UTXO_SKEY}" \ + --out-file $WORK/alonzo.tx + +# SUBMIT $WORK/alonzo.tx containing the correct redeemer + +echo "Submit the tx with plutus script and wait 5 seconds..." +$CARDANO_CLI transaction submit --tx-file $WORK/alonzo.tx --testnet-magic "$TESTNET_MAGIC" +sleep 5 +echo "" +echo "Querying UTxO at $dummyaddress. If there is ADA at the address the Plutus script successfully executed!" +echo "" +$CARDANO_CLI query utxo --address "$dummyaddress" --testnet-magic "$TESTNET_MAGIC" \ + | tee "$RESULT_FILE" diff --git a/scripts/plutus/scripts/v2/context-equivalence-test.plutus b/scripts/plutus/scripts/v2/context-equivalence-test.plutus new file mode 100644 index 00000000000..18ac63b14ee --- /dev/null +++ b/scripts/plutus/scripts/v2/context-equivalence-test.plutus @@ -0,0 +1,5 @@ +{ + "type": "PlutusScriptV2", + "description": "", + "cborHex": "5910285910250100003232332233223232323232323232323232323232332232323232323232323232323232323232323232323232323232323232323232323223223232323232323232323232232325335323232323232330413500522222222222333200150403355058355303b12001027323500122222222222200c500e3355303b1200102700b330413500522222222222333200150403355058355303b12001027323500122222222222200b500e3355303b1200102700a33041350052222222222233320013530531200122533333335002215333333350022133054002001221059210581057105722105922105922153333333500321059221533533056004002133057003001105a210591058105822105a22105a2153333333500221058221059213305400200110571057221059221059153333333500121057221058210571057105622105822105815333333350012105722105821057105610572210582210582215333333350032105922105a21059105810582215335333573466e3c01000816c1684cc15c00c00441688841688854ccccccd400c8416488416884164416041608841688854cd4ccd5cd19b8f00400205b05a133058003001105a3235001222222222222007500e0063304135005222222222223332001353053120010513235001222222222222004500e0033304135005222222222223233353054120012235002223500322533533058004002133044003001105b0010023235001222222222222002500e330413500522232222222223304d333200135305412001223500222350032233330560040030020013355303c12001027500e3355303c1200102700a3304d33320013530541200122533350021533350011058210582105821533350021058213304200200121059215333500210582105921330560020013355303c12001026500e3355303c1200102600a3304d33320013530541200122533500221533500221330560020011058153350012105810583355303c12001025500e3355303c1200102500a3304d33053335503d30491200133503f500d500948020cc14ccd540f4c12448004cd54164c8c88cc008005416cc8004d5416c8894cd4008541708854cd4ccd4c0bc4800401800800c4cc01400400c4cd4174008cc014004cd417400800cc10814ccd40fd4035402520061335530331200101b001350052222222222233052335503c5503f3235001222222222222003500e335503c5503f00213355302f1200101750011323500122222222222200a5001135001220023333573466e1cd55cea80224000466442466002006004646464646464646464646464646666ae68cdc39aab9d500c480008cccccccccccc88888888888848cccccccccccc00403403002c02802402001c01801401000c008cd40a40a8d5d0a80619a8148151aba1500b33502902b35742a014666aa05aeb940b0d5d0a804999aa816bae502c35742a01066a0520646ae85401cccd540b40cdd69aba1500633503575a6ae854014cd40a5d71aba150043335502d02f200135742a006666aa05aeb88004d5d0a80118189aba135744a004464c6407266ae700e80e40dc4d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135573ca00226ea8004d5d0a80218109aba135744a008464c6405666ae700b00ac0a4cccd5cd19b8735573aa01e900011999999999991111111111091999999999980080600580500480400380300280200180119a80d00d9aba1500f33501a01b35742a01c66a0340386ae854034ccd54079d7280e9aba1500c3335501e75ca03a6ae85402ccd406808cd5d0a805199aa80f0123ad35742a01266a04ceb4d5d0a80419a80d3ae35742a00e666aa03c04040026ae854018ccd54079d710009aba135744a00c464c6405466ae700ac0a80a0cccd5cd19b8735573aa020900011bad357426aae7940448c98c80a4cd5ce015014813881409931901419ab9c4910350543500028135573ca00226ea80044d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d5d1280089aab9e50011375400226ea80048d4004888800c8d400488880048d400488880088d400488880108d400488004c8004d540c48848894cd400440c48854cd4cc01400801040d04ccd4c01c4800401401000448c88c008dd6000990009aa818911999aab9f00125032233503130043574200460066ae8800804c8c8c8cccd5cd19b8735573aa004900011991091980080180118051aba150023005357426ae8940088c98c804ccd5ce00a00980889aab9e5001137540024646464646666ae68cdc39aab9d5004480008cccc888848cccc00401401000c008c8c8c8cccd5cd19b8735573aa004900011991091980080180118099aba1500233500d012357426ae8940088c98c8060cd5ce00c80c00b09aab9e5001137540026ae854010ccd54021d728039aba150033232323333573466e1d4005200423212223002004357426aae79400c8cccd5cd19b875002480088c84888c004010dd71aba135573ca00846666ae68cdc3a801a400042444006464c6403466ae7006c06806005c0584d55cea80089baa00135742a00466a012eb8d5d09aba2500223263201433573802a02802426ae8940044d5d1280089aab9e500113754002266aa002eb9d6889119118011bab0013200135502e223233335573e0044a060466a05e66aa03e600c6aae754008c014d55cf280118021aba200301113574200224464646666ae68cdc3a800a40004642446004006600a6ae84d55cf280191999ab9a3370ea0049001109100091931900899ab9c01201100f00e135573aa00226ea80048c8c8cccd5cd19b875001480188c848888c010014c01cd5d09aab9e500323333573466e1d400920042321222230020053009357426aae7940108cccd5cd19b875003480088c848888c004014c01cd5d09aab9e500523333573466e1d40112000232122223003005375c6ae84d55cf280311931900899ab9c01201100f00e00d00c135573aa00226ea80048c8c8cccd5cd19b8735573aa004900011991091980080180118029aba15002375a6ae84d5d1280111931900699ab9c00e00d00b135573ca00226ea80048c8cccd5cd19b8735573aa002900011bae357426aae7940088c98c802ccd5ce00600580489baa001232323232323333573466e1d4005200c21222222200323333573466e1d4009200a21222222200423333573466e1d400d2008233221222222233001009008375c6ae854014dd69aba135744a00a46666ae68cdc3a8022400c4664424444444660040120106eb8d5d0a8039bae357426ae89401c8cccd5cd19b875005480108cc8848888888cc018024020c030d5d0a8049bae357426ae8940248cccd5cd19b875006480088c848888888c01c020c034d5d09aab9e500b23333573466e1d401d2000232122222223005008300e357426aae7940308c98c8050cd5ce00a80a00900880800780700680609aab9d5004135573ca00626aae7940084d55cf280089baa0012323232323333573466e1d400520022333222122333001005004003375a6ae854010dd69aba15003375a6ae84d5d1280191999ab9a3370ea0049000119091180100198041aba135573ca00c464c6401a66ae7003803402c0284d55cea80189aba25001135573ca00226ea80048c8c8cccd5cd19b875001480088c8488c00400cdd71aba135573ca00646666ae68cdc3a8012400046424460040066eb8d5d09aab9e500423263200a33573801601401000e26aae7540044dd500089119191999ab9a3370e6aae75400920002332212330010030023232323333573466e1cd55cea8012400046644246600200600466a0140126ae854008c02cd5d09aba2500223263200d33573801c01a01626aae7940044dd50009aba150023232323333573466e1cd55cea8012400046644246600200600466a0140126ae854008c02cd5d09aba2500223263200d33573801c01a01626aae7940044dd50009aba135744a004464c6401266ae7002802401c4d55cf280089baa00112232323333573466e1d400520042122200123333573466e1d40092002232122230030043006357426aae7940108cccd5cd19b87500348000848880088c98c8028cd5ce00580500400380309aab9d5001137540024646666ae68cdc3a800a4004404246666ae68cdc3a801240004042464c6400c66ae7001c01801000c4d55ce9baa00149848005240103505431003200135501e221122533500115020221335021300400233553006120010040011122333355002323350152233350130030010023501000133501422230033002001200122337000029001000a400044666ae68cdd780100080d00c891199aa980389000a80d0008010888911199aa98060900080191a80091180280080089a980989000911a80111111a802111a8039111191a80291299a999980f0048040010008a99a9998080108060030a999a8058a999a8028a801908121081210a999a803081210a99a999ab9a3375e00400204c04a2a00a204a4204a42a666a00c20484204a42a66a666ae68cdc78010008130128a8028812881188118a99a80390a99a801109980f80100088108a99a800908108810911199aa9805090009a807a80691a80091199aa9806890009a809280811a80091199a800919805240000024466016004002466014002900000099aa98048900091a8009119aa805801199a800919aa98068900091a8009119aa8078011aa80700080091199aaa80480c001000919aa98068900091a8009119aa8078011aa806800800999aaa802009801000888911199aa980209000a80b99aa98040900091a8009119aa8050011aa804800999aa980209000911a80111299a999aa9806890009919a80a11199a801910010010009a80091000891980091299a801080e880080d11a80091198050010028030801899a80d802001a80c00099aa98040900091a800911919aa8058019800802990009aa80e91299a80089aa8050019109a80111299a99806001004089111980100500209803001801190009aa80b1108911299a800880111099802801199aa980389000802802000889091118018020890911180080208910919800801801190009aa809110891299a8008a80a11099a80a980200119aa980309000802000990009aa8089108911299a80089a803001910999a8048029802001199aa980389000802802000891a80091000891a800910010891980080100591299a801080088050919a80111199a801910010010009a80091000891091980080180111111919a802919a8021299a999ab9a3371e00400201a0182a00620184018466a00840184a66a666ae68cdc78010008068060a80188060a99a80190a99a801109980380100088050a99a8009080508051119a801119a801119a801119a8011198038010009005119a801100511980380100091100511119a8021005111299a999ab9a3370e00c00601a0182a66a666ae68cdc38028010068060998050020008806080611199ab9a3371e00400200c00a44666ae68cdc3801000802802190009aa803110911299a8010a99a8008803910804110a99a8018804110a99a998038020010999a9804890008038018008805091001091000889100109109119800802001889118010008891918008009119801980100100081" +} diff --git a/scripts/plutus/scripts/v2/minting-context-equivalance-test.plutus b/scripts/plutus/scripts/v2/minting-context-equivalance-test.plutus new file mode 100644 index 00000000000..399ec082311 --- /dev/null +++ b/scripts/plutus/scripts/v2/minting-context-equivalance-test.plutus @@ -0,0 +1,5 @@ +{ + "type": "PlutusScriptV2", + "description": "", + "cborHex": "590c49590c4601000032332232323232332232323232323232323232323232323232323232323232323233223232232323232323232323232323223232533532323302c3500222222222222232333553025120013503a503823500122333553028120013503d503b2350012233350012330484800000488cc1240080048cc1200052000001335530241200123500122335504100233350012335530281200123500122335504500235502a001001223335550250450020012335530281200123500122335504500235502900100133355502004000100932350012222222222220083500d220023500222222222222253350012132333350012333350032533333335002215333333350022133044002001221048210471046104622104822104822153333333500321048221533533046004002133047003001104921048104710472210492210492153333333500221047221048213304400200110461046221048221048153333333500121046221047210461046104522104722104715333333350012104622104721046104510462210472210472215333333350032104822104921048104710472215335333573466e3c0100081281244cc11c00c00441248841248854ccccccd400c8412088412484120411c411c8841248854cd4ccd5cd19b8f00400204a049133048003001104920452045204523333500320452330430020012045204523333500320452045233042002001204523333500320452045204525335333573466e3cd400888008d4004880081181144ccd5cd19b873500222001350012200104604510453500e22001163333573466e1cd55cea801a4000466442466002006004646464646464646464646464646666ae68cdc39aab9d500c480008cccccccccccc88888888888848cccccccccccc00403403002c02802402001c01801401000c008cd409c0a0d5d0a80619a8138141aba1500b33502702935742a014666aa056eb940a8d5d0a804999aa815bae502a35742a01066a04e0606ae85401cccd540ac0c5d69aba1500633503375a6ae854014cd409dd71aba150043335502b02d200135742a006666aa056eb88004d5d0a80118179aba135744a004464c6406e66ae700e00dc0d44d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135573ca00226ea8004d5d0a801980f9aba135744a006464c6405266ae700a80a409ccccd5cd19b8735573aa01e900011999999999999111111111110919999999999980080680600580500480400380300280200180119a80c00c9aba1500f33501801935742a01c66a0300346ae854034ccd54071d7280d9aba1500c3335501c75ca0366ae85402ccd4060084d5d0a805199aa80e0113ad35742a01266a048eb4d5d0a80419a80c3ae35742a00e666aa03803c40026ae854018ccd54071d710009aba1500533501d01e357426ae8940148c98c80a0cd5ce014814013081389931901399ab9c49010350543500027135573ca00226ea80044d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135573ca00226ea8004444888ccd54c01048005407ccd54c01c480048d400488cd54090008d54024004ccd54c0104800488d4008894cd4ccd54c03048004c8cd408c88ccd400c88008008004d40048800448cc004894cd400840b440040a88d400488cc028008014018400c4cd408c01000d4080004cd54c01c480048d400488c8cd5409400cc004014c8004d540a8894cd40044d5402800c884d4008894cd4cc03000802044888cc0080280104c01800c008c8004d5408c88448894cd40044008884cc014008ccd54c01c480040140100044484888c00c0104484888c004010c8004d540808844894cd400454074884cd4078c010008cd54c01848004010004c8004d5407c88448894cd40044d400c88004884ccd401488008c010008ccd54c01c4800401401000448c88c008dd6000990009aa80f911999aab9f0012501b233501a30043574200460066ae8800804c8c8c8cccd5cd19b8735573aa004900011991091980080180118051aba150023005357426ae8940088c98c804ccd5ce00a00980889aab9e5001137540024646464646666ae68cdc39aab9d5004480008cccc888848cccc00401401000c008c8c8c8cccd5cd19b8735573aa004900011991091980080180118099aba1500233500d012357426ae8940088c98c8060cd5ce00c80c00b09aab9e5001137540026ae854010ccd54021d728039aba150033232323333573466e1d4005200423212223002004357426aae79400c8cccd5cd19b875002480088c84888c004010dd71aba135573ca00846666ae68cdc3a801a400042444006464c6403466ae7006c06806005c0584d55cea80089baa00135742a00466a012eb8d5d09aba2500223263201433573802a02802426ae8940044d5d1280089aab9e500113754002266aa002eb9d6889119118011bab0013200135501c223233335573e0044a032466a03066aa034600c6aae754008c014d55cf280118021aba200301113574200224464646666ae68cdc3a800a40004642446004006600a6ae84d55cf280191999ab9a3370ea0049001109100091931900899ab9c01201100f00e135573aa00226ea80048c8c8cccd5cd19b875001480188c848888c010014c01cd5d09aab9e500323333573466e1d400920042321222230020053009357426aae7940108cccd5cd19b875003480088c848888c004014c01cd5d09aab9e500523333573466e1d40112000232122223003005375c6ae84d55cf280311931900899ab9c01201100f00e00d00c135573aa00226ea80048c8c8cccd5cd19b8735573aa004900011991091980080180118029aba15002375a6ae84d5d1280111931900699ab9c00e00d00b135573ca00226ea80048c8cccd5cd19b8735573aa002900011bae357426aae7940088c98c802ccd5ce00600580489baa001232323232323333573466e1d4005200c21222222200323333573466e1d4009200a21222222200423333573466e1d400d2008233221222222233001009008375c6ae854014dd69aba135744a00a46666ae68cdc3a8022400c4664424444444660040120106eb8d5d0a8039bae357426ae89401c8cccd5cd19b875005480108cc8848888888cc018024020c030d5d0a8049bae357426ae8940248cccd5cd19b875006480088c848888888c01c020c034d5d09aab9e500b23333573466e1d401d2000232122222223005008300e357426aae7940308c98c8050cd5ce00a80a00900880800780700680609aab9d5004135573ca00626aae7940084d55cf280089baa0012323232323333573466e1d400520022333222122333001005004003375a6ae854010dd69aba15003375a6ae84d5d1280191999ab9a3370ea0049000119091180100198041aba135573ca00c464c6401a66ae7003803402c0284d55cea80189aba25001135573ca00226ea80048c8c8cccd5cd19b875001480088c8488c00400cdd71aba135573ca00646666ae68cdc3a8012400046424460040066eb8d5d09aab9e500423263200a33573801601401000e26aae7540044dd500089119191999ab9a3370e6aae75400920002332212330010030023232323333573466e1cd55cea8012400046644246600200600466a0140126ae854008c02cd5d09aba2500223263200d33573801c01a01626aae7940044dd50009aba150023232323333573466e1cd55cea8012400046644246600200600466a0140126ae854008c02cd5d09aba2500223263200d33573801c01a01626aae7940044dd50009aba135744a004464c6401266ae7002802401c4d55cf280089baa00112232323333573466e1d400520042122200123333573466e1d40092002232122230030043006357426aae7940108cccd5cd19b87500348000848880088c98c8028cd5ce00580500400380309aab9d5001137540024646666ae68cdc3a800a4004402446666ae68cdc3a801240004024464c6400c66ae7001c01801000c4d55ce9baa00149848005240103505431001123300100200c2253350021001100b123350022233350032200200200135001220011221233001003002112200212212233001004003112212330010030022233500223350022335002233500223300700200120092335002200923300700200122200922233500420092225335333573466e1c01800c03002c54cd4ccd5cd19b8700500200c00b13300a004001100b100b22333573466e3c00800401401088ccd5cd19b870020010040031220021220011123230010012233003300200200101" +} From 289b7e42dfcbff4ff924b4d34f3d8853682ff603 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Tue, 30 Aug 2022 09:19:04 -0500 Subject: [PATCH 2/2] Review fixes --- scripts/babbage/example-babbage-script-usage.sh | 3 +-- scripts/babbage/script-context-equivalance-test.sh | 6 +++--- scripts/babbage/script-mint-context-equivalance-test.sh | 3 +-- scripts/lite/example-build-cmd.sh | 1 - scripts/lite/split-txouts.sh | 1 - scripts/plutus/always-fails.sh | 1 - scripts/plutus/example-txin-locking-plutus-script.sh | 1 - scripts/plutus/script-context-equivalance-test.sh | 3 +-- 8 files changed, 6 insertions(+), 13 deletions(-) diff --git a/scripts/babbage/example-babbage-script-usage.sh b/scripts/babbage/example-babbage-script-usage.sh index c012e70d093..f5789046d90 100755 --- a/scripts/babbage/example-babbage-script-usage.sh +++ b/scripts/babbage/example-babbage-script-usage.sh @@ -15,7 +15,6 @@ export UTXO_SKEY="${UTXO_SKEY:-example/utxo-keys/utxo1.skey}" export RESULT_FILE="${RESULT_FILE:-$WORK/result.out}" echo "Socket path: $CARDANO_NODE_SOCKET_PATH" -echo "Socket path: $(pwd)" ls -al "$CARDANO_NODE_SOCKET_PATH" @@ -110,7 +109,7 @@ $CARDANO_CLI query utxo --address $plutusspendingscriptaddr --testnet-magic "$TE plutuslockedutxotxin=$(jq -r 'keys[0]' $WORK/plutusutxo.json) lovelaceatplutusspendingscriptaddr=$(jq -r ".[\"$plutuslockedutxotxin\"].value.lovelace" $WORK/plutusutxo.json) -#Get read only reference input +# Get read only reference input $CARDANO_CLI query utxo --address "$readonlyaddress" --cardano-mode \ --testnet-magic "$TESTNET_MAGIC" --out-file $WORK/read-only-ref-input-utxo.json readonlyrefinput=$(jq -r 'keys[0]' $WORK/read-only-ref-input-utxo.json) diff --git a/scripts/babbage/script-context-equivalance-test.sh b/scripts/babbage/script-context-equivalance-test.sh index 0fd9357e62c..f5cd931184b 100755 --- a/scripts/babbage/script-context-equivalance-test.sh +++ b/scripts/babbage/script-context-equivalance-test.sh @@ -17,7 +17,6 @@ export RESULT_FILE="${RESULT_FILE:-$WORK/result.out}" mkdir -p "$WORK" echo "Socket path: $CARDANO_NODE_SOCKET_PATH" -echo "Socket path: $(pwd)" ls -al "$CARDANO_NODE_SOCKET_PATH" @@ -40,6 +39,7 @@ cardano-cli stake-address registration-certificate \ plutusscriptaddr=$($CARDANO_CLI address build --payment-script-file "$plutusscriptinuse" --testnet-magic "$TESTNET_MAGIC") +# The input at the readonlyaddress will be used as a reference input readonlyaddress=addr_test1vz3t3f2kgy2re66tnhgxc4t8jgylw2cqfnxdwlrq9agfmtstxxkm5 mkdir -p "$WORK" @@ -96,14 +96,14 @@ dummyaddress=addr_test1vpqgspvmh6m2m5pwangvdg499srfzre2dd96qq57nlnw6yctpasy4 lovelaceatplutusscriptaddr=$(jq -r ".[\"$plutusutxotxin\"].value.lovelace" $WORK/plutusutxo.json) -#Get read only reference input +# Get read only reference input $CARDANO_CLI query utxo --address "$readonlyaddress" --cardano-mode \ --testnet-magic "$TESTNET_MAGIC" --out-file $WORK/read-only-ref-input-utxo.json readonlyrefinput=$(jq -r 'keys[0]' $WORK/read-only-ref-input-utxo.json) -# We need to generate a dummy redeemer in order to create a txbody from which we can generate +# We need to generate a dummy redeemer (the cli demands a redeemer) in order to create a txbody from which we can generate # a tx and then derive the correct redeemer. create-script-context --plutus-v2 --out-file "$WORK/script-context.redeemer" diff --git a/scripts/babbage/script-mint-context-equivalance-test.sh b/scripts/babbage/script-mint-context-equivalance-test.sh index 4e2d8475c7e..13e6ad02349 100755 --- a/scripts/babbage/script-mint-context-equivalance-test.sh +++ b/scripts/babbage/script-mint-context-equivalance-test.sh @@ -17,7 +17,6 @@ export RESULT_FILE="${RESULT_FILE:-$WORK/result.out}" mkdir -p "$WORK" echo "Socket path: $CARDANO_NODE_SOCKET_PATH" -echo "Socket path: $(pwd)" ls -al "$CARDANO_NODE_SOCKET_PATH" @@ -70,7 +69,7 @@ txinfunding1=$(jq -r 'keys[1]' $WORK/utxo-2.json) dummyaddress=addr_test1vpqgspvmh6m2m5pwangvdg499srfzre2dd96qq57nlnw6yctpasy4 -# We need to generate a dummy redeemer in order to create a txbody from which we can generate +# We need to generate a dummy redeemer (the cli demands a redeemer) in order to create a txbody from which we can generate # a tx and then derive the correct redeemer. create-script-context --plutus-v2 --out-file "$WORK/script-context.redeemer" diff --git a/scripts/lite/example-build-cmd.sh b/scripts/lite/example-build-cmd.sh index e30af029a79..93d0e20d564 100755 --- a/scripts/lite/example-build-cmd.sh +++ b/scripts/lite/example-build-cmd.sh @@ -16,7 +16,6 @@ export RESULT_FILE_TARGET="${RESULT_FILE:-$WORK/target.out}" export RESULT_FILE_CHANGE="${RESULT_FILE:-$WORK/change.out}" echo "Socket path: $CARDANO_NODE_SOCKET_PATH" -echo "Socket path: $(pwd)" ls -al "$CARDANO_NODE_SOCKET_PATH" diff --git a/scripts/lite/split-txouts.sh b/scripts/lite/split-txouts.sh index 5e60f725a5a..9035540201e 100755 --- a/scripts/lite/split-txouts.sh +++ b/scripts/lite/split-txouts.sh @@ -17,7 +17,6 @@ export RESULT_FILE_TARGET="${RESULT_FILE:-$WORK/target.out}" export RESULT_FILE_CHANGE="${RESULT_FILE:-$WORK/change.out}" echo "Socket path: $CARDANO_NODE_SOCKET_PATH" -echo "Socket path: $(pwd)" count="${1:-1000000}" diff --git a/scripts/plutus/always-fails.sh b/scripts/plutus/always-fails.sh index bb28a7c6fdb..ea6c34fbc3d 100755 --- a/scripts/plutus/always-fails.sh +++ b/scripts/plutus/always-fails.sh @@ -16,7 +16,6 @@ export RESULT_FILE="${RESULT_FILE:-$WORK/result.out}" export PV=v1 # Plutus Script Version echo "Socket path: $CARDANO_NODE_SOCKET_PATH" -echo "Socket path: $(pwd)" ls -al "$CARDANO_NODE_SOCKET_PATH" diff --git a/scripts/plutus/example-txin-locking-plutus-script.sh b/scripts/plutus/example-txin-locking-plutus-script.sh index 3077a44261b..ea04fcd893e 100755 --- a/scripts/plutus/example-txin-locking-plutus-script.sh +++ b/scripts/plutus/example-txin-locking-plutus-script.sh @@ -15,7 +15,6 @@ export UTXO_SKEY="${UTXO_SKEY:-example/utxo-keys/utxo1.skey}" export RESULT_FILE="${RESULT_FILE:-$WORK/result.out}" echo "Socket path: $CARDANO_NODE_SOCKET_PATH" -echo "Socket path: $(pwd)" ls -al "$CARDANO_NODE_SOCKET_PATH" diff --git a/scripts/plutus/script-context-equivalance-test.sh b/scripts/plutus/script-context-equivalance-test.sh index 4eb92727413..3d705c03748 100755 --- a/scripts/plutus/script-context-equivalance-test.sh +++ b/scripts/plutus/script-context-equivalance-test.sh @@ -16,7 +16,6 @@ export RESULT_FILE="${RESULT_FILE:-$WORK/result.out}" export PV=v1 # Plutus Script Version echo "Socket path: $CARDANO_NODE_SOCKET_PATH" -echo "Socket path: $(pwd)" ls -al "$CARDANO_NODE_SOCKET_PATH" @@ -94,7 +93,7 @@ echo "$plutusutxotxin" echo "Collateral" echo "$txinCollateral" -# We need to generate a dummy redeemer in order to create a txbody from which we can generate +# We need to generate a dummy redeemer (the cli demands a redeemer) in order to create a txbody from which we can generate # a tx and then derive the correct redeemer. create-script-context --out-file "$WORK/script-context.redeemer"