git.delta.rocks / unique-network / refs/commits / 95c1ed5151b9

difftreelog

Scheduler benchmarks fixed. Useless code in pallet was removed.

Dev2022-06-09parent: #c557492.patch.diff
in: master

4 files changed

modifiedMakefilediffbeforeafterboth
--- a/Makefile
+++ b/Makefile
@@ -93,5 +93,9 @@
 bench-structure:
 	make _bench PALLET=structure
 
+.PHONY: bench-scheduler
+bench-scheduler:
+	make _bench PALLET=unq-scheduler	
+
 .PHONY: bench
-bench: bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible
+bench: bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-scheduler
modifiedpallets/fungible/src/weights.rsdiffbeforeafterboth
3//! Autogenerated weights for pallet_fungible3//! Autogenerated weights for pallet_fungible
4//!4//!
5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
6//! DATE: 2022-03-01, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`6//! DATE: 2022-06-09, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`
7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 10247//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
88
9// Executed Command:9// Executed Command:
10// target/release/unique-collator10// target/release/unique-collator
11// benchmark11// benchmark
12// pallet
12// --pallet13// --pallet
13// pallet-fungible14// pallet-fungible
14// --wasm-execution15// --wasm-execution
47 // Storage: Fungible TotalSupply (r:1 w:1)48 // Storage: Fungible TotalSupply (r:1 w:1)
48 // Storage: Fungible Balance (r:1 w:1)49 // Storage: Fungible Balance (r:1 w:1)
49 fn create_item() -> Weight {50 fn create_item() -> Weight {
50 (14_407_000 as Weight)51 (40_678_000 as Weight)
51 .saturating_add(T::DbWeight::get().reads(2 as Weight))52 .saturating_add(T::DbWeight::get().reads(2 as Weight))
52 .saturating_add(T::DbWeight::get().writes(2 as Weight))53 .saturating_add(T::DbWeight::get().writes(2 as Weight))
53 }54 }
54 // Storage: Fungible TotalSupply (r:1 w:1)55 // Storage: Fungible TotalSupply (r:1 w:1)
55 // Storage: Fungible Balance (r:4 w:4)56 // Storage: Fungible Balance (r:4 w:4)
56 fn create_multiple_items_ex(b: u32, ) -> Weight {57 fn create_multiple_items_ex(b: u32, ) -> Weight {
57 (13_030_000 as Weight)58 (13_036_000 as Weight)
58 // Standard Error: 1_00059 // Standard Error: 9_000
59 .saturating_add((3_779_000 as Weight).saturating_mul(b as Weight))60 .saturating_add((15_611_000 as Weight).saturating_mul(b as Weight))
60 .saturating_add(T::DbWeight::get().reads(1 as Weight))61 .saturating_add(T::DbWeight::get().reads(1 as Weight))
61 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))62 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
62 .saturating_add(T::DbWeight::get().writes(1 as Weight))63 .saturating_add(T::DbWeight::get().writes(1 as Weight))
65 // Storage: Fungible TotalSupply (r:1 w:1)66 // Storage: Fungible TotalSupply (r:1 w:1)
66 // Storage: Fungible Balance (r:1 w:1)67 // Storage: Fungible Balance (r:1 w:1)
67 fn burn_item() -> Weight {68 fn burn_item() -> Weight {
68 (15_565_000 as Weight)69 (42_340_000 as Weight)
69 .saturating_add(T::DbWeight::get().reads(2 as Weight))70 .saturating_add(T::DbWeight::get().reads(2 as Weight))
70 .saturating_add(T::DbWeight::get().writes(2 as Weight))71 .saturating_add(T::DbWeight::get().writes(2 as Weight))
71 }72 }
72
73 // Storage: Fungible Balance (r:2 w:2)73 // Storage: Fungible Balance (r:2 w:2)
74 fn transfer() -> Weight {74 fn transfer() -> Weight {
75 (17_713_000 as Weight)75 (47_321_000 as Weight)
76 .saturating_add(T::DbWeight::get().reads(2 as Weight))76 .saturating_add(T::DbWeight::get().reads(2 as Weight))
77 .saturating_add(T::DbWeight::get().writes(2 as Weight))77 .saturating_add(T::DbWeight::get().writes(2 as Weight))
78 }78 }
79 // Storage: Fungible Balance (r:1 w:0)79 // Storage: Fungible Balance (r:1 w:0)
80 // Storage: Fungible Allowance (r:0 w:1)80 // Storage: Fungible Allowance (r:0 w:1)
81 fn approve() -> Weight {81 fn approve() -> Weight {
82 (14_834_000 as Weight)82 (38_385_000 as Weight)
83 .saturating_add(T::DbWeight::get().reads(1 as Weight))83 .saturating_add(T::DbWeight::get().reads(1 as Weight))
84 .saturating_add(T::DbWeight::get().writes(1 as Weight))84 .saturating_add(T::DbWeight::get().writes(1 as Weight))
85 }85 }
86 // Storage: Fungible Allowance (r:1 w:1)86 // Storage: Fungible Allowance (r:1 w:1)
87 // Storage: Fungible Balance (r:2 w:2)87 // Storage: Fungible Balance (r:2 w:2)
88 fn transfer_from() -> Weight {88 fn transfer_from() -> Weight {
89 (25_189_000 as Weight)89 (69_001_000 as Weight)
90 .saturating_add(T::DbWeight::get().reads(3 as Weight))90 .saturating_add(T::DbWeight::get().reads(3 as Weight))
91 .saturating_add(T::DbWeight::get().writes(3 as Weight))91 .saturating_add(T::DbWeight::get().writes(3 as Weight))
92 }92 }
93 // Storage: Fungible Allowance (r:1 w:1)93 // Storage: Fungible Allowance (r:1 w:1)
94 // Storage: Fungible TotalSupply (r:1 w:1)94 // Storage: Fungible TotalSupply (r:1 w:1)
95 // Storage: Fungible Balance (r:1 w:1)95 // Storage: Fungible Balance (r:1 w:1)
96 fn burn_from() -> Weight {96 fn burn_from() -> Weight {
97 (24_065_000 as Weight)97 (63_996_000 as Weight)
98 .saturating_add(T::DbWeight::get().reads(3 as Weight))98 .saturating_add(T::DbWeight::get().reads(3 as Weight))
99 .saturating_add(T::DbWeight::get().writes(3 as Weight))99 .saturating_add(T::DbWeight::get().writes(3 as Weight))
100 }100 }
105 // Storage: Fungible TotalSupply (r:1 w:1)105 // Storage: Fungible TotalSupply (r:1 w:1)
106 // Storage: Fungible Balance (r:1 w:1)106 // Storage: Fungible Balance (r:1 w:1)
107 fn create_item() -> Weight {107 fn create_item() -> Weight {
108 (14_407_000 as Weight)108 (40_678_000 as Weight)
109 .saturating_add(RocksDbWeight::get().reads(2 as Weight))109 .saturating_add(RocksDbWeight::get().reads(2 as Weight))
110 .saturating_add(RocksDbWeight::get().writes(2 as Weight))110 .saturating_add(RocksDbWeight::get().writes(2 as Weight))
111 }111 }
112 // Storage: Fungible TotalSupply (r:1 w:1)112 // Storage: Fungible TotalSupply (r:1 w:1)
113 // Storage: Fungible Balance (r:4 w:4)113 // Storage: Fungible Balance (r:4 w:4)
114 fn create_multiple_items_ex(b: u32, ) -> Weight {114 fn create_multiple_items_ex(b: u32, ) -> Weight {
115 (13_030_000 as Weight)115 (13_036_000 as Weight)
116 // Standard Error: 1_000116 // Standard Error: 9_000
117 .saturating_add((3_779_000 as Weight).saturating_mul(b as Weight))117 .saturating_add((15_611_000 as Weight).saturating_mul(b as Weight))
118 .saturating_add(RocksDbWeight::get().reads(1 as Weight))118 .saturating_add(RocksDbWeight::get().reads(1 as Weight))
119 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))119 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
120 .saturating_add(RocksDbWeight::get().writes(1 as Weight))120 .saturating_add(RocksDbWeight::get().writes(1 as Weight))
123 // Storage: Fungible TotalSupply (r:1 w:1)123 // Storage: Fungible TotalSupply (r:1 w:1)
124 // Storage: Fungible Balance (r:1 w:1)124 // Storage: Fungible Balance (r:1 w:1)
125 fn burn_item() -> Weight {125 fn burn_item() -> Weight {
126 (15_565_000 as Weight)126 (42_340_000 as Weight)
127 .saturating_add(RocksDbWeight::get().reads(2 as Weight))127 .saturating_add(RocksDbWeight::get().reads(2 as Weight))
128 .saturating_add(RocksDbWeight::get().writes(2 as Weight))128 .saturating_add(RocksDbWeight::get().writes(2 as Weight))
129 }129 }
130
131 // Storage: Fungible Balance (r:2 w:2)130 // Storage: Fungible Balance (r:2 w:2)
132 fn transfer() -> Weight {131 fn transfer() -> Weight {
133 (17_713_000 as Weight)132 (47_321_000 as Weight)
134 .saturating_add(RocksDbWeight::get().reads(2 as Weight))133 .saturating_add(RocksDbWeight::get().reads(2 as Weight))
135 .saturating_add(RocksDbWeight::get().writes(2 as Weight))134 .saturating_add(RocksDbWeight::get().writes(2 as Weight))
136 }135 }
137 // Storage: Fungible Balance (r:1 w:0)136 // Storage: Fungible Balance (r:1 w:0)
138 // Storage: Fungible Allowance (r:0 w:1)137 // Storage: Fungible Allowance (r:0 w:1)
139 fn approve() -> Weight {138 fn approve() -> Weight {
140 (14_834_000 as Weight)139 (38_385_000 as Weight)
141 .saturating_add(RocksDbWeight::get().reads(1 as Weight))140 .saturating_add(RocksDbWeight::get().reads(1 as Weight))
142 .saturating_add(RocksDbWeight::get().writes(1 as Weight))141 .saturating_add(RocksDbWeight::get().writes(1 as Weight))
143 }142 }
144 // Storage: Fungible Allowance (r:1 w:1)143 // Storage: Fungible Allowance (r:1 w:1)
145 // Storage: Fungible Balance (r:2 w:2)144 // Storage: Fungible Balance (r:2 w:2)
146 fn transfer_from() -> Weight {145 fn transfer_from() -> Weight {
147 (25_189_000 as Weight)146 (69_001_000 as Weight)
148 .saturating_add(RocksDbWeight::get().reads(3 as Weight))147 .saturating_add(RocksDbWeight::get().reads(3 as Weight))
149 .saturating_add(RocksDbWeight::get().writes(3 as Weight))148 .saturating_add(RocksDbWeight::get().writes(3 as Weight))
150 }149 }
151 // Storage: Fungible Allowance (r:1 w:1)150 // Storage: Fungible Allowance (r:1 w:1)
152 // Storage: Fungible TotalSupply (r:1 w:1)151 // Storage: Fungible TotalSupply (r:1 w:1)
153 // Storage: Fungible Balance (r:1 w:1)152 // Storage: Fungible Balance (r:1 w:1)
154 fn burn_from() -> Weight {153 fn burn_from() -> Weight {
155 (24_065_000 as Weight)154 (63_996_000 as Weight)
156 .saturating_add(RocksDbWeight::get().reads(3 as Weight))155 .saturating_add(RocksDbWeight::get().reads(3 as Weight))
157 .saturating_add(RocksDbWeight::get().writes(3 as Weight))156 .saturating_add(RocksDbWeight::get().writes(3 as Weight))
158 }157 }
modifiedpallets/scheduler/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/scheduler/src/benchmarking.rs
+++ b/pallets/scheduler/src/benchmarking.rs
@@ -1,23 +1,6 @@
-// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
-// This file is part of Unique Network.
-
-// Unique Network is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Unique Network is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-
-// Original license
 // This file is part of Substrate.
 
-// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2022 Parity Technologies (UK) Ltd.
 // SPDX-License-Identifier: Apache-2.0
 
 // Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,91 +16,203 @@
 // limitations under the License.
 
 //! Scheduler pallet benchmarking.
-
-#![cfg(feature = "runtime-benchmarks")]
 
 use super::*;
-use sp_std::{vec, prelude::*};
+use frame_benchmarking::benchmarks;
+use frame_support::{
+	ensure,
+	traits::{OnInitialize, PreimageProvider, PreimageRecipient},
+};
 use frame_system::RawOrigin;
-use frame_support::{ensure, traits::OnInitialize};
-use frame_benchmarking::{benchmarks, impl_benchmark_test_suite};
+use sp_runtime::traits::Hash;
+use sp_std::{prelude::*, vec};
 
-use crate::Module as Scheduler;
+use crate::Pallet as Scheduler;
 use frame_system::Pallet as System;
 
 const BLOCK_NUMBER: u32 = 2;
 
-// Add `n` named items to the schedule
-fn fill_schedule<T: Config>(when: T::BlockNumber, n: u32) -> Result<(), &'static str> {
-	// Essentially a no-op call.
-	let call = frame_system::Call::set_storage { items: vec![] };
+/// Add `n` named 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> {
 	for i in 0..n {
 		// Named schedule is strictly heavier than anonymous
-		Scheduler::<T>::do_schedule_named(
-			i.encode(),
-			DispatchTime::At(when),
-			// Add periodicity
-			Some((T::BlockNumber::one(), 100)),
-			// HARD_DEADLINE priority means it gets executed no matter what
-			0,
-			frame_system::RawOrigin::Root.into(),
-			call.clone().into(),
-		)?;
+		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().try_into().unwrap_or([0; MAX_TASK_ID_LENGTH_IN_BYTES as usize]),
+			t, period, 0, origin, call_or_hash)?;
+		} else {
+			Scheduler::<T>::do_schedule(t, period, 0, origin, call_or_hash)?;
+		}
 	}
