plutus
plutus copied to clipboard
Fix `costIsAcceptable`
costIsAcceptable in both PIR and UPLC thinks that any Constr node containing a single element is fine as long as the cost of the latter is acceptable:
costIsAcceptable :: Term name uni fun a -> Bool
costIsAcceptable = \case
<...>
Constr _ _ es ->
case es of
[] -> True
[e] -> costIsAcceptable e
_ -> False
Which makes sense on the surface until you realize that you can a 100-level-deep Constr node each containing a single element at each level -- and the cost of that isn't acceptable, because all those levels are gonna get evaluated at runtime. This needs to be fixed.