Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Update Benchmarks and Weights for Delayed Proxy #6811

Merged
merged 5 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 27 additions & 23 deletions bin/node/runtime/src/weights/pallet_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,60 +20,64 @@ use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
pub struct WeightInfo;
impl pallet_proxy::WeightInfo for WeightInfo {
fn proxy(p: u32, ) -> Weight {
(27894000 as Weight)
.saturating_add((196000 as Weight).saturating_mul(p as Weight))
(26127000 as Weight)
.saturating_add((214000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
}
fn proxy_announced(p: u32, ) -> Weight {
(78353000 as Weight)
.saturating_add((201000 as Weight).saturating_mul(p as Weight))
fn proxy_announced(a: u32, p: u32, ) -> Weight {
(55405000 as Weight)
.saturating_add((774000 as Weight).saturating_mul(a as Weight))
.saturating_add((209000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(3 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn remove_announcement(p: u32, ) -> Weight {
(60264000 as Weight)
.saturating_add((4000 as Weight).saturating_mul(p as Weight))
fn remove_announcement(a: u32, p: u32, ) -> Weight {
(35879000 as Weight)
.saturating_add((783000 as Weight).saturating_mul(a as Weight))
.saturating_add((20000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn reject_announcement(p: u32, ) -> Weight {
(60141000 as Weight)
.saturating_add((10000 as Weight).saturating_mul(p as Weight))
fn reject_announcement(a: u32, p: u32, ) -> Weight {
(36097000 as Weight)
.saturating_add((780000 as Weight).saturating_mul(a as Weight))
.saturating_add((12000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn announce(p: u32, ) -> Weight {
(74751000 as Weight)
.saturating_add((208000 as Weight).saturating_mul(p as Weight))
fn announce(a: u32, p: u32, ) -> Weight {
(53769000 as Weight)
.saturating_add((675000 as Weight).saturating_mul(a as Weight))
.saturating_add((214000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(3 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn add_proxy(p: u32, ) -> Weight {
(36250000 as Weight)
.saturating_add((223000 as Weight).saturating_mul(p as Weight))
(36082000 as Weight)
.saturating_add((234000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn remove_proxy(p: u32, ) -> Weight {
(32843000 as Weight)
.saturating_add((258000 as Weight).saturating_mul(p as Weight))
(32885000 as Weight)
.saturating_add((267000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn remove_proxies(p: u32, ) -> Weight {
(31834000 as Weight)
.saturating_add((203000 as Weight).saturating_mul(p as Weight))
(31735000 as Weight)
.saturating_add((215000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn anonymous(p: u32, ) -> Weight {
(50947000 as Weight)
.saturating_add((44000 as Weight).saturating_mul(p as Weight))
(50907000 as Weight)
.saturating_add((61000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn kill_anonymous(p: u32, ) -> Weight {
(34213000 as Weight)
(33926000 as Weight)
.saturating_add((208000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
Expand Down
17 changes: 10 additions & 7 deletions frame/proxy/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ benchmarks! {
// ... and "real" is the traditional caller. This is not a typo.
let real: T::AccountId = account("caller", 0, SEED);
let call: <T as Trait>::Call = frame_system::Call::<T>::remark(vec![]).into();
add_announcements::<T>(T::MaxPending::get(), Some(caller.clone()), None)?;
}: _(RawOrigin::Signed(caller), real, Some(T::ProxyType::default()), Box::new(call))
verify {
assert_last_event::<T>(RawEvent::ProxyExecuted(Ok(())).into())
}

proxy_announced {
let a in 0 .. T::MaxPending::get() - 1;
let p in ...;
// In this case the caller is the "target" proxy
let caller: T::AccountId = account("anonymous", 0, SEED);
Expand All @@ -112,13 +112,14 @@ benchmarks! {
real.clone(),
T::CallHasher::hash_of(&call),
)?;
add_announcements::<T>(T::MaxPending::get() - 1, Some(delegate.clone()), None)?;
add_announcements::<T>(a, Some(delegate.clone()), None)?;
}: _(RawOrigin::Signed(caller), delegate, real, Some(T::ProxyType::default()), Box::new(call))
verify {
assert_last_event::<T>(RawEvent::ProxyExecuted(Ok(())).into())
}

remove_announcement {
let a in 0 .. T::MaxPending::get() - 1;
let p in ...;
// In this case the caller is the "target" proxy
let caller: T::AccountId = account("target", p - 1, SEED);
Expand All @@ -131,14 +132,15 @@ benchmarks! {
real.clone(),
T::CallHasher::hash_of(&call),
)?;
add_announcements::<T>(T::MaxPending::get() - 1, Some(caller.clone()), None)?;
add_announcements::<T>(a, Some(caller.clone()), None)?;
}: _(RawOrigin::Signed(caller.clone()), real, T::CallHasher::hash_of(&call))
verify {
let (announcements, _) = Announcements::<T>::get(&caller);
assert_eq!(announcements.len() as u32, T::MaxPending::get() - 1);
assert_eq!(announcements.len() as u32, a);
}

reject_announcement {
let a in 0 .. T::MaxPending::get() - 1;
let p in ...;
// In this case the caller is the "target" proxy
let caller: T::AccountId = account("target", p - 1, SEED);
Expand All @@ -151,21 +153,22 @@ benchmarks! {
real.clone(),
T::CallHasher::hash_of(&call),
)?;
add_announcements::<T>(T::MaxPending::get() - 1, Some(caller.clone()), None)?;
add_announcements::<T>(a, Some(caller.clone()), None)?;
}: _(RawOrigin::Signed(real), caller.clone(), T::CallHasher::hash_of(&call))
verify {
let (announcements, _) = Announcements::<T>::get(&caller);
assert_eq!(announcements.len() as u32, T::MaxPending::get() - 1);
assert_eq!(announcements.len() as u32, a);
}

announce {
let a in 0 .. T::MaxPending::get() - 1;
let p in ...;
// In this case the caller is the "target" proxy
let caller: T::AccountId = account("target", p - 1, SEED);
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
// ... and "real" is the traditional caller. This is not a typo.
let real: T::AccountId = account("caller", 0, SEED);
add_announcements::<T>(T::MaxPending::get() - 1, Some(caller.clone()), None)?;
add_announcements::<T>(a, Some(caller.clone()), None)?;
let call: <T as Trait>::Call = frame_system::Call::<T>::remark(vec![]).into();
let call_hash = T::CallHasher::hash_of(&call);
}: _(RawOrigin::Signed(caller.clone()), real.clone(), call_hash)
Expand Down
50 changes: 27 additions & 23 deletions frame/proxy/src/default_weight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,60 +19,64 @@ use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};

impl crate::WeightInfo for () {
fn proxy(p: u32, ) -> Weight {
(27894000 as Weight)
.saturating_add((196000 as Weight).saturating_mul(p as Weight))
(26127000 as Weight)
.saturating_add((214000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
}
fn proxy_announced(p: u32, ) -> Weight {
(78353000 as Weight)
.saturating_add((201000 as Weight).saturating_mul(p as Weight))
fn proxy_announced(a: u32, p: u32, ) -> Weight {
(55405000 as Weight)
.saturating_add((774000 as Weight).saturating_mul(a as Weight))
.saturating_add((209000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(3 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn remove_announcement(p: u32, ) -> Weight {
(60264000 as Weight)
.saturating_add((4000 as Weight).saturating_mul(p as Weight))
fn remove_announcement(a: u32, p: u32, ) -> Weight {
(35879000 as Weight)
.saturating_add((783000 as Weight).saturating_mul(a as Weight))
.saturating_add((20000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn reject_announcement(p: u32, ) -> Weight {
(60141000 as Weight)
.saturating_add((10000 as Weight).saturating_mul(p as Weight))
fn reject_announcement(a: u32, p: u32, ) -> Weight {
(36097000 as Weight)
.saturating_add((780000 as Weight).saturating_mul(a as Weight))
.saturating_add((12000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn announce(p: u32, ) -> Weight {
(74751000 as Weight)
.saturating_add((208000 as Weight).saturating_mul(p as Weight))
fn announce(a: u32, p: u32, ) -> Weight {
(53769000 as Weight)
.saturating_add((675000 as Weight).saturating_mul(a as Weight))
.saturating_add((214000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(3 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn add_proxy(p: u32, ) -> Weight {
(36250000 as Weight)
.saturating_add((223000 as Weight).saturating_mul(p as Weight))
(36082000 as Weight)
.saturating_add((234000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn remove_proxy(p: u32, ) -> Weight {
(32843000 as Weight)
.saturating_add((258000 as Weight).saturating_mul(p as Weight))
(32885000 as Weight)
.saturating_add((267000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn remove_proxies(p: u32, ) -> Weight {
(31834000 as Weight)
.saturating_add((203000 as Weight).saturating_mul(p as Weight))
(31735000 as Weight)
.saturating_add((215000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn anonymous(p: u32, ) -> Weight {
(50947000 as Weight)
.saturating_add((44000 as Weight).saturating_mul(p as Weight))
(50907000 as Weight)
.saturating_add((61000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn kill_anonymous(p: u32, ) -> Weight {
(34213000 as Weight)
(33926000 as Weight)
.saturating_add((208000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
Expand Down
41 changes: 27 additions & 14 deletions frame/proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ mod default_weight;
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;

pub trait WeightInfo {
fn proxy_announced(p: u32, ) -> Weight;
fn remove_announcement(p: u32, ) -> Weight;
fn reject_announcement(p: u32, ) -> Weight;
fn announce(p: u32, ) -> Weight;
fn proxy_announced(a: u32, p: u32, ) -> Weight;
fn remove_announcement(a: u32, p: u32, ) -> Weight;
fn reject_announcement(a: u32, p: u32, ) -> Weight;
fn announce(a: u32, p: u32, ) -> Weight;
fn proxy(p: u32, ) -> Weight;
fn add_proxy(p: u32, ) -> Weight;
fn remove_proxy(p: u32, ) -> Weight;
Expand Down Expand Up @@ -425,9 +425,7 @@ decl_module! {
/// account whose `anonymous` call has corresponding parameters.
///
/// # <weight>
/// P is the number of proxies the user has
/// - Base weight: 15.65 + .137 * P µs
/// - DB weight: 1 storage read and write.
/// Weight is a function of the number of proxies the user has (P).
/// # </weight>
#[weight = T::WeightInfo::kill_anonymous(T::MaxProxies::get().into())]
fn kill_anonymous(origin,
Expand Down Expand Up @@ -464,9 +462,11 @@ decl_module! {
/// - `call_hash`: The hash of the call to be made by the `real` account.
///
/// # <weight>
/// Weight is a function of the number of proxies the user has (P).
/// Weight is a function of:
/// - A: the number of announcements made.
/// - P: the number of proxies the user has.
/// # </weight>
#[weight = T::WeightInfo::announce(T::MaxProxies::get().into())]
#[weight = T::WeightInfo::announce(T::MaxPending::get(), T::MaxProxies::get().into())]
fn announce(origin, real: T::AccountId, call_hash: CallHashOf<T>) {
let who = ensure_signed(origin)?;
Proxies::<T>::get(&real).0.into_iter()
Expand Down Expand Up @@ -504,7 +504,13 @@ decl_module! {
/// Parameters:
/// - `real`: The account that the proxy will make a call on behalf of.
/// - `call_hash`: The hash of the call to be made by the `real` account.
#[weight = T::WeightInfo::remove_announcement(T::MaxProxies::get().into())]
///
/// # <weight>
/// Weight is a function of:
/// - A: the number of announcements made.
/// - P: the number of proxies the user has.
/// # </weight>
#[weight = T::WeightInfo::remove_announcement(T::MaxPending::get(), T::MaxProxies::get().into())]
fn remove_announcement(origin, real: T::AccountId, call_hash: CallHashOf<T>) {
let who = ensure_signed(origin)?;
Self::edit_announcements(&who, |ann| ann.real != real || ann.call_hash != call_hash)?;
Expand All @@ -520,13 +526,18 @@ decl_module! {
/// Parameters:
/// - `delegate`: The account that previously announced the call.
/// - `call_hash`: The hash of the call to be made.
#[weight = T::WeightInfo::reject_announcement(T::MaxProxies::get().into())]
///
/// # <weight>
/// Weight is a function of:
/// - A: the number of announcements made.
/// - P: the number of proxies the user has.
/// # </weight>
#[weight = T::WeightInfo::reject_announcement(T::MaxPending::get(), T::MaxProxies::get().into())]
fn reject_announcement(origin, delegate: T::AccountId, call_hash: CallHashOf<T>) {
let who = ensure_signed(origin)?;
Self::edit_announcements(&delegate, |ann| ann.real != who || ann.call_hash != call_hash)?;
}


/// Dispatch the given `call` from an account that the sender is authorised for through
/// `add_proxy`.
///
Expand All @@ -540,11 +551,13 @@ decl_module! {
/// - `call`: The call to be made by the `real` account.
///
/// # <weight>
/// Weight is a function of the number of proxies the user has (P).
/// Weight is a function of:
/// - A: the number of announcements made.
/// - P: the number of proxies the user has.
/// # </weight>
#[weight = {
let di = call.get_dispatch_info();
(T::WeightInfo::proxy_announced(T::MaxProxies::get().into())
(T::WeightInfo::proxy_announced(T::MaxPending::get(), T::MaxProxies::get().into())
.saturating_add(di.weight),
di.class)
}]
Expand Down