-	ensure!(
-		Agenda::<T>::get(when).len() == n as usize,
-		"didn't fill schedule"
-	);
+	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>::Call, T::Hash) {
+	// Essentially a no-op call.
+	let call: <T as Config>::Call = frame_system::Call::remark { remark: i.encode() }.into();
+	let hash = T::Hashing::hash_of(&call);
+	(call, hash)
+}
+
+
 benchmarks! {
-	schedule {
-		let s in 0 .. T::MaxScheduledPerBlock::get();
+	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);
+		}
+	}
+
+	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);
+	}
+
+	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);
+		}
+	}
+
+	on_initialize_resolved {
+		let s in 1 .. T::MaxScheduledPerBlock::get();
 		let when = BLOCK_NUMBER.into();
-		let periodic = Some((T::BlockNumber::one(), 100));
-		let priority = 0;
-		// Essentially a no-op call.
-		let call = Box::new(frame_system::Call::set_storage { items: vec![] }.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);
+	}
 
-		fill_schedule::<T>(when, s)?;
-	}: _(RawOrigin::Root, when, periodic, priority, call)
+	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 {
-		ensure!(
-			Agenda::<T>::get(when).len() == (s + 1) as usize,
-			"didn't add to schedule"
-		);
+		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);
+		}
+	}
+
+	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);
+		}
+	}
+
+	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()); }
+	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);
+		}
 	}
 
