Skip to content

Commit 83a05ac

Browse files
Transaction outcome description (ton-community#708)
* Transaction outcome Definition of success and some TVM details. * Upd transaction outcome * Update message-delivery-guarantees.mdx * Update tvm-overview.mdx
1 parent 686aee0 commit 83a05ac

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

docs/develop/smart-contracts/guidelines/message-delivery-guarantees.mdx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ConceptImage from '@site/src/components/conceptImage';
22
import ThemedImage from '@theme/ThemedImage';
33

4-
# Message Overview
4+
# Messages and Transactions
55

66
TON is an asynchronous blockchain with a complex structure very different from other blockchains. Because of this, new developers often have questions about low-level things in TON. In this article, we will have a look at one of these related to message delivery.
77

@@ -58,6 +58,38 @@ To achieve the infinite sharding paradigm, it is necessary to ensure full parall
5858
More detailed and accurate description on the [Transaction Layout](/develop/data-formats/transaction-layout) page.
5959
:::
6060

61+
### Transaction outcome
62+
63+
There is a [TVM exit code](/learn/tvm-instructions/tvm-exit-codes) for transaction which had compute phase, if it is >1 then there was an error.
64+
Also TVM [compute phase may be skipped](/learn/tvm-instructions/tvm-overview#compute-phase-skipped) for some reasons like absence of funds or state.
65+
66+
:::info
67+
To determine successful transaction one should use tx.description.action.success && tx.description.compute_ph.success:
68+
:::
69+
```json
70+
"transactions": [
71+
{
72+
"description": {
73+
. . . . . . . .
74+
"action": {
75+
"valid": true,
76+
"success": true,
77+
. . . . . . . .
78+
},
79+
. . . . . . . .
80+
"destroyed": false,
81+
"compute_ph": {
82+
"mode": 0,
83+
"type": "vm",
84+
"success": true,
85+
```
86+
87+
Transaction may have one of three results:
88+
89+
- Success, exit code 0 or 1
90+
- Fail, `aborted: true`
91+
- Fail, [exit code >= 2 ](https://testnet.tonviewer.com/transaction/5889803bb1e0f58fdee381382fe1e38f74f3ea002a700441f8a21d52f7234ef8), `aborted: true`
92+
6193
## What is a Logical time?
6294

6395
In such a system with asynchronous and parallel smart contract calls, it can be hard to define the order of actions to process. That's why each message in TON has its _Logical time_ or _Lamport time_ (later just _lt_). It is used to understand which event caused another and what a validator needs to process first.

docs/learn/tvm-instructions/tvm-overview.mdx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,22 @@ Each transaction consists of up to 5 phases:
5959
## Compute phase
6060
In this phase, the TVM execution occurs.
6161

62+
:::tip
63+
* TVM 4.3.5 — [**TON Blockchain paper**](https://docs.ton.org/assets/files/tblkch-6aaf006b94ee2843a982ebf21d7c1247.pdf)
64+
:::
65+
66+
### Compute phase skipped
67+
68+
The computing phase consists in invoking TVM with correct inputs. On some occasions, TVM cannot be invoked at all (e.g., if the account is absent, not initialized, or frozen, and the inbound message being processed has no code or data fields or these fields have an incorrect hash)
69+
70+
This is reflected by corresponding [constructors](https://github.com/ton-blockchain/ton/blob/5c392e0f2d946877bb79a09ed35068f7b0bd333a/crypto/block/block.tlb#L314):
71+
72+
- `cskip_no_state$00` - The [absence of a state](https://testnet.tonviewer.com/transaction/7e78394d082882375a5d21affa6397dec60fc5a3ecbea87f401b0e460fb5c80c) (i.e., smart-contract code and data) in both the account (non-existing, uninitialized, or frozen) and the message.
73+
74+
- `cskip_bad_state$01` - An invalid state passed in the message (i.e., the state's hash differs from the expected value) to a frozen or uninitialized account.
75+
76+
- `cskip_no_gas$10` - The [absence of funds](https://testnet.tonviewer.com/transaction/a1612cde7fd66139a7d04b30f38db192bdb743a8b12054feba3c16061a4cb9a6) to buy gas. (About < 0.00004 TON by [08.2024](https://testnet.tonviewer.com/transaction/9789306d7b29318c90477aa3df6599ee4a897031162ad41a24decb87db65402b))
77+
6278
### TVM state
6379
At any given moment, the TVM state is fully determined by 6 properties:
6480
* Stack (see below)
@@ -112,4 +128,4 @@ Note, that since there is a limit on max cell-depth `<1024`, and particularly th
112128
## See Also
113129

114130
- [TVM Instructions](/learn/tvm-instructions/instructions)
115-
- [TON TVM](https://ton.org/tvm.pdf) TVM Concepts(may include outdated information)
131+
- [TON TVM](https://ton.org/tvm.pdf) TVM Concepts(may include outdated information)

0 commit comments

Comments
 (0)