Skip to content

Commit

Permalink
add some exit codes
Browse files Browse the repository at this point in the history
  • Loading branch information
aSpite committed Jan 17, 2024
1 parent a3a298e commit 3d76f22
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions docs/learn/tvm-instructions/tvm-exit-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,36 @@ If TVM exits with an arbitrary 16-bit unsigned integer `exit_code`. `exit_code`
The list of standard exit codes contains all universal TVM exit codes defined for TON Blockchain. Alternative exit codes should be sought in the source code of corresponded contract.
:::

| Exit Code | TVM Phase | Description |
|----------|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `0` | Compute Phase | Standard successful execution exit code. |
| `1` | Compute Phase | Alternative successful execution exit code. |
| `2` | Compute Phase | Stack underflow. Last op-code consumed more elements than there are on the stacks. <sup>1</sup> |
| `3` | Compute Phase | Stack overflow. More values have been stored on a stack than allowed by this version of TVM. |
| `4` | Compute Phase | Integer overflow. Integer does not fit into −2<sup>256</sup> ≤ x < 2<sup>256</sup> or a division by zero has occurred. |
| `5` | Compute Phase | Integer out of expected range. |
| `6` | Compute Phase | Invalid opcode. Instruction is unknown in the current TVM version. |
| `7` | Compute Phase | Type check error. An argument to a primitive is of an incorrect value type. <sup>1</sup> |
| `8` | Compute Phase | Cell overflow. Writing to builder is not possible since after operation there would be more than 1023 bits or 4 references. |
| `9` | Compute Phase | Cell underflow. Read from slice primitive tried to read more bits or references than there are. |
| `10` | Compute Phase | Dictionary error. Error during manipulation with dictionary (hashmaps). |
| Exit Code | TVM Phase | Description
| --------- | ------------- | -------------
| `0` | Compute Phase | Standard successful execution exit code.
| `1` | Compute Phase | Alternative successful execution exit code.
| `2` | Compute Phase | Stack underflow. Last op-code consumed more elements than there are on the stacks. <sup>1</sup>
| `3` | Compute Phase | Stack overflow. More values have been stored on a stack than allowed by this version of TVM.
| `4` | Compute Phase | Integer overflow. Integer does not fit into −2<sup>256</sup> ≤ x < 2<sup>256</sup> or a division by zero has occurred.
| `5` | Compute Phase | Integer out of expected range.
| `6` | Compute Phase | Invalid opcode. Instruction is unknown in the current TVM version.
| `7` | Compute Phase | Type check error. An argument to a primitive is of an incorrect value type. <sup>1</sup>
| `8` | Compute Phase | Cell overflow. Writing to builder is not possible since after operation there would be more than 1023 bits or 4 references.
| `9` | Compute Phase | Cell underflow. Read from slice primitive tried to read more bits or references than there are.
| `10` | Compute Phase | Dictionary error. Error during manipulation with dictionary (hashmaps).
| `11` | Compute Phase | Most oftenly caused by trying to call get-method whose id wasn't found in the code (missing `method_id` modifier or wrong get-method name specified when trying to call it). In [TVM docs](https://ton.org/tvm.pdf) its described as "Unknown error, may be thrown by user programs". |
| `12` | Compute Phase | Thrown by TVM in situations deemed impossible. |
| `13` | Compute Phase | Out of gas error. Thrown by TVM when the remaining gas becomes negative. |
| `-14` | Compute Phase | It means out of gas error, same as `13`. Negative, because it [cannot be faked](https://github.com/ton-blockchain/ton/blob/20758d6bdd0c1327091287e8a620f660d1a9f4da/crypto/vm/vm.cpp#L492) |
| `32` | Action Phase | Action list is invalid. Set during action phase if c5 register after execution contains unparsable object. |
| `-32` | Action Phase | (the same as prev 32) - Method ID not found. Returned by TonLib during an attempt to execute non-existent get method. |
| `33` | Action Phase | Action list is too long. |
| `34` | Action Phase | Action is invalid or not supported. Set during action phase if current action cannot be applied. <br/> |
| `36` | Action Phase | Invalid Source address in outbound message. |
| `37` | Action Phase | Not enough TON. Message sends too much TON (or there is not enough TON after deducting fees). |
| `38` | Action Phase | Not enough extra-currencies. |
| `12` | Compute Phase | Thrown by TVM in situations deemed impossible.
| `13` | Compute Phase | Out of gas error. Thrown by TVM when the remaining gas becomes negative.
| `-14` | Compute Phase | It means out of gas error, same as `13`. Negative, because it [cannot be faked](https://github.com/ton-blockchain/ton/blob/20758d6bdd0c1327091287e8a620f660d1a9f4da/crypto/vm/vm.cpp#L492)
| `32` | Action Phase | Action list is invalid. Set during action phase if c5 register after execution contains unparsable object.
| `-32` | Action Phase | (the same as prev 32) - Method ID not found. Returned by TonLib during an attempt to execute non-existent get method.
| `33` | Action Phase | Action list is too long.
| `34` | Action Phase | Action is invalid or not supported. Set during action phase if current action cannot be applied.
| `35` | Action Phase | Invalid Source address in outbound message.
| `36` | Action Phase | Invalid Destinastion address in outbound message.
| `37` | Action Phase | Not enough TON. Message sends too much TON (or there is not enough TON after deducting fees)
| `38` | Action Phase | Not enough extra-currencies.
| `40` | Action Phase | Not enough funds to process a message. This error is thrown when there is only enough gas to cover part of the message, but does not cover it completely.
| `43` | Action Phase | The maximum number of cells in the library is exceeded or the maximum depth of the Merkle tree is exceeded.

<sup>1</sup> If you encounter such exception in a _func_ contract it probably means a type error in `asm` declarations.

:::info
Often you can see the exit code `0xffff`. This usually means that the received opcode is unknown to the contract. When writing contracts, this code is set by the developer himself.
:::

0 comments on commit 3d76f22

Please sign in to comment.