Skip to content
Snippets Groups Projects
Commit 53454077 authored by Alexander Theißen's avatar Alexander Theißen Committed by GitHub
Browse files

Update COMPLEXITY.md for ext_terminate (#5275)

parent 9fbbdfdf
No related branches found
No related tags found
No related merge requests found
......@@ -166,7 +166,8 @@ This function performs the following steps:
In the course of the execution this function can perform up to 2 DB reads to `get_balance` of source and destination accounts. It can also induce up to 2 DB writes via `set_balance` if flushed to the storage.
Moreover, if the source balance goes below `existential_deposit` then the account will be deleted along with all its storage which requires time proportional to the number of storage entries of that account.
Moreover, if the source balance goes below `existential_deposit` then the transfer is denied and
returns with an error.
Assuming marshaled size of a balance value is of the constant size we can neglect its effect on the performance.
......@@ -187,6 +188,23 @@ implementation they just involve a DB read.
For subsequent calls and instantiations during contract execution, the initialization requires no
expensive operations.
## Terminate
This function performs the following steps:
1. Check the calling contract is not already on the callstack by calling `is_live`.
2. `transfer` funds from caller to the beneficiary.
3. Flag the caller contract as deleted in the overlay.
`is_live` does not do any database access nor does it allocate memory. It walks up the call
stack and therefore executes in linear time depending on size of the call stack. Because
the call stack is of a fixed maximum size we consider this operation as constant time.
**complexity**: Database accesses as described in Transfer + Removal of the contract. Currently,
we are using child trie removal which is linear in the amount of stored keys. Upcoming changes
will make the account removal constant time.
## Call
This function receives input data for the contract execution. The execution consists of the following steps:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment