git.delta.rocks / unique-network / refs/commits / e7f57de8c599

difftreelog

fix(scheduler-v2) fix benchmarks

Igor Kozyrev2022-10-28parent: #2a17a69.patch.diff
in: master

5 files changed

modifiedMakefilediffbeforeafterboth
118118
119.PHONY: bench-scheduler119.PHONY: bench-scheduler
120bench-scheduler:120bench-scheduler:
121 make _bench PALLET=unique-scheduler PALLET_DIR=scheduler121 make _bench PALLET=unique-scheduler-v2 PALLET_DIR=scheduler-v2
122122
123.PHONY: bench-rmrk-core123.PHONY: bench-rmrk-core
124bench-rmrk-core:124bench-rmrk-core:
modifiedpallets/scheduler-v2/src/benchmarking.rsdiffbeforeafterboth
5151
52const BLOCK_NUMBER: u32 = 2;52const BLOCK_NUMBER: u32 = 2;
5353
54type SystemOrigin<T> = <T as frame_system::Config>::Origin;54type SystemOrigin<T> = <T as frame_system::Config>::RuntimeOrigin;
5555
56/// Add `n` items to the schedule.56/// Add `n` items to the schedule.
57///57///
70 Scheduler::<T>::do_schedule_named(name, t, period, 0, origin.clone(), call)?;70 Scheduler::<T>::do_schedule_named(name, t, period, 0, origin.clone(), call)?;
71 }71 }
72 ensure!(72 ensure!(
73 Agenda::<T>::get(when).len() == n as usize,73 Agenda::<T>::get(when).agenda.len() == n as usize,
74 "didn't fill schedule"74 "didn't fill schedule"
75 );75 );
76 Ok(())76 Ok(())
108}108}
109109
110fn bounded<T: Config>(len: u32) -> Option<ScheduledCall<T>> {110fn bounded<T: Config>(len: u32) -> Option<ScheduledCall<T>> {
111 let call = <<T as Config>::Call>::from(SystemCall::remark {111 let call = <<T as Config>::RuntimeCall>::from(SystemCall::remark {
112 remark: vec![0; len as usize],112 remark: vec![0; len as usize],
113 });113 });
114 ScheduledCall::new(call).ok()114 ScheduledCall::new(call).ok()
197 //assert_eq!(result, Ok(()));197 //assert_eq!(result, Ok(()));
198 }198 }
199199
200 // TODO uncomment if we will use the Preimages
200 // `service_task` when the task is a non-periodic, non-named, fetched call (with a known201 // // `service_task` when the task is a non-periodic, non-named, fetched call (with a known
201 // preimage length) and which is not dispatched (e.g. due to being overweight).202 // // preimage length) and which is not dispatched (e.g. due to being overweight).
202 service_task_fetched {203 // service_task_fetched {
203 let s in (EncodedCall::bound() as u32) .. (<T::Preimages as PreimageRecipient<T::Hash>>::MaxSize::get());204 // let s in (EncodedCall::bound() as u32) .. (<T::Preimages as PreimageRecipient<T::Hash>>::MaxSize::get());
204 let now = BLOCK_NUMBER.into();205 // let now = BLOCK_NUMBER.into();
205 let task = make_task::<T>(false, false, false, Some(s), 0);206 // let task = make_task::<T>(false, false, false, Some(s), 0);
206 // prevent any tasks from actually being executed as we only want the surrounding weight.207 // // prevent any tasks from actually being executed as we only want the surrounding weight.
207 let mut counter = WeightCounter { used: Weight::zero(), limit: Weight::zero() };208 // let mut counter = WeightCounter { used: Weight::zero(), limit: Weight::zero() };
208 }: {209 // }: {
209 let result = Scheduler::<T>::service_task(&mut counter, now, now, 0, true, task);210 // let result = Scheduler::<T>::service_task(&mut counter, now, now, 0, true, task);
210 } verify {211 // } verify {
211 }212 // }
212213
213 // `service_task` when the task is a non-periodic, named, non-fetched call which is not214 // `service_task` when the task is a non-periodic, named, non-fetched call which is not
214 // dispatched (e.g. due to being overweight).215 // dispatched (e.g. due to being overweight).
268 }: _(RawOrigin::Root, when, periodic, priority, call)269 }: _(RawOrigin::Root, when, periodic, priority, call)
269 verify {270 verify {
270 ensure!(271 ensure!(
271 Agenda::<T>::get(when).len() == (s + 1) as usize,272 Agenda::<T>::get(when).agenda.len() == (s + 1) as usize,
272 "didn't add to schedule"273 "didn't add to schedule"
273 );274 );
274 }275 }
278 let when = BLOCK_NUMBER.into();279 let when = BLOCK_NUMBER.into();
279280
280 fill_schedule::<T>(when, s)?;281 fill_schedule::<T>(when, s)?;
281 assert_eq!(Agenda::<T>::get(when).len(), s as usize);282 assert_eq!(Agenda::<T>::get(when).agenda.len(), s as usize);
282 let schedule_origin = T::ScheduleOrigin::successful_origin();283 let schedule_origin = T::ScheduleOrigin::successful_origin();
283 }: _<SystemOrigin<T>>(schedule_origin, when, 0)284 }: _<SystemOrigin<T>>(schedule_origin, when, 0)
284 verify {285 verify {
288 );289 );
289 // Removed schedule is NONE290 // Removed schedule is NONE
290 ensure!(291 ensure!(
291 Agenda::<T>::get(when)[0].is_none(),292 Agenda::<T>::get(when).agenda[0].is_none(),
292 "didn't remove from schedule"293 "didn't remove from schedule"
293 );294 );
294 }295 }
306 }: _(RawOrigin::Root, id, when, periodic, priority, call)307 }: _(RawOrigin::Root, id, when, periodic, priority, call)
307 verify {308 verify {
308 ensure!(309 ensure!(
309 Agenda::<T>::get(when).len() == (s + 1) as usize,310 Agenda::<T>::get(when).agenda.len() == (s + 1) as usize,
310 "didn't add to schedule"311 "didn't add to schedule"
311 );312 );
312 }313 }
324 );325 );
325 // Removed schedule is NONE326 // Removed schedule is NONE
326 ensure!(327 ensure!(
327 Agenda::<T>::get(when)[0].is_none(),328 Agenda::<T>::get(when).agenda[0].is_none(),
328 "didn't remove from schedule"329 "didn't remove from schedule"
329 );330 );
330 }331 }
340 }: _(origin, id, priority)341 }: _(origin, id, priority)
341 verify {342 verify {
342 ensure!(343 ensure!(
343 Agenda::<T>::get(when)[idx as usize].clone().unwrap().priority == priority,344 Agenda::<T>::get(when).agenda[idx as usize].clone().unwrap().priority == priority,
344 "didn't change the priority"345 "didn't change the priority"
345 );346 );
346 }347 }
modifiedpallets/scheduler-v2/src/lib.rsdiffbeforeafterboth
347 let base = Self::service_task_base();347 let base = Self::service_task_base();
348 let mut total = match maybe_lookup_len {348 let mut total = match maybe_lookup_len {
349 None => base,349 None => base,
350 Some(l) => Self::service_task_fetched(l as u32),350 Some(_l) => {
351 // TODO uncomment if we will use the Preimages
352 // Self::service_task_fetched(l as u32)
353 base
354 },
351 };355 };
352 if named {356 if named {
353 total.saturating_accrue(Self::service_task_named().saturating_sub(base));357 total.saturating_accrue(Self::service_task_named().saturating_sub(base));
modifiedruntime/common/construct_runtime/mod.rsdiffbeforeafterboth
57 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,57 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,
58 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,58 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,
5959
60 // #[runtimes(opal)]60 #[runtimes(opal)]
61 // Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event<T>} = 62,61 Scheduler: pallet_unique_scheduler_v2::{Pallet, Call, Storage, Event<T>} = 62,
6262
63 Configuration: pallet_configuration::{Pallet, Call, Storage} = 63,63 Configuration: pallet_configuration::{Pallet, Call, Storage} = 63,
6464
94 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,94 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,
95 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,95 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,
9696
97 Maintenance: pallet_maintenance::{Pallet, Call, Storage, Event<T>} = 154,97 Maintenance: pallet_maintenance::{Pallet, Call, Storage, Event<T>} = 154,
98
99 #[runtimes(opal)]
100 Scheduler: pallet_unique_scheduler_v2::{Pallet, Call, Storage, Event<T>} = 154,
10198
102 #[runtimes(opal)]99 #[runtimes(opal)]
103 TestUtils: pallet_test_utils = 255,100 TestUtils: pallet_test_utils = 255,
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
683 #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]683 #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
684 list_benchmark!(list, extra, pallet_refungible, Refungible);684 list_benchmark!(list, extra, pallet_refungible, Refungible);
685685
686 // #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]686 #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
687 // list_benchmark!(list, extra, pallet_unique_scheduler, Scheduler);687 list_benchmark!(list, extra, pallet_unique_scheduler_v2, Scheduler);
688688
689 #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]689 #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
690 list_benchmark!(list, extra, pallet_proxy_rmrk_core, RmrkCore);690 list_benchmark!(list, extra, pallet_proxy_rmrk_core, RmrkCore);
743 #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]743 #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
744 add_benchmark!(params, batches, pallet_refungible, Refungible);744 add_benchmark!(params, batches, pallet_refungible, Refungible);
745745
746 // #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]746 #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
747 // add_benchmark!(params, batches, pallet_unique_scheduler, Scheduler);747 add_benchmark!(params, batches, pallet_unique_scheduler_v2, Scheduler);
748748
749 #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]749 #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
750 add_benchmark!(params, batches, pallet_proxy_rmrk_core, RmrkCore);750 add_benchmark!(params, batches, pallet_proxy_rmrk_core, RmrkCore);