mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-16 21:21:03 +00:00
Fix weight for inner call with new origin (#7196)
* fix weight for inner call with new origin * fix
This commit is contained in:
committed by
GitHub
parent
a56f90fa9a
commit
6182878933
@@ -237,8 +237,9 @@ decl_module! {
|
||||
/// # </weight>
|
||||
#[weight = (
|
||||
T::WeightInfo::as_multi_threshold_1(call.using_encoded(|c| c.len() as u32))
|
||||
.saturating_add(call.get_dispatch_info().weight
|
||||
),
|
||||
.saturating_add(call.get_dispatch_info().weight)
|
||||
// AccountData for inner call origin accountdata.
|
||||
.saturating_add(T::DbWeight::get().reads_writes(1, 1)),
|
||||
call.get_dispatch_info().class,
|
||||
)]
|
||||
fn as_multi_threshold_1(origin,
|
||||
|
||||
@@ -244,7 +244,9 @@ decl_module! {
|
||||
#[weight = {
|
||||
let di = call.get_dispatch_info();
|
||||
(T::WeightInfo::proxy(T::MaxProxies::get().into())
|
||||
.saturating_add(di.weight),
|
||||
.saturating_add(di.weight)
|
||||
// AccountData for inner call origin accountdata.
|
||||
.saturating_add(T::DbWeight::get().reads_writes(1, 1)),
|
||||
di.class)
|
||||
}]
|
||||
fn proxy(origin,
|
||||
@@ -542,7 +544,9 @@ decl_module! {
|
||||
#[weight = {
|
||||
let di = call.get_dispatch_info();
|
||||
(T::WeightInfo::proxy_announced(T::MaxPending::get(), T::MaxProxies::get().into())
|
||||
.saturating_add(di.weight),
|
||||
.saturating_add(di.weight)
|
||||
// AccountData for inner call origin accountdata.
|
||||
.saturating_add(T::DbWeight::get().reads_writes(1, 1)),
|
||||
di.class)
|
||||
}]
|
||||
fn proxy_announced(origin,
|
||||
|
||||
@@ -352,7 +352,13 @@ decl_module! {
|
||||
/// - The weight of the `call` + 10,000.
|
||||
/// - One storage lookup to check account is recovered by `who`. O(1)
|
||||
/// # </weight>
|
||||
#[weight = (call.get_dispatch_info().weight + 10_000, call.get_dispatch_info().class)]
|
||||
#[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
|
||||
)]
|
||||
fn as_recovered(origin,
|
||||
account: T::AccountId,
|
||||
call: Box<<T as Trait>::Call>
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -95,7 +95,7 @@ use frame_support::{
|
||||
};
|
||||
use frame_support::{
|
||||
weights::{Weight, GetDispatchInfo, Pays},
|
||||
traits::UnfilteredDispatchable,
|
||||
traits::{UnfilteredDispatchable, Get},
|
||||
dispatch::DispatchResultWithPostInfo,
|
||||
};
|
||||
use frame_system::ensure_signed;
|
||||
@@ -197,7 +197,13 @@ 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 = (
|
||||
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
|
||||
)]
|
||||
fn sudo_as(origin,
|
||||
who: <T::Lookup as StaticLookup>::Source,
|
||||
call: Box<<T as Trait>::Call>
|
||||
|
||||
@@ -61,7 +61,7 @@ use sp_core::TypeId;
|
||||
use sp_io::hashing::blake2_256;
|
||||
use frame_support::{decl_module, decl_event, decl_storage, Parameter};
|
||||
use frame_support::{
|
||||
traits::{OriginTrait, UnfilteredDispatchable},
|
||||
traits::{OriginTrait, UnfilteredDispatchable, Get},
|
||||
weights::{Weight, GetDispatchInfo, DispatchClass}, dispatch::PostDispatchInfo,
|
||||
};
|
||||
use frame_system::{ensure_signed, ensure_root};
|
||||
@@ -185,7 +185,9 @@ decl_module! {
|
||||
/// The dispatch origin for this call must be _Signed_.
|
||||
#[weight = (
|
||||
T::WeightInfo::as_derivative()
|
||||
.saturating_add(call.get_dispatch_info().weight),
|
||||
.saturating_add(call.get_dispatch_info().weight)
|
||||
// AccountData for inner call origin accountdata.
|
||||
.saturating_add(T::DbWeight::get().reads_writes(1, 1)),
|
||||
call.get_dispatch_info().class,
|
||||
)]
|
||||
fn as_derivative(origin, index: u16, call: Box<<T as Trait>::Call>) -> DispatchResult {
|
||||
|
||||
Reference in New Issue
Block a user