git.delta.rocks / unique-network / refs/commits / 18b6b278d214

difftreelog

feature: add benchmarks for scheduler v2

Daniel Shiposha2022-10-19parent: #67ae8db.patch.diff
in: master

3 files changed

addedpallets/scheduler-v2/src/benchmarking.rsdiffbeforeafterboth

no changes

modifiedpallets/scheduler-v2/src/lib.rsdiffbeforeafterboth
--- a/pallets/scheduler-v2/src/lib.rs
+++ b/pallets/scheduler-v2/src/lib.rs
@@ -143,6 +143,14 @@
 		}
 	}
 
+	/// Returns whether the image will require a lookup to be peeked.
+	pub fn lookup_needed(&self) -> bool {
+		match self {
+			Self::Inline(_) => false,
+			Self::PreimageLookup { .. } => true,
+		}
+	}
+
 	fn decode(mut data: &[u8]) -> Result<<T as Config>::Call, DispatchError> {
 		<T as Config>::Call::decode(&mut data)
 				.map_err(|_| <Error<T>>::ScheduledCallCorrupted.into())
@@ -153,6 +161,11 @@
     fn drop(call: &ScheduledCall<T>);
 
 	fn peek(call: &ScheduledCall<T>) -> Result<(<T as pallet::Config>::Call, Option<u32>), DispatchError>;
+
+	/// Convert the given scheduled `call` value back into its original instance. If successful,
+	/// `drop` any data backing it. This will not break the realisability of independently
+	/// created instances of `ScheduledCall` which happen to have identical data.
+	fn realize(call: &ScheduledCall<T>) -> Result<(<T as pallet::Config>::Call, Option<u32>), DispatchError>;
 }
 
 impl<T: Config, PP: PreimageRecipient<T::Hash>> SchedulerPreimages<T> for PP {
@@ -175,6 +188,12 @@
 			},
 		}
 	}
+
+	fn realize(call: &ScheduledCall<T>) -> Result<(<T as pallet::Config>::Call, Option<u32>), DispatchError> {
+		let r = Self::peek(call)?;
+		Self::drop(call);
+		Ok(r)
+	}
 }
 
 pub type TaskName = [u8; 32];
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -42,6 +42,7 @@
     'pallet-inflation/runtime-benchmarks',
     'pallet-app-promotion/runtime-benchmarks',
     'pallet-unique-scheduler/runtime-benchmarks',
+    'pallet-unique-scheduler-v2/runtime-benchmarks',
     'pallet-xcm/runtime-benchmarks',
     'sp-runtime/runtime-benchmarks',
     'xcm-builder/runtime-benchmarks',