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

[DRAFT] Minimal example of PIR simplifier memory consumption bug #6184

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions plutus-tx-plugin/app/SimplifierBugMinimalExample.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
-- editorconfig-checker-disable-file
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}

-- Comment out in order to reproduce the compilation issue.
-- WATCH OUT: THIS IS PROBABLY GOING TO OOO YOUR MACHINE
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:max-simplifier-iterations-pir=1 #-}

module Main where

import PlutusTx qualified
import PlutusTx.Prelude hiding (Semigroup (..), unless)
import Prelude qualified as H

main :: H.IO ()
main = do
H.pure ()

data C = A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R

PlutusTx.makeIsDataIndexed ''C [ ('A, 0) , ('B, 1) , ('C, 2) , ('D, 3) , ('E, 4) , ('F, 5) , ('G, 6) , ('H, 7) , ('I, 8) , ('J, 9) , ('K, 10) , ('L, 11) , ('M, 12) , ('N, 13) , ('O, 14) , ('P, 15) , ('Q, 16) , ('R, 17) ]

{-# INLINABLE validator #-}
validator ::
BuiltinData
-> BuiltinData
-> BuiltinData
-> Bool
validator d _ _ =
let !_ = PlutusTx.unsafeFromBuiltinData @C d
in True

unappliedValidator ::
PlutusTx.CompiledCode (PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> BuiltinUnit)
unappliedValidator =
$$(PlutusTx.compile [|| \d r c -> check $ validator d r c ||])

12 changes: 12 additions & 0 deletions plutus-tx-plugin/plutus-tx-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ executable gen-plugin-opts-doc

default-language: Haskell2010

executable simplifier-bug-minimal-example
import: lang, ghc-version-support
main-is: SimplifierBugMinimalExample.hs
hs-source-dirs: app
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
, base >=4.7 && <5
, plutus-tx
, plutus-tx-plugin ^>=1.29

default-language: Haskell2010

test-suite plutus-tx-plugin-tests
import: lang, ghc-version-support

Expand Down