plutus
plutus copied to clipboard
Make CekEvaluationError more informative in ScriptError
It would be great to be able to tell whether it was
- explicit
error
- builtin function invariant violation (e.g. calling
equalsInteger
with non-integers) - "type" error, e.g. trying to apply non-lambda or builtin
EDIT: I was trying to figure out what happens in the evaluation, so ended up traceShow
data arguments in applyValidator
.
After that I used them to evaluateCek
manually. That gave me an error like:
An error has occurred: User error:
The provided Plutus code called 'error'.
Caused by: (force headList [])
And I immediately understood where the problem lies!
(here however Plutus code called
error' is slightly incorrect, that's probably a consequence of that expression reducing to error
?)
And I immediately understood where the problem lies!
@phadej Out of curiosity, what was the problem with force headList []
?
@srid me calling head
on an empty list, obviously! :)
Ah, yes, of course. :-)
I asked only because I'm in the middle of figuring out how to use HeadList
properly from UPLC, but the following program (takes a list as argument) throws a CekEvaluationFailure:
Program
()
(Version () 1 0 0)
(LamAbs
()
(DeBruijn {dbnIndex = 0})
(Apply
()
(Force () (Builtin () HeadList))
(Var () (DeBruijn {dbnIndex = 1}))))
Error(eval): EvaluationError [] "(CekEvaluationFailure,Just (Apply () (Force () (Builtin () HeadList)) (Constant () (Some (ValueOf data (List [I 1,I 2,I 3]))))))"
Aha, never mind! Just as I wrote it, I figured out the problem - I was missing a UnListData
.
I think it does tell you this... there's some place where I think it gets turned into a string in a way that throws away the information. Was this error coming from the node?
@michaelpj while running EmulatorTrace
, I get something like:
[WARNING] Slot 3: W2e463c8: Validation error: Phase2 1719c980d51347a575fcbbd0bd574f9bd9afd5ccda7f6c0f2c34183fcf4ba7d9: ScriptFailure (EvaluationError [] "CekEvaluationFailure")
which is very terse.
hmm, we improved this a bit recently: https://github.com/input-output-hk/plutus/commit/35f6773c6ba8394345000b57e9bf149d092347a1#diff-cb4fae72ab44c8b348c3d0f7dc80d29cc4f3c63805870ab6836ce435caece150R204
Maybe you need a newer plutus
version?
Also this whole thing could be less string-y.
Maybe you need a newer plutus version?
I'll test once testnet's cardano-node
is updated. (We try to keep dependencies in sync).
Wait, is this coming from cardano-node
?
@michaelpj no. But its version is pinning its dependencies for us.
hmm, we improved this a bit recently: https://github.com/input-output-hk/plutus/commit/35f6773c6ba8394345000b57e9bf149d092347a1#diff-cb4fae72ab44c8b348c3d0f7dc80d29cc4f3c63805870ab6836ce435caece150R204
Seems like the issue was addressed, so I'm closing the ticket.
@phadej please reopen if you still experience the issue.