Skip to content

Amend documentation in Builtins.Internal about budgeting and invariants on Bytestring builtins #7109

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions plutus-tx/src/PlutusTx/Builtins/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
Please note that the documentation for each function will only include operational invariants
if there are any. This documentation assumes type system correctly enforces and prevents any structural
errors on the generated UPLC. See Note [Structural vs operational errors within builtins].

Also note that all builtin functions will fail if the CEK machine exceeds its evaluation budget.
Builtin functions with dynamic costing are particularly prone to budget overruns: for example,
addInteger and appendByteString differ cost based on input size, so supplying very large integers or
byte strings will cause these functions to abort when the budget limit is reached and fail.
See Note [Budgeting].
-}
module PlutusTx.Builtins.Internal where

Expand Down Expand Up @@ -875,7 +881,9 @@ CONVERSION

-- | Converts the given integer to a bytestring. The first argument specifies
-- endianness (True for big-endian), followed by the target length of the resulting bytestring
-- and the integer itself. See 'PlutusCore.Bitwise.integerToByteString' for its invariances.
-- and the integer itself. Fails if the target length is greater than 8192 or if the length
-- argument is 0 and the result won't fit into 8192 bytes.
-- See 'PlutusCore.Bitwise.integerToByteString' for its invariances in detail.
integerToByteString
:: BuiltinBool
-> BuiltinInteger
Expand Down Expand Up @@ -1014,7 +1022,8 @@ writeBits (BuiltinByteString bs) (BuiltinList ixes) (BuiltinBool bit) =
{-# OPAQUE writeBits #-}

-- | Creates a bytestring of a given length by repeating the given byte.
-- Fails if the byte, second argument, is not in range @[0,255]@ or the length is negative.
-- Fails if the byte, second argument, is not in range @[0,255]@, the length is negative,
-- or when the length is greater than 8192.
replicateByte ::
BuiltinInteger ->
BuiltinInteger ->
Expand Down
Loading