plutus icon indicating copy to clipboard operation
plutus copied to clipboard

Fix `costIsAcceptable`

Open effectfully opened this issue 5 months ago • 0 comments

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.

effectfully avatar Jul 09 '25 07:07 effectfully