pallet-scheduler: Ensure we request a preimage (#13340)

* pallet-scheduler: Ensure we request a preimage

The scheduler was not requesting a preimage. When a preimage is requested, a user can deposit it
without paying any fees.

* Review changes
This commit is contained in:
Bastian Köcher
2023-02-09 11:00:55 +01:00
committed by GitHub
parent 00d626c801
commit 214d1c0cc3
3 changed files with 62 additions and 19 deletions
+21 -2
View File
@@ -777,6 +777,8 @@ impl<T: Config> Pallet<T> {
) -> Result<TaskAddress<T::BlockNumber>, DispatchError> {
let when = Self::resolve_time(when)?;
let lookup_hash = call.lookup_hash();
// sanitize maybe_periodic
let maybe_periodic = maybe_periodic
.filter(|p| p.1 > 1 && !p.0.is_zero())
@@ -790,7 +792,14 @@ impl<T: Config> Pallet<T> {
origin,
_phantom: PhantomData,
};
Self::place_task(when, task).map_err(|x| x.0)
let res = Self::place_task(when, task).map_err(|x| x.0)?;
if let Some(hash) = lookup_hash {
// Request the call to be made available.
T::Preimages::request(&hash);
}
Ok(res)
}
fn do_cancel(
@@ -862,6 +871,8 @@ impl<T: Config> Pallet<T> {
let when = Self::resolve_time(when)?;
let lookup_hash = call.lookup_hash();
// sanitize maybe_periodic
let maybe_periodic = maybe_periodic
.filter(|p| p.1 > 1 && !p.0.is_zero())
@@ -876,7 +887,14 @@ impl<T: Config> Pallet<T> {
origin,
_phantom: Default::default(),
};
Self::place_task(when, task).map_err(|x| x.0)
let res = Self::place_task(when, task).map_err(|x| x.0)?;
if let Some(hash) = lookup_hash {
// Request the call to be made available.
T::Preimages::request(&hash);
}
Ok(res)
}
fn do_cancel_named(origin: Option<T::PalletsOrigin>, id: TaskName) -> DispatchResult {
@@ -1027,6 +1045,7 @@ impl<T: Config> Pallet<T> {
} else {
Agenda::<T>::remove(when);
}
postponed == 0
}