plutus icon indicating copy to clipboard operation
plutus copied to clipboard

Builtins are versioned in Plutus but not in Haskell

Open effectfully opened this issue 1 year ago • 0 comments

PlutusTx.Builtins.Internal has

consByteString :: BuiltinInteger -> BuiltinByteString -> BuiltinByteString
consByteString n (BuiltinByteString b) = BuiltinByteString $ BS.cons (fromIntegral n) b

but that's the old definition of consByteString, the new one doesn't use fromIntegral and instead fails if n doesn't fit into Word8. This means that some builtins behave differently on whether we evaluate them in Plutus or Haskell.

From what I was able to gather, people mostly evaluate Plutus as Haskell just for the purposes of testing, but if the behavior is inconsistent, then such tests can be extremely misleading. We should either make builtins versioned in Haskell as well or remove that functionality entirely and require people to always evaluate Plutus code using a Plutus evaluator.

effectfully avatar May 09 '24 01:05 effectfully