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

Update ScriptErrorEvaluationFailed with DebugPlutusFailure #672

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Jimbo4350
Copy link
Contributor

@Jimbo4350 Jimbo4350 commented Nov 4, 2024

Improved plutus script error debugging output.

Before:

The Plutus script evaluation failed: An error has occurred:
The machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
Script debugging logs: PT5

After:

Command failed: transaction build  Error: The following scripts have execution failures:
the script for transaction input 0 (in ascending order of the TxIds) failed with: 
Script hash: 581cc61bfa1c138524b69f378bc69504322f39289ce554d549db4d1e2b50
Script language: PlutusV3
Protocol version: Version 10
Script arguments: 
   ScriptInfo: SpendingScript (TxOutRef {txOutRefId = cb2c9611ad51f6e37c529f7a3cb8dde4eaeaf97e5a47ba03a8c0026fe7a94bc5, txOutRefIdx = 0}) (Just (Datum {getDatum = I 0}))
   TxInfo:
     TxId: a95d7c79d606c74cde9aad2dae26db6ececa3915a6fc3075bea15ae8a8c69c86
     Inputs: [ cb2c9611ad51f6e37c529f7a3cb8dde4eaeaf97e5a47ba03a8c0026fe7a94bc5!0 -> - Value {getValue = Map {unMap = [(,Map {unMap = [("",5000000)]})]}} addressed to
                                                                                       ScriptCredential: c61bfa1c138524b69f378bc69504322f39289ce554d549db4d1e2b50 (no staking credential)
                                                                                       with datum
                                                                                       datum hash:  03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314
                                                                                       with referenceScript
                                                                                        ]
     Reference inputs: []
     Outputs: [ - Value {getValue = Map {unMap = [(,Map {unMap = [("",2000000)]}),(c61bfa1c138524b69f378bc69504322f39289ce554d549db4d1e2b50,Map {unMap = [("MillarCoin",5)]})]}} addressed to
                  PubKeyCredential: e0d8d2f61fbf9c6b1a2db4b7073c50e6013e3374661a2403d0826920 (no staking credential)
                  with datum
                  no datum
                  with referenceScript

              , - Value {getValue = Map {unMap = [(,Map {unMap = [("",1000000)]})]}} addressed to
                  PubKeyCredential: e0d8d2f61fbf9c6b1a2db4b7073c50e6013e3374661a2403d0826920 (no staking credential)
                  with datum
                  datum hash:  ee155ace9c40292074cb6aff8c9ccdd273c81648ff1149ef36bcea6ebb8a3e25
                  with referenceScript

              , - Value {getValue = Map {unMap = [(,Map {unMap = [("",15000005000000)]})]}} addressed to
                  PubKeyCredential: 5b438ecb59a1fdd3b8ece9cf076821d827eb121460d027e7a9fdc351 (no staking credential)
                  with datum
                  no datum
                  with referenceScript
                   ]
     Fee: 0
     Value minted: Value {getValue = Map {unMap = [(c61bfa1c138524b69f378bc69504322f39289ce554d549db4d1e2b50,Map {unMap = [("MillarCoin",5)]})]}}
     TxCerts: [ TxCertRegStaking (ScriptCredential c61bfa1c138524b69f378bc69504322f39289ce554d549db4d1e2b50) (Just 400000) ]
     Wdrl: []
     Valid range: (-∞ , +∞)
     Signatories: []
     Redeemers: [ ( Spending (TxOutRef {txOutRefId = cb2c9611ad51f6e37c529f7a3cb8dde4eaeaf97e5a47ba03a8c0026fe7a94bc5, txOutRefIdx = 0})
                , 0 )
                , ( Minting c61bfa1c138524b69f378bc69504322f39289ce554d549db4d1e2b50
                , 0 )
                , ( Certifying 0 (TxCertRegStaking (ScriptCredential c61bfa1c138524b69f378bc69504322f39289ce554d549db4d1e2b50) (Just 400000))
                , 0 ) ]
     Datums: [ ( 03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314
             , 0 )
             , ( ee155ace9c40292074cb6aff8c9ccdd273c81648ff1149ef36bcea6ebb8a3e25
             , 1 ) ]
     Votes: []
     Proposal Procedures: []
     Current Treasury Amount: 
     Treasury Donation: 
   Redeemer:
     0
Script evaluation error: An error has occurred:
The machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
Script execution logs: Unknown error code: PT5

Script base64 encoded arguments: 2Hmf2Hmfn9h5n9h5.....
Script base64 encoded bytes: WQ5wAQAAMjIzIjMiMyIyMjIyMjIyMjIyMjIy..... 

Changelog

- description: |
   Improve plutus script failure error
# uncomment types applicable to the change:
  type:
  - feature        # introduces a new feature

Context

Additional context for the PR goes here. If the PR fixes a particular issue please provide a link to the issue.

How to trust this PR

Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

Copy link
Member

@zliu41 zliu41 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, this is a nice improvement.

Script arguments: ScriptInfo: CertifyingScript 0 (TxCertRegStaking (ScriptCredential c61bfa1c138524b69f378bc69504322f39289ce554d549db4d1e2b50) (Just 400000))
TxInfo:

This makes it look like "Script arguments" and "TxInfo" are at the same level. The following would be better:

Script arguments:
  argument 1:
    ScriptInfo: ...
    TxInfo: ...
  ...

Can you also print the base64-encoded arguments? That would be more useful for re-running the script locally. Or is it already printed elsewhere?

@Jimbo4350
Copy link
Contributor Author

Great, this is a nice improvement.

Script arguments: ScriptInfo: CertifyingScript 0 (TxCertRegStaking (ScriptCredential c61bfa1c138524b69f378bc69504322f39289ce554d549db4d1e2b50) (Just 400000))
TxInfo:

This makes it look like "Script arguments" and "TxInfo" are at the same level. The following would be better:

Script arguments:
  argument 1:
    ScriptInfo: ...
    TxInfo: ...
  ...

Can you also print the base64-encoded arguments? That would be more useful for re-running the script locally. Or is it already printed elsewhere?

Made the changes however I'm not sure why it's saying PT5 is an unknown error code.

@zliu41
Copy link
Member

zliu41 commented Nov 4, 2024

Made the changes however I'm not sure why it's saying PT5 is an unknown error code.

I'm not sure. It doesn't look like this is from the plutus repo: grepping "unknown error code" returns no result.

@Jimbo4350
Copy link
Contributor Author

Made the changes however I'm not sure why it's saying PT5 is an unknown error code.

I'm not sure. It doesn't look like this is from the plutus repo: grepping "unknown error code" returns no result.

It comes from: https://github.com/IntersectMBO/cardano-api/pull/672/files#diff-4909897d92b6ddafd851db4cfc8d8584ad03948c0d94a42a41c8a3391711cd48R73

@zliu41
Copy link
Member

zliu41 commented Nov 4, 2024

It's a bug in Plutus - I'll fix it.

By the way, I don't think you'd want to look up everything in that map and prints "unknown error code" if not found. The log may also contain arbitrary strings the user puts there.

@zliu41
Copy link
Member

zliu41 commented Nov 4, 2024

Fixed in IntersectMBO/plutus#6635

@Jimbo4350 Jimbo4350 mentioned this pull request Nov 5, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants