diff --git a/substrate/node/runtime/src/lib.rs b/substrate/node/runtime/src/lib.rs index 355eaaab36..8b5a6530d0 100644 --- a/substrate/node/runtime/src/lib.rs +++ b/substrate/node/runtime/src/lib.rs @@ -69,8 +69,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to equal spec_version. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 112, - impl_version: 112, + spec_version: 113, + impl_version: 113, apis: RUNTIME_API_VERSIONS, }; diff --git a/substrate/srml/contracts/COMPLEXITY.md b/substrate/srml/contracts/COMPLEXITY.md index acf1ee7375..6ae7b8fb73 100644 --- a/substrate/srml/contracts/COMPLEXITY.md +++ b/substrate/srml/contracts/COMPLEXITY.md @@ -174,15 +174,19 @@ Assuming marshaled size of a balance value is of the constant size we can neglec ## Initialization -Before a call or create can be performed the execution context must be initialized. This involves -two calls: +Before a call or create can be performed the execution context must be initialized. + +For the first call or instantiation in the handling of an extrinsic, this involves two calls: 1. `>::now()` 2. `>::block_number()` -the complexity of initialization depends on the complexity of these functions. In the current +The complexity of initialization depends on the complexity of these functions. In the current implementation they just involve a DB read. +For subsequent calls and instantiations during contract execution, the initialization requires no +expensive operations. + ## Call This function receives input data for the contract execution. The execution consists of the following steps: diff --git a/substrate/srml/contracts/src/exec.rs b/substrate/srml/contracts/src/exec.rs index 49fb741e29..4a83e606ac 100644 --- a/substrate/srml/contracts/src/exec.rs +++ b/substrate/srml/contracts/src/exec.rs @@ -264,6 +264,8 @@ pub struct ExecutionContext<'a, T: Trait + 'a, V, L> { pub config: &'a Config, pub vm: &'a V, pub loader: &'a L, + pub timestamp: T::Moment, + pub block_number: T::BlockNumber, } impl<'a, T, E, V, L> ExecutionContext<'a, T, V, L> @@ -287,6 +289,8 @@ where config: &cfg, vm: &vm, loader: &loader, + timestamp: >::now(), + block_number: >::block_number(), } } @@ -303,6 +307,8 @@ where config: self.config, vm: self.vm, loader: self.loader, + timestamp: self.timestamp.clone(), + block_number: self.block_number.clone(), } } @@ -368,8 +374,8 @@ where ctx: &mut nested, caller: self.self_account.clone(), value_transferred: value, - timestamp: >::now(), - block_number: >::block_number(), + timestamp: self.timestamp.clone(), + block_number: self.block_number.clone(), }, input_data, empty_output_buf, @@ -439,8 +445,8 @@ where ctx: &mut nested, caller: self.self_account.clone(), value_transferred: endowment, - timestamp: >::now(), - block_number: >::block_number(), + timestamp: self.timestamp.clone(), + block_number: self.block_number.clone(), }, input_data, EmptyOutputBuf::new(),