From 4ef1ba69de9735538e37b28a681e09d49ce88f2f Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 14 Feb 2023 09:16:30 +0100 Subject: [PATCH 1/8] Use blueprint in hello-world example. --- examples/hello_world/hello_world-lock.ts | 7 ++++--- examples/hello_world/hello_world-unlock.ts | 9 +++++---- examples/hello_world/plutus.json | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/hello_world/hello_world-lock.ts b/examples/hello_world/hello_world-lock.ts index 8cc7efe3..2cb1d00f 100644 --- a/examples/hello_world/hello_world-lock.ts +++ b/examples/hello_world/hello_world-lock.ts @@ -20,14 +20,15 @@ const lucid = await Lucid.new( lucid.selectWalletFromPrivateKey(await Deno.readTextFile("./key.sk")); -const validator = await readValidator("./assets/hello_world/spend/script.cbor"); +const validator = await readValidator(); // --- Supporting functions -async function readValidator(filepath: String): Promise { +async function readValidator(): Promise { + const validator = JSON.parse(await Deno.readTextFile("plutus.json")).validators[0]; return { type: "PlutusV2", - script: toHex(cbor.encode(fromHex(await Deno.readTextFile(filepath)))), + script: toHex(cbor.encode(fromHex(validator.compiledCode))), }; } diff --git a/examples/hello_world/hello_world-unlock.ts b/examples/hello_world/hello_world-unlock.ts index ab753762..646cfc12 100644 --- a/examples/hello_world/hello_world-unlock.ts +++ b/examples/hello_world/hello_world-unlock.ts @@ -21,7 +21,7 @@ const lucid = await Lucid.new( lucid.selectWalletFromPrivateKey(await Deno.readTextFile("./key.sk")); -const validator = await readValidator("./assets/hello_world/spend/script.cbor"); +const validator = await readValidator(); const utxo = { txHash: Deno.args[0], outputIndex: 0 }; @@ -55,9 +55,10 @@ async function unlock(ref, { from, using }): Promise { return signedTx.submit(); } -async function readValidator(filepath: String): Promise { +async function readValidator(): Promise { + const validator = JSON.parse(await Deno.readTextFile("plutus.json")).validators[0]; return { - type: "PlutusV2", - script: toHex(cbor.encode(fromHex(await Deno.readTextFile(filepath)))), + type: "PlutusV2", + script: toHex(cbor.encode(fromHex(validator.compiledCode))), }; } diff --git a/examples/hello_world/plutus.json b/examples/hello_world/plutus.json index 3e4e8b09..d456df61 100644 --- a/examples/hello_world/plutus.json +++ b/examples/hello_world/plutus.json @@ -40,8 +40,8 @@ } ] }, - "compiledCode": "58ad0100003232322225333004323253330063372e646e64004dd7198009801002240009210d48656c6c6f2c20576f726c64210013233300100137586600460066600460060089000240206eb8cc008c00c019200022253335573e004294054ccc024cdc79bae300a00200114a226660060066016004002294088c8ccc0040052000003222333300a3370e008004016466600800866e0000d2002300d001001235573c6ea8004526165734ae855d11", - "hash": "5e1e8fa84f2b557ddc362329413caa3fd89a1be26bfd24be05ce0a02" + "compiledCode": "58e10100003232323232323232222533300632323232533300a002100114a06464660026eb0cc010c014cc010c014019200048040dd7198021802804240006002002444a66601e00429404c8c94ccc038cdc78010018a5113330050050010033012003375c602000466e5cc8dcc8009bae330013002004480012410d48656c6c6f2c20576f726c64210022323330010014800000c888cccc030cdc3802001008119980200219b8000348008c0480040048c024dd50008a4c2c6002002444a66600e004293099802980098040011998018019804801000ab9a5736aae7955cfaba15745", + "hash": "287233442cf812fafd74ab135d665f110de89ac12775204ad741f220" } ] } \ No newline at end of file From 545323128cdbb7256cb1cb64ccffa24c820ec860 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 14 Feb 2023 10:39:31 +0100 Subject: [PATCH 2/8] Write basic e2e validator with evaluation. --- examples/acceptance_tests/062/aiken.lock | 13 +++++++ examples/acceptance_tests/062/aiken.toml | 8 +++++ .../062/data/001-basic/inputs.cbor | 1 + .../062/data/001-basic/outputs.cbor.template | 1 + .../062/data/001-basic/tx.cbor.template | 1 + examples/acceptance_tests/062/plutus.json | 36 +++++++++++++++++++ examples/acceptance_tests/062/prepare.sh | 4 +++ .../acceptance_tests/062/validators/basic.ak | 6 ++++ 8 files changed, 70 insertions(+) create mode 100644 examples/acceptance_tests/062/aiken.lock create mode 100644 examples/acceptance_tests/062/aiken.toml create mode 100644 examples/acceptance_tests/062/data/001-basic/inputs.cbor create mode 100644 examples/acceptance_tests/062/data/001-basic/outputs.cbor.template create mode 100644 examples/acceptance_tests/062/data/001-basic/tx.cbor.template create mode 100644 examples/acceptance_tests/062/plutus.json create mode 100755 examples/acceptance_tests/062/prepare.sh create mode 100644 examples/acceptance_tests/062/validators/basic.ak diff --git a/examples/acceptance_tests/062/aiken.lock b/examples/acceptance_tests/062/aiken.lock new file mode 100644 index 00000000..0423f31b --- /dev/null +++ b/examples/acceptance_tests/062/aiken.lock @@ -0,0 +1,13 @@ +# This file was generated by Aiken +# You typically do not need to edit this file + +[[requirements]] +name = "aiken-lang/stdlib" +version = "main" +source = "github" + +[[packages]] +name = "aiken-lang/stdlib" +version = "main" +requirements = [] +source = "github" diff --git a/examples/acceptance_tests/062/aiken.toml b/examples/acceptance_tests/062/aiken.toml new file mode 100644 index 00000000..afc17aa0 --- /dev/null +++ b/examples/acceptance_tests/062/aiken.toml @@ -0,0 +1,8 @@ +name = 'aiken-lang/acceptance_test_062' +version = '0.0.0' +description = '' + +[[dependencies]] +name = 'aiken-lang/stdlib' +version = 'main' +source = 'github' diff --git a/examples/acceptance_tests/062/data/001-basic/inputs.cbor b/examples/acceptance_tests/062/data/001-basic/inputs.cbor new file mode 100644 index 00000000..e7f75b49 --- /dev/null +++ b/examples/acceptance_tests/062/data/001-basic/inputs.cbor @@ -0,0 +1 @@ +81825820000000000000000000000000000000000000000000000000000000000000000000 diff --git a/examples/acceptance_tests/062/data/001-basic/outputs.cbor.template b/examples/acceptance_tests/062/data/001-basic/outputs.cbor.template new file mode 100644 index 00000000..ca3e5631 --- /dev/null +++ b/examples/acceptance_tests/062/data/001-basic/outputs.cbor.template @@ -0,0 +1 @@ +81A300581D70{{ VALIDATOR_HASH }}1ED86D464F20AB66EE47AB662572820052078CC8D75345E06A9E8D4011A3B9ACA00028201D81843D87980 diff --git a/examples/acceptance_tests/062/data/001-basic/tx.cbor.template b/examples/acceptance_tests/062/data/001-basic/tx.cbor.template new file mode 100644 index 00000000..72e92176 --- /dev/null +++ b/examples/acceptance_tests/062/data/001-basic/tx.cbor.template @@ -0,0 +1 @@ +84A80081825820000000000000000000000000000000000000000000000000000000000000000000018182581D60000000000000000000000000000000000000000000000000000000001A3B9ACA00021A0002DF6705A1581DE0000000000000000000000000000000000000000000000000000000001A0280DE800B5820FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D818258200000000000000000000000000000000000000000000000000000000000000000001082581D60000000000000000000000000000000000000000000000000000000001A3B9ACA00111A00044F1BA20581840000D87980821A000F42401A05F5E100068158A2{{ VALIDATOR }}8A00100003232323232323232222533300632323370E646460026EB0CC00CC010CC00CC010015200048010C004004894CCC03400452000132337009001198018018009807800A400444646660020029000001911199980619B8700400201023330040043370000690011809000800918049BAA001149858C0040048894CCC01C0085261330053001300800233300300330090020015734AE6D55CF2AB9F5742AE89F5F6 diff --git a/examples/acceptance_tests/062/plutus.json b/examples/acceptance_tests/062/plutus.json new file mode 100644 index 00000000..c6abab15 --- /dev/null +++ b/examples/acceptance_tests/062/plutus.json @@ -0,0 +1,36 @@ +{ + "preamble": { + "title": "aiken-lang/acceptance_test_062", + "version": "0.0.0" + }, + "validators": [ + { + "title": "basic", + "purpose": "spend", + "datum": { + "title": "Unit", + "description": "The nullary constructor.", + "anyOf": [ + { + "dataType": "constructor", + "index": 0, + "fields": [] + } + ] + }, + "redeemer": { + "title": "Unit", + "description": "The nullary constructor.", + "anyOf": [ + { + "dataType": "constructor", + "index": 0, + "fields": [] + } + ] + }, + "compiledCode": "58a00100003232323232323232222533300632323370e646460026eb0cc00cc010cc00cc010015200048010c004004894ccc03400452000132337009001198018018009807800a400444646660020029000001911199980619b8700400201023330040043370000690011809000800918049baa001149858c0040048894ccc01c0085261330053001300800233300300330090020015734ae6d55cf2ab9f5742ae89", + "hash": "81ed86d464f20ab66ee47ab662572820052078cc8d75345e06a9e8d4" + } + ] +} \ No newline at end of file diff --git a/examples/acceptance_tests/062/prepare.sh b/examples/acceptance_tests/062/prepare.sh new file mode 100755 index 00000000..bab2e77f --- /dev/null +++ b/examples/acceptance_tests/062/prepare.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +aiken build +VALIDATOR=$(jq ".validators[] | select(.title == \"basic\")" plutus.json) diff --git a/examples/acceptance_tests/062/validators/basic.ak b/examples/acceptance_tests/062/validators/basic.ak new file mode 100644 index 00000000..dcb77e24 --- /dev/null +++ b/examples/acceptance_tests/062/validators/basic.ak @@ -0,0 +1,6 @@ +use aiken/list +use aiken/transaction.{ScriptContext} + +fn spend(_datum: Void, _redeemer: Void, ctx: ScriptContext) { + list.length(ctx.transaction.outputs) == 1 +} From 251aa756d984bcf067021a94275c84e4d6a881c5 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 14 Feb 2023 11:37:10 +0100 Subject: [PATCH 3/8] Make basic script a template, and add more assertions. --- examples/acceptance_tests/062/.gitignore | 1 + .../062/data/001-basic/outputs.cbor.template | 1 - .../062/data/001-basic/tx.cbor.template | 1 - .../inputs.cbor.template} | 0 .../062/data/basic/outputs.cbor.template | 1 + .../062/data/basic/tx.cbor.template | 1 + .../062/data/basic/tx.diag.template | 32 ++++++++++++++ examples/acceptance_tests/062/plutus.json | 4 +- examples/acceptance_tests/062/prepare.sh | 4 -- examples/acceptance_tests/062/test.sh | 42 +++++++++++++++++++ .../acceptance_tests/062/validators/basic.ak | 41 +++++++++++++++++- 11 files changed, 118 insertions(+), 10 deletions(-) create mode 100644 examples/acceptance_tests/062/.gitignore delete mode 100644 examples/acceptance_tests/062/data/001-basic/outputs.cbor.template delete mode 100644 examples/acceptance_tests/062/data/001-basic/tx.cbor.template rename examples/acceptance_tests/062/data/{001-basic/inputs.cbor => basic/inputs.cbor.template} (100%) create mode 100644 examples/acceptance_tests/062/data/basic/outputs.cbor.template create mode 100644 examples/acceptance_tests/062/data/basic/tx.cbor.template create mode 100644 examples/acceptance_tests/062/data/basic/tx.diag.template delete mode 100755 examples/acceptance_tests/062/prepare.sh create mode 100755 examples/acceptance_tests/062/test.sh diff --git a/examples/acceptance_tests/062/.gitignore b/examples/acceptance_tests/062/.gitignore new file mode 100644 index 00000000..f5d99950 --- /dev/null +++ b/examples/acceptance_tests/062/.gitignore @@ -0,0 +1 @@ +data/**/*.cbor diff --git a/examples/acceptance_tests/062/data/001-basic/outputs.cbor.template b/examples/acceptance_tests/062/data/001-basic/outputs.cbor.template deleted file mode 100644 index ca3e5631..00000000 --- a/examples/acceptance_tests/062/data/001-basic/outputs.cbor.template +++ /dev/null @@ -1 +0,0 @@ -81A300581D70{{ VALIDATOR_HASH }}1ED86D464F20AB66EE47AB662572820052078CC8D75345E06A9E8D4011A3B9ACA00028201D81843D87980 diff --git a/examples/acceptance_tests/062/data/001-basic/tx.cbor.template b/examples/acceptance_tests/062/data/001-basic/tx.cbor.template deleted file mode 100644 index 72e92176..00000000 --- a/examples/acceptance_tests/062/data/001-basic/tx.cbor.template +++ /dev/null @@ -1 +0,0 @@ -84A80081825820000000000000000000000000000000000000000000000000000000000000000000018182581D60000000000000000000000000000000000000000000000000000000001A3B9ACA00021A0002DF6705A1581DE0000000000000000000000000000000000000000000000000000000001A0280DE800B5820FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D818258200000000000000000000000000000000000000000000000000000000000000000001082581D60000000000000000000000000000000000000000000000000000000001A3B9ACA00111A00044F1BA20581840000D87980821A000F42401A05F5E100068158A2{{ VALIDATOR }}8A00100003232323232323232222533300632323370E646460026EB0CC00CC010CC00CC010015200048010C004004894CCC03400452000132337009001198018018009807800A400444646660020029000001911199980619B8700400201023330040043370000690011809000800918049BAA001149858C0040048894CCC01C0085261330053001300800233300300330090020015734AE6D55CF2AB9F5742AE89F5F6 diff --git a/examples/acceptance_tests/062/data/001-basic/inputs.cbor b/examples/acceptance_tests/062/data/basic/inputs.cbor.template similarity index 100% rename from examples/acceptance_tests/062/data/001-basic/inputs.cbor rename to examples/acceptance_tests/062/data/basic/inputs.cbor.template diff --git a/examples/acceptance_tests/062/data/basic/outputs.cbor.template b/examples/acceptance_tests/062/data/basic/outputs.cbor.template new file mode 100644 index 00000000..71a0de30 --- /dev/null +++ b/examples/acceptance_tests/062/data/basic/outputs.cbor.template @@ -0,0 +1 @@ +81A300581D70{{ VALIDATOR_HASH }}011A3B9ACA00028201D81843D87980 diff --git a/examples/acceptance_tests/062/data/basic/tx.cbor.template b/examples/acceptance_tests/062/data/basic/tx.cbor.template new file mode 100644 index 00000000..1b121c91 --- /dev/null +++ b/examples/acceptance_tests/062/data/basic/tx.cbor.template @@ -0,0 +1 @@ +84A70081825820000000000000000000000000000000000000000000000000000000000000000000018182581D60111111111111111111111111111111111111111111111111111111111A3B9ACA0002182A0B5820FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D818258200000000000000000000000000000000000000000000000000000000000000000001082581D60000000000000000000000000000000000000000000000000000000001A3B9ACA001101A20581840000D87980821A000F42401A05F5E1000681{{ VALIDATOR }}F5F6 diff --git a/examples/acceptance_tests/062/data/basic/tx.diag.template b/examples/acceptance_tests/062/data/basic/tx.diag.template new file mode 100644 index 00000000..872528af --- /dev/null +++ b/examples/acceptance_tests/062/data/basic/tx.diag.template @@ -0,0 +1,32 @@ +[ + { 0: + [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] + ] + + , 1: + [ [h'6011111111111111111111111111111111111111111111111111111111', 1000000000] + ] + + , 2: 42 + + , 11: h'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' + + , 13: + [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] + ] + + , 16: + [ h'6000000000000000000000000000000000000000000000000000000000', 1000000000 + ] + + , 17: 1 + }, + + { 5: [[0, 0, 121([]), [1000000, 100000000]]] + + , 6: [h'VALIDATOR'] + + }, + true, + null +] diff --git a/examples/acceptance_tests/062/plutus.json b/examples/acceptance_tests/062/plutus.json index c6abab15..89e8f7ce 100644 --- a/examples/acceptance_tests/062/plutus.json +++ b/examples/acceptance_tests/062/plutus.json @@ -29,8 +29,8 @@ } ] }, - "compiledCode": "58a00100003232323232323232222533300632323370e646460026eb0cc00cc010cc00cc010015200048010c004004894ccc03400452000132337009001198018018009807800a400444646660020029000001911199980619b8700400201023330040043370000690011809000800918049baa001149858c0040048894ccc01c0085261330053001300800233300300330090020015734ae6d55cf2ab9f5742ae89", - "hash": "81ed86d464f20ab66ee47ab662572820052078cc8d75345e06a9e8d4" + "compiledCode": "5903dd010000323232323232323232323222253330063232323232300200132323232323301533300f323253330113370e002900109919299980999baf3300c300d0014800130126d8799f58200000000000000000000000000000000000000000000000000000000000000000ff0013370e6eb4cc030c034005200248000528180c80098058010a99809a491c73637269707420707572706f73652069736e277420275370656e6427001630133754002660106012014900126103d87a80004c0103d87980003301533300f32325333016001153301349011c756e6578706563746564206e756d626572206f66206f7574707574730016132533301700113232300b001330193330133375e6e98dd5998061806800a40046e98c0152080a8d6b9074c103d87a80004c0103d8798000330193330133375e66018601a66018601a002900024000980122d8799f581c11111111111111111111111111111111111111111111111111111111ff004c0103d87a80004c0103d879800033019333013323253330153370e0029000099250300f00214a2602e6ea8004cc030c034cc030c034005200048009300103d87a80004c0103d87980004bd70180c8010a9980a2491c756e6578706563746564206e756d626572206f66206f757470757473001630190013758660126014002900219804180480524000980103d87a80004c0103d87980003301533300f323375e6e98dd5998049805000a400c6e98c009205433008300900a4800130103d87a80004c0103d87980004bd7011999111919000999911199804801801000a5eb7bdb180010004ccc888ccc02800c0080052f5bded8c0004002910100488100001300100122225333015003133016337606ea4008dd3000a5eb7bdb1804c8c8c8c94ccc050cdc800300089980d19bb0375200c6e9801401c54ccc050cdc780300089980d19bb0375200c6e9801400c4cc068cdd81ba9001374c004666601001000600c00a6eb8c05800cdd5980b001180c802180b80198008009111299980980189980a19bb037520046ea00052f5bded8c0264646464a66602466e400180044cc060cdd81ba9006375000a00e2a66602466e3c0180044cc060cdd81ba9006375000a00626603066ec0dd48009ba80023333008008003006005375c60280066eb4c050008c05c010c05400cc004004894ccc03c0045288991929998060010998020020008a5030130023370e900118069baa301100122323330010014800000c888cccc030cdc3802001009919980200219b8000348008c0540040048c02cdd50008a4c2c6002002444a666012004293099802980098058011998018019806001000ab9a5736ae7155ceaab9e5573eae815d0aba201", + "hash": "0a7d654e443b18df327a2710a65bd9eee74dc7a9e26b1aca91bac9e5" } ] } \ No newline at end of file diff --git a/examples/acceptance_tests/062/prepare.sh b/examples/acceptance_tests/062/prepare.sh deleted file mode 100755 index bab2e77f..00000000 --- a/examples/acceptance_tests/062/prepare.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -aiken build -VALIDATOR=$(jq ".validators[] | select(.title == \"basic\")" plutus.json) diff --git a/examples/acceptance_tests/062/test.sh b/examples/acceptance_tests/062/test.sh new file mode 100755 index 00000000..2dc83d9e --- /dev/null +++ b/examples/acceptance_tests/062/test.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +TITLE=$1 +if [ -z $TITLE ]; then + echo -e "\033[31mMissing argument: \033[1mVALIDATOR_TITLE\033[0m" + echo "" + echo -e "\033[1mUsage: \033[0m" + echo " test.sh {ACCEPTANCE_TEST}" + echo "" + echo -e "\033[1mExample: \033[0m" + echo " test.sh basic" + exit 1 +fi + +if ! command -v jq &> /dev/null +then + echo "\033[1mjq\033[0m missing from system but required." + exit 1 +fi + +if ! command -v cbor-diag &> /dev/null +then + echo "\033[1mcbor-diag\033[0m missing from system but required." + exit 1 +fi + +aiken build +if [ $? -ne 0 ]; then + exit $? +fi + +BLUEPRINT=$(jq ".validators[] | select(.title == \"$TITLE\")" plutus.json) + +VALIDATOR_HASH=$(echo $BLUEPRINT | jq .hash | sed s/\"//g) +VALIDATOR=$(echo $BLUEPRINT | jq .compiledCode | sed s/\"//g) +VALIDATOR=$(cbor-diag --to hex --from diag <<< "h'$VALIDATOR'") + +cp data/$TITLE/inputs.cbor.template data/$TITLE/inputs.cbor +sed "s/{{ VALIDATOR_HASH }}/$VALIDATOR_HASH/" data/$TITLE/outputs.cbor.template > data/$TITLE/outputs.cbor +sed "s/{{ VALIDATOR }}/$VALIDATOR/" data/$TITLE/tx.cbor.template > data/$TITLE/tx.cbor + +aiken tx simulate data/$TITLE/tx.cbor data/$TITLE/inputs.cbor data/$TITLE/outputs.cbor diff --git a/examples/acceptance_tests/062/validators/basic.ak b/examples/acceptance_tests/062/validators/basic.ak index dcb77e24..79351baa 100644 --- a/examples/acceptance_tests/062/validators/basic.ak +++ b/examples/acceptance_tests/062/validators/basic.ak @@ -1,6 +1,43 @@ use aiken/list -use aiken/transaction.{ScriptContext} +use aiken/option +use aiken/transaction.{ScriptContext, Spend, TransactionId} +use aiken/transaction/credential.{VerificationKeyCredential} +use aiken/transaction/value fn spend(_datum: Void, _redeemer: Void, ctx: ScriptContext) { - list.length(ctx.transaction.outputs) == 1 + [ + assert_purpose(ctx.purpose), + assert_outputs(ctx.transaction), + assert_fee(ctx.transaction), + ] + |> list.and +} + +fn assert_purpose(purpose) { + when purpose is { + Spend(ref) -> + ref.transaction_id == TransactionId( + #"0000000000000000000000000000000000000000000000000000000000000000", + ) && ref.output_index == 0 + _ -> error("script purpose isn't 'Spend'") + } +} + +fn assert_fee(transaction) { + transaction.fee == value.from_lovelace(42) +} + +fn assert_outputs(transaction) { + when transaction.outputs is { + [output] -> + [ + output.value == value.from_lovelace(1000000000), + output.address.payment_credential == VerificationKeyCredential( + #"11111111111111111111111111111111111111111111111111111111", + ), + option.is_none(output.address.stake_credential), + ] + |> list.and + _ -> error("unexpected number of outputs") + } } From 34596b30843606dc91628795815f9390febe45d6 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 14 Feb 2023 15:58:34 +0100 Subject: [PATCH 4/8] Fix collecting withdrawal scripts in eval_phase_one The current implementation assumed that ALL withdrawals present in a transaction had to be locked by a script and failed otherwise. But a transaction can actually be composed of both. So instead of failing, we should rather just ignore withdrawals that can't be referenced by redeemers. --- crates/uplc/src/tx/phase_one.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/uplc/src/tx/phase_one.rs b/crates/uplc/src/tx/phase_one.rs index 127188f6..3fc3dc02 100644 --- a/crates/uplc/src/tx/phase_one.rs +++ b/crates/uplc/src/tx/phase_one.rs @@ -283,15 +283,13 @@ fn build_redeemer_ptr( for (idx, x) in reward_accounts.iter().enumerate() { let cred = match Address::from_bytes(x).unwrap() { Address::Stake(a) => match a.payload() { - StakePayload::Script(sh) => StakeCredential::Scripthash(*sh), - StakePayload::Stake(_) => { - return Err(Error::ScriptKeyHash); - } + StakePayload::Script(sh) => Some(StakeCredential::Scripthash(*sh)), + StakePayload::Stake(_) => None, }, _ => return Err(Error::BadWithdrawalAddress), }; - if cred == *racnt { + if cred == Some(racnt.to_owned()) { maybe_idx = Some(idx); } } From 5369872a3d019f835d9a52cb10b3a73baac604e8 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 14 Feb 2023 16:08:51 +0100 Subject: [PATCH 5/8] Add new script_context acceptance scenario for withdrawals. --- examples/acceptance_tests/062/plutus.json | 36 ----------- examples/acceptance_tests/ci | 6 +- .../{062 => script_context}/.gitignore | 0 .../{062 => script_context}/aiken.lock | 0 .../{062 => script_context}/aiken.toml | 0 .../data/basic/inputs.cbor.template | 0 .../data/basic/outputs.cbor.template | 0 .../data/basic/tx.cbor.template | 0 .../data/basic/tx.diag.template | 0 .../data/withdrawals/inputs.cbor.template | 1 + .../data/withdrawals/outputs.cbor.template | 1 + .../data/withdrawals/tx.cbor.template | 1 + .../data/withdrawals/tx.diag.template | 40 ++++++++++++ .../script_context/plutus.json | 64 +++++++++++++++++++ .../{062 => script_context}/test.sh | 2 +- .../validators/basic.ak | 0 .../script_context/validators/withdrawals.ak | 35 ++++++++++ 17 files changed, 145 insertions(+), 41 deletions(-) delete mode 100644 examples/acceptance_tests/062/plutus.json rename examples/acceptance_tests/{062 => script_context}/.gitignore (100%) rename examples/acceptance_tests/{062 => script_context}/aiken.lock (100%) rename examples/acceptance_tests/{062 => script_context}/aiken.toml (100%) rename examples/acceptance_tests/{062 => script_context}/data/basic/inputs.cbor.template (100%) rename examples/acceptance_tests/{062 => script_context}/data/basic/outputs.cbor.template (100%) rename examples/acceptance_tests/{062 => script_context}/data/basic/tx.cbor.template (100%) rename examples/acceptance_tests/{062 => script_context}/data/basic/tx.diag.template (100%) create mode 100644 examples/acceptance_tests/script_context/data/withdrawals/inputs.cbor.template create mode 100644 examples/acceptance_tests/script_context/data/withdrawals/outputs.cbor.template create mode 100644 examples/acceptance_tests/script_context/data/withdrawals/tx.cbor.template create mode 100644 examples/acceptance_tests/script_context/data/withdrawals/tx.diag.template create mode 100644 examples/acceptance_tests/script_context/plutus.json rename examples/acceptance_tests/{062 => script_context}/test.sh (92%) rename examples/acceptance_tests/{062 => script_context}/validators/basic.ak (100%) create mode 100644 examples/acceptance_tests/script_context/validators/withdrawals.ak diff --git a/examples/acceptance_tests/062/plutus.json b/examples/acceptance_tests/062/plutus.json deleted file mode 100644 index 89e8f7ce..00000000 --- a/examples/acceptance_tests/062/plutus.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "preamble": { - "title": "aiken-lang/acceptance_test_062", - "version": "0.0.0" - }, - "validators": [ - { - "title": "basic", - "purpose": "spend", - "datum": { - "title": "Unit", - "description": "The nullary constructor.", - "anyOf": [ - { - "dataType": "constructor", - "index": 0, - "fields": [] - } - ] - }, - "redeemer": { - "title": "Unit", - "description": "The nullary constructor.", - "anyOf": [ - { - "dataType": "constructor", - "index": 0, - "fields": [] - } - ] - }, - "compiledCode": "5903dd010000323232323232323232323222253330063232323232300200132323232323301533300f323253330113370e002900109919299980999baf3300c300d0014800130126d8799f58200000000000000000000000000000000000000000000000000000000000000000ff0013370e6eb4cc030c034005200248000528180c80098058010a99809a491c73637269707420707572706f73652069736e277420275370656e6427001630133754002660106012014900126103d87a80004c0103d87980003301533300f32325333016001153301349011c756e6578706563746564206e756d626572206f66206f7574707574730016132533301700113232300b001330193330133375e6e98dd5998061806800a40046e98c0152080a8d6b9074c103d87a80004c0103d8798000330193330133375e66018601a66018601a002900024000980122d8799f581c11111111111111111111111111111111111111111111111111111111ff004c0103d87a80004c0103d879800033019333013323253330153370e0029000099250300f00214a2602e6ea8004cc030c034cc030c034005200048009300103d87a80004c0103d87980004bd70180c8010a9980a2491c756e6578706563746564206e756d626572206f66206f757470757473001630190013758660126014002900219804180480524000980103d87a80004c0103d87980003301533300f323375e6e98dd5998049805000a400c6e98c009205433008300900a4800130103d87a80004c0103d87980004bd7011999111919000999911199804801801000a5eb7bdb180010004ccc888ccc02800c0080052f5bded8c0004002910100488100001300100122225333015003133016337606ea4008dd3000a5eb7bdb1804c8c8c8c94ccc050cdc800300089980d19bb0375200c6e9801401c54ccc050cdc780300089980d19bb0375200c6e9801400c4cc068cdd81ba9001374c004666601001000600c00a6eb8c05800cdd5980b001180c802180b80198008009111299980980189980a19bb037520046ea00052f5bded8c0264646464a66602466e400180044cc060cdd81ba9006375000a00e2a66602466e3c0180044cc060cdd81ba9006375000a00626603066ec0dd48009ba80023333008008003006005375c60280066eb4c050008c05c010c05400cc004004894ccc03c0045288991929998060010998020020008a5030130023370e900118069baa301100122323330010014800000c888cccc030cdc3802001009919980200219b8000348008c0540040048c02cdd50008a4c2c6002002444a666012004293099802980098058011998018019806001000ab9a5736ae7155ceaab9e5573eae815d0aba201", - "hash": "0a7d654e443b18df327a2710a65bd9eee74dc7a9e26b1aca91bac9e5" - } - ] -} \ No newline at end of file diff --git a/examples/acceptance_tests/ci b/examples/acceptance_tests/ci index 4a93a982..26ec60f4 100755 --- a/examples/acceptance_tests/ci +++ b/examples/acceptance_tests/ci @@ -1,5 +1,3 @@ -for scenario in $(find . -maxdepth 1 -mindepth 1 -type d) -do - ./run $scenario +for scenario in $(find . -maxdepth 1 -mindepth 1 -regex ".*[0-9]\{3\}" -type d); do + ./run $scenario done - diff --git a/examples/acceptance_tests/062/.gitignore b/examples/acceptance_tests/script_context/.gitignore similarity index 100% rename from examples/acceptance_tests/062/.gitignore rename to examples/acceptance_tests/script_context/.gitignore diff --git a/examples/acceptance_tests/062/aiken.lock b/examples/acceptance_tests/script_context/aiken.lock similarity index 100% rename from examples/acceptance_tests/062/aiken.lock rename to examples/acceptance_tests/script_context/aiken.lock diff --git a/examples/acceptance_tests/062/aiken.toml b/examples/acceptance_tests/script_context/aiken.toml similarity index 100% rename from examples/acceptance_tests/062/aiken.toml rename to examples/acceptance_tests/script_context/aiken.toml diff --git a/examples/acceptance_tests/062/data/basic/inputs.cbor.template b/examples/acceptance_tests/script_context/data/basic/inputs.cbor.template similarity index 100% rename from examples/acceptance_tests/062/data/basic/inputs.cbor.template rename to examples/acceptance_tests/script_context/data/basic/inputs.cbor.template diff --git a/examples/acceptance_tests/062/data/basic/outputs.cbor.template b/examples/acceptance_tests/script_context/data/basic/outputs.cbor.template similarity index 100% rename from examples/acceptance_tests/062/data/basic/outputs.cbor.template rename to examples/acceptance_tests/script_context/data/basic/outputs.cbor.template diff --git a/examples/acceptance_tests/062/data/basic/tx.cbor.template b/examples/acceptance_tests/script_context/data/basic/tx.cbor.template similarity index 100% rename from examples/acceptance_tests/062/data/basic/tx.cbor.template rename to examples/acceptance_tests/script_context/data/basic/tx.cbor.template diff --git a/examples/acceptance_tests/062/data/basic/tx.diag.template b/examples/acceptance_tests/script_context/data/basic/tx.diag.template similarity index 100% rename from examples/acceptance_tests/062/data/basic/tx.diag.template rename to examples/acceptance_tests/script_context/data/basic/tx.diag.template diff --git a/examples/acceptance_tests/script_context/data/withdrawals/inputs.cbor.template b/examples/acceptance_tests/script_context/data/withdrawals/inputs.cbor.template new file mode 100644 index 00000000..e7f75b49 --- /dev/null +++ b/examples/acceptance_tests/script_context/data/withdrawals/inputs.cbor.template @@ -0,0 +1 @@ +81825820000000000000000000000000000000000000000000000000000000000000000000 diff --git a/examples/acceptance_tests/script_context/data/withdrawals/outputs.cbor.template b/examples/acceptance_tests/script_context/data/withdrawals/outputs.cbor.template new file mode 100644 index 00000000..71a0de30 --- /dev/null +++ b/examples/acceptance_tests/script_context/data/withdrawals/outputs.cbor.template @@ -0,0 +1 @@ +81A300581D70{{ VALIDATOR_HASH }}011A3B9ACA00028201D81843D87980 diff --git a/examples/acceptance_tests/script_context/data/withdrawals/tx.cbor.template b/examples/acceptance_tests/script_context/data/withdrawals/tx.cbor.template new file mode 100644 index 00000000..62f86104 --- /dev/null +++ b/examples/acceptance_tests/script_context/data/withdrawals/tx.cbor.template @@ -0,0 +1 @@ +84A80081825820000000000000000000000000000000000000000000000000000000000000000000018182581D60111111111111111111111111111111111111111111111111111111111A3B9ACA0002182A05A2581DE022222222222222222222222222222222222222222222222222222222182A581DF05E1E8FA84F2B557DDC362329413CAA3FD89A1BE26BFD24BE05CE0A020E0B5820FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D818258200000000000000000000000000000000000000000000000000000000000000000001082581D60000000000000000000000000000000000000000000000000000000001A3B9ACA001101A20582840000D87980821A000F42401A05F5E100840301D87980821A000F42401A05F5E1000682{{ VALIDATOR }}58AF58AD0100003232322225333004323253330063372E646E64004DD7198009801002240009210D48656C6C6F2C20576F726C64210013233300100137586600460066600460060089000240206EB8CC008C00C019200022253335573E004294054CCC024CDC79BAE300A00200114A226660060066016004002294088C8CCC0040052000003222333300A3370E008004016466600800866E0000D2002300D001001235573C6EA8004526165734AE855D11F5F6 diff --git a/examples/acceptance_tests/script_context/data/withdrawals/tx.diag.template b/examples/acceptance_tests/script_context/data/withdrawals/tx.diag.template new file mode 100644 index 00000000..787cabbe --- /dev/null +++ b/examples/acceptance_tests/script_context/data/withdrawals/tx.diag.template @@ -0,0 +1,40 @@ +[ + { 0: + [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] + ] + + , 1: + [ [h'6011111111111111111111111111111111111111111111111111111111', 1000000000] + ] + + , 2: 42 + + , 5: + { h'e022222222222222222222222222222222222222222222222222222222': 42 + , h'f05e1e8fa84f2b557ddc362329413caa3fd89a1be26bfd24be05ce0a02': 14 + } + + , 11: h'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' + + , 13: + [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] + ] + + , 16: + [ h'6000000000000000000000000000000000000000000000000000000000', 1000000000 + ] + + , 17: 1 + }, + + { 5: + [ [0, 0, 121([]), [1000000, 100000000]] + , [3, 1, 121([]), [1000000, 100000000]] + ] + + , 6: [ h'58ad0100003232322225333004323253330063372e646e64004dd7198009801002240009210d48656c6c6f2c20576f726c64210013233300100137586600460066600460060089000240206eb8cc008c00c019200022253335573e004294054ccc024cdc79bae300a00200114a226660060066016004002294088c8ccc0040052000003222333300a3370e008004016466600800866e0000d2002300d001001235573c6ea8004526165734ae855d11' ] + + }, + true, + null +] diff --git a/examples/acceptance_tests/script_context/plutus.json b/examples/acceptance_tests/script_context/plutus.json new file mode 100644 index 00000000..1250babe --- /dev/null +++ b/examples/acceptance_tests/script_context/plutus.json @@ -0,0 +1,64 @@ +{ + "preamble": { + "title": "aiken-lang/acceptance_test_062", + "version": "0.0.0" + }, + "validators": [ + { + "title": "withdrawals", + "purpose": "spend", + "datum": { + "title": "Unit", + "description": "The nullary constructor.", + "anyOf": [ + { + "dataType": "constructor", + "index": 0, + "fields": [] + } + ] + }, + "redeemer": { + "title": "Unit", + "description": "The nullary constructor.", + "anyOf": [ + { + "dataType": "constructor", + "index": 0, + "fields": [] + } + ] + }, + "compiledCode": "5902d80100003232323232323232323232222533300632323232323001003300100122533301000114a226464a66601a0042660080080022940c050008cdc3a4004601c6ea8c048004c8c8c8cc044ccc02cc8c94ccc034cdc3800a40042a6601e9211c616c6963652773207769746864726177616c206e6f7420666f756e640016132323370e002902a1bad30150013007002300f3754002660026eaccc010c014cc010c01401920004803130126d8799fd8799f581c22222222222222222222222222222222222222222222222222222222ffff004c0103d87a80004c0103d87980003301133300b3232533300d3370e00290010a99807a491a626f622773207769746864726177616c206e6f7420666f756e640016132323370e002900e1bad30150013007002300f3754002660026eaccc010c014cc010c01401920004803130126d8799fd87a9f581c5e1e8fa84f2b557ddc362329413caa3fd89a1be26bfd24be05ce0a02ffff004c0103d87a80004c0103d87980003301133300b3375e6e9cc8c8c8c008004dd599803180399803180380424000900618008009129998090008a5eb804c8c8c8c8cc05c004cc01801800cc04c00cdd69809801180b001180a0009ba7330114c0126d8799fd8799f581c22222222222222222222222222222222222222222222222222222222ffff00330114c126d8799fd87a9f581c5e1e8fa84f2b557ddc362329413caa3fd89a1be26bfd24be05ce0a02ffff004bd7026103d87a80004c0103d87980004bd70111980180100098008009112999808001099ba5480092f5c0264646464a66601e66ebc0140044cdd2a40006602a6ea00092f5c0266600e00e00600a60220066eb4c044008c05000cc04800888c8ccc0040052000003222333300c3370e008004026466600800866e0000d200230150010012300b37540022930b180080091129998048010a4c26600a600260160046660060066018004002ae695cdab9c5573aaae7955cfaba05742ae89", + "hash": "26dca991cde0d8e0554e3019488f4576e6f4b91c46dd14bd91053281" + }, + { + "title": "basic", + "purpose": "spend", + "datum": { + "title": "Unit", + "description": "The nullary constructor.", + "anyOf": [ + { + "dataType": "constructor", + "index": 0, + "fields": [] + } + ] + }, + "redeemer": { + "title": "Unit", + "description": "The nullary constructor.", + "anyOf": [ + { + "dataType": "constructor", + "index": 0, + "fields": [] + } + ] + }, + "compiledCode": "59042a010000323232323232323232323222253330063232323232300200132323232323233016333010323253330123370e002900109919299980a19baf3300d300e0014800130126d8799f58200000000000000000000000000000000000000000000000000000000000000000ff0013370e6eb4cc034c038005200248000528180d00098060010a9980a2491c73637269707420707572706f73652069736e277420275370656e6427001630143754002660126014016900126103d87a80004c0103d87980003301633301032325333017001153301449011c756e6578706563746564206e756d626572206f66206f7574707574730016132533301800113232300c0013301a3330143375e6e98dd5998069807000a40046e98c0152080a8d6b9074c103d87a80004c0103d87980003301a3330143375e6601a601c6601a601c002900024000980122d8799f581c11111111111111111111111111111111111111111111111111111111ff004c0103d87a80004c0103d87980003301a333014323253330163370e0029000099250301000214a260306ea8004cc034c038cc034c038005200048009300103d87a80004c0103d87980004bd70180d0010a9980aa491c756e6578706563746564206e756d626572206f66206f7574707574730016301a00137586601460160029002198049805005a4000980103d87a80004c0103d879800033016333010323375e6e98dd5998051805800a400c6e98c009205433009300a00b4800130103d87a80004c0103d87980004bd7011999111919000999991111999805002001801000a5eb7bdb180010004020cccc8888cccc03001000c0080052f5bded8c000400200e9101004881000013001001222225333017004133018337606ea400cdd300125eb7bdb1804c8c8c8c94ccc058cdd79980280380099ba5480012f5c026603866ec0dd48039ba6006008153330163371e00e00226603866ec0dd48039ba600600313301c337606ea4004dd3001199998048048018038030029bae301800337566030004603600a603200844a66601c66e400080044cdd2a400097ae01533300e3371e004002266e9520024bd70099ba5480112f5c0600200244444a66602800826602a66ec0dd48019ba80024bd6f7b630099191919299980999baf330050070013374a900025eb804cc064cdd81ba9007375000c0102a66602666e3c01c0044cc064cdd81ba9007375000c00626603266ec0dd48009ba800233333009009003007006005375c602a0066eb4c054008c060014c058010c004004894ccc03c0045288991929998060010998020020008a5030130023370e900118069baa301100122323330010014800000c888cccc030cdc3802001009919980200219b8000348008c0540040048c02cdd50008a4c2c6002002444a666012004293099802980098058011998018019806001000ab9a5736ae7155ceaab9e5573eae815d0aba201", + "hash": "1afe9a73274c140722127c27511395d861b5ed8e0bee1e7e9171c47a" + } + ] +} \ No newline at end of file diff --git a/examples/acceptance_tests/062/test.sh b/examples/acceptance_tests/script_context/test.sh similarity index 92% rename from examples/acceptance_tests/062/test.sh rename to examples/acceptance_tests/script_context/test.sh index 2dc83d9e..fb0d90fb 100755 --- a/examples/acceptance_tests/062/test.sh +++ b/examples/acceptance_tests/script_context/test.sh @@ -39,4 +39,4 @@ cp data/$TITLE/inputs.cbor.template data/$TITLE/inputs.cbor sed "s/{{ VALIDATOR_HASH }}/$VALIDATOR_HASH/" data/$TITLE/outputs.cbor.template > data/$TITLE/outputs.cbor sed "s/{{ VALIDATOR }}/$VALIDATOR/" data/$TITLE/tx.cbor.template > data/$TITLE/tx.cbor -aiken tx simulate data/$TITLE/tx.cbor data/$TITLE/inputs.cbor data/$TITLE/outputs.cbor +cargo run -- tx simulate data/$TITLE/tx.cbor data/$TITLE/inputs.cbor data/$TITLE/outputs.cbor diff --git a/examples/acceptance_tests/062/validators/basic.ak b/examples/acceptance_tests/script_context/validators/basic.ak similarity index 100% rename from examples/acceptance_tests/062/validators/basic.ak rename to examples/acceptance_tests/script_context/validators/basic.ak diff --git a/examples/acceptance_tests/script_context/validators/withdrawals.ak b/examples/acceptance_tests/script_context/validators/withdrawals.ak new file mode 100644 index 00000000..36fafe50 --- /dev/null +++ b/examples/acceptance_tests/script_context/validators/withdrawals.ak @@ -0,0 +1,35 @@ +use aiken/dict +use aiken/list +use aiken/transaction.{ScriptContext} +use aiken/transaction/credential.{ + Inline, ScriptCredential, VerificationKeyCredential, +} + +fn spend(_datum: Void, _redeemer: Void, ctx: ScriptContext) { + let alice = + Inline( + VerificationKeyCredential( + #"22222222222222222222222222222222222222222222222222222222", + )) + + + let bob = + Inline( + ScriptCredential( + #"5e1e8fa84f2b557ddc362329413caa3fd89a1be26bfd24be05ce0a02", + )) + + + [ + when dict.get(ctx.transaction.withdrawals, alice) is { + None -> error("alice's withdrawal not found") + Some(value) -> value == 42 + }, + when dict.get(ctx.transaction.withdrawals, bob) is { + None -> error("bob's withdrawal not found") + Some(value) -> value == 14 + }, + dict.keys(ctx.transaction.withdrawals) == [alice, bob], + ] + |> list.and +} From 685473ead648213dcb659272e19895558e2e1548 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 14 Feb 2023 16:10:45 +0100 Subject: [PATCH 6/8] Rename data -> ctx --- .../data/basic/inputs.cbor.template | 1 - .../data/basic/outputs.cbor.template | 1 - .../data/basic/tx.cbor.template | 1 - .../data/basic/tx.diag.template | 32 --------------- .../data/withdrawals/inputs.cbor.template | 1 - .../data/withdrawals/outputs.cbor.template | 1 - .../data/withdrawals/tx.cbor.template | 1 - .../data/withdrawals/tx.diag.template | 40 ------------------- .../acceptance_tests/script_context/test.sh | 10 ++--- 9 files changed, 5 insertions(+), 83 deletions(-) delete mode 100644 examples/acceptance_tests/script_context/data/basic/inputs.cbor.template delete mode 100644 examples/acceptance_tests/script_context/data/basic/outputs.cbor.template delete mode 100644 examples/acceptance_tests/script_context/data/basic/tx.cbor.template delete mode 100644 examples/acceptance_tests/script_context/data/basic/tx.diag.template delete mode 100644 examples/acceptance_tests/script_context/data/withdrawals/inputs.cbor.template delete mode 100644 examples/acceptance_tests/script_context/data/withdrawals/outputs.cbor.template delete mode 100644 examples/acceptance_tests/script_context/data/withdrawals/tx.cbor.template delete mode 100644 examples/acceptance_tests/script_context/data/withdrawals/tx.diag.template diff --git a/examples/acceptance_tests/script_context/data/basic/inputs.cbor.template b/examples/acceptance_tests/script_context/data/basic/inputs.cbor.template deleted file mode 100644 index e7f75b49..00000000 --- a/examples/acceptance_tests/script_context/data/basic/inputs.cbor.template +++ /dev/null @@ -1 +0,0 @@ -81825820000000000000000000000000000000000000000000000000000000000000000000 diff --git a/examples/acceptance_tests/script_context/data/basic/outputs.cbor.template b/examples/acceptance_tests/script_context/data/basic/outputs.cbor.template deleted file mode 100644 index 71a0de30..00000000 --- a/examples/acceptance_tests/script_context/data/basic/outputs.cbor.template +++ /dev/null @@ -1 +0,0 @@ -81A300581D70{{ VALIDATOR_HASH }}011A3B9ACA00028201D81843D87980 diff --git a/examples/acceptance_tests/script_context/data/basic/tx.cbor.template b/examples/acceptance_tests/script_context/data/basic/tx.cbor.template deleted file mode 100644 index 1b121c91..00000000 --- a/examples/acceptance_tests/script_context/data/basic/tx.cbor.template +++ /dev/null @@ -1 +0,0 @@ -84A70081825820000000000000000000000000000000000000000000000000000000000000000000018182581D60111111111111111111111111111111111111111111111111111111111A3B9ACA0002182A0B5820FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D818258200000000000000000000000000000000000000000000000000000000000000000001082581D60000000000000000000000000000000000000000000000000000000001A3B9ACA001101A20581840000D87980821A000F42401A05F5E1000681{{ VALIDATOR }}F5F6 diff --git a/examples/acceptance_tests/script_context/data/basic/tx.diag.template b/examples/acceptance_tests/script_context/data/basic/tx.diag.template deleted file mode 100644 index 872528af..00000000 --- a/examples/acceptance_tests/script_context/data/basic/tx.diag.template +++ /dev/null @@ -1,32 +0,0 @@ -[ - { 0: - [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] - ] - - , 1: - [ [h'6011111111111111111111111111111111111111111111111111111111', 1000000000] - ] - - , 2: 42 - - , 11: h'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' - - , 13: - [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] - ] - - , 16: - [ h'6000000000000000000000000000000000000000000000000000000000', 1000000000 - ] - - , 17: 1 - }, - - { 5: [[0, 0, 121([]), [1000000, 100000000]]] - - , 6: [h'VALIDATOR'] - - }, - true, - null -] diff --git a/examples/acceptance_tests/script_context/data/withdrawals/inputs.cbor.template b/examples/acceptance_tests/script_context/data/withdrawals/inputs.cbor.template deleted file mode 100644 index e7f75b49..00000000 --- a/examples/acceptance_tests/script_context/data/withdrawals/inputs.cbor.template +++ /dev/null @@ -1 +0,0 @@ -81825820000000000000000000000000000000000000000000000000000000000000000000 diff --git a/examples/acceptance_tests/script_context/data/withdrawals/outputs.cbor.template b/examples/acceptance_tests/script_context/data/withdrawals/outputs.cbor.template deleted file mode 100644 index 71a0de30..00000000 --- a/examples/acceptance_tests/script_context/data/withdrawals/outputs.cbor.template +++ /dev/null @@ -1 +0,0 @@ -81A300581D70{{ VALIDATOR_HASH }}011A3B9ACA00028201D81843D87980 diff --git a/examples/acceptance_tests/script_context/data/withdrawals/tx.cbor.template b/examples/acceptance_tests/script_context/data/withdrawals/tx.cbor.template deleted file mode 100644 index 62f86104..00000000 --- a/examples/acceptance_tests/script_context/data/withdrawals/tx.cbor.template +++ /dev/null @@ -1 +0,0 @@ -84A80081825820000000000000000000000000000000000000000000000000000000000000000000018182581D60111111111111111111111111111111111111111111111111111111111A3B9ACA0002182A05A2581DE022222222222222222222222222222222222222222222222222222222182A581DF05E1E8FA84F2B557DDC362329413CAA3FD89A1BE26BFD24BE05CE0A020E0B5820FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D818258200000000000000000000000000000000000000000000000000000000000000000001082581D60000000000000000000000000000000000000000000000000000000001A3B9ACA001101A20582840000D87980821A000F42401A05F5E100840301D87980821A000F42401A05F5E1000682{{ VALIDATOR }}58AF58AD0100003232322225333004323253330063372E646E64004DD7198009801002240009210D48656C6C6F2C20576F726C64210013233300100137586600460066600460060089000240206EB8CC008C00C019200022253335573E004294054CCC024CDC79BAE300A00200114A226660060066016004002294088C8CCC0040052000003222333300A3370E008004016466600800866E0000D2002300D001001235573C6EA8004526165734AE855D11F5F6 diff --git a/examples/acceptance_tests/script_context/data/withdrawals/tx.diag.template b/examples/acceptance_tests/script_context/data/withdrawals/tx.diag.template deleted file mode 100644 index 787cabbe..00000000 --- a/examples/acceptance_tests/script_context/data/withdrawals/tx.diag.template +++ /dev/null @@ -1,40 +0,0 @@ -[ - { 0: - [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] - ] - - , 1: - [ [h'6011111111111111111111111111111111111111111111111111111111', 1000000000] - ] - - , 2: 42 - - , 5: - { h'e022222222222222222222222222222222222222222222222222222222': 42 - , h'f05e1e8fa84f2b557ddc362329413caa3fd89a1be26bfd24be05ce0a02': 14 - } - - , 11: h'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' - - , 13: - [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] - ] - - , 16: - [ h'6000000000000000000000000000000000000000000000000000000000', 1000000000 - ] - - , 17: 1 - }, - - { 5: - [ [0, 0, 121([]), [1000000, 100000000]] - , [3, 1, 121([]), [1000000, 100000000]] - ] - - , 6: [ h'58ad0100003232322225333004323253330063372e646e64004dd7198009801002240009210d48656c6c6f2c20576f726c64210013233300100137586600460066600460060089000240206eb8cc008c00c019200022253335573e004294054ccc024cdc79bae300a00200114a226660060066016004002294088c8ccc0040052000003222333300a3370e008004016466600800866e0000d2002300d001001235573c6ea8004526165734ae855d11' ] - - }, - true, - null -] diff --git a/examples/acceptance_tests/script_context/test.sh b/examples/acceptance_tests/script_context/test.sh index fb0d90fb..bd91d6d4 100755 --- a/examples/acceptance_tests/script_context/test.sh +++ b/examples/acceptance_tests/script_context/test.sh @@ -24,7 +24,7 @@ then exit 1 fi -aiken build +cargo run --quiet -- build if [ $? -ne 0 ]; then exit $? fi @@ -35,8 +35,8 @@ VALIDATOR_HASH=$(echo $BLUEPRINT | jq .hash | sed s/\"//g) VALIDATOR=$(echo $BLUEPRINT | jq .compiledCode | sed s/\"//g) VALIDATOR=$(cbor-diag --to hex --from diag <<< "h'$VALIDATOR'") -cp data/$TITLE/inputs.cbor.template data/$TITLE/inputs.cbor -sed "s/{{ VALIDATOR_HASH }}/$VALIDATOR_HASH/" data/$TITLE/outputs.cbor.template > data/$TITLE/outputs.cbor -sed "s/{{ VALIDATOR }}/$VALIDATOR/" data/$TITLE/tx.cbor.template > data/$TITLE/tx.cbor +cp ctx/$TITLE/inputs.cbor.template ctx/$TITLE/inputs.cbor +sed "s/{{ VALIDATOR_HASH }}/$VALIDATOR_HASH/" ctx/$TITLE/outputs.cbor.template > ctx/$TITLE/outputs.cbor +sed "s/{{ VALIDATOR }}/$VALIDATOR/" ctx/$TITLE/tx.cbor.template > ctx/$TITLE/tx.cbor -cargo run -- tx simulate data/$TITLE/tx.cbor data/$TITLE/inputs.cbor data/$TITLE/outputs.cbor +cargo run --quiet -- tx simulate ctx/$TITLE/tx.cbor ctx/$TITLE/inputs.cbor ctx/$TITLE/outputs.cbor From a3078adce83f83cd167675016e67e3ced831d285 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 14 Feb 2023 16:25:17 +0100 Subject: [PATCH 7/8] Add succinct README to explain what's going on. --- .../script_context/.gitignore | 2 +- .../acceptance_tests/script_context/README.md | 18 +++++++++ .../ctx/basic/inputs.cbor.template | 1 + .../ctx/basic/outputs.cbor.template | 1 + .../script_context/ctx/basic/tx.cbor.template | 1 + .../script_context/ctx/basic/tx.diag.template | 32 +++++++++++++++ .../ctx/withdrawals/inputs.cbor.template | 1 + .../ctx/withdrawals/outputs.cbor.template | 1 + .../ctx/withdrawals/tx.cbor.template | 1 + .../ctx/withdrawals/tx.diag.template | 40 +++++++++++++++++++ 10 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 examples/acceptance_tests/script_context/README.md create mode 100644 examples/acceptance_tests/script_context/ctx/basic/inputs.cbor.template create mode 100644 examples/acceptance_tests/script_context/ctx/basic/outputs.cbor.template create mode 100644 examples/acceptance_tests/script_context/ctx/basic/tx.cbor.template create mode 100644 examples/acceptance_tests/script_context/ctx/basic/tx.diag.template create mode 100644 examples/acceptance_tests/script_context/ctx/withdrawals/inputs.cbor.template create mode 100644 examples/acceptance_tests/script_context/ctx/withdrawals/outputs.cbor.template create mode 100644 examples/acceptance_tests/script_context/ctx/withdrawals/tx.cbor.template create mode 100644 examples/acceptance_tests/script_context/ctx/withdrawals/tx.diag.template diff --git a/examples/acceptance_tests/script_context/.gitignore b/examples/acceptance_tests/script_context/.gitignore index f5d99950..f6631aa1 100644 --- a/examples/acceptance_tests/script_context/.gitignore +++ b/examples/acceptance_tests/script_context/.gitignore @@ -1 +1 @@ -data/**/*.cbor +ctx/**/*.cbor diff --git a/examples/acceptance_tests/script_context/README.md b/examples/acceptance_tests/script_context/README.md new file mode 100644 index 00000000..dc31ed3b --- /dev/null +++ b/examples/acceptance_tests/script_context/README.md @@ -0,0 +1,18 @@ +# Script Context Tests + +This project contains a few handcrafted validators and transactions whose sole +purpose is to test the interpretation of the `ScriptContext` from within an +Aiken's validators. + +So validators are meant to work hand-in-hand with an associated context. +Because we can't have fully static context (since they contain the validator +and its hash), we define _templates_. + +Everything is a bit clunky, but steps have been captured in a `test.sh` script +for convenience. + +## How to use + +``` +./test.sh [VALIDATOR_TITLE] +``` diff --git a/examples/acceptance_tests/script_context/ctx/basic/inputs.cbor.template b/examples/acceptance_tests/script_context/ctx/basic/inputs.cbor.template new file mode 100644 index 00000000..e7f75b49 --- /dev/null +++ b/examples/acceptance_tests/script_context/ctx/basic/inputs.cbor.template @@ -0,0 +1 @@ +81825820000000000000000000000000000000000000000000000000000000000000000000 diff --git a/examples/acceptance_tests/script_context/ctx/basic/outputs.cbor.template b/examples/acceptance_tests/script_context/ctx/basic/outputs.cbor.template new file mode 100644 index 00000000..71a0de30 --- /dev/null +++ b/examples/acceptance_tests/script_context/ctx/basic/outputs.cbor.template @@ -0,0 +1 @@ +81A300581D70{{ VALIDATOR_HASH }}011A3B9ACA00028201D81843D87980 diff --git a/examples/acceptance_tests/script_context/ctx/basic/tx.cbor.template b/examples/acceptance_tests/script_context/ctx/basic/tx.cbor.template new file mode 100644 index 00000000..1b121c91 --- /dev/null +++ b/examples/acceptance_tests/script_context/ctx/basic/tx.cbor.template @@ -0,0 +1 @@ +84A70081825820000000000000000000000000000000000000000000000000000000000000000000018182581D60111111111111111111111111111111111111111111111111111111111A3B9ACA0002182A0B5820FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D818258200000000000000000000000000000000000000000000000000000000000000000001082581D60000000000000000000000000000000000000000000000000000000001A3B9ACA001101A20581840000D87980821A000F42401A05F5E1000681{{ VALIDATOR }}F5F6 diff --git a/examples/acceptance_tests/script_context/ctx/basic/tx.diag.template b/examples/acceptance_tests/script_context/ctx/basic/tx.diag.template new file mode 100644 index 00000000..872528af --- /dev/null +++ b/examples/acceptance_tests/script_context/ctx/basic/tx.diag.template @@ -0,0 +1,32 @@ +[ + { 0: + [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] + ] + + , 1: + [ [h'6011111111111111111111111111111111111111111111111111111111', 1000000000] + ] + + , 2: 42 + + , 11: h'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' + + , 13: + [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] + ] + + , 16: + [ h'6000000000000000000000000000000000000000000000000000000000', 1000000000 + ] + + , 17: 1 + }, + + { 5: [[0, 0, 121([]), [1000000, 100000000]]] + + , 6: [h'VALIDATOR'] + + }, + true, + null +] diff --git a/examples/acceptance_tests/script_context/ctx/withdrawals/inputs.cbor.template b/examples/acceptance_tests/script_context/ctx/withdrawals/inputs.cbor.template new file mode 100644 index 00000000..e7f75b49 --- /dev/null +++ b/examples/acceptance_tests/script_context/ctx/withdrawals/inputs.cbor.template @@ -0,0 +1 @@ +81825820000000000000000000000000000000000000000000000000000000000000000000 diff --git a/examples/acceptance_tests/script_context/ctx/withdrawals/outputs.cbor.template b/examples/acceptance_tests/script_context/ctx/withdrawals/outputs.cbor.template new file mode 100644 index 00000000..71a0de30 --- /dev/null +++ b/examples/acceptance_tests/script_context/ctx/withdrawals/outputs.cbor.template @@ -0,0 +1 @@ +81A300581D70{{ VALIDATOR_HASH }}011A3B9ACA00028201D81843D87980 diff --git a/examples/acceptance_tests/script_context/ctx/withdrawals/tx.cbor.template b/examples/acceptance_tests/script_context/ctx/withdrawals/tx.cbor.template new file mode 100644 index 00000000..62f86104 --- /dev/null +++ b/examples/acceptance_tests/script_context/ctx/withdrawals/tx.cbor.template @@ -0,0 +1 @@ +84A80081825820000000000000000000000000000000000000000000000000000000000000000000018182581D60111111111111111111111111111111111111111111111111111111111A3B9ACA0002182A05A2581DE022222222222222222222222222222222222222222222222222222222182A581DF05E1E8FA84F2B557DDC362329413CAA3FD89A1BE26BFD24BE05CE0A020E0B5820FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D818258200000000000000000000000000000000000000000000000000000000000000000001082581D60000000000000000000000000000000000000000000000000000000001A3B9ACA001101A20582840000D87980821A000F42401A05F5E100840301D87980821A000F42401A05F5E1000682{{ VALIDATOR }}58AF58AD0100003232322225333004323253330063372E646E64004DD7198009801002240009210D48656C6C6F2C20576F726C64210013233300100137586600460066600460060089000240206EB8CC008C00C019200022253335573E004294054CCC024CDC79BAE300A00200114A226660060066016004002294088C8CCC0040052000003222333300A3370E008004016466600800866E0000D2002300D001001235573C6EA8004526165734AE855D11F5F6 diff --git a/examples/acceptance_tests/script_context/ctx/withdrawals/tx.diag.template b/examples/acceptance_tests/script_context/ctx/withdrawals/tx.diag.template new file mode 100644 index 00000000..787cabbe --- /dev/null +++ b/examples/acceptance_tests/script_context/ctx/withdrawals/tx.diag.template @@ -0,0 +1,40 @@ +[ + { 0: + [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] + ] + + , 1: + [ [h'6011111111111111111111111111111111111111111111111111111111', 1000000000] + ] + + , 2: 42 + + , 5: + { h'e022222222222222222222222222222222222222222222222222222222': 42 + , h'f05e1e8fa84f2b557ddc362329413caa3fd89a1be26bfd24be05ce0a02': 14 + } + + , 11: h'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' + + , 13: + [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] + ] + + , 16: + [ h'6000000000000000000000000000000000000000000000000000000000', 1000000000 + ] + + , 17: 1 + }, + + { 5: + [ [0, 0, 121([]), [1000000, 100000000]] + , [3, 1, 121([]), [1000000, 100000000]] + ] + + , 6: [ h'58ad0100003232322225333004323253330063372e646e64004dd7198009801002240009210d48656c6c6f2c20576f726c64210013233300100137586600460066600460060089000240206eb8cc008c00c019200022253335573e004294054ccc024cdc79bae300a00200114a226660060066016004002294088c8ccc0040052000003222333300a3370e008004016466600800866e0000d2002300d001001235573c6ea8004526165734ae855d11' ] + + }, + true, + null +] From 428b5f2b372263acc31299dbd8e903c3a8df27db Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 14 Feb 2023 16:49:13 +0100 Subject: [PATCH 8/8] Align output of `tx simulate` with other Aiken's commands. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And also return a structured output as JSON, so it's more easily used by other tools. ``` Parsing script context Simulating 78ec148ea647cf9969446891af31939c5d57b275a2455706782c6183ef0b62f1 Redeemer Spend → 0 {"mem":151993,"cpu":58180696} ``` --- crates/aiken/src/cmd/tx/simulate.rs | 45 ++++++++++++++++++++------- crates/uplc/src/machine/cost_model.rs | 2 +- crates/uplc/src/tx.rs | 5 +++ crates/uplc/src/tx/tests.rs | 11 +++++++ 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/crates/aiken/src/cmd/tx/simulate.rs b/crates/aiken/src/cmd/tx/simulate.rs index 2888cf41..ae3a3dda 100644 --- a/crates/aiken/src/cmd/tx/simulate.rs +++ b/crates/aiken/src/cmd/tx/simulate.rs @@ -1,11 +1,11 @@ use miette::IntoDiagnostic; +use owo_colors::OwoColorize; use pallas_primitives::{ - babbage::{TransactionInput, TransactionOutput}, + babbage::{Redeemer, TransactionInput, TransactionOutput}, Fragment, }; use pallas_traverse::{Era, MultiEraTx}; -use std::fs; -use std::path::PathBuf; +use std::{fmt, fs, path::PathBuf, process}; use uplc::{ machine::cost_model::ExBudget, tx::{ @@ -54,6 +54,8 @@ pub fn exec( zero_slot, }: Args, ) -> miette::Result<()> { + eprintln!("{} script context", " Parsing".bold().purple(),); + let (tx_bytes, inputs_bytes, outputs_bytes) = if cbor { ( fs::read(input).into_diagnostic()?, @@ -76,6 +78,8 @@ pub fn exec( .or_else(|_| MultiEraTx::decode(Era::Alonzo, &tx_bytes)) .into_diagnostic()?; + eprintln!("{} {}", " Simulating".bold().purple(), tx.hash()); + let inputs = Vec::::decode_fragment(&inputs_bytes).unwrap(); let outputs = Vec::::decode_fragment(&outputs_bytes).unwrap(); @@ -88,8 +92,6 @@ pub fn exec( }) .collect(); - println!("Simulating: {}", tx.hash()); - if let Some(tx_babbage) = tx.as_babbage() { let slot_config = SlotConfig { zero_time, @@ -97,13 +99,27 @@ pub fn exec( slot_length, }; - let result = - tx::eval_phase_two(tx_babbage, &resolved_inputs, None, None, &slot_config, true); + let with_redeemer = |redeemer: &Redeemer| { + println!( + "{} {:?} → {}", + " Redeemer".bold().purple(), + redeemer.tag, + redeemer.index + ) + }; + + let result = tx::eval_phase_two( + tx_babbage, + &resolved_inputs, + None, + None, + &slot_config, + true, + with_redeemer, + ); match result { Ok(redeemers) => { - println!("\nTotal Budget Used\n-----------------\n"); - let total_budget_used = redeemers .iter() @@ -112,11 +128,16 @@ pub fn exec( cpu: accum.cpu + curr.ex_units.steps as i64, }); - println!("mem: {}", total_budget_used.mem); - println!("cpu: {}", total_budget_used.cpu); + println!( + "\n{}", + serde_json::to_string(&total_budget_used) + .map_err(|_| fmt::Error) + .into_diagnostic()? + ); } Err(err) => { - eprintln!("\nError\n-----\n\n{err}\n"); + eprintln!("{} {}", " Error".bold().red(), err.red()); + process::exit(1); } } } diff --git a/crates/uplc/src/machine/cost_model.rs b/crates/uplc/src/machine/cost_model.rs index 90c03c5b..16c1a62c 100644 --- a/crates/uplc/src/machine/cost_model.rs +++ b/crates/uplc/src/machine/cost_model.rs @@ -18,7 +18,7 @@ macro_rules! hashmap { } /// Can be negative -#[derive(Debug, Clone, PartialEq, Eq, Copy)] +#[derive(Debug, Clone, PartialEq, Eq, Copy, serde::Serialize)] pub struct ExBudget { pub mem: i64, pub cpu: i64, diff --git a/crates/uplc/src/tx.rs b/crates/uplc/src/tx.rs index 31fd50f2..643675be 100644 --- a/crates/uplc/src/tx.rs +++ b/crates/uplc/src/tx.rs @@ -35,6 +35,7 @@ pub fn eval_phase_two( initial_budget: Option<&ExBudget>, slot_config: &SlotConfig, run_phase_one: bool, + with_redeemer: fn(&Redeemer) -> (), ) -> Result, Error> { let redeemers = tx.transaction_witness_set.redeemer.as_ref(); @@ -52,6 +53,8 @@ pub fn eval_phase_two( let mut remaining_budget = *initial_budget.unwrap_or(&ExBudget::default()); for redeemer in rs.iter() { + with_redeemer(redeemer); + let redeemer = eval::eval_redeemer( tx, utxos, @@ -87,6 +90,7 @@ pub fn eval_phase_two_raw( initial_budget: (u64, u64), slot_config: (u64, u64, u32), run_phase_one: bool, + with_redeemer: fn(&Redeemer) -> (), ) -> Result>, Error> { let multi_era_tx = MultiEraTx::decode(Era::Babbage, tx_bytes) .or_else(|_| MultiEraTx::decode(Era::Alonzo, tx_bytes))?; @@ -122,6 +126,7 @@ pub fn eval_phase_two_raw( Some(&budget), &sc, run_phase_one, + with_redeemer, ) { Ok(redeemers) => Ok(redeemers .iter() diff --git a/crates/uplc/src/tx/tests.rs b/crates/uplc/src/tx/tests.rs index 7cfbe1ad..c988122b 100644 --- a/crates/uplc/src/tx/tests.rs +++ b/crates/uplc/src/tx/tests.rs @@ -246,6 +246,7 @@ fn test_eval() { Some(&initial_budget), &slot_config, false, + |_| (), ) .unwrap(); @@ -516,6 +517,7 @@ fn test_eval_1() { Some(&initial_budget), &slot_config, false, + |_| (), ) .unwrap(); @@ -621,6 +623,7 @@ fn test_eval_2() { Some(&initial_budget), &slot_config, false, + |_| (), ) .unwrap(); @@ -885,6 +888,7 @@ fn test_eval_3() { Some(&initial_budget), &slot_config, false, + |_| (), ) .unwrap(); @@ -987,6 +991,7 @@ fn test_eval_4() { Some(&initial_budget), &slot_config, false, + |_| (), ) .is_err()); } @@ -1069,6 +1074,7 @@ fn test_eval_5() { Some(&initial_budget), &slot_config, false, + |_| (), ) .unwrap(); @@ -1173,6 +1179,7 @@ fn test_eval_6() { Some(&initial_budget), &slot_config, false, + |_| (), ) .unwrap(); @@ -1277,6 +1284,7 @@ fn test_eval_7() { Some(&initial_budget), &slot_config, false, + |_| (), ) .unwrap(); @@ -1532,6 +1540,7 @@ fn test_eval_8() { Some(&initial_budget), &slot_config, false, + |_| (), ) .unwrap(); @@ -1632,6 +1641,7 @@ fn eval_missing_redeemer() { Some(&initial_budget), &slot_config, false, + |_| (), ) .unwrap(); } @@ -1711,6 +1721,7 @@ fn eval_extraneous_redeemer() { Some(&initial_budget), &slot_config, false, + |_| (), ) .is_err()); }