|
25 | 25 | //! create smart-contracts or send messages to existing smart-contracts.
|
26 | 26 | //!
|
27 | 27 | //! For any actions invoked by the smart-contracts fee must be paid. The fee is paid in gas.
|
28 |
| -//! Gas is bought upfront. Any unused is refunded after the transaction (regardless of the |
29 |
| -//! execution outcome). If all gas is used, then changes made for the specific call or create |
30 |
| -//! are reverted (including balance transfers). |
| 28 | +//! Gas is bought upfront up to the, specified in transaction, limit. Any unused gas is refunded |
| 29 | +//! after the transaction (regardless of the execution outcome). If all gas is used, |
| 30 | +//! then changes made for the specific call or create are reverted (including balance transfers). |
31 | 31 | //!
|
32 | 32 | //! Failures are typically not cascading. That, for example, means that if contract A calls B and B errors
|
33 | 33 | //! somehow, then A can decide if it should proceed or error.
|
34 | 34 | //! TODO: That is not the case now, since call/create externalities traps on any error now.
|
| 35 | +//! |
| 36 | +//! # Interaction with the system |
| 37 | +//! |
| 38 | +//! ## Finalization |
| 39 | +//! |
| 40 | +//! This module requires performing some finalization steps at the end of the block. If not performed |
| 41 | +//! the module will have incorrect behavior. |
| 42 | +//! |
| 43 | +//! Call [`Module::execute`] at the end of the block. The order in relation to |
| 44 | +//! the other module doesn't matter. |
| 45 | +//! |
| 46 | +//! ## Account killing |
| 47 | +//! |
| 48 | +//! When `staking` module determines that account is dead (e.g. account's balance fell below |
| 49 | +//! exsistential deposit) then it reaps the account. That will lead to deletion of the associated |
| 50 | +//! code and storage of the account. |
| 51 | +//! |
| 52 | +//! [`Module::execute`]: struct.Module.html#impl-Executable |
35 | 53 |
|
36 | 54 | #![cfg_attr(not(feature = "std"), no_std)]
|
37 | 55 |
|
@@ -149,7 +167,7 @@ decl_storage! {
|
149 | 167 | GasSpent get(gas_spent): b"con:gas_spent" => default T::Gas;
|
150 | 168 |
|
151 | 169 | // The code associated with an account.
|
152 |
| - pub CodeOf: b"con:cod:" => default map [ T::AccountId => Vec<u8> ]; // TODO Vec<u8> values should be optimised to not do a length prefix. |
| 170 | + CodeOf: b"con:cod:" => default map [ T::AccountId => Vec<u8> ]; // TODO Vec<u8> values should be optimised to not do a length prefix. |
153 | 171 | }
|
154 | 172 |
|
155 | 173 | // TODO: consider storing upper-bound for contract's gas limit in fixed-length runtime
|
@@ -257,7 +275,7 @@ impl<T: Trait> staking::OnAccountKill<T::AccountId> for Module<T> {
|
257 | 275 | }
|
258 | 276 | }
|
259 | 277 |
|
260 |
| -/// Finalisation hook for the smart-contract module. |
| 278 | +/// Finalization hook for the smart-contract module. |
261 | 279 | impl<T: Trait> Executable for Module<T> {
|
262 | 280 | fn execute() {
|
263 | 281 | <GasSpent<T>>::kill();
|
|
0 commit comments