-
Notifications
You must be signed in to change notification settings - Fork 286
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
clarification for actions limits #882
Conversation
@@ -122,7 +122,7 @@ Besides exit_code and consumed gas data, TVM indirectly outputs the following da | |||
|
|||
All other register values will be neglected. | |||
|
|||
Note, that since there is a limit on max cell-depth `<1024`, and particularly the limit on c4 and c5 depth `<=512`, there will be a limit on the number of output actions in one tx `<=255`. If a contract needs to send more than that, it may send a message with the request `continue_sending` to itself and send all necessary messages in subsequent transactions. | |||
Note, that since there is a limit on max cell-depth `<1024`, and particularly the limit in messages and c4 and c5 depth `<=512`, for c5 register there will be a limit on the number of output actions in one transaction `<=255` during `action phase`, exceeding `<=512` limit will result in earlier error during `compute phase`. If a contract needs to send more than 255, it may send a message with the request to itself and send all necessary messages in subsequent transaction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe that should be rephrased a bit?
Note that there is a global limit on max cell-depth <1024. However, after contract execution, registers c4, c5 and account state must be <512 in depth. Going beyond these limits results an error in the computation phase.
An additional constraint is imposed in the action phase. A contract cannot create more than 255 output actions.
If a contract wants to send more than 255 messages, it can do so by sending a message to itself, which will contain the request of sending the remaining messages. An example of this approach can be seen at https://github.com/ton-blockchain/highload-wallet-contract-v3/blob/main/contracts/highload-wallet-v3.func#L50.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I'd prefer "during contract execution"
-Don't want to use termaccount state
because i'm struggling to find comprehensive definition of it in documentation or whitepapers, as far as i see, it's used like an collective abstract term for contract balance, c3, c4, and, i guess, c7. Anyway, i don't see how this term can be directly related to this constraint. - <=512 not <512, i'm sure
- i guess "compute phase"
Note that there is a global limit on max cell-depth <1024. However, during contract execution, registers c4 and c5 must be <=512 in depth. Going beyond these limits results an error in the compute phase.
An additional constraint is imposed in the action phase. A contract cannot create more than 255 output actions.
:::tip
If a contract wants to send more than 255 messages, it can do so by sending a message to itself, which will contain the request of sending the remaining messages. An example of this approach can be seen at https://github.com/ton-blockchain/highload-wallet-contract-v3/blob/main/contracts/highload-wallet-v3.func#L50.
:::
I'm ready to agree with this variant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPD:
As far as i discovered from block.tlb: https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb
My assumption about acount state
is kinda right and i doesn't see additional constraints on depth for c3 & c7 in realization(vm.cpp and transaction.cpp), except standart one - 1024, so, i definitely sure we shouldn't use this term.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally agree with all points except that it still seems to me that the depth limit of c5 and, most likely, c4, is checked after the transaction is fully executed. Here I was able to make 800 actions and then reset them.
if(op == 15) {
int iter = 0;
while(iter < 700) {
var msg = begin_cell()
.store_uint(0x18, 6)
.store_slice(s_addr)
.store_coins(1)
.store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1);
send_raw_message(msg.end_cell(),0);
iter = iter + 1;
}
set_actions(begin_cell().end_cell());
var msg = begin_cell()
.store_uint(0x18, 6)
.store_slice(s_addr)
.store_coins(1)
.store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1);
send_raw_message(msg.end_cell(),64);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess question here what is transcation execution, i thought that transaction execution including both compute phase and action phase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will be most accurate:
Note that there is a global limit on max cell-depth <1024 during contract execution. However registers c4 and c5 must be <=512 in depth. Going beyond these limits results an error at the end of compute phase.
An additional constraint is imposed in the action phase. A contract cannot create more than 255 output actions.
:::tip
If a contract wants to send more than 255 messages, it can do so by sending a message to itself, which will contain the request of sending the remaining messages. An example of this approach can be seen at https://github.com/ton-blockchain/highload-wallet-contract-v3/blob/main/contracts/highload-wallet-v3.func#L50.
:::
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'l update text tomorrow, don't merge yet, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, setting more than 512 values results in exit code 8. (at least in sandbox). And this exit code corresponds to compute phase, so there are 0 disagreements here. But during contract execution the depth can exceed 512, so I would write that the check is performed at the end of the compute phase, and until then the limitation is standard < 1024.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will be most accurate:
Note that there is a global limit on max cell-depth <1024 during contract execution. However registers c4 and c5 must be <=512 in depth. Going beyond these limits results an error at the end of compute phase. An additional constraint is imposed in the action phase. A contract cannot create more than 255 output actions.
:::tip If a contract wants to send more than 255 messages, it can do so by sending a message to itself, which will contain the request of sending the remaining messages. An example of this approach can be seen at https://github.com/ton-blockchain/highload-wallet-contract-v3/blob/main/contracts/highload-wallet-v3.func#L50. :::
Perfect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to consistent version. Ready to merge.
@Alexey-Ostrovsky @Shvandre, thank you! |
No description provided.