-	cancel {
+	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);
+	}
 
-		fill_schedule::<T>(when, s)?;
-		assert_eq!(Agenda::<T>::get(when).len(), s as usize);
-	}: _(RawOrigin::Root, when, 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 {
-		ensure!(
-			Lookup::<T>::get(0.encode()).is_none(),
-			"didn't remove from lookup"
-		);
-		// Removed schedule is NONE
-		ensure!(
-			Agenda::<T>::get(when)[0].is_none(),
-			"didn't remove from schedule"
-		);
+		assert_eq!(System::<T>::event_count(), s);
+		assert!(Agenda::<T>::iter().count() == 0);
 	}
 
 	schedule_named {
 		let s in 0 .. T::MaxScheduledPerBlock::get();
-		let id = s.encode();
+		let id = s.encode().try_into().unwrap_or([0; MAX_TASK_ID_LENGTH_IN_BYTES as usize]);
 		let when = BLOCK_NUMBER.into();
 		let periodic = Some((T::BlockNumber::one(), 100));
 		let priority = 0;
 		// Essentially a no-op call.
-		let call = Box::new(frame_system::Call::set_storage { items: vec![] }.into());
+		let inner_call = frame_system::Call::set_storage { items: vec![] }.into();
+		let call = Box::new(CallOrHashOf::<T>::Value(inner_call));
 
-		fill_schedule::<T>(when, s)?;
+		fill_schedule::<T>(when, s, true, true, Some(false))?;
 	}: _(RawOrigin::Root, id, when, periodic, priority, call)
 	verify {
 		ensure!(
@@ -129,12 +224,13 @@
 	cancel_named {
 		let s in 1 .. T::MaxScheduledPerBlock::get();
 		let when = BLOCK_NUMBER.into();
+		let id = 0.encode().try_into().unwrap_or([0; MAX_TASK_ID_LENGTH_IN_BYTES as usize]);
 
-		fill_schedule::<T>(when, s)?;
-	}: _(RawOrigin::Root, 0.encode())
+		fill_schedule::<T>(when, s, true, true, Some(false))?;
+	}: _(RawOrigin::Root, id)
 	verify {
 		ensure!(
-			Lookup::<T>::get(0.encode()).is_none(),
+			Lookup::<T>::get(id).is_none(),
 			"didn't remove from lookup"
 		);
 		// Removed schedule is NONE
@@ -144,21 +240,5 @@
 		);
 	}
 
-	// TODO [#7141]: Make this more complex and flexible so it can be used in automation.
-	#[extra]
-	on_initialize {
-		let s in 0 .. T::MaxScheduledPerBlock::get();
-		let when = BLOCK_NUMBER.into();
-		fill_schedule::<T>(when, s)?;
-	}: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }
-	verify {
-		assert_eq!(System::<T>::event_count(), s);
-		// Next block should have all the schedules again
-		ensure!(
-			Agenda::<T>::get(when + T::BlockNumber::one()).len() == s as usize,
-			"didn't append schedule"
-		);
-	}
+	impl_benchmark_test_suite!(Scheduler, crate::mock::new_test_ext(), crate::mock::Test);
 }
