You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**65536+**: Default range for user functions when using automatic generation `(crc16() & 0xffff) | 0x10000`
317
+
318
+
**Best practice**: It's recommended to **avoid setting method IDs manually** and rely on automatic generation instead. Manual assignment can lead to conflicts and unexpected behavior.
<summary><b>Technical details about method_id parsing</b></summary>
319
323
320
-
This function (`crypto/common/bigint.hpp`) is responsible for parsing the hexadecimal string.
324
+
While the FunC compiler can initially accept larger hex values during parsing, the actual limitation comes from the TVM assembler which restricts method IDs to 19 bits (`@procdictkeylen = 19` in Asm.fif).
321
325
322
-
It first performs a basic check on the length of the hex string:
326
+
The parsing of the hexadecimal string for `method_id` is handled by functions in `crypto/common/bigint.hpp` (specifically `AnyIntView::parse_hex_any` called via `td::string_to_int256` and `BigInt<257>::parse_hex`).
327
+
328
+
`AnyIntView::parse_hex_any` first performs a basic check on the length of the hex string:
A 65-character hex string represents \( 65 times 4 = 260 \) bits.
337
-
So, `260 < 310 - 2`. Such a number (65 hex digits) can *pass* this initial length check. This check is designed to quickly reject inputs that are grossly too large. The `-2` is a slight margin.
338
-
339
-
After basic parsing into internal `digits_`, it calls `normalize_bool_any()`.
346
+
The calculated bit limit for the quick check is 322 bits. Since `260` is not greater than `322`, such a number (65 hex digits) can *pass* this initial length check. This check is designed to quickly reject inputs that are grossly too large. The `-2` offers a slight margin.
340
347
341
-
If `normalize_bool_any()` returns `false`, `parse_hex_any` will invalidate the `BigInt` and return `0`, indicating a parsing failure. This leads to `td::string_to_int256` returning a `null``RefInt256`.
348
+
After this initial parsing into internal `digits_`, `parse_hex_any` calls `normalize_bool_any()`. This function converts the internal representation into a canonical signed form.
349
+
If `normalize_bool_any()` returns `false`, it indicates an overflow during this canonicalization. This can happen even if the number passed the initial length check, for example, if a carry propagates such that it requires more than `max_size()` words to represent in the specific signed format, or if the most significant word itself overflows. In such a case, `parse_hex_any` invalidates the `BigInt` and returns `0`, leading to `td::string_to_int256` returning a `null RefInt256` and FunC reporting an "invalid integer constant".
0 commit comments