srml-contracts: Avoid unnecessary lookups during call context initialization (#3121)

* srml-contracts: Remove lookups during CallContext initialization.

* Bump node runtime impl_version.
This commit is contained in:
Jim Posen
2019-07-16 22:30:45 +02:00
committed by Sergei Pepyakin
parent 8e09338e27
commit eea9437805
3 changed files with 19 additions and 9 deletions
+2 -2
View File
@@ -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,
};
+7 -3
View File
@@ -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:
+10 -4
View File
@@ -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(),