-
-impl_benchmark_test_suite!(Scheduler, crate::tests::new_test_ext(), crate::tests::Test,);
modifiedpallets/scheduler/src/lib.rsdiffbeforeafterboth
--- a/pallets/scheduler/src/lib.rs
+++ b/pallets/scheduler/src/lib.rs
@@ -60,9 +60,8 @@
 // Ensure we're `no_std` when compiling for Wasm.
 #![cfg_attr(not(feature = "std"), no_std)]
 
-// FIXME
-// #[cfg(feature = "runtime-benchmarks")]
-// mod benchmarking;
+#[cfg(feature = "runtime-benchmarks")]
+mod benchmarking;
 
 pub mod weights;
 
@@ -639,66 +638,7 @@
 
 		Ok((when, index))
 	}
-
-	fn do_cancel(
-		origin: Option<T::PalletsOrigin>,
-		(when, index): TaskAddress<T::BlockNumber>,
-	) -> Result<(), DispatchError> {
-		let scheduled = Agenda::<T>::try_mutate(when, |agenda| {
-			agenda.get_mut(index as usize).map_or(
-				Ok(None),
-				|s| -> Result<Option<Scheduled<_, _, _, _>>, DispatchError> {
-					if let (Some(ref o), Some(ref s)) = (origin, s.borrow()) {
-						if matches!(
-							T::OriginPrivilegeCmp::cmp_privilege(o, &s.origin),
-							Some(Ordering::Less) | None
-						) {
-							return Err(BadOrigin.into());
-						}
-					};
-					Ok(s.take())
-				},
-			)
-		})?;
-		if let Some(s) = scheduled {
-			s.call.ensure_unrequested::<T::PreimageProvider>();
-			if let Some(id) = s.maybe_id {
-				Lookup::<T>::remove(id);
-			}
-			Self::deposit_event(Event::Canceled { when, index });
-			Ok(())
-		} else {
-			Err(Error::<T>::NotFound)?
-		}
-	}
-
-	fn do_reschedule(
-		(when, index): TaskAddress<T::BlockNumber>,
-		new_time: DispatchTime<T::BlockNumber>,
-	) -> Result<TaskAddress<T::BlockNumber>, DispatchError> {
-		let new_time = Self::resolve_time(new_time)?;
-
-		if new_time == when {
-			return Err(Error::<T>::RescheduleNoChange.into());
-		}
 
-		Agenda::<T>::try_mutate(when, |agenda| -> DispatchResult {
-			let task = agenda.get_mut(index as usize).ok_or(Error::<T>::NotFound)?;
-			let task = task.take().ok_or(Error::<T>::NotFound)?;
-			Agenda::<T>::append(new_time, Some(task));
-			Ok(())
-		})?;
-
-		let new_index = Agenda::<T>::decode_len(new_time).unwrap_or(1) as u32 - 1;
-		Self::deposit_event(Event::Canceled { when, index });
-		Self::deposit_event(Event::Scheduled {
-			when: new_time,
-			index: new_index,
-		});
-
-		Ok((new_time, new_index))
-	}
-
 	fn do_schedule_named(
 		id: ScheduledId,
 		when: DispatchTime<T::BlockNumber>,
@@ -790,124 +730,3 @@
 			}
 		})
 	}
