diff --git a/substrate/node/runtime/src/lib.rs b/substrate/node/runtime/src/lib.rs index 355eaaab36c56a702fbf9871f76c833452b943e2..8b5a6530d0aeb647ff1ddc310e09ab2b82894ccf 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 acf1ee737589f566a66544aef0373e5be2ed615e..6ae7b8fb73c284a4d9a91e9c3106f079939a2dbd 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. `<timestamp::Module<T>>::now()` 2. `<system::Module<T>>::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 49fb741e29337c48f04b0aa032e4a7614df51f37..4a83e606ac86b6862e82d127381558495165bea5 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<T>, 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: <timestamp::Module<T>>::now(), + block_number: <system::Module<T>>::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: <timestamp::Module<T>>::now(), - block_number: <system::Module<T>>::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: <timestamp::Module<T>>::now(), - block_number: <system::Module<T>>::block_number(), + timestamp: self.timestamp.clone(), + block_number: self.block_number.clone(), }, input_data, EmptyOutputBuf::new(),