|
18 | 18 | Most users should not use this module directly, but rather use 'PlutusTx.Builtins'.
|
19 | 19 |
|
20 | 20 | Please note that the documentation for each function will only include operational invariants
|
21 |
| - if there are any. This documentation assumes type system correctly enforces and prevents any structural |
22 |
| - errors on the generated UPLC. See Note [Structural vs operational errors within builtins]. |
| 21 | + if there are any. This documentation assumes that the type system correctly enforces and |
| 22 | + prevents any structural errors on the generated UPLC. See Note [Structural vs operational errors |
| 23 | + within builtins]. |
| 24 | +
|
| 25 | + Also note that all builtin functions will fail if the CEK machine exceeds its evaluation budget. |
| 26 | + Builtin functions with dynamic costing are particularly prone to budget overruns: for example, |
| 27 | + addInteger and appendByteString differ cost based on input size, so supplying very large integers or |
| 28 | + byte strings will cause these functions to abort when the budget limit is reached and fail. |
| 29 | + See Note [Budgeting]. |
23 | 30 | -}
|
24 | 31 | module PlutusTx.Builtins.Internal where
|
25 | 32 |
|
@@ -893,9 +900,11 @@ bls12_381_finalVerify (BuiltinBLS12_381_MlResult a) (BuiltinBLS12_381_MlResult b
|
893 | 900 | CONVERSION
|
894 | 901 | -}
|
895 | 902 |
|
896 |
| -{-| Converts the given integer to a bytestring. The first argument specifies |
897 |
| -endianness (True for big-endian), followed by the target length of the resulting bytestring |
898 |
| -and the integer itself. See 'PlutusCore.Bitwise.integerToByteString' for its invariances. |
| 903 | +{- | Converts the given integer to a bytestring. The first argument specifies |
| 904 | + endianness (True for big-endian), followed by the target length of the resulting bytestring |
| 905 | + and the integer itself. Fails if the target length is greater than 8192 or if the length |
| 906 | + argument is 0 and the result won't fit into 8192 bytes. |
| 907 | + See 'PlutusCore.Bitwise.integerToByteString' for its invariants in detail. |
899 | 908 | -}
|
900 | 909 | integerToByteString
|
901 | 910 | :: BuiltinBool
|
@@ -1045,13 +1054,14 @@ writeBits (BuiltinByteString bs) (BuiltinList ixes) (BuiltinBool bit) =
|
1045 | 1054 | BuiltinSuccessWithLogs logs bs' -> traceAll logs $ BuiltinByteString bs'
|
1046 | 1055 | {-# OPAQUE writeBits #-}
|
1047 | 1056 |
|
1048 |
| -{-| Creates a bytestring of a given length by repeating the given byte. |
1049 |
| -Fails if the byte, second argument, is not in range @[0,255]@ or the length is negative. |
| 1057 | +{- | Creates a bytestring of a given length by repeating the given byte. |
| 1058 | +Fails if the byte, second argument, is not in range @[0,255]@, the length is negative, |
| 1059 | +or when the length is greater than 8192. |
1050 | 1060 | -}
|
1051 |
| -replicateByte |
1052 |
| - :: BuiltinInteger |
1053 |
| - -> BuiltinInteger |
1054 |
| - -> BuiltinByteString |
| 1061 | +replicateByte :: |
| 1062 | + BuiltinInteger -> |
| 1063 | + BuiltinInteger -> |
| 1064 | + BuiltinByteString |
1055 | 1065 | replicateByte n w8 =
|
1056 | 1066 | case Bitwise.replicateByte n (fromIntegral w8) of
|
1057 | 1067 | BuiltinFailure logs err ->
|
|
0 commit comments