Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions foundations/actions/reserve.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ Notation:
- `amount` – the amount of Toncoin passed to the `RAWRESERVE` instruction.
- `mode` – the integer mode passed to the `RAWRESERVE` instruction.
- `original_balance`:
- if after the storage phase, account's balance is less than the value of incoming message with bounce flag set to `false`, then `original_balance` is set to $0$;
- if after the storage phase, account's balance is less than the value of incoming message with bounce flag set to `false`, then `original_balance` is set to 0;
- otherwise, `original_balance` equals account's balance before the compute phase minus incoming message value.
- `remaining_balance` – account's balance before the reservation action.
- `reserve` – the final amount to be reserved.

The algorithm is as follows:

1. Check that `mode` has flag `ReserveBounceIfActionFail`:
- if so, then in case of any failure the action phase will be interrupted and the bounce phase will be initiated;
- if not, then in case of any failure the reservation action will be skipped.
- if so, then in case of any failure during reservation, the rest of the action phase will be skipped, and the bounce phase will be initiated afterward.
1. Set `reserve` to `amount`.
1. Check that `mode` has flag `ReserveAddOriginalBalance`:
1. If so, then check that `mode` has flag `ReserveInvertSign`:
Expand Down Expand Up @@ -86,4 +85,4 @@ The following errors can occur during the reservation flow:
- Some problems with unpacking the reserve action cell.
- A problem related to extra-currency.

If the action had flag `16`, then in case of any of the above errors a [bounce message](/foundations/messages/internal#bounces) is sent back to a sender.
If the action had flag `16`, i.e., `ReserveBounceIfActionFail`, then in case of any of the above errors the transaction enters [bounce phase](/foundations/phases#bounce-phase).
4 changes: 2 additions & 2 deletions foundations/messages/internal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ A bounce message is used to inform the sender that handling of their message fai
- there is enough Toncoin to send it left from handling the failed message,
- and the message is bounceable,
- and when either
- a message throws an error from the [compute phase](/foundations/phases#compute-phase) during message processing and state was not committed by [`COMMIT`](/tvm/instructions#f80f-commit) TVM instruction,
- or a message throws an error in the [action phase](/foundations/phases#action-phase) and mode [`SendBounceIfActionFail`](/foundations/messages/modes) is used.
- a contract throws an error from the [compute phase](/foundations/phases#compute-phase) during message processing, and the state was not committed by [`COMMIT`](/tvm/instructions#f80f-commit) TVM instruction,
- or an action fails in the [action phase](/foundations/phases#action-phase) with the `+16` flag enabled, for example [`SendBounceIfActionFail`](/foundations/messages/modes) in case of message sends or [`ReserveBounceIfActionFail`](/foundations/actions/reserve#modes) in case of reservations.

### Default bounce

Expand Down
Loading