IntersectMBO / IntersectMBO/plutus
"Debug symbols" for plutus-tx
- Dominant language
- Haskell
- Stars
- 1.6k
- Forks
- 508
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 22
Description
### Describe the feature you'd like
Would be great if the compiler produced 2 artifacts, one version of the contract with all debugging code-paths stripped out to be used on-chain and one with debugging kept in for off-chain usage.
This goes beyond `remove-trace` in two ways:
1. Both artifacts are created at once, so there's no need to call with a different set of plugin options
2. User extensible definition of "debugging code path" (described below)
I think there are 2 kinds of cases where we'd want to specify something as a "debug code path" (perhaps telling the compiler this through annotations?)
First is "unconditional", where any time some term appears it is unconditionally replaced with some other term. `trace` gets replaced with `flip const`.
Second is "conditional", where we use some special function to indicate a promise that some subset of the codomain corresponds to failure-case debugging. E.g. `debugFailure (fromBuiltinData d) :: Maybe a` would get rewritten to `(Just . unsafeFromBuiltinData) d :: Maybe a` in prod mode (and `debugFailure` would act as `id` otherwise), and the user is promising that in the `Nothing` case there will just be some tracing followed, ultimately, by a call to `error`.
### Describe alternatives you've considered
Status quo, basically.
Contributor guide
Assessment
This issue has not been assessed yet.