Store dispatch info of calls locally in weight calculation (#7849)

* utility

* sudo

* more

* recovery

* better formatting
This commit is contained in:
Shawn Tabrizi
2021-01-08 12:04:46 -04:00
committed by GitHub
parent a4032b1dfb
commit 1d73b011a9
4 changed files with 66 additions and 47 deletions
+14 -8
View File
@@ -130,7 +130,10 @@ decl_module! {
/// - One DB write (event).
/// - Weight of derivative `call` execution + 10,000.
/// # </weight>
#[weight = (call.get_dispatch_info().weight + 10_000, call.get_dispatch_info().class)]
#[weight = {
let dispatch_info = call.get_dispatch_info();
(dispatch_info.weight.saturating_add(10_000), dispatch_info.class)
}]
fn sudo(origin, call: Box<<T as Config>::Call>) -> DispatchResultWithPostInfo {
// This is a public call, so we ensure that the origin is some signed account.
let sender = ensure_signed(origin)?;
@@ -197,13 +200,16 @@ decl_module! {
/// - One DB write (event).
/// - Weight of derivative `call` execution + 10,000.
/// # </weight>
#[weight = (
call.get_dispatch_info().weight
.saturating_add(10_000)
// AccountData for inner call origin accountdata.
.saturating_add(T::DbWeight::get().reads_writes(1, 1)),
call.get_dispatch_info().class
)]
#[weight = {
let dispatch_info = call.get_dispatch_info();
(
dispatch_info.weight
.saturating_add(10_000)
// AccountData for inner call origin accountdata.
.saturating_add(T::DbWeight::get().reads_writes(1, 1)),
dispatch_info.class,
)
}]
fn sudo_as(origin,
who: <T::Lookup as StaticLookup>::Source,
call: Box<<T as Config>::Call>