diff --git a/substrate/srml/contracts/COMPLEXITY.md b/substrate/srml/contracts/COMPLEXITY.md index 55aa8f60b4..1e306038ef 100644 --- a/substrate/srml/contracts/COMPLEXITY.md +++ b/substrate/srml/contracts/COMPLEXITY.md @@ -223,9 +223,9 @@ Finally, all changes are `commit`-ted into the underlying overlay. The complexit - Only for the first invocation of the contract: up to 5 DB reads and one DB write as well as logic executed by `ensure_can_withdraw`, `withdraw`, `make_free_balance_be`. - On top of that for every invocation: Up to 5 DB reads. DB read of the code is of dynamic size. There can also be up to 2 DB writes (if flushed to the storage). Additionally, if the source account removal takes place a DB write will be performed per one storage entry that the account has. -## Create +## Instantiate -This function takes the code of the constructor and input data. Creation of a contract consists of the following steps: +This function takes the code of the constructor and input data. Instantiation of a contract consists of the following steps: 1. Initialization of the execution context. 2. Calling `DetermineContractAddress` hook to determine an address for the contract, @@ -303,7 +303,7 @@ Loading `input_data` should be charged in any case. **complexity**: All complexity comes from loading buffers and executing `call` executive function. The former component is proportional to the sizes of `callee`, `value` and `input_data` buffers. The latter component completely depends on the complexity of `call` executive function, and also dominated by it. -## ext_create +## ext_instantiate This function receives the following arguments: diff --git a/substrate/srml/contracts/src/lib.rs b/substrate/srml/contracts/src/lib.rs index 1a369c1122..615f6c8b99 100644 --- a/substrate/srml/contracts/src/lib.rs +++ b/substrate/srml/contracts/src/lib.rs @@ -580,9 +580,9 @@ decl_module! { .map_err(|e| e.reason) } - /// Creates a new contract from the `codehash` generated by `put_code`, optionally transferring some balance. + /// Instantiates a new contract from the `codehash` generated by `put_code`, optionally transferring some balance. /// - /// Creation is executed as follows: + /// Instantiation is executed as follows: /// /// - The destination address is computed based on the sender and hash of the code. /// - The smart-contract account is created at the computed address. diff --git a/substrate/srml/contracts/src/tests.rs b/substrate/srml/contracts/src/tests.rs index fd016ec67c..fc58a51d95 100644 --- a/substrate/srml/contracts/src/tests.rs +++ b/substrate/srml/contracts/src/tests.rs @@ -1621,7 +1621,7 @@ const CODE_CALLER_CONTRACT: &str = r#" (import "env" "ext_scratch_read" (func $ext_scratch_read (param i32 i32 i32))) (import "env" "ext_balance" (func $ext_balance)) (import "env" "ext_call" (func $ext_call (param i32 i32 i64 i32 i32 i32 i32) (result i32))) - (import "env" "ext_create" (func $ext_create (param i32 i32 i64 i32 i32 i32 i32) (result i32))) + (import "env" "ext_instantiate" (func $ext_instantiate (param i32 i32 i64 i32 i32 i32 i32) (result i32))) (import "env" "ext_println" (func $ext_println (param i32 i32))) (import "env" "memory" (memory 1 1)) @@ -1677,7 +1677,7 @@ const CODE_CALLER_CONTRACT: &str = r#" ;; Fail to deploy the contract since it returns a non-zero exit status. (set_local $exit_code - (call $ext_create + (call $ext_instantiate (i32.const 24) ;; Pointer to the code hash. (i32.const 32) ;; Length of the code hash. (i64.const 0) ;; How much gas to devote for the execution. 0 = all. @@ -1705,7 +1705,7 @@ const CODE_CALLER_CONTRACT: &str = r#" ;; Fail to deploy the contract due to insufficient gas. (set_local $exit_code - (call $ext_create + (call $ext_instantiate (i32.const 24) ;; Pointer to the code hash. (i32.const 32) ;; Length of the code hash. (i64.const 200) ;; How much gas to devote for the execution. @@ -1733,7 +1733,7 @@ const CODE_CALLER_CONTRACT: &str = r#" ;; Deploy the contract successfully. (set_local $exit_code - (call $ext_create + (call $ext_instantiate (i32.const 24) ;; Pointer to the code hash. (i32.const 32) ;; Length of the code hash. (i64.const 0) ;; How much gas to devote for the execution. 0 = all. @@ -2118,7 +2118,7 @@ const CODE_DESTROY_AND_TRANSFER: &str = r#" (import "env" "ext_get_storage" (func $ext_get_storage (param i32) (result i32))) (import "env" "ext_set_storage" (func $ext_set_storage (param i32 i32 i32 i32))) (import "env" "ext_call" (func $ext_call (param i32 i32 i64 i32 i32 i32 i32) (result i32))) - (import "env" "ext_create" (func $ext_create (param i32 i32 i64 i32 i32 i32 i32) (result i32))) + (import "env" "ext_instantiate" (func $ext_instantiate (param i32 i32 i64 i32 i32 i32 i32) (result i32))) (import "env" "memory" (memory 1 1)) (func $assert (param i32) @@ -2149,7 +2149,7 @@ const CODE_DESTROY_AND_TRANSFER: &str = r#" ;; Deploy the contract with the provided code hash. (call $assert (i32.eq - (call $ext_create + (call $ext_instantiate (i32.const 48) ;; Pointer to the code hash. (i32.const 32) ;; Length of the code hash. (i64.const 0) ;; How much gas to devote for the execution. 0 = all. diff --git a/substrate/srml/contracts/src/wasm/mod.rs b/substrate/srml/contracts/src/wasm/mod.rs index 9d48738ed1..68ea126338 100644 --- a/substrate/srml/contracts/src/wasm/mod.rs +++ b/substrate/srml/contracts/src/wasm/mod.rs @@ -478,7 +478,7 @@ mod tests { const CODE_CREATE: &str = r#" (module - ;; ext_create( + ;; ext_instantiate( ;; code_ptr: u32, ;; code_len: u32, ;; gas: u64, @@ -487,11 +487,11 @@ mod tests { ;; input_data_ptr: u32, ;; input_data_len: u32, ;; ) -> u32 - (import "env" "ext_create" (func $ext_create (param i32 i32 i64 i32 i32 i32 i32) (result i32))) + (import "env" "ext_instantiate" (func $ext_instantiate (param i32 i32 i64 i32 i32 i32 i32) (result i32))) (import "env" "memory" (memory 1 1)) (func (export "call") (drop - (call $ext_create + (call $ext_instantiate (i32.const 16) ;; Pointer to `code_hash` (i32.const 32) ;; Length of `code_hash` (i64.const 0) ;; How much gas to devote for the execution. 0 = all. diff --git a/substrate/srml/contracts/src/wasm/runtime.rs b/substrate/srml/contracts/src/wasm/runtime.rs index 573132cf31..beab043ce2 100644 --- a/substrate/srml/contracts/src/wasm/runtime.rs +++ b/substrate/srml/contracts/src/wasm/runtime.rs @@ -29,7 +29,7 @@ use rstd::mem; use codec::{Decode, Encode}; use sr_primitives::traits::{Bounded, SaturatedConversion}; -/// The value returned from ext_call and ext_create contract external functions if the call or +/// The value returned from ext_call and ext_instantiate contract external functions if the call or /// instantiation traps. This value is chosen as if the execution does not trap, the return value /// will always be an 8-bit integer, so 0x0100 is the smallest value that could not be returned. const TRAP_RETURN_CODE: u32 = 0x0100; @@ -456,7 +456,7 @@ define_env!(Env, , // - value_len: length of the value buffer. // - input_data_ptr: a pointer to a buffer to be used as input data to the initializer code. // - input_data_len: length of the input data buffer. - ext_create( + ext_instantiate( ctx, code_hash_ptr: u32, code_hash_len: u32,