mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 03:31:10 +00:00
Bound uses of Call (#11649)
* Introduce preimages module in traits * Multisize Preimages * Len not actually necessary * Tweaks to the preimage API * Fixes * Get Scheduler building with new API * Scheduler tests pass * Bounded Scheduler 🎉 * Use Agenda holes and introduce IncompleteSince to avoid need to reschedule * Tests pass with new weight system * New benchmarks * Add missing file * Drop preimage when permenantly overeight * Drop preimage when permenantly overeight * Referenda uses latest preimage API * Testing ok * Adding tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add preimage migration Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Docs * Remove dbg * Refactor Democracy * Refactor Democracy * Add final MEL * Remove silly maps * Fixes * Minor refactor * Formatting * Fixes * Fixes * Fixes * Update frame/preimage/src/lib.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Add migrations to Democracy * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Resolve conflicts Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Revert "Resolve conflicts" This reverts commit 734d66d69e54553471ffa54fa52e3e304dc8f106. * Undo wrong resolves... Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Make compile Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * massage clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * clippy annoyance Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * clippy annoyance Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * add missing file * Test <Preimage as QueryPreimage> Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Clippy harassment Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fixup tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove old stuff Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test <Scheduler as Anon> trait functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update pallet-ui tests Why is this needed? Should not be the case unless master is broken... Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More scheduler trait test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Apply review suggestion Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Beauty fixes Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add Scheduler test migration_v3_to_v4_works Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Merge fixup Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Keep referenda benchmarks instantiatable Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update weights Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use new scheduler weight functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use new democracy weight functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use weight compare functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update pallet-ui tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More renaming… Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More renaming… Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add comment Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Implement OnRuntimeUpgrade for scheduler::v3_to_v4 migration Put the migration into a proper `MigrateToV4` struct and implement the OnRuntimeUpgrade hooks for it. Also move the test to use that instead. This should make it easier for adding it to Polkadot. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Handle undecodable Agendas Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove trash Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use new OnRuntimeUpgrade functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fix test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix BoundedSlice::truncate_from Co-authored-by: jakoblell Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix pre_upgrade hook return values Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add more error logging Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Find too large preimages in the pre_upgrade hook Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test that too large Calls in agendas are ignored Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use new OnRuntimeUpgrade hooks Why did the CI not catch this?! Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * works fine - just more logs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix staking migration Causing issues on Kusama... Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix UI tests No idea why this is needed. This is actually undoing an earlier change. Maybe the CI has different rustc versions!? Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove multisig's Calls (#12072) * Remove multisig's Calls * Multisig: Fix tests and re-introduce reserve logic (#12241) * Fix tests and re-introduce reserve logic * fix benches * add todo * remove irrelevant bench * [Feature] Add a migration that drains and refunds stored calls (#12313) * [Feature] Add a migration that drains and refunds stored calls * migration fixes * fixes * address review comments * consume the whole block weight * fix assertions * license header * fix interface Co-authored-by: parity-processbot <> Co-authored-by: parity-processbot <> Co-authored-by: Roman Useinov <roman.useinov@gmail.com> * Fix test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix multisig benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * ".git/.scripts/bench-bot.sh" pallet dev pallet_democracy * ".git/.scripts/bench-bot.sh" pallet dev pallet_scheduler * ".git/.scripts/bench-bot.sh" pallet dev pallet_preimage Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: parity-processbot <> Co-authored-by: Roman Useinov <roman.useinov@gmail.com>
This commit is contained in:
@@ -18,201 +18,219 @@
|
||||
//! Scheduler pallet benchmarking.
|
||||
|
||||
use super::*;
|
||||
use frame_benchmarking::benchmarks;
|
||||
use frame_benchmarking::{account, benchmarks};
|
||||
use frame_support::{
|
||||
ensure,
|
||||
traits::{OnInitialize, PreimageProvider, PreimageRecipient},
|
||||
traits::{schedule::Priority, BoundedInline},
|
||||
};
|
||||
use sp_runtime::traits::Hash;
|
||||
use frame_system::RawOrigin;
|
||||
use sp_std::{prelude::*, vec};
|
||||
|
||||
use crate::Pallet as Scheduler;
|
||||
use frame_system::Pallet as System;
|
||||
use frame_system::Call as SystemCall;
|
||||
|
||||
const SEED: u32 = 0;
|
||||
|
||||
const BLOCK_NUMBER: u32 = 2;
|
||||
|
||||
type SystemOrigin<T> = <T as frame_system::Config>::RuntimeOrigin;
|
||||
|
||||
/// Add `n` named items to the schedule.
|
||||
/// Add `n` items to the schedule.
|
||||
///
|
||||
/// For `resolved`:
|
||||
/// - `
|
||||
/// - `None`: aborted (hash without preimage)
|
||||
/// - `Some(true)`: hash resolves into call if possible, plain call otherwise
|
||||
/// - `Some(false)`: plain call
|
||||
fn fill_schedule<T: Config>(
|
||||
when: T::BlockNumber,
|
||||
n: u32,
|
||||
periodic: bool,
|
||||
named: bool,
|
||||
resolved: Option<bool>,
|
||||
) -> Result<(), &'static str> {
|
||||
fn fill_schedule<T: Config>(when: T::BlockNumber, n: u32) -> Result<(), &'static str> {
|
||||
let t = DispatchTime::At(when);
|
||||
let origin: <T as Config>::PalletsOrigin = frame_system::RawOrigin::Root.into();
|
||||
for i in 0..n {
|
||||
// Named schedule is strictly heavier than anonymous
|
||||
let (call, hash) = call_and_hash::<T>(i);
|
||||
let call_or_hash = match resolved {
|
||||
Some(true) => {
|
||||
T::PreimageProvider::note_preimage(call.encode().try_into().unwrap());
|
||||
if T::PreimageProvider::have_preimage(&hash) {
|
||||
CallOrHashOf::<T>::Hash(hash)
|
||||
} else {
|
||||
call.into()
|
||||
}
|
||||
},
|
||||
Some(false) => call.into(),
|
||||
None => CallOrHashOf::<T>::Hash(hash),
|
||||
};
|
||||
let period = match periodic {
|
||||
true => Some(((i + 100).into(), 100)),
|
||||
false => None,
|
||||
};
|
||||
let t = DispatchTime::At(when);
|
||||
let origin = frame_system::RawOrigin::Root.into();
|
||||
if named {
|
||||
Scheduler::<T>::do_schedule_named(i.encode(), t, period, 0, origin, call_or_hash)?;
|
||||
} else {
|
||||
Scheduler::<T>::do_schedule(t, period, 0, origin, call_or_hash)?;
|
||||
}
|
||||
let call = make_call::<T>(None);
|
||||
let period = Some(((i + 100).into(), 100));
|
||||
let name = u32_to_name(i);
|
||||
Scheduler::<T>::do_schedule_named(name, t, period, 0, origin.clone(), call)?;
|
||||
}
|
||||
ensure!(Agenda::<T>::get(when).len() == n as usize, "didn't fill schedule");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn call_and_hash<T: Config>(i: u32) -> (<T as Config>::RuntimeCall, T::Hash) {
|
||||
// Essentially a no-op call.
|
||||
let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark: i.encode() }.into();
|
||||
let hash = T::Hashing::hash_of(&call);
|
||||
(call, hash)
|
||||
fn u32_to_name(i: u32) -> TaskName {
|
||||
i.using_encoded(blake2_256)
|
||||
}
|
||||
|
||||
fn make_task<T: Config>(
|
||||
periodic: bool,
|
||||
named: bool,
|
||||
signed: bool,
|
||||
maybe_lookup_len: Option<u32>,
|
||||
priority: Priority,
|
||||
) -> ScheduledOf<T> {
|
||||
let call = make_call::<T>(maybe_lookup_len);
|
||||
let maybe_periodic = match periodic {
|
||||
true => Some((100u32.into(), 100)),
|
||||
false => None,
|
||||
};
|
||||
let maybe_id = match named {
|
||||
true => Some(u32_to_name(0)),
|
||||
false => None,
|
||||
};
|
||||
let origin = make_origin::<T>(signed);
|
||||
Scheduled { maybe_id, priority, call, maybe_periodic, origin, _phantom: PhantomData }
|
||||
}
|
||||
|
||||
fn bounded<T: Config>(len: u32) -> Option<Bounded<<T as Config>::RuntimeCall>> {
|
||||
let call =
|
||||
<<T as Config>::RuntimeCall>::from(SystemCall::remark { remark: vec![0; len as usize] });
|
||||
T::Preimages::bound(call).ok()
|
||||
}
|
||||
|
||||
fn make_call<T: Config>(maybe_lookup_len: Option<u32>) -> Bounded<<T as Config>::RuntimeCall> {
|
||||
let bound = BoundedInline::bound() as u32;
|
||||
let mut len = match maybe_lookup_len {
|
||||
Some(len) => len.min(T::Preimages::MAX_LENGTH as u32 - 2).max(bound) - 3,
|
||||
None => bound.saturating_sub(4),
|
||||
};
|
||||
|
||||
loop {
|
||||
let c = match bounded::<T>(len) {
|
||||
Some(x) => x,
|
||||
None => {
|
||||
len -= 1;
|
||||
continue
|
||||
},
|
||||
};
|
||||
if c.lookup_needed() == maybe_lookup_len.is_some() {
|
||||
break c
|
||||
}
|
||||
if maybe_lookup_len.is_some() {
|
||||
len += 1;
|
||||
} else {
|
||||
if len > 0 {
|
||||
len -= 1;
|
||||
} else {
|
||||
break c
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn make_origin<T: Config>(signed: bool) -> <T as Config>::PalletsOrigin {
|
||||
match signed {
|
||||
true => frame_system::RawOrigin::Signed(account("origin", 0, SEED)).into(),
|
||||
false => frame_system::RawOrigin::Root.into(),
|
||||
}
|
||||
}
|
||||
|
||||
fn dummy_counter() -> WeightCounter {
|
||||
WeightCounter { used: Weight::zero(), limit: Weight::MAX }
|
||||
}
|
||||
|
||||
benchmarks! {
|
||||
on_initialize_periodic_named_resolved {
|
||||
let s in 1 .. T::MaxScheduledPerBlock::get();
|
||||
let when = BLOCK_NUMBER.into();
|
||||
fill_schedule::<T>(when, s, true, true, Some(true))?;
|
||||
}: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }
|
||||
verify {
|
||||
assert_eq!(System::<T>::event_count(), s * 2);
|
||||
for i in 0..s {
|
||||
assert_eq!(Agenda::<T>::get(when + (i + 100).into()).len(), 1 as usize);
|
||||
}
|
||||
// `service_agendas` when no work is done.
|
||||
service_agendas_base {
|
||||
let now = T::BlockNumber::from(BLOCK_NUMBER);
|
||||
IncompleteSince::<T>::put(now - One::one());
|
||||
}: {
|
||||
Scheduler::<T>::service_agendas(&mut dummy_counter(), now, 0);
|
||||
} verify {
|
||||
assert_eq!(IncompleteSince::<T>::get(), Some(now - One::one()));
|
||||
}
|
||||
|
||||
on_initialize_named_resolved {
|
||||
let s in 1 .. T::MaxScheduledPerBlock::get();
|
||||
let when = BLOCK_NUMBER.into();
|
||||
fill_schedule::<T>(when, s, false, true, Some(true))?;
|
||||
}: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }
|
||||
verify {
|
||||
assert_eq!(System::<T>::event_count(), s * 2);
|
||||
assert!(Agenda::<T>::iter().count() == 0);
|
||||
// `service_agenda` when no work is done.
|
||||
service_agenda_base {
|
||||
let now = BLOCK_NUMBER.into();
|
||||
let s in 0 .. T::MaxScheduledPerBlock::get();
|
||||
fill_schedule::<T>(now, s)?;
|
||||
let mut executed = 0;
|
||||
}: {
|
||||
Scheduler::<T>::service_agenda(&mut dummy_counter(), &mut executed, now, now, 0);
|
||||
} verify {
|
||||
assert_eq!(executed, 0);
|
||||
}
|
||||
|
||||
on_initialize_periodic_resolved {
|
||||
let s in 1 .. T::MaxScheduledPerBlock::get();
|
||||
let when = BLOCK_NUMBER.into();
|
||||
fill_schedule::<T>(when, s, true, false, Some(true))?;
|
||||
}: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }
|
||||
verify {
|
||||
assert_eq!(System::<T>::event_count(), s * 2);
|
||||
for i in 0..s {
|
||||
assert_eq!(Agenda::<T>::get(when + (i + 100).into()).len(), 1 as usize);
|
||||
}
|
||||
// `service_task` when the task is a non-periodic, non-named, non-fetched call which is not
|
||||
// dispatched (e.g. due to being overweight).
|
||||
service_task_base {
|
||||
let now = BLOCK_NUMBER.into();
|
||||
let task = make_task::<T>(false, false, false, None, 0);
|
||||
// prevent any tasks from actually being executed as we only want the surrounding weight.
|
||||
let mut counter = WeightCounter { used: Weight::zero(), limit: Weight::zero() };
|
||||
}: {
|
||||
let result = Scheduler::<T>::service_task(&mut counter, now, now, 0, true, task);
|
||||
} verify {
|
||||
//assert_eq!(result, Ok(()));
|
||||
}
|
||||
|
||||
on_initialize_resolved {
|
||||
let s in 1 .. T::MaxScheduledPerBlock::get();
|
||||
let when = BLOCK_NUMBER.into();
|
||||
fill_schedule::<T>(when, s, false, false, Some(true))?;
|
||||
}: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }
|
||||
verify {
|
||||
assert_eq!(System::<T>::event_count(), s * 2);
|
||||
assert!(Agenda::<T>::iter().count() == 0);
|
||||
// `service_task` when the task is a non-periodic, non-named, fetched call (with a known
|
||||
// preimage length) and which is not dispatched (e.g. due to being overweight).
|
||||
service_task_fetched {
|
||||
let s in (BoundedInline::bound() as u32) .. (T::Preimages::MAX_LENGTH as u32);
|
||||
let now = BLOCK_NUMBER.into();
|
||||
let task = make_task::<T>(false, false, false, Some(s), 0);
|
||||
// prevent any tasks from actually being executed as we only want the surrounding weight.
|
||||
let mut counter = WeightCounter { used: Weight::zero(), limit: Weight::zero() };
|
||||
}: {
|
||||
let result = Scheduler::<T>::service_task(&mut counter, now, now, 0, true, task);
|
||||
} verify {
|
||||
}
|
||||
|
||||
on_initialize_named_aborted {
|
||||
let s in 1 .. T::MaxScheduledPerBlock::get();
|
||||
let when = BLOCK_NUMBER.into();
|
||||
fill_schedule::<T>(when, s, false, true, None)?;
|
||||
}: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }
|
||||
verify {
|
||||
assert_eq!(System::<T>::event_count(), 0);
|
||||
if let Some(delay) = T::NoPreimagePostponement::get() {
|
||||
assert_eq!(Agenda::<T>::get(when + delay).len(), s as usize);
|
||||
} else {
|
||||
assert!(Agenda::<T>::iter().count() == 0);
|
||||
}
|
||||
// `service_task` when the task is a non-periodic, named, non-fetched call which is not
|
||||
// dispatched (e.g. due to being overweight).
|
||||
service_task_named {
|
||||
let now = BLOCK_NUMBER.into();
|
||||
let task = make_task::<T>(false, true, false, None, 0);
|
||||
// prevent any tasks from actually being executed as we only want the surrounding weight.
|
||||
let mut counter = WeightCounter { used: Weight::zero(), limit: Weight::zero() };
|
||||
}: {
|
||||
let result = Scheduler::<T>::service_task(&mut counter, now, now, 0, true, task);
|
||||
} verify {
|
||||
}
|
||||
|
||||
on_initialize_aborted {
|
||||
let s in 1 .. T::MaxScheduledPerBlock::get();
|
||||
let when = BLOCK_NUMBER.into();
|
||||
fill_schedule::<T>(when, s, false, false, None)?;
|
||||
}: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }
|
||||
verify {
|
||||
assert_eq!(System::<T>::event_count(), 0);
|
||||
if let Some(delay) = T::NoPreimagePostponement::get() {
|
||||
assert_eq!(Agenda::<T>::get(when + delay).len(), s as usize);
|
||||
} else {
|
||||
assert!(Agenda::<T>::iter().count() == 0);
|
||||
}
|
||||
// `service_task` when the task is a periodic, non-named, non-fetched call which is not
|
||||
// dispatched (e.g. due to being overweight).
|
||||
service_task_periodic {
|
||||
let now = BLOCK_NUMBER.into();
|
||||
let task = make_task::<T>(true, false, false, None, 0);
|
||||
// prevent any tasks from actually being executed as we only want the surrounding weight.
|
||||
let mut counter = WeightCounter { used: Weight::zero(), limit: Weight::zero() };
|
||||
}: {
|
||||
let result = Scheduler::<T>::service_task(&mut counter, now, now, 0, true, task);
|
||||
} verify {
|
||||
}
|
||||
|
||||
on_initialize_periodic_named {
|
||||
let s in 1 .. T::MaxScheduledPerBlock::get();
|
||||
let when = BLOCK_NUMBER.into();
|
||||
fill_schedule::<T>(when, s, true, true, Some(false))?;
|
||||
}: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }
|
||||
// `execute_dispatch` when the origin is `Signed`, not counting the dispatable's weight.
|
||||
execute_dispatch_signed {
|
||||
let mut counter = WeightCounter { used: Weight::zero(), limit: Weight::MAX };
|
||||
let origin = make_origin::<T>(true);
|
||||
let call = T::Preimages::realize(&make_call::<T>(None)).unwrap().0;
|
||||
}: {
|
||||
assert!(Scheduler::<T>::execute_dispatch(&mut counter, origin, call).is_ok());
|
||||
}
|
||||
verify {
|
||||
assert_eq!(System::<T>::event_count(), s);
|
||||
for i in 0..s {
|
||||
assert_eq!(Agenda::<T>::get(when + (i + 100).into()).len(), 1 as usize);
|
||||
}
|
||||
}
|
||||
|
||||
on_initialize_periodic {
|
||||
let s in 1 .. T::MaxScheduledPerBlock::get();
|
||||
let when = BLOCK_NUMBER.into();
|
||||
fill_schedule::<T>(when, s, true, false, Some(false))?;
|
||||
}: { Scheduler::<T>::on_initialize(when); }
|
||||
verify {
|
||||
assert_eq!(System::<T>::event_count(), s);
|
||||
for i in 0..s {
|
||||
assert_eq!(Agenda::<T>::get(when + (i + 100).into()).len(), 1 as usize);
|
||||
}
|
||||
// `execute_dispatch` when the origin is not `Signed`, not counting the dispatable's weight.
|
||||
execute_dispatch_unsigned {
|
||||
let mut counter = WeightCounter { used: Weight::zero(), limit: Weight::MAX };
|
||||
let origin = make_origin::<T>(false);
|
||||
let call = T::Preimages::realize(&make_call::<T>(None)).unwrap().0;
|
||||
}: {
|
||||
assert!(Scheduler::<T>::execute_dispatch(&mut counter, origin, call).is_ok());
|
||||
}
|
||||
|
||||
on_initialize_named {
|
||||
let s in 1 .. T::MaxScheduledPerBlock::get();
|
||||
let when = BLOCK_NUMBER.into();
|
||||
fill_schedule::<T>(when, s, false, true, Some(false))?;
|
||||
}: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }
|
||||
verify {
|
||||
assert_eq!(System::<T>::event_count(), s);
|
||||
assert!(Agenda::<T>::iter().count() == 0);
|
||||
}
|
||||
|
||||
on_initialize {
|
||||
let s in 1 .. T::MaxScheduledPerBlock::get();
|
||||
let when = BLOCK_NUMBER.into();
|
||||
fill_schedule::<T>(when, s, false, false, Some(false))?;
|
||||
}: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }
|
||||
verify {
|
||||
assert_eq!(System::<T>::event_count(), s);
|
||||
assert!(Agenda::<T>::iter().count() == 0);
|
||||
}
|
||||
|
||||
schedule {
|
||||
let s in 0 .. T::MaxScheduledPerBlock::get();
|
||||
let s in 0 .. (T::MaxScheduledPerBlock::get() - 1);
|
||||
let when = BLOCK_NUMBER.into();
|
||||
let periodic = Some((T::BlockNumber::one(), 100));
|
||||
let priority = 0;
|
||||
// Essentially a no-op call.
|
||||
let inner_call = frame_system::Call::set_storage { items: vec![] }.into();
|
||||
let call = Box::new(CallOrHashOf::<T>::Value(inner_call));
|
||||
let call = Box::new(SystemCall::set_storage { items: vec![] }.into());
|
||||
|
||||
fill_schedule::<T>(when, s, true, true, Some(false))?;
|
||||
let schedule_origin = T::ScheduleOrigin::successful_origin();
|
||||
}: _<SystemOrigin<T>>(schedule_origin, when, periodic, priority, call)
|
||||
fill_schedule::<T>(when, s)?;
|
||||
}: _(RawOrigin::Root, when, periodic, priority, call)
|
||||
verify {
|
||||
ensure!(
|
||||
Agenda::<T>::get(when).len() == (s + 1) as usize,
|
||||
@@ -224,13 +242,13 @@ benchmarks! {
|
||||
let s in 1 .. T::MaxScheduledPerBlock::get();
|
||||
let when = BLOCK_NUMBER.into();
|
||||
|
||||
fill_schedule::<T>(when, s, true, true, Some(false))?;
|
||||
fill_schedule::<T>(when, s)?;
|
||||
assert_eq!(Agenda::<T>::get(when).len(), s as usize);
|
||||
let schedule_origin = T::ScheduleOrigin::successful_origin();
|
||||
}: _<SystemOrigin<T>>(schedule_origin, when, 0)
|
||||
verify {
|
||||
ensure!(
|
||||
Lookup::<T>::get(0.encode()).is_none(),
|
||||
Lookup::<T>::get(u32_to_name(0)).is_none(),
|
||||
"didn't remove from lookup"
|
||||
);
|
||||
// Removed schedule is NONE
|
||||
@@ -241,18 +259,16 @@ benchmarks! {
|
||||
}
|
||||
|
||||
schedule_named {
|
||||
let s in 0 .. T::MaxScheduledPerBlock::get();
|
||||
let id = s.encode();
|
||||
let s in 0 .. (T::MaxScheduledPerBlock::get() - 1);
|
||||
let id = u32_to_name(s);
|
||||
let when = BLOCK_NUMBER.into();
|
||||
let periodic = Some((T::BlockNumber::one(), 100));
|
||||
let priority = 0;
|
||||
// Essentially a no-op call.
|
||||
let inner_call = frame_system::Call::set_storage { items: vec![] }.into();
|
||||
let call = Box::new(CallOrHashOf::<T>::Value(inner_call));
|
||||
let call = Box::new(SystemCall::set_storage { items: vec![] }.into());
|
||||
|
||||
fill_schedule::<T>(when, s, true, true, Some(false))?;
|
||||
let schedule_origin = T::ScheduleOrigin::successful_origin();
|
||||
}: _<SystemOrigin<T>>(schedule_origin, id, when, periodic, priority, call)
|
||||
fill_schedule::<T>(when, s)?;
|
||||
}: _(RawOrigin::Root, id, when, periodic, priority, call)
|
||||
verify {
|
||||
ensure!(
|
||||
Agenda::<T>::get(when).len() == (s + 1) as usize,
|
||||
@@ -264,12 +280,11 @@ benchmarks! {
|
||||
let s in 1 .. T::MaxScheduledPerBlock::get();
|
||||
let when = BLOCK_NUMBER.into();
|
||||
|
||||
fill_schedule::<T>(when, s, true, true, Some(false))?;
|
||||
let schedule_origin = T::ScheduleOrigin::successful_origin();
|
||||
}: _<SystemOrigin<T>>(schedule_origin, 0.encode())
|
||||
fill_schedule::<T>(when, s)?;
|
||||
}: _(RawOrigin::Root, u32_to_name(0))
|
||||
verify {
|
||||
ensure!(
|
||||
Lookup::<T>::get(0.encode()).is_none(),
|
||||
Lookup::<T>::get(u32_to_name(0)).is_none(),
|
||||
"didn't remove from lookup"
|
||||
);
|
||||
// Removed schedule is NONE
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,402 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) 2017-2022 Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Migrations for the scheduler pallet.
|
||||
|
||||
use super::*;
|
||||
use frame_support::traits::OnRuntimeUpgrade;
|
||||
|
||||
/// The log target.
|
||||
const TARGET: &'static str = "runtime::scheduler::migration";
|
||||
|
||||
pub mod v1 {
|
||||
use super::*;
|
||||
use frame_support::pallet_prelude::*;
|
||||
|
||||
#[frame_support::storage_alias]
|
||||
pub(crate) type Agenda<T: Config> = StorageMap<
|
||||
Pallet<T>,
|
||||
Twox64Concat,
|
||||
<T as frame_system::Config>::BlockNumber,
|
||||
Vec<
|
||||
Option<
|
||||
ScheduledV1<<T as Config>::RuntimeCall, <T as frame_system::Config>::BlockNumber>,
|
||||
>,
|
||||
>,
|
||||
ValueQuery,
|
||||
>;
|
||||
|
||||
#[frame_support::storage_alias]
|
||||
pub(crate) type Lookup<T: Config> = StorageMap<
|
||||
Pallet<T>,
|
||||
Twox64Concat,
|
||||
Vec<u8>,
|
||||
TaskAddress<<T as frame_system::Config>::BlockNumber>,
|
||||
>;
|
||||
}
|
||||
|
||||
pub mod v2 {
|
||||
use super::*;
|
||||
use frame_support::pallet_prelude::*;
|
||||
|
||||
#[frame_support::storage_alias]
|
||||
pub(crate) type Agenda<T: Config> = StorageMap<
|
||||
Pallet<T>,
|
||||
Twox64Concat,
|
||||
<T as frame_system::Config>::BlockNumber,
|
||||
Vec<Option<ScheduledV2Of<T>>>,
|
||||
ValueQuery,
|
||||
>;
|
||||
|
||||
#[frame_support::storage_alias]
|
||||
pub(crate) type Lookup<T: Config> = StorageMap<
|
||||
Pallet<T>,
|
||||
Twox64Concat,
|
||||
Vec<u8>,
|
||||
TaskAddress<<T as frame_system::Config>::BlockNumber>,
|
||||
>;
|
||||
}
|
||||
|
||||
pub mod v3 {
|
||||
use super::*;
|
||||
use frame_support::pallet_prelude::*;
|
||||
|
||||
#[frame_support::storage_alias]
|
||||
pub(crate) type Agenda<T: Config> = StorageMap<
|
||||
Pallet<T>,
|
||||
Twox64Concat,
|
||||
<T as frame_system::Config>::BlockNumber,
|
||||
Vec<Option<ScheduledV3Of<T>>>,
|
||||
ValueQuery,
|
||||
>;
|
||||
|
||||
#[frame_support::storage_alias]
|
||||
pub(crate) type Lookup<T: Config> = StorageMap<
|
||||
Pallet<T>,
|
||||
Twox64Concat,
|
||||
Vec<u8>,
|
||||
TaskAddress<<T as frame_system::Config>::BlockNumber>,
|
||||
>;
|
||||
|
||||
/// Migrate the scheduler pallet from V3 to V4.
|
||||
pub struct MigrateToV4<T>(sp_std::marker::PhantomData<T>);
|
||||
|
||||
impl<T: Config<Hash = PreimageHash>> OnRuntimeUpgrade for MigrateToV4<T> {
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
|
||||
assert_eq!(StorageVersion::get::<Pallet<T>>(), 3, "Can only upgrade from version 3");
|
||||
|
||||
let agendas = Agenda::<T>::iter_keys().count() as u32;
|
||||
let decodable_agendas = Agenda::<T>::iter_values().count() as u32;
|
||||
if agendas != decodable_agendas {
|
||||
// This is not necessarily an error, but can happen when there are Calls
|
||||
// in an Agenda that are not valid anymore with the new runtime.
|
||||
log::error!(
|
||||
target: TARGET,
|
||||
"Can only decode {} of {} agendas - others will be dropped",
|
||||
decodable_agendas,
|
||||
agendas
|
||||
);
|
||||
}
|
||||
log::info!(target: TARGET, "Trying to migrate {} agendas...", decodable_agendas);
|
||||
|
||||
// Check that no agenda overflows `MaxScheduledPerBlock`.
|
||||
let max_scheduled_per_block = T::MaxScheduledPerBlock::get() as usize;
|
||||
for (block_number, agenda) in Agenda::<T>::iter() {
|
||||
if agenda.iter().cloned().filter_map(|s| s).count() > max_scheduled_per_block {
|
||||
log::error!(
|
||||
target: TARGET,
|
||||
"Would truncate agenda of block {:?} from {} items to {} items.",
|
||||
block_number,
|
||||
agenda.len(),
|
||||
max_scheduled_per_block,
|
||||
);
|
||||
return Err("Agenda would overflow `MaxScheduledPerBlock`.")
|
||||
}
|
||||
}
|
||||
// Check that bounding the calls will not overflow `MAX_LENGTH`.
|
||||
let max_length = T::Preimages::MAX_LENGTH as usize;
|
||||
for (block_number, agenda) in Agenda::<T>::iter() {
|
||||
for schedule in agenda.iter().cloned().filter_map(|s| s) {
|
||||
match schedule.call {
|
||||
frame_support::traits::schedule::MaybeHashed::Value(call) => {
|
||||
let l = call.using_encoded(|c| c.len());
|
||||
if l > max_length {
|
||||
log::error!(
|
||||
target: TARGET,
|
||||
"Call in agenda of block {:?} is too large: {} byte",
|
||||
block_number,
|
||||
l,
|
||||
);
|
||||
return Err("Call is too large.")
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok((decodable_agendas as u32).encode())
|
||||
}
|
||||
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
let version = StorageVersion::get::<Pallet<T>>();
|
||||
if version != 3 {
|
||||
log::warn!(
|
||||
target: TARGET,
|
||||
"skipping v3 to v4 migration: executed on wrong storage version.\
|
||||
Expected version 3, found {:?}",
|
||||
version,
|
||||
);
|
||||
return T::DbWeight::get().reads(1)
|
||||
}
|
||||
|
||||
crate::Pallet::<T>::migrate_v3_to_v4()
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(state: Vec<u8>) -> Result<(), &'static str> {
|
||||
assert_eq!(StorageVersion::get::<Pallet<T>>(), 4, "Must upgrade");
|
||||
|
||||
// Check that everything decoded fine.
|
||||
for k in crate::Agenda::<T>::iter_keys() {
|
||||
assert!(crate::Agenda::<T>::try_get(k).is_ok(), "Cannot decode V4 Agenda");
|
||||
}
|
||||
|
||||
let old_agendas: u32 =
|
||||
Decode::decode(&mut &state[..]).expect("pre_upgrade provides a valid state; qed");
|
||||
let new_agendas = crate::Agenda::<T>::iter_keys().count() as u32;
|
||||
if old_agendas != new_agendas {
|
||||
// This is not necessarily an error, but can happen when there are Calls
|
||||
// in an Agenda that are not valid anymore in the new runtime.
|
||||
log::error!(
|
||||
target: TARGET,
|
||||
"Did not migrate all Agendas. Previous {}, Now {}",
|
||||
old_agendas,
|
||||
new_agendas,
|
||||
);
|
||||
} else {
|
||||
log::info!(target: TARGET, "Migrated {} agendas.", new_agendas);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(feature = "try-runtime")]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::mock::*;
|
||||
use frame_support::Hashable;
|
||||
use sp_std::borrow::Cow;
|
||||
use substrate_test_utils::assert_eq_uvec;
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn migration_v3_to_v4_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Assume that we are at V3.
|
||||
StorageVersion::new(3).put::<Scheduler>();
|
||||
|
||||
// Call that will be bounded to a `Lookup`.
|
||||
let large_call =
|
||||
RuntimeCall::System(frame_system::Call::remark { remark: vec![0; 1024] });
|
||||
// Call that can be inlined.
|
||||
let small_call =
|
||||
RuntimeCall::System(frame_system::Call::remark { remark: vec![0; 10] });
|
||||
// Call that is already hashed and can will be converted to `Legacy`.
|
||||
let hashed_call =
|
||||
RuntimeCall::System(frame_system::Call::remark { remark: vec![0; 2048] });
|
||||
let bound_hashed_call = Preimage::bound(hashed_call.clone()).unwrap();
|
||||
assert!(bound_hashed_call.lookup_needed());
|
||||
// A Call by hash that will fail to decode becomes `None`.
|
||||
let trash_data = vec![255u8; 1024];
|
||||
let undecodable_hash = Preimage::note(Cow::Borrowed(&trash_data)).unwrap();
|
||||
|
||||
for i in 0..2u64 {
|
||||
let k = i.twox_64_concat();
|
||||
let old = vec![
|
||||
Some(ScheduledV3Of::<Test> {
|
||||
maybe_id: None,
|
||||
priority: i as u8 + 10,
|
||||
call: small_call.clone().into(),
|
||||
maybe_periodic: None, // 1
|
||||
origin: root(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
}),
|
||||
None,
|
||||
Some(ScheduledV3Of::<Test> {
|
||||
maybe_id: Some(vec![i as u8; 32]),
|
||||
priority: 123,
|
||||
call: large_call.clone().into(),
|
||||
maybe_periodic: Some((4u64, 20)),
|
||||
origin: signed(i),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
}),
|
||||
Some(ScheduledV3Of::<Test> {
|
||||
maybe_id: Some(vec![255 - i as u8; 320]),
|
||||
priority: 123,
|
||||
call: MaybeHashed::Hash(bound_hashed_call.hash()),
|
||||
maybe_periodic: Some((8u64, 10)),
|
||||
origin: signed(i),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
}),
|
||||
Some(ScheduledV3Of::<Test> {
|
||||
maybe_id: Some(vec![i as u8; 320]),
|
||||
priority: 123,
|
||||
call: MaybeHashed::Hash(undecodable_hash.clone()),
|
||||
maybe_periodic: Some((4u64, 20)),
|
||||
origin: root(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
}),
|
||||
];
|
||||
frame_support::migration::put_storage_value(b"Scheduler", b"Agenda", &k, old);
|
||||
}
|
||||
|
||||
let state = v3::MigrateToV4::<Test>::pre_upgrade().unwrap();
|
||||
let _w = v3::MigrateToV4::<Test>::on_runtime_upgrade();
|
||||
v3::MigrateToV4::<Test>::post_upgrade(state).unwrap();
|
||||
|
||||
let mut x = Agenda::<Test>::iter().map(|x| (x.0, x.1.into_inner())).collect::<Vec<_>>();
|
||||
x.sort_by_key(|x| x.0);
|
||||
|
||||
let bound_large_call = Preimage::bound(large_call).unwrap();
|
||||
assert!(bound_large_call.lookup_needed());
|
||||
let bound_small_call = Preimage::bound(small_call).unwrap();
|
||||
assert!(!bound_small_call.lookup_needed());
|
||||
|
||||
let expected = vec![
|
||||
(
|
||||
0,
|
||||
vec![
|
||||
Some(ScheduledOf::<Test> {
|
||||
maybe_id: None,
|
||||
priority: 10,
|
||||
call: bound_small_call.clone(),
|
||||
maybe_periodic: None,
|
||||
origin: root(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
}),
|
||||
None,
|
||||
Some(ScheduledOf::<Test> {
|
||||
maybe_id: Some(blake2_256(&[0u8; 32])),
|
||||
priority: 123,
|
||||
call: bound_large_call.clone(),
|
||||
maybe_periodic: Some((4u64, 20)),
|
||||
origin: signed(0),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
}),
|
||||
Some(ScheduledOf::<Test> {
|
||||
maybe_id: Some(blake2_256(&[255u8; 320])),
|
||||
priority: 123,
|
||||
call: Bounded::from_legacy_hash(bound_hashed_call.hash()),
|
||||
maybe_periodic: Some((8u64, 10)),
|
||||
origin: signed(0),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
}),
|
||||
None,
|
||||
],
|
||||
),
|
||||
(
|
||||
1,
|
||||
vec![
|
||||
Some(ScheduledOf::<Test> {
|
||||
maybe_id: None,
|
||||
priority: 11,
|
||||
call: bound_small_call.clone(),
|
||||
maybe_periodic: None,
|
||||
origin: root(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
}),
|
||||
None,
|
||||
Some(ScheduledOf::<Test> {
|
||||
maybe_id: Some(blake2_256(&[1u8; 32])),
|
||||
priority: 123,
|
||||
call: bound_large_call.clone(),
|
||||
maybe_periodic: Some((4u64, 20)),
|
||||
origin: signed(1),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
}),
|
||||
Some(ScheduledOf::<Test> {
|
||||
maybe_id: Some(blake2_256(&[254u8; 320])),
|
||||
priority: 123,
|
||||
call: Bounded::from_legacy_hash(bound_hashed_call.hash()),
|
||||
maybe_periodic: Some((8u64, 10)),
|
||||
origin: signed(1),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
}),
|
||||
None,
|
||||
],
|
||||
),
|
||||
];
|
||||
for (outer, (i, j)) in x.iter().zip(expected.iter()).enumerate() {
|
||||
assert_eq!(i.0, j.0);
|
||||
for (inner, (x, y)) in i.1.iter().zip(j.1.iter()).enumerate() {
|
||||
assert_eq!(x, y, "at index: outer {} inner {}", outer, inner);
|
||||
}
|
||||
}
|
||||
assert_eq_uvec!(x, expected);
|
||||
|
||||
assert_eq!(StorageVersion::get::<Scheduler>(), 4);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn migration_v3_to_v4_too_large_calls_are_ignored() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Assume that we are at V3.
|
||||
StorageVersion::new(3).put::<Scheduler>();
|
||||
|
||||
let too_large_call = RuntimeCall::System(frame_system::Call::remark {
|
||||
remark: vec![0; <Test as Config>::Preimages::MAX_LENGTH + 1],
|
||||
});
|
||||
|
||||
let i = 0u64;
|
||||
let k = i.twox_64_concat();
|
||||
let old = vec![Some(ScheduledV3Of::<Test> {
|
||||
maybe_id: None,
|
||||
priority: 1,
|
||||
call: too_large_call.clone().into(),
|
||||
maybe_periodic: None,
|
||||
origin: root(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
})];
|
||||
frame_support::migration::put_storage_value(b"Scheduler", b"Agenda", &k, old);
|
||||
|
||||
// The pre_upgrade hook fails:
|
||||
let err = v3::MigrateToV4::<Test>::pre_upgrade().unwrap_err();
|
||||
assert!(err.contains("Call is too large"));
|
||||
// But the migration itself works:
|
||||
let _w = v3::MigrateToV4::<Test>::on_runtime_upgrade();
|
||||
|
||||
let mut x = Agenda::<Test>::iter().map(|x| (x.0, x.1.into_inner())).collect::<Vec<_>>();
|
||||
x.sort_by_key(|x| x.0);
|
||||
// The call becomes `None`.
|
||||
let expected = vec![(0, vec![None])];
|
||||
assert_eq_uvec!(x, expected);
|
||||
|
||||
assert_eq!(StorageVersion::get::<Scheduler>(), 4);
|
||||
});
|
||||
}
|
||||
|
||||
fn signed(i: u64) -> OriginCaller {
|
||||
system::RawOrigin::Signed(i).into()
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ parameter_types! {
|
||||
}
|
||||
impl system::Config for Test {
|
||||
type BaseCallFilter = BaseFilter;
|
||||
type BlockWeights = ();
|
||||
type BlockWeights = BlockWeights;
|
||||
type BlockLength = ();
|
||||
type DbWeight = RocksDbWeight;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
@@ -151,10 +151,6 @@ impl system::Config for Test {
|
||||
impl logger::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
}
|
||||
parameter_types! {
|
||||
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
|
||||
pub const NoPreimagePostponement: Option<u64> = Some(2);
|
||||
}
|
||||
ord_parameter_types! {
|
||||
pub const One: u64 = 1;
|
||||
}
|
||||
@@ -164,11 +160,54 @@ impl pallet_preimage::Config for Test {
|
||||
type WeightInfo = ();
|
||||
type Currency = ();
|
||||
type ManagerOrigin = EnsureRoot<u64>;
|
||||
type MaxSize = ConstU32<1024>;
|
||||
type BaseDeposit = ();
|
||||
type ByteDeposit = ();
|
||||
}
|
||||
|
||||
pub struct TestWeightInfo;
|
||||
impl WeightInfo for TestWeightInfo {
|
||||
fn service_agendas_base() -> Weight {
|
||||
Weight::from_ref_time(0b0000_0001)
|
||||
}
|
||||
fn service_agenda_base(i: u32) -> Weight {
|
||||
Weight::from_ref_time((i << 8) as u64 + 0b0000_0010)
|
||||
}
|
||||
fn service_task_base() -> Weight {
|
||||
Weight::from_ref_time(0b0000_0100)
|
||||
}
|
||||
fn service_task_periodic() -> Weight {
|
||||
Weight::from_ref_time(0b0000_1100)
|
||||
}
|
||||
fn service_task_named() -> Weight {
|
||||
Weight::from_ref_time(0b0001_0100)
|
||||
}
|
||||
fn service_task_fetched(s: u32) -> Weight {
|
||||
Weight::from_ref_time((s << 8) as u64 + 0b0010_0100)
|
||||
}
|
||||
fn execute_dispatch_signed() -> Weight {
|
||||
Weight::from_ref_time(0b0100_0000)
|
||||
}
|
||||
fn execute_dispatch_unsigned() -> Weight {
|
||||
Weight::from_ref_time(0b1000_0000)
|
||||
}
|
||||
fn schedule(_s: u32) -> Weight {
|
||||
Weight::from_ref_time(50)
|
||||
}
|
||||
fn cancel(_s: u32) -> Weight {
|
||||
Weight::from_ref_time(50)
|
||||
}
|
||||
fn schedule_named(_s: u32) -> Weight {
|
||||
Weight::from_ref_time(50)
|
||||
}
|
||||
fn cancel_named(_s: u32) -> Weight {
|
||||
Weight::from_ref_time(50)
|
||||
}
|
||||
}
|
||||
parameter_types! {
|
||||
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
|
||||
BlockWeights::get().max_block;
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
@@ -177,10 +216,9 @@ impl Config for Test {
|
||||
type MaximumWeight = MaximumSchedulerWeight;
|
||||
type ScheduleOrigin = EitherOfDiverse<EnsureRoot<u64>, EnsureSignedBy<One, u64>>;
|
||||
type MaxScheduledPerBlock = ConstU32<10>;
|
||||
type WeightInfo = ();
|
||||
type WeightInfo = TestWeightInfo;
|
||||
type OriginPrivilegeCmp = EqualPrivilegeOnly;
|
||||
type PreimageProvider = Preimage;
|
||||
type NoPreimagePostponement = NoPreimagePostponement;
|
||||
type Preimages = Preimage;
|
||||
}
|
||||
|
||||
pub type LoggerCall = logger::Call<Test>;
|
||||
|
||||
+1093
-387
File diff suppressed because it is too large
Load Diff
@@ -18,22 +18,24 @@
|
||||
//! Autogenerated weights for pallet_scheduler
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-05-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! DATE: 2022-10-03, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./target/production/substrate
|
||||
// /home/benchbot/cargo_target_dir/production/substrate
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain=dev
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --pallet=pallet_scheduler
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --template=./.maintain/frame-weight-template.hbs
|
||||
// --heap-pages=4096
|
||||
// --pallet=pallet_scheduler
|
||||
// --chain=dev
|
||||
// --output=./frame/scheduler/src/weights.rs
|
||||
// --template=./.maintain/frame-weight-template.hbs
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
@@ -44,16 +46,14 @@ use sp_std::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for pallet_scheduler.
|
||||
pub trait WeightInfo {
|
||||
fn on_initialize_periodic_named_resolved(s: u32, ) -> Weight;
|
||||
fn on_initialize_named_resolved(s: u32, ) -> Weight;
|
||||
fn on_initialize_periodic_resolved(s: u32, ) -> Weight;
|
||||
fn on_initialize_resolved(s: u32, ) -> Weight;
|
||||
fn on_initialize_named_aborted(s: u32, ) -> Weight;
|
||||
fn on_initialize_aborted(s: u32, ) -> Weight;
|
||||
fn on_initialize_periodic_named(s: u32, ) -> Weight;
|
||||
fn on_initialize_periodic(s: u32, ) -> Weight;
|
||||
fn on_initialize_named(s: u32, ) -> Weight;
|
||||
fn on_initialize(s: u32, ) -> Weight;
|
||||
fn service_agendas_base() -> Weight;
|
||||
fn service_agenda_base(s: u32, ) -> Weight;
|
||||
fn service_task_base() -> Weight;
|
||||
fn service_task_fetched(s: u32, ) -> Weight;
|
||||
fn service_task_named() -> Weight;
|
||||
fn service_task_periodic() -> Weight;
|
||||
fn execute_dispatch_signed() -> Weight;
|
||||
fn execute_dispatch_unsigned() -> Weight;
|
||||
fn schedule(s: u32, ) -> Weight;
|
||||
fn cancel(s: u32, ) -> Weight;
|
||||
fn schedule_named(s: u32, ) -> Weight;
|
||||
@@ -63,149 +63,84 @@ pub trait WeightInfo {
|
||||
/// Weights for pallet_scheduler using the Substrate node and recommended hardware.
|
||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Scheduler Agenda (r:2 w:2)
|
||||
// Storage: Preimage PreimageFor (r:1 w:1)
|
||||
// Storage: Preimage StatusFor (r:1 w:1)
|
||||
// Storage: Scheduler Lookup (r:0 w:1)
|
||||
fn on_initialize_periodic_named_resolved(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(9_994_000 as u64)
|
||||
// Standard Error: 20_000
|
||||
.saturating_add(Weight::from_ref_time(19_843_000 as u64).saturating_mul(s as u64))
|
||||
// Storage: Scheduler IncompleteSince (r:1 w:1)
|
||||
fn service_agendas_base() -> Weight {
|
||||
Weight::from_ref_time(4_992_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes((4 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
/// The range of component `s` is `[0, 512]`.
|
||||
fn service_agenda_base(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(4_320_000 as u64)
|
||||
// Standard Error: 619
|
||||
.saturating_add(Weight::from_ref_time(336_713 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
fn service_task_base() -> Weight {
|
||||
Weight::from_ref_time(10_864_000 as u64)
|
||||
}
|
||||
// Storage: Preimage PreimageFor (r:1 w:1)
|
||||
// Storage: Preimage StatusFor (r:1 w:1)
|
||||
// Storage: Scheduler Lookup (r:0 w:1)
|
||||
fn on_initialize_named_resolved(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(10_318_000 as u64)
|
||||
// Standard Error: 17_000
|
||||
.saturating_add(Weight::from_ref_time(15_451_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:2 w:2)
|
||||
// Storage: Preimage PreimageFor (r:1 w:1)
|
||||
// Storage: Preimage StatusFor (r:1 w:1)
|
||||
fn on_initialize_periodic_resolved(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(11_675_000 as u64)
|
||||
// Standard Error: 17_000
|
||||
.saturating_add(Weight::from_ref_time(17_019_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
// Storage: Preimage PreimageFor (r:1 w:1)
|
||||
// Storage: Preimage StatusFor (r:1 w:1)
|
||||
fn on_initialize_resolved(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(11_934_000 as u64)
|
||||
// Standard Error: 11_000
|
||||
.saturating_add(Weight::from_ref_time(14_134_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:2 w:2)
|
||||
// Storage: Preimage PreimageFor (r:1 w:0)
|
||||
// Storage: Scheduler Lookup (r:0 w:1)
|
||||
fn on_initialize_named_aborted(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(7_279_000 as u64)
|
||||
// Standard Error: 5_000
|
||||
.saturating_add(Weight::from_ref_time(5_388_000 as u64).saturating_mul(s as u64))
|
||||
/// The range of component `s` is `[128, 4194304]`.
|
||||
fn service_task_fetched(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(24_586_000 as u64)
|
||||
// Standard Error: 1
|
||||
.saturating_add(Weight::from_ref_time(1_138 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(2 as u64))
|
||||
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:2 w:2)
|
||||
// Storage: Preimage PreimageFor (r:1 w:0)
|
||||
fn on_initialize_aborted(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(8_619_000 as u64)
|
||||
// Standard Error: 4_000
|
||||
.saturating_add(Weight::from_ref_time(2_969_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(2 as u64))
|
||||
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:2 w:2)
|
||||
// Storage: Scheduler Lookup (r:0 w:1)
|
||||
fn on_initialize_periodic_named(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(16_129_000 as u64)
|
||||
// Standard Error: 7_000
|
||||
.saturating_add(Weight::from_ref_time(9_772_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(s as u64)))
|
||||
fn service_task_named() -> Weight {
|
||||
Weight::from_ref_time(13_127_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:2 w:2)
|
||||
fn on_initialize_periodic(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(15_785_000 as u64)
|
||||
// Standard Error: 5_000
|
||||
.saturating_add(Weight::from_ref_time(7_208_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
// Storage: Scheduler Lookup (r:0 w:1)
|
||||
fn on_initialize_named(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(15_778_000 as u64)
|
||||
// Standard Error: 3_000
|
||||
.saturating_add(Weight::from_ref_time(5_597_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
fn on_initialize(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(15_912_000 as u64)
|
||||
// Standard Error: 5_000
|
||||
.saturating_add(Weight::from_ref_time(4_530_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
fn service_task_periodic() -> Weight {
|
||||
Weight::from_ref_time(11_053_000 as u64)
|
||||
}
|
||||
fn execute_dispatch_signed() -> Weight {
|
||||
Weight::from_ref_time(4_158_000 as u64)
|
||||
}
|
||||
fn execute_dispatch_unsigned() -> Weight {
|
||||
Weight::from_ref_time(4_104_000 as u64)
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
/// The range of component `s` is `[0, 511]`.
|
||||
fn schedule(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(18_013_000 as u64)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(87_000 as u64).saturating_mul(s as u64))
|
||||
Weight::from_ref_time(20_074_000 as u64)
|
||||
// Standard Error: 765
|
||||
.saturating_add(Weight::from_ref_time(343_285 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
// Storage: Scheduler Lookup (r:0 w:1)
|
||||
/// The range of component `s` is `[1, 512]`.
|
||||
fn cancel(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(18_131_000 as u64)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(595_000 as u64).saturating_mul(s as u64))
|
||||
Weight::from_ref_time(21_509_000 as u64)
|
||||
// Standard Error: 708
|
||||
.saturating_add(Weight::from_ref_time(323_013 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
// Storage: Scheduler Lookup (r:1 w:1)
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
/// The range of component `s` is `[0, 511]`.
|
||||
fn schedule_named(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(21_230_000 as u64)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(98_000 as u64).saturating_mul(s as u64))
|
||||
Weight::from_ref_time(22_427_000 as u64)
|
||||
// Standard Error: 850
|
||||
.saturating_add(Weight::from_ref_time(357_265 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(2 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
// Storage: Scheduler Lookup (r:1 w:1)
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
/// The range of component `s` is `[1, 512]`.
|
||||
fn cancel_named(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(20_139_000 as u64)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(595_000 as u64).saturating_mul(s as u64))
|
||||
Weight::from_ref_time(22_875_000 as u64)
|
||||
// Standard Error: 693
|
||||
.saturating_add(Weight::from_ref_time(336_643 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(2 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
@@ -213,149 +148,84 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
|
||||
// For backwards compatibility and tests
|
||||
impl WeightInfo for () {
|
||||
// Storage: Scheduler Agenda (r:2 w:2)
|
||||
// Storage: Preimage PreimageFor (r:1 w:1)
|
||||
// Storage: Preimage StatusFor (r:1 w:1)
|
||||
// Storage: Scheduler Lookup (r:0 w:1)
|
||||
fn on_initialize_periodic_named_resolved(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(9_994_000 as u64)
|
||||
// Standard Error: 20_000
|
||||
.saturating_add(Weight::from_ref_time(19_843_000 as u64).saturating_mul(s as u64))
|
||||
// Storage: Scheduler IncompleteSince (r:1 w:1)
|
||||
fn service_agendas_base() -> Weight {
|
||||
Weight::from_ref_time(4_992_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads((3 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes((4 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
/// The range of component `s` is `[0, 512]`.
|
||||
fn service_agenda_base(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(4_320_000 as u64)
|
||||
// Standard Error: 619
|
||||
.saturating_add(Weight::from_ref_time(336_713 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
}
|
||||
fn service_task_base() -> Weight {
|
||||
Weight::from_ref_time(10_864_000 as u64)
|
||||
}
|
||||
// Storage: Preimage PreimageFor (r:1 w:1)
|
||||
// Storage: Preimage StatusFor (r:1 w:1)
|
||||
// Storage: Scheduler Lookup (r:0 w:1)
|
||||
fn on_initialize_named_resolved(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(10_318_000 as u64)
|
||||
// Standard Error: 17_000
|
||||
.saturating_add(Weight::from_ref_time(15_451_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes((3 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:2 w:2)
|
||||
// Storage: Preimage PreimageFor (r:1 w:1)
|
||||
// Storage: Preimage StatusFor (r:1 w:1)
|
||||
fn on_initialize_periodic_resolved(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(11_675_000 as u64)
|
||||
// Standard Error: 17_000
|
||||
.saturating_add(Weight::from_ref_time(17_019_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads((3 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes((3 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
// Storage: Preimage PreimageFor (r:1 w:1)
|
||||
// Storage: Preimage StatusFor (r:1 w:1)
|
||||
fn on_initialize_resolved(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(11_934_000 as u64)
|
||||
// Standard Error: 11_000
|
||||
.saturating_add(Weight::from_ref_time(14_134_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:2 w:2)
|
||||
// Storage: Preimage PreimageFor (r:1 w:0)
|
||||
// Storage: Scheduler Lookup (r:0 w:1)
|
||||
fn on_initialize_named_aborted(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(7_279_000 as u64)
|
||||
// Standard Error: 5_000
|
||||
.saturating_add(Weight::from_ref_time(5_388_000 as u64).saturating_mul(s as u64))
|
||||
/// The range of component `s` is `[128, 4194304]`.
|
||||
fn service_task_fetched(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(24_586_000 as u64)
|
||||
// Standard Error: 1
|
||||
.saturating_add(Weight::from_ref_time(1_138 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:2 w:2)
|
||||
// Storage: Preimage PreimageFor (r:1 w:0)
|
||||
fn on_initialize_aborted(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(8_619_000 as u64)
|
||||
// Standard Error: 4_000
|
||||
.saturating_add(Weight::from_ref_time(2_969_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as u64))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:2 w:2)
|
||||
// Storage: Scheduler Lookup (r:0 w:1)
|
||||
fn on_initialize_periodic_named(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(16_129_000 as u64)
|
||||
// Standard Error: 7_000
|
||||
.saturating_add(Weight::from_ref_time(9_772_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(s as u64)))
|
||||
fn service_task_named() -> Weight {
|
||||
Weight::from_ref_time(13_127_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:2 w:2)
|
||||
fn on_initialize_periodic(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(15_785_000 as u64)
|
||||
// Standard Error: 5_000
|
||||
.saturating_add(Weight::from_ref_time(7_208_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(s as u64)))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
// Storage: Scheduler Lookup (r:0 w:1)
|
||||
fn on_initialize_named(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(15_778_000 as u64)
|
||||
// Standard Error: 3_000
|
||||
.saturating_add(Weight::from_ref_time(5_597_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(s as u64)))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
fn on_initialize(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(15_912_000 as u64)
|
||||
// Standard Error: 5_000
|
||||
.saturating_add(Weight::from_ref_time(4_530_000 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
fn service_task_periodic() -> Weight {
|
||||
Weight::from_ref_time(11_053_000 as u64)
|
||||
}
|
||||
fn execute_dispatch_signed() -> Weight {
|
||||
Weight::from_ref_time(4_158_000 as u64)
|
||||
}
|
||||
fn execute_dispatch_unsigned() -> Weight {
|
||||
Weight::from_ref_time(4_104_000 as u64)
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
/// The range of component `s` is `[0, 511]`.
|
||||
fn schedule(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(18_013_000 as u64)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(87_000 as u64).saturating_mul(s as u64))
|
||||
Weight::from_ref_time(20_074_000 as u64)
|
||||
// Standard Error: 765
|
||||
.saturating_add(Weight::from_ref_time(343_285 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
}
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
// Storage: Scheduler Lookup (r:0 w:1)
|
||||
/// The range of component `s` is `[1, 512]`.
|
||||
fn cancel(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(18_131_000 as u64)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(595_000 as u64).saturating_mul(s as u64))
|
||||
Weight::from_ref_time(21_509_000 as u64)
|
||||
// Standard Error: 708
|
||||
.saturating_add(Weight::from_ref_time(323_013 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as u64))
|
||||
}
|
||||
// Storage: Scheduler Lookup (r:1 w:1)
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
/// The range of component `s` is `[0, 511]`.
|
||||
fn schedule_named(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(21_230_000 as u64)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(98_000 as u64).saturating_mul(s as u64))
|
||||
Weight::from_ref_time(22_427_000 as u64)
|
||||
// Standard Error: 850
|
||||
.saturating_add(Weight::from_ref_time(357_265 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as u64))
|
||||
}
|
||||
// Storage: Scheduler Lookup (r:1 w:1)
|
||||
// Storage: Scheduler Agenda (r:1 w:1)
|
||||
/// The range of component `s` is `[1, 512]`.
|
||||
fn cancel_named(s: u32, ) -> Weight {
|
||||
Weight::from_ref_time(20_139_000 as u64)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(595_000 as u64).saturating_mul(s as u64))
|
||||
Weight::from_ref_time(22_875_000 as u64)
|
||||
// Standard Error: 693
|
||||
.saturating_add(Weight::from_ref_time(336_643 as u64).saturating_mul(s as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as u64))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user