Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - plutus transaction txins are not properly validated in build command (the impossible happened: RedeemerNotNeeded) #3018

Closed
mkoura opened this issue Aug 4, 2021 · 5 comments · Fixed by #3187
Labels
alonzo-white Relates to the Alonzo White Testnet API&CLI-Backlog bug Something isn't working comp: cardano-cli era: alonzo type: bug Something is not working user type: internal Created by an IOG employee

Comments

@mkoura
Copy link
Contributor

mkoura commented Aug 4, 2021

Internal

Area
Plutus Related to Plutus Scripts (Alonzo).

Summary
When using the transaction build command with plutus script, the txins are not checked if they are plutus UTxOs. When plutus txin is invalid, unclear error message is printed.

$ cardano-cli transaction build --tx-in 3f9a74c9737f9eea69b81615313e0ebfd9eb78223dd790c8589c9f6eed784b6a#0 --tx-in-collateral 3f9a74c9737f9eea69b81615313e0ebfd9eb78223dd790c8589c9f6eed784b6a#1 --tx-in-script-file always-succeeds-spending.plutus --tx-in-datum-file 42.datum --tx-in-redeemer-file 42.redeemer --protocol-params-file pparams-ldfn.json  --tx-out addr_test1vp3spvevxxf3r8zkgt3a693k294dtq5aedhe9qlcwyqkvqqcvxsz5+50000000 --change-address addr_test1vpeheaqj6379mukd0t6crpq4r205lptugg8w04y9xlgq3esktg7gt --alonzo-era --testnet-magic 42 --out-file test_build_txin_locking_always_succeeds_step2_tx.body

cardano-cli: evaluateTransactionExecutionUnits: the impossible happened: RedeemerNotNeeded ScriptWitnessIndexTxIn 0
CallStack (from HasCallStack):
  error, called at src/Cardano/Api/Fees.hs:525:25 in cardano-api-1.28.0-CdKYZmszYHCPvjSsEYlNu:Cardano.Api.Fees

That was caused by using a UTxO without datum hash for plutus script, and a UTxO with datum hash as collateral.

System info (please complete the following information):

  • OS Name: Fedora
  • OS Version 34
  • Node version: git rev cb11587
  • CLI version: git rev cb11587
@mkoura mkoura added the bug Something isn't working label Aug 4, 2021
@catch-21 catch-21 added the alonzo-white Relates to the Alonzo White Testnet label Aug 4, 2021
@newhoggy
Copy link
Contributor

newhoggy commented Aug 9, 2021

When I modify the example-txin-locking-plutus-script.sh script like this:

diff --git a/scripts/plutus/example-txin-locking-plutus-script.sh b/scripts/plutus/example-txin-locking-plutus-script.sh
index 2f5130ca1..ebdc0d0a2 100755
--- a/scripts/plutus/example-txin-locking-plutus-script.sh
+++ b/scripts/plutus/example-txin-locking-plutus-script.sh
@@ -69,7 +69,6 @@ $CARDANO_CLI transaction build \
   --change-address "$utxoaddr" \
   --tx-in "$txin" \
   --tx-out "$plutusscriptaddr+$lovelaceattxindiv3" \
-  --tx-out-datum-hash "$scriptdatumhash" \
   --tx-out "$utxoaddr+$lovelaceattxindiv3" \
   --protocol-params-file "$WORK/pparams.json" \
   --out-file "$WORK/create-datum-output.body"

I get the following error:

Command failed: transaction build  Error: The following scripts have execution failures:
the script for transaction input 0 (in the order of the TxIds) failed with The Plutus script witness for the txin does not have a script datum (according to the UTxO). The txin in question is 49f84ea68f0c4cbe7bd73b1f87dc87b2643f1ef3698f858315733bbcd31c082f#1

When I use a UTxO that that is not that of a plutus script like this:

