Skip to content

Complete terminology (actor model, asynchronous in ton, account, transactions) & transactions processing example #1222

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 3 commits into
base: main
Choose a base branch
from

Conversation

fivestarsfi
Copy link

Description

<--Brief description of the changes introduced in this pull request. Include any relevant issue numbers or links.-->

Closes <--link to issue]-->.

Checklist

  • I have created an issue.
  • I am working on content that aligns with the Style guide.
  • I have reviewed and formatted the content according to Content standardization.
  • I have reviewed and formatted the text in the article according to Typography.

@fivestarsfi fivestarsfi requested a review from reveloper as a code owner June 2, 2025 13:41

**Асинхронность** означает, что операции в TON происходят **не мгновенно** и **не в строгой последовательности**:

- Когда вы отправляете транзакцию, она **не выполняется сразу**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мы же не отправляем транзакции.

**Асинхронность** означает, что операции в TON происходят **не мгновенно** и **не в строгой последовательности**:

- Когда вы отправляете транзакцию, она **не выполняется сразу**
- Сообщения между контрактами **доставляются с задержкой**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

На основании чего такое пишем? Что именно имеется в виду?

- **Контракт C**: Пул ликвидности
### Как это работает в TON:

1. **Шаг 1**: Контракт A отправляет сообщение → **сразу завершает свою транзакцию**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Объяснение неполное, непонятно почему эта транзакция вообще есть. Эта информация критична для объяснения.


Поэтому TON может обрабатывать **миллионы транзакций** в секунду, в то время как Ethereum ограничен **~15 транзакциями** в секунду.

## **Аккаунт**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот раздел содержит множество ошибок.


## **Транзакция**

**Транзакция** в TON — это изменение состояния (стейта) одного конкретного аккаунта в результате обработки входящего сообщения.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Определение неполное. Важно указывать часть про результат - "возможно, отправляется 1 или несколько сообщений"


Что такое "изменение стейта"?

Стейт (состояние) аккаунта включает:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Строго говоря это не так.
State - это состояние Аккаунта в блокчейне - Non Exist, Uninit, ...
https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L266

Фаза действий (Action Phase): обрабатывает действия из Compute Phase, если они завершаются успешно. Действия могут включать отправку сообщений, обновление кода контракта или изменение библиотек. Если действие завершается неудачей, например, из-за нехватки средств, транзакция может быть отменена или пропустить действие, в зависимости от ее режима (отправить или отменить или попробовать отправить, если нет, проигнорировать).
Фаза возврата (Bounce Phase): если на этапе вычисления происходит сбой (exit_code >= 2), на этом этапе генерируется сообщение об отказе для транзакций, инициированных входящим сообщением.

Если вам не хватает средств на этапе Storage Phase, то транзакция будет отклонена и не попадет в блокчейн.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это не совсем верно, так как событие с получением входящего сообщения обновляет запись в Storage:
https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L264

Входящее сообщение это уже часть транзакции. Учитывая что у нас заявлена гарантия доставки internal сообщений, то транзакция будет всегда когда отправлено сообщение контракту.

Пример, транзакции, которые не вписывается в утверждение что "не попадет в блокчейн": транзакция порождаемая jetton transfer notification сообщением - https://tonviewer.com/transaction/846f87178f46dba6b71b68e9e93c7a3846eaf8c4fb362e5c57e056e45c8e7ecb

Для Compute и Action phases существуеют exit codes - это 32-битные signed integer, которые в случае неудачной транзакции выдают число, означающие ошибку. Со всеми exit codes можно ознакомиться здесь: https://docs.ton.org/v3/documentation/tvm/tvm-exit-codes.

Если вы получили exit code = 0, то значит транзакция завершилась удачно.
Пример: В Compute Phase вы получили exit code = 0, в Action Phase success = true, в Bounce Phase no_bounce - это означает полное выполнение, сообщение выполнилось без ошибок и баунса транзакции назад не было.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сообщение выполнилось без ошибок

@Mobyman Mobyman force-pushed the main branch 15 times, most recently from 784bb94 to 2a1295e Compare June 24, 2025 07:50
@Mobyman Mobyman force-pushed the main branch 10 times, most recently from 66874be to 1683a8c Compare June 24, 2025 11:03
@Mobyman Mobyman force-pushed the main branch 5 times, most recently from 013e776 to 26fd3e2 Compare June 25, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants