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

Added reporting of why Plutus scripts fail. #2386

Merged
merged 1 commit into from
Aug 2, 2021

Conversation

TimSheard
Copy link
Contributor

Exended UtxosPredicateFailure, by adding a Text field to its constructor ValidationTagMismatch.
Altered the functions runPLCScript and evalScripts return a ScriptResult rather than a Bool.

data ScriptResult = Passes | Fails ![String]

So when evalScripts fails in the Utxos rule, we add the reason why to ValidationTagMismatch.
Right now the text string is a rather crude concatenation of a bunch of show results. In the next step we will construct the Text object by using the PrettyA class, so the result is more informative.

@TimSheard TimSheard force-pushed the ts-plutusScriptFails-document branch from a4b1650 to 8f912d6 Compare July 16, 2021 20:12
Copy link
Contributor

@JaredCorduan JaredCorduan left a comment

Choose a reason for hiding this comment

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

Looks great to me!

@JaredCorduan
Copy link
Contributor

@TimSheard - this is not a WIP anymore, is it?

Copy link
Contributor

@nc6 nc6 left a comment

Choose a reason for hiding this comment

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

Made a couple of suggestions, but in general looks good. I'm assuming no longer WIP

alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxos.hs Outdated Show resolved Hide resolved
@TimSheard TimSheard force-pushed the ts-plutusScriptFails-document branch 3 times, most recently from f7595cb to 4b91a8a Compare July 30, 2021 15:03
@TimSheard TimSheard changed the title WIP Added reporting of why Plutus scripts fail. Added reporting of why Plutus scripts fail. Jul 30, 2021
@TimSheard TimSheard force-pushed the ts-plutusScriptFails-document branch from 4b91a8a to 75d22e3 Compare July 30, 2021 16:01
@TimSheard TimSheard force-pushed the ts-plutusScriptFails-document branch from 75d22e3 to 21f49bf Compare July 30, 2021 16:56
@JaredCorduan JaredCorduan merged commit edf2ace into master Aug 2, 2021
@iohk-bors iohk-bors bot deleted the ts-plutusScriptFails-document branch August 2, 2021 23:22
nc6 added a commit that referenced this pull request May 3, 2022
Initially, Plutus scripts were evaluated using the following:
```
      evalScripts @era tx sLst
        ?!## ValidationTagMismatch (getField @"isValid" tx)
```

However, as of #2386, additional reporting was added to Plutus script
failure, and this was changed to the following:
```
      case evalScripts @era tx sLst of
        Fails sss -> False ?!## ValidationTagMismatch (getField @"isValidating" tx) (pack (Prelude.unlines sss))
        Passes -> pure ()
```
The problem here: `evalScripts` is no longer gated by the `?!##`
operator; it must be evaulated at least to WHNF in order to match the
`Fails` constructor. This means that when reapplying transactions in the
mempool (as well as when replaying blocks), we are always running all
Plutus scripts.

The current semantics for using "labeled" predicates is insufficient to
solve this, since we cannot carry out additional actions (such as
emitting events) inside the predicate. As such, we introduce additional
functionality in the STS system to allow gating sections of rules (which
do not result in a return value) with labels. For the sake of
consistency, the existing `labeledPred` function et al are updated to
make use of this new feature.

The entire call to `evalScripts` is now gated by a `nonStatic` label,
and hence will not be evaulated in any `reapply` scenario.
nc6 added a commit that referenced this pull request May 4, 2022
Initially, Plutus scripts were evaluated using the following:
```
      evalScripts @era tx sLst
        ?!## ValidationTagMismatch (getField @"isValid" tx)
```

However, as of #2386, additional reporting was added to Plutus script
failure, and this was changed to the following:
```
      case evalScripts @era tx sLst of
        Fails sss -> False ?!## ValidationTagMismatch (getField @"isValidating" tx) (pack (Prelude.unlines sss))
        Passes -> pure ()
```
The problem here: `evalScripts` is no longer gated by the `?!##`
operator; it must be evaulated at least to WHNF in order to match the
`Fails` constructor. This means that when reapplying transactions in the
mempool (as well as when replaying blocks), we are always running all
Plutus scripts.

The current semantics for using "labeled" predicates is insufficient to
solve this, since we cannot carry out additional actions (such as
emitting events) inside the predicate. As such, we introduce additional
functionality in the STS system to allow gating sections of rules (which
do not result in a return value) with labels. For the sake of
consistency, the existing `labeledPred` function et al are updated to
make use of this new feature.

The entire call to `evalScripts` is now gated by a `nonStatic` label,
and hence will not be evaulated in any `reapply` scenario.
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.

3 participants