Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 32b4b52

Browse files
committed
Docs and clean-up.
1 parent a4d1efd commit 32b4b52

File tree

1 file changed

+23
-5
lines changed
  • substrate/runtime/contract/src

1 file changed

+23
-5
lines changed

substrate/runtime/contract/src/lib.rs

+23-5
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,31 @@
2525
//! create smart-contracts or send messages to existing smart-contracts.
2626
//!
2727
//! 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).
3131
//!
3232
//! Failures are typically not cascading. That, for example, means that if contract A calls B and B errors
3333
//! somehow, then A can decide if it should proceed or error.
3434
//! 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
3553
3654
#![cfg_attr(not(feature = "std"), no_std)]
3755

@@ -149,7 +167,7 @@ decl_storage! {
149167
GasSpent get(gas_spent): b"con:gas_spent" => default T::Gas;
150168

151169
// 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.
153171
}
154172

155173
// 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> {
257275
}
258276
}
259277

260-
/// Finalisation hook for the smart-contract module.
278+
/// Finalization hook for the smart-contract module.
261279
impl<T: Trait> Executable for Module<T> {
262280
fn execute() {
263281
<GasSpent<T>>::kill();

0 commit comments

Comments
 (0)