Skip to content

Commit da36e2a

Browse files
muharemnathanwhit
authored andcommitted
Scheduler pre block limit note (paritytech#13231)
Co-authored-by: parity-processbot <>
1 parent be82359 commit da36e2a

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

bin/node/runtime/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,10 @@ impl pallet_scheduler::Config for Runtime {
364364
type RuntimeCall = RuntimeCall;
365365
type MaximumWeight = MaximumSchedulerWeight;
366366
type ScheduleOrigin = EnsureRoot<AccountId>;
367+
#[cfg(feature = "runtime-benchmarks")]
367368
type MaxScheduledPerBlock = ConstU32<512>;
369+
#[cfg(not(feature = "runtime-benchmarks"))]
370+
type MaxScheduledPerBlock = ConstU32<50>;
368371
type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
369372
type OriginPrivilegeCmp = EqualPrivilegeOnly;
370373
type Preimages = Preimage;

frame/referenda/src/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -874,22 +874,21 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
874874
let when = (when.saturating_add(alarm_interval.saturating_sub(One::one())) /
875875
alarm_interval)
876876
.saturating_mul(alarm_interval);
877-
let maybe_result = T::Scheduler::schedule(
877+
let result = T::Scheduler::schedule(
878878
DispatchTime::At(when),
879879
None,
880880
128u8,
881881
frame_system::RawOrigin::Root.into(),
882882
call,
883-
)
884-
.ok()
885-
.map(|x| (when, x));
883+
);
886884
debug_assert!(
887-
maybe_result.is_some(),
888-
"Unable to schedule a new alarm at #{:?} (now: #{:?})?!",
885+
result.is_ok(),
886+
"Unable to schedule a new alarm at #{:?} (now: #{:?}), scheduler error: `{:?}`",
889887
when,
890-
frame_system::Pallet::<T>::block_number()
888+
frame_system::Pallet::<T>::block_number(),
889+
result.unwrap_err(),
891890
);
892-
maybe_result
891+
result.ok().map(|x| (when, x))
893892
}
894893

895894
/// Mutate a referendum's `status` into the correct deciding state.

frame/scheduler/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ pub mod pallet {
216216
type OriginPrivilegeCmp: PrivilegeCmp<Self::PalletsOrigin>;
217217

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

0 commit comments

Comments
 (0)