-
-	fn do_reschedule_named(
-		id: ScheduledId,
-		new_time: DispatchTime<T::BlockNumber>,
-	) -> Result<TaskAddress<T::BlockNumber>, DispatchError> {
-		let new_time = Self::resolve_time(new_time)?;
-
-		Lookup::<T>::try_mutate_exists(
-			id,
-			|lookup| -> Result<TaskAddress<T::BlockNumber>, DispatchError> {
-				let (when, index) = lookup.ok_or(Error::<T>::NotFound)?;
-
-				if new_time == when {
-					return Err(Error::<T>::RescheduleNoChange.into());
-				}
-
-				Agenda::<T>::try_mutate(when, |agenda| -> DispatchResult {
-					let task = agenda.get_mut(index as usize).ok_or(Error::<T>::NotFound)?;
-					let task = task.take().ok_or(Error::<T>::NotFound)?;
-					Agenda::<T>::append(new_time, Some(task));
-
-					Ok(())
-				})?;
-
-				let new_index = Agenda::<T>::decode_len(new_time).unwrap_or(1) as u32 - 1;
-				Self::deposit_event(Event::Canceled { when, index });
-				Self::deposit_event(Event::Scheduled {
-					when: new_time,
-					index: new_index,
-				});
-
-				*lookup = Some((new_time, new_index));
-
-				Ok((new_time, new_index))
-			},
-		)
-	}
-}
-
-impl<T: Config> schedule::v2::Anon<T::BlockNumber, <T as Config>::Call, T::PalletsOrigin>
-	for Pallet<T>
-{
-	type Address = TaskAddress<T::BlockNumber>;
-	type Hash = T::Hash;
-
-	fn schedule(
-		when: DispatchTime<T::BlockNumber>,
-		maybe_periodic: Option<schedule::Period<T::BlockNumber>>,
-		priority: schedule::Priority,
-		origin: T::PalletsOrigin,
-		call: CallOrHashOf<T>,
-	) -> Result<Self::Address, DispatchError> {
-		Self::do_schedule(when, maybe_periodic, priority, origin, call)
-	}
-
-	fn cancel((when, index): Self::Address) -> Result<(), ()> {
-		Self::do_cancel(None, (when, index)).map_err(|_| ())
-	}
-
-	fn reschedule(
-		address: Self::Address,
-		when: DispatchTime<T::BlockNumber>,
-	) -> Result<Self::Address, DispatchError> {
-		Self::do_reschedule(address, when)
-	}
-
-	fn next_dispatch_time((when, index): Self::Address) -> Result<T::BlockNumber, ()> {
-		Agenda::<T>::get(when)
-			.get(index as usize)
-			.ok_or(())
-			.map(|_| when)
-	}
-}
-
-impl<T: Config> schedule::v2::Named<T::BlockNumber, <T as Config>::Call, T::PalletsOrigin>
-	for Pallet<T>
-{
-	type Address = TaskAddress<T::BlockNumber>;
-	type Hash = T::Hash;
-
-	fn schedule_named(
-		id: Vec<u8>,
-		when: DispatchTime<T::BlockNumber>,
-		maybe_periodic: Option<schedule::Period<T::BlockNumber>>,
-		priority: schedule::Priority,
-		origin: T::PalletsOrigin,
-		call: CallOrHashOf<T>,
-	) -> Result<Self::Address, ()> {
-		let inner_id: ScheduledId = id
-			.try_into()
-			.unwrap_or([0; MAX_TASK_ID_LENGTH_IN_BYTES as usize]);
-		Self::do_schedule_named(inner_id, when, maybe_periodic, priority, origin, call)
-			.map_err(|_| ())
-	}
-
-	fn cancel_named(id: Vec<u8>) -> Result<(), ()> {
-		let inner_id: ScheduledId = id
-			.try_into()
-			.unwrap_or([0; MAX_TASK_ID_LENGTH_IN_BYTES as usize]);
-		Self::do_cancel_named(None, inner_id).map_err(|_| ())
-	}
-
-	fn reschedule_named(
-		id: Vec<u8>,
-		when: DispatchTime<T::BlockNumber>,
-	) -> Result<Self::Address, DispatchError> {
-		let inner_id: ScheduledId = id
-			.try_into()
-			.unwrap_or([0; MAX_TASK_ID_LENGTH_IN_BYTES as usize]);
-		Self::do_reschedule_named(inner_id, when)
-	}
-
-	fn next_dispatch_time(id: Vec<u8>) -> Result<T::BlockNumber, ()> {
-		let inner_id: ScheduledId = id
-			.try_into()
-			.unwrap_or([0; MAX_TASK_ID_LENGTH_IN_BYTES as usize]);
-		Lookup::<T>::get(inner_id)
-			.and_then(|(when, index)| Agenda::<T>::get(when).get(index as usize).map(|_| when))
-			.ok_or(())
-	}
-}