diff --git a/scripts/plutus/example-txin-locking-plutus-script.sh b/scripts/plutus/example-txin-locking-plutus-script.sh
index 2f5130ca1..777948b66 100755
--- a/scripts/plutus/example-txin-locking-plutus-script.sh
+++ b/scripts/plutus/example-txin-locking-plutus-script.sh
@@ -113,7 +113,7 @@ $CARDANO_CLI transaction build \
   --cardano-mode \
   --testnet-magic "$TESTNET_MAGIC" \
   --change-address "$utxoaddr" \
-  --tx-in "$plutusutxotxin" \
+  --tx-in "$txin" \
   --tx-in-collateral "$txinCollateral" \
   --tx-out "$dummyaddress+10000000" \
   --tx-in-script-file "$plutusscriptinuse" \

I then get the error that you report:

cardano-cli: evaluateTransactionExecutionUnits: the impossible happened: RedeemerNotNeeded ScriptWitnessIndexTxIn 0
CallStack (from HasCallStack):
  error, called at src/Cardano/Api/Fees.hs:524:25 in cardano-api-1.28.0-inplace:Cardano.Api.Fees%

Is this what you mean or are you pointing to something else?

@mkoura
Copy link
Contributor Author

mkoura commented Aug 9, 2021

@newhoggy Yes, that's the scenario.

@bwbush
Copy link
Contributor

bwbush commented Aug 9, 2021

I'm seeing something very similar: in particular, if the --tx-in for the UTxO at the script is repeated, I get the following:

$ cardano-cli transaction build $MAGIC --alonzo-era --tx-in e801cd49279e89cd72b0309151b9a1703221d7c99aca2fd1af4ff4793e433fa6#1 --tx-in e801cd49279e89cd72b0309151b9a1703221d7c99aca2fd1af4ff4793e433fa6#1 --change-address $(cat keys/alonzo-purple.payment-0.address) --tx-in-redeemer-value 4 --tx-in-script-file always-succeeds.plutus --tx-in-datum-value 42 --out-file tx.raw --tx-in-collateral e801cd49279e89cd72b0309151b9a1703221d7c99aca2fd1af4ff4793e433fa6#0 --protocol-params-file alonzo-purple.protocol

cardano-cli: evaluateTransactionExecutionUnits: the impossible happened: RedeemerNotNeeded ScriptWitnessIndexTxIn 1
CallStack (from HasCallStack):
  error, called at src/Cardano/Api/Fees.hs:525:25 in cardano-api-1.28.0-CdKYZmszYHCPvjSsEYlNu:Cardano.Api.Fees

$ git log -n 1 --pretty=oneline
708de685d49ec6af4b2d8b3cbfa0eca0e9e43edf (HEAD, tag: alonzo-purple-1.0.1) Merge #3013

Removing the duplicate --tx-in results in success.

@Titan-C
Copy link

Titan-C commented Aug 22, 2021

On tag 1.29.0-rc2.
I can also trigger the errors by trying to spend a script output that was already spent(my error updating the bash script). Sure double spend should fail, but the error should say that UTXO is not longer there instead of redeemernotneeded. It makes debugging way harder.

@kevinhammond
Copy link
Contributor

I have tripped over this one as well. Indeed, the confusing thing is the "impossible" error message (it's just a normal error situation). I might have hit the "two identical tx-in" case (which I wouldn't expect to be an error? (could easily happen with automation)

@catch-21 catch-21 changed the title [BUG] - plutus transaction txins are not properly validated in build command [BUG] - plutus transaction txins are not properly validated in build command (the impossible happened: RedeemerNotNeeded) Aug 27, 2021
@iohk-bors iohk-bors bot closed this as completed in aa355eb Sep 13, 2021
@dorin100 dorin100 added type: bug Something is not working user type: internal Created by an IOG employee era: alonzo comp: cardano-cli labels Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alonzo-white Relates to the Alonzo White Testnet API&CLI-Backlog bug Something isn't working comp: cardano-cli era: alonzo type: bug Something is not working user type: internal Created by an IOG employee
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants