Function producing compiled script fails if is not exported
uhbif19 opened this issue · comments
Summary
We have function returning compiled script. It crashes if we call it. Script does not matter.
Script compilation do not break exactly if:
- Function signature has HasCallStack
- Function is exported
- Function is used for compilation of another script, that is exported
- It is not function, but term (has no arguments)
Steps to reproduce the behavior
Minimal code example so far:
scriptValidatorForTerms :: AuctionScript -> AuctionTerms -> SerialisedScript
scriptValidatorForTerms Deposit = depositValidator
{-# INLINEABLE depositValidator #-}
depositValidator :: SerialisedScript
depositValidator =
serialiseCompiledCode $
$$(PlutusTx.compile [||wrapValidator . func||])
where
func ::
Prelude.Integer
-> Prelude.Integer -> Prelude.Integer -> Prelude.Integer -> Bool
func _ _ _ _ = True
Calling show $ scriptValidatorForTerms Deposit undefined
raises exception.
Actual Result
If depositValidator is exported - it works. If not - calling scriptValidatorForTerms Deposit undefined will raise:
"*** Exception: This must be replaced by the core-to-plc plugin during compilation: plc
CallStack (from HasCallStack):
error, called at src/PlutusTx/Utils.hs:8:26 in plutus-tx-1.1.1.0-8fuGrqxACC7A8obj3qrZvt
Expected Result
Serialized script.
Describe the approach you would take to fix this
No response
System info
plutus-tx-plugin ==1.1.0.0
GHC version: 8.10.7
All options from troubleshooting seems to be enabled.
@michaelpj the floor is yours. This:
If depositValidator is exported - it works. If not - calling scriptValidatorForTerms Deposit undefined will raise:
looks like the issue is with depositValidator
getting inlined in scriptValidatorForTerms
.
@uhbif19 thank you for the report!
show $ scriptValidatorForTerms Deposit undefined
Do you have to have undefined
in there for this to be a reproducer?
Sorry, I missed your answer.
Do you have to have undefined in there for this to be a reproducer?
No, I tried with real values, and it still reproduces.
@uhbif19 I tried something similar to what you did on master and couldn't reproduce. It would be helpful if you can confirm whether this is still a problem on 1.10.0.0 (or a recent version), if not on master. And if it is, try adding {-# OPTIONS_GHC -fomit-interface-pragmas #-}
in PlutusTx.Plugin.Utils
(the module where plc
is defined).
We don't have a reproducer and it's been 3 months since the last message, hence I'm going to close this ticket. Do feel free to reopen any time.