Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a compiler option to remove traces (#4219)
* Add a compiler option to remove traces * Add remove-trace tests. Refactor plugin options in plutus-tx-plugin tests * define builtin trace: use liftQuote instead of runQuote to maintain unique counting
- Loading branch information
Showing
30 changed files
with
232 additions
and
66 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
nix/pkgs/haskell/materialized-darwin/.plan.nix/plutus-tx-plugin.nix
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
nix/pkgs/haskell/materialized-linux/.plan.nix/plutus-tx-plugin.nix
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
nix/pkgs/haskell/materialized-windows/.plan.nix/plutus-tx-plugin.nix
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# OPTIONS_GHC -fplugin PlutusTx.Plugin #-} | ||
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:defer-errors #-} | ||
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:remove-trace #-} | ||
|
||
module Plugin.NoTrace.Spec where | ||
|
||
import Common | ||
import Data.Proxy | ||
import Lib | ||
import Prelude qualified as H | ||
|
||
import PlutusTx | ||
import PlutusTx.Builtins qualified as B | ||
import PlutusTx.Plugin | ||
import PlutusTx.Prelude qualified as P | ||
|
||
noTrace :: TestNested | ||
noTrace = testNested "NoTrace" | ||
[ goldenPir "trace" trace | ||
, goldenPir "traceComplex" traceComplex | ||
, goldenEvalCekLog "traceDirect" [traceDirect] | ||
, goldenEvalCekLog "tracePrelude" [tracePrelude] | ||
, goldenEvalCekLog "traceRepeatedly" [traceRepeatedly] | ||
] | ||
|
||
-- Half-stolen from Plugin.Primitives.Spec | ||
trace :: CompiledCode (B.BuiltinString -> ()) | ||
trace = plc (Proxy @"trace") (\(x :: B.BuiltinString) -> B.trace x ()) | ||
|
||
traceComplex :: CompiledCode (H.Bool -> ()) | ||
traceComplex = plc (Proxy @"traceComplex") (\(b :: H.Bool) -> if b then P.trace "yes" () else P.traceError "no") | ||
|
||
-- Half-stolen from TH.Spec | ||
traceDirect :: CompiledCode () | ||
traceDirect = $$(compile [|| B.trace "test" () ||]) | ||
|
||
tracePrelude :: CompiledCode H.Integer | ||
tracePrelude = $$(compile [|| P.trace "test" (1::H.Integer) ||]) | ||
|
||
traceRepeatedly :: CompiledCode P.Integer | ||
traceRepeatedly = $$(compile | ||
[|| | ||
let i1 = P.trace "Making my first int" (1::P.Integer) | ||
i2 = P.trace "Making my second int" (2::P.Integer) | ||
i3 = P.trace "Adding them up" (i1 P.+ i2) | ||
in i3 | ||
||]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(program | ||
(let | ||
(nonrec) | ||
(datatypebind | ||
(datatype (tyvardecl Unit (type)) Unit_match (vardecl Unit Unit)) | ||
) | ||
(lam ds (con string) Unit) | ||
) | ||
) |
Oops, something went wrong.