Fix weight for inner call with new origin (#7196)

* fix weight for inner call with new origin

* fix
This commit is contained in:
Guillaume Thiolliere
2020-10-01 10:24:34 +02:00
committed by GitHub
parent a56f90fa9a
commit 6182878933
6 changed files with 39 additions and 10 deletions
+11 -1
View File
@@ -63,7 +63,7 @@ use frame_support::{
traits::{Get, schedule::{self, DispatchTime}, OriginTrait, EnsureOrigin, IsType},
weights::{GetDispatchInfo, Weight},
};
use frame_system::{self as system};
use frame_system::{self as system, ensure_signed};
pub trait WeightInfo {
fn schedule(s: u32, ) -> Weight;
@@ -351,6 +351,16 @@ decl_module! {
*cumulative_weight = cumulative_weight
.saturating_add(s.call.get_dispatch_info().weight);
let origin = <<T as Trait>::Origin as From<T::PalletsOrigin>>::from(
s.origin.clone()
).into();
if ensure_signed(origin).is_ok() {
// AccountData for inner call origin accountdata.
*cumulative_weight = cumulative_weight
.saturating_add(T::DbWeight::get().reads_writes(1, 1));
}
if s.maybe_id.is_some() {
// Remove/Modify Lookup
*cumulative_weight = cumulative_weight.saturating_add(T::DbWeight::get().writes(1));