Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Scheduler pre block limit note #13231

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,10 @@ impl pallet_scheduler::Config for Runtime {
type RuntimeCall = RuntimeCall;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
#[cfg(feature = "runtime-benchmarks")]
type MaxScheduledPerBlock = ConstU32<512>;
#[cfg(not(feature = "runtime-benchmarks"))]
type MaxScheduledPerBlock = ConstU32<50>;
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
type OriginPrivilegeCmp = EqualPrivilegeOnly;
type Preimages = Preimage;
Expand Down
15 changes: 7 additions & 8 deletions frame/referenda/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,22 +874,21 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
let when = (when.saturating_add(alarm_interval.saturating_sub(One::one())) /
alarm_interval)
.saturating_mul(alarm_interval);
let maybe_result = T::Scheduler::schedule(
let result = T::Scheduler::schedule(
DispatchTime::At(when),
None,
128u8,
frame_system::RawOrigin::Root.into(),
call,
)
.ok()
.map(|x| (when, x));
);
debug_assert!(
maybe_result.is_some(),
"Unable to schedule a new alarm at #{:?} (now: #{:?})?!",
result.is_ok(),
"Unable to schedule a new alarm at #{:?} (now: #{:?}), scheduler error: `{:?}`",
when,
frame_system::Pallet::<T>::block_number()
frame_system::Pallet::<T>::block_number(),
result.unwrap_err(),
);
maybe_result
result.ok().map(|x| (when, x))
}

/// Mutate a referendum's `status` into the correct deciding state.
Expand Down
4 changes: 4 additions & 0 deletions frame/scheduler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ pub mod pallet {
type OriginPrivilegeCmp: PrivilegeCmp<Self::PalletsOrigin>;

/// The maximum number of scheduled calls in the queue for a single block.
///
/// NOTE:
/// + Dependent pallets' benchmarks might require a higher limit for the setting. Set a
/// higher limit under `runtime-benchmarks` feature.
#[pallet::constant]
type MaxScheduledPerBlock: Get<u32>;

Expand Down