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 #683

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

Jimbo4350
Copy link
Contributor

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:  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

@Jimbo4350
Copy link
Contributor Author

#672 was accidentally merged to master

rather than UTF-8

We fix this by explicitly specifying UTF-8 on reading and writing golden
files
@Jimbo4350 Jimbo4350 force-pushed the jordan/temp-plutus-debug-final branch from c1195d7 to bd03c74 Compare November 19, 2024 18:51
(goldenFilesLocation </> fqtn </> constructorName <> ".txt")

-- TODO: Upstream all to hedgehog-extras
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that the only change here is setting the encoding to utf8 when accessing files with strings? Can you add a comment explaining the change, and when to remove those functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll link to the PR which has everything: input-output-hk/hedgehog-extras#75

Comment on lines +40 to +41
renderDebugPlutusFailure :: DebugPlutusFailure -> Text
renderDebugPlutusFailure dpf =
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use Pretty or Error class? Tbf I prefer those in comparison to renderXXXX functions.

base64PlutusScriptArgsBytes =
"2Hmf2Hmfn9h5n9h5n1ggp4nVTEZsdm+0vF4Jy816CkYJdWfk/2BiCVVip0BLnL8A/9h5n9h5n9h6n1gcxhv6HBOFJLafN4vGlQQyLzkonOVU1UnbTR4rUP/YeoD/oUChQBoATEtA2HqfWCADFwoudZe3t+PYTAU5HROaYrFX54eG2MCC8p3PTBETFP/YeoD///+An9h5n9h5n9h5n1gcxbyvlPIHUatyym5imViDpytwsNh06mjqCXkOk//YeoD/okChQBoAHoSAWBzGG/ocE4Uktp83i8aVBDIvOSic5VTVSdtNHitQoUpNaWxsYXJDb2luBdh5gNh6gP/YeZ/YeZ/YeZ9YHMW8r5TyB1GrcspuYplYg6crcLDYdOpo6gl5DpP/2HqA/6FAoUAaAA9CQNh6n1gg7hVazpxAKSB0y2r/jJzN0nPIFkj/EUnvNrzqbruKPiX/2HqA/9h5n9h5n9h5n1gcKSM+X/Qw3SW5FG9fON4SNYYd6scERBygsGr5Ev/YeoD/oUChQBsAAA2kdfg7QNh5gNh6gP//AKFYHMYb+hwThSS2nzeLxpUEMi85KJzlVNVJ200eK1ChSk1pbGxhckNvaW4Fn9h5n9h6n1gcxhv6HBOFJLafN4vGlQQyLzkonOVU1UnbTR4rUP/YeZ8aAAYagP///6DYeZ/YeZ/YeYDYeoD/2Hmf2HuA2HqA//+Ao9h6n9h5n1ggp4nVTEZsdm+0vF4Jy816CkYJdWfk/2BiCVVip0BLnL8A//8A2HmfWBzGG/ocE4Uktp83i8aVBDIvOSic5VTVSdtNHitQ/wDYfJ8A2Hmf2HqfWBzGG/ocE4Uktp83i8aVBDIvOSic5VTVSdtNHitQ/9h5nxoABhqA////AKJYIAMXCi51l7e349hMBTkdE5pisVfnh4bYwILync9MERMUAFgg7hVazpxAKSB0y2r/jJzN0nPIFkj/EUnvNrzqbruKPiUBWCDYftkmm+fgwSsSsBQx2QwFWHhnvtoPcpBPuBHJ7A+Z0KCA2HqA2HqA/wDYfJ8A2Hmf2HqfWBzGG/ocE4Uktp83i8aVBDIvOSic5VTVSdtNHitQ/9h5nxoABhqA/////w=="

hexPlutusScriptBytes :: Text
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this script do? can you add a comment explaining that? can it be useful in other places as well?

I'm concerned about code duplication and reusability. For example we're reading a simple plutus script here too:

Maybe it would make sense to have a plutus reading code for the test purposes in a single place?


hexPlutusScriptBytes :: Text
hexPlutusScriptBytes =
"590e73590e7001000032323322332233223232323232323232323232323225335533535353232325335333573466e1d200000201301213232323232333222123330010040030023232325335333573466e1d200000201b01a1323232323232323232323232323232323333333333332333233233222222222222222212333333333333333300101101000f00e00d00c00b00a00900800700600500400300230013574202860026ae8404cc0948c8c8c94cd4ccd5cd19b87480000080c40c04cc8848cc00400c008c074d5d080098029aba135744002260589201035054310035573c0046aae74004dd5000998128009aba101123232325335333573466e1d200000203002f13232333322221233330010050040030023232325335333573466e1d2000002035034133221233001003002302e357420026605e4646464a66a666ae68cdc3a4000004072070264244600400660646ae8400454cd4ccd5cd19b87480080080e40e04c8ccc888488ccc00401401000cdd69aba1002375a6ae84004dd69aba1357440026ae880044c0d12401035054310035573c0046aae74004dd50009aba135744002260609201035054310035573c0046aae74004dd51aba1003300735742004646464a66a666ae68cdc3a400000406a068224440062a66a666ae68cdc3a400400406a068264244460020086eb8d5d08008a99a999ab9a3370e900200101a81a099091118010021aba1001130304901035054310035573c0046aae74004dd51aba10013302c75c6ae84d5d10009aba200135744002260569201035054310035573c0046aae74004dd50009bad3574201e60026ae84038c008c009d69981180a9aba100c33302702475a6ae8402cc8c8c94cd4ccd5cd19b87480000080b80b44cc8848cc00400c008c8c8c94cd4ccd5cd19b87480000080c40c04cc8848cc00400c008cc09dd69aba10013026357426ae880044c0b1241035054310035573c0046aae74004dd51aba10013232325335333573466e1d20000020310301332212330010030023302775a6ae84004c098d5d09aba20011302c491035054310035573c0046aae74004dd51aba13574400226052921035054310035573c0046aae74004dd51aba100a3302375c6ae84024ccc09c8c8c8c94cd4ccd5cd19b87480000080bc0b84c84888888c01401cdd71aba100115335333573466e1d200200202f02e13212222223002007301b357420022a66a666ae68cdc3a400800405e05c2642444444600600e60506ae8400454cd4ccd5cd19b87480180080bc0b84cc884888888cc01802001cdd69aba10013019357426ae8800454cd4ccd5cd19b87480200080bc0b84c84888888c00401cc068d5d08008a99a999ab9a3370e9005001017817099910911111198020040039bad3574200260306ae84d5d1000898152481035054310035573c0046aae74004dd500080f9aba10083300201f3574200e6eb8d5d080319981380b198138111191919299a999ab9a3370e9000001017817089110010a99a999ab9a3370e9001001017817089110008a99a999ab9a3370e900200101781708911001898152481035054310035573c0046aae74004dd50009aba1005330230143574200860026ae8400cc004d5d09aba2003302475a604aeb8d5d10009aba2001357440026ae88004d5d10009aba2001357440026ae88004d5d10009aba2001357440026ae88004d5d10009aba200113016491035054310035573c0046aae74004dd51aba10063574200a646464a66a666ae68cdc3a40000040360342642444444600a00e6eb8d5d08008a99a999ab9a3370e900100100d80d0999109111111980100400398039aba10013301500f357426ae8800454cd4ccd5cd19b874801000806c0684c84888888c00c01cc050d5d08008a99a999ab9a3370e900300100d80d099910911111198030040039bad35742002600a6ae84d5d10008a99a999ab9a3370e900400100d80d0990911111180080398031aba100115335333573466e1d200a00201b01a13322122222233004008007375a6ae84004c010d5d09aba2001130164901035054310035573c0046aae74004dd51aba13574400a4646464a66a666ae68cdc3a4000004036034264666444246660020080060046eb4d5d0801180a9aba10013232325335333573466e1d200000201f01e1323332221222222233300300a0090083301a017357420046ae84004cc069d71aba1357440026ae8800454cd4ccd5cd19b874800800807c0784cc8848888888cc01c024020cc064058d5d0800991919299a999ab9a3370e90000010110108999109198008018011bad357420026eb4d5d09aba20011301d491035054310035573c0046aae74004dd51aba1357440022a66a666ae68cdc3a400800403e03c266442444444466004012010666036030eb4d5d08009980cbae357426ae8800454cd4ccd5cd19b874801800807c0784c848888888c010020cc064058d5d08008a99a999ab9a3370e900400100f80f09919199991110911111119998008058050048041980d80c1aba10033301901a3574200466603a034eb4d5d08009a991919299a999ab9a3370e90000010120118998149bad357420026eb4d5d09aba20011301f4901035054310035573c0046aae74004dd51aba135744002446602a0040026ae88004d5d10008a99a999ab9a3370e900500100f80f0999109111111198028048041980c80b1aba10013232325335333573466e1d200000202202113301c75c6ae840044c075241035054310035573c0046aae74004dd51aba1357440022a66a666ae68cdc3a401800403e03c22444444400c26034921035054310035573c0046aae74004dd51aba1357440026ae880044c059241035054310035573c0046aae74004dd50009191919299a999ab9a3370e900000100d00c899910911111111111980280680618099aba10013301475a6ae84d5d10008a99a999ab9a3370e900100100d00c899910911111111111980100680618099aba10013301475a6ae84d5d10008a9919a999ab9a3370e900200180d80d0999109111111111119805006806180a1aba10023001357426ae8800854cd4ccd5cd19b874801800c06c0684c8ccc888488888888888ccc018038034030c054d5d080198011aba1001375a6ae84d5d10009aba200215335333573466e1d200800301b01a133221222222222223300700d00c3014357420046eb4d5d09aba200215335333573466e1d200a00301b01a132122222222222300100c3014357420042a66a666ae68cdc3a4018006036034266442444444444446600601a01860286ae84008dd69aba1357440042a66a666ae68cdc3a401c006036034266442444444444446601201a0186eb8d5d08011bae357426ae8800854cd4ccd5cd19b874804000c06c0684cc88488888888888cc020034030dd71aba1002375a6ae84d5d10010a99a999ab9a3370e900900180d80d0999109111111111119805806806180a1aba10023014357426ae8800854cd4ccd5cd19b874805000c06c0684c8488888888888c010030c050d5d08010980b2481035054310023232325335333573466e1d200000201e01d13212223003004375c6ae8400454c8cd4ccd5cd19b874800800c07c0784c84888c004010c004d5d08010a99a999ab9a3370e900200180f80f099910911198010028021bae3574200460026ae84d5d10010980d2481035054310023232325335333573466e1d200000202202113212223003004301b357420022a66a666ae68cdc3a4004004044042224440042a66a666ae68cdc3a4008004044042224440022603a921035054310035573c0046aae74004dd50009aab9e00235573a0026ea8004d55cf0011aab9d00137540024646464a66a666ae68cdc3a40000040320302642444600600860246ae8400454cd4ccd5cd19b87480080080640604c84888c008010c048d5d08008a99a999ab9a3370e900200100c80c099091118008021bae3574200226028921035054310035573c0046aae74004dd50009191919299a999ab9a3370e900000100c00b8999109198008018011bae357420026eb4d5d09aba200113013491035054310035573c0046aae74004dd50009aba20011300e491035054310035573c0046aae74004dd50009110019111111111111111180f0031080888078a4c26016921035054350030142225335333573466e1d20000010110101300c491035054330015335333573466e20005200001101013300333702900000119b81480000044c8cc8848cc00400c008cdc200180099b840020013300400200130132225335333573466e1d200000101000f10021330030013370c00400240024646464a66a666ae68cdc3a400000401e01c201c2a66a666ae68cdc3a400400401e01c201e260149201035054310035573c0046aae74004dd500091191919299a999ab9a3370e9000001007807089110010a99a999ab9a3370e90010010078070990911180180218029aba100115335333573466e1d200400200f00e112220011300a4901035054310035573c0046aae74004dd50009191919299a999ab9a3370e90000010068060999109198008018011bae357420026eb4d5d09aba200113008491035054310035573c0046aae74004dd5000919118011bac001300f2233335573e002401c466a01a60086ae84008c00cd5d10010041191919299a999ab9a3370e900000100580509909118010019bae357420022a66a666ae68cdc3a400400401601426424460020066eb8d5d0800898032481035054310035573c0046aae74004dd500091191919299a999ab9a3370e90010010058050a8070a99a999ab9a3370e90000010058050980798029aba1001130064901035054310035573c0046aae74004dd5000919319ab9c00100322322300237560026018446666aae7c004802c8c8cd402ccc03cc018d55ce80098029aab9e0013004357440066ae8400801448004c020894cd40045401c884d4008894cd4ccd5cd19b8f4881210104312775add93ed57c301fab7501f74beb3dbc3a70a659ef36bcea6ebb8a3e25000020080071300c001130060031220021220011220021221223300100400321223002003112200122123300100300223230010012300223300200200101"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move base64PlutusScriptArgsBytes and hexPlutusScriptBytes definitions to the bottom of the file? It would be nicer to not have to scroll through the wall of text to get to more meaningful test code.

@Jimbo4350 Jimbo4350 added this pull request to the merge queue Nov 20, 2024
Merged via the queue into master with commit 0c45959 Nov 20, 2024
29 checks passed
@Jimbo4350 Jimbo4350 deleted the jordan/temp-plutus-debug-final branch November 20, 2024 15:22
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