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:
Gavin Wood
2022-10-05 19:21:37 +01:00
committed by GitHub
parent 24f0c3601c
commit 93e8ffed55
67 changed files with 5089 additions and 3488 deletions
+173 -158
View File
@@ -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