Skip to content

Commit 40f124f

Browse files
ggwpezactions-user
andauthored
Fix scheduler weight and add test (#614)
- **Add test to collectives pallet** - **Manually edit scheduler weight** ## Investigation The Rust compiler changed how the `stringify!` macro formats paths on [Aug 12th '24](rust-lang/rust#128992 (comment)). I assume that this broke the V1 benchmarking [here](https://github.com/paritytech/polkadot-sdk/blob/7ecf3f757a5d6f622309cea7f788e8a547a5dce8/substrate/frame/benchmarking/src/v1.rs#L1011). We had updated the scheduler pallet to V2 syntax (which is [not affected](https://github.com/paritytech/polkadot-sdk/blob/df99fb9431a579589c1c87832222c9551b5c4f7c/substrate/frame/support/procedural/src/benchmark.rs#L565)) on [Nov 20th '24](paritytech/polkadot-sdk#6292). We did not back-port this since there was no apparent reason for it. The is why it seemingly fixed it self on SDK master but not in the runtimes repo (since that is using V1 scheduler benchmarking). Another indication for this is the fact that it did work on the [whitelist pallet](https://github.com/polkadot-fellows/runtimes/blob/6b85bf6adb427942976648e6d235e0169dfced16/relay/polkadot/src/weights/pallet_whitelist.rs#L85), which is on V2 much longer but used the same [custom pov mode](https://github.com/paritytech/polkadot-sdk/blob/b76e91acc953e682b3ddcfc45ecacaaf26c694a1/substrate/frame/whitelist/src/benchmarking.rs#L68). Adding some sanity checks to prevent this in the future here paritytech/polkadot-sdk#7785 - [ ] Does not require a CHANGELOG entry --------- Signed-off-by: Oliver Tale-Yazdi <[email protected]> Co-authored-by: GitHub Action <[email protected]>
1 parent 6b85bf6 commit 40f124f

File tree

3 files changed

+93
-62
lines changed

3 files changed

+93
-62
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Changelog for the runtimes governed by the Polkadot Fellowship.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## [Unreleased]
8+
9+
### Fixed
10+
11+
- Correct weights of the scheduler pallet to avoid failing fellowship proposals ([polkadot-fellows/runtimes#614](https://github.com/polkadot-fellows/runtimes/pull/614))
12+
713
## [1.4.1] 26.02.2025
814

915
### Fixed

system-parachains/collectives/collectives-polkadot/src/lib.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,3 +1311,30 @@ fn test_transasction_byte_fee_is_one_twentieth_of_relay() {
13111311
let parachain_tbf = TransactionByteFee::get();
13121312
assert_eq!(relay_tbf / 20, parachain_tbf);
13131313
}
1314+
1315+
#[test]
1316+
fn scheduler_weight_is_sane() {
1317+
use pallet_scheduler::WeightInfo;
1318+
type W = <Runtime as pallet_scheduler::Config>::WeightInfo;
1319+
1320+
fn lookup_weight(s: u32) -> Weight {
1321+
W::service_agendas_base() +
1322+
W::service_agenda_base(
1323+
<Runtime as pallet_scheduler::Config>::MaxScheduledPerBlock::get(),
1324+
) + W::service_task_base() +
1325+
W::service_task_fetched(s) +
1326+
W::service_task_named() +
1327+
W::service_task_periodic()
1328+
}
1329+
1330+
let limit = Perbill::from_percent(90) * MaximumSchedulerWeight::get();
1331+
1332+
let small_lookup = lookup_weight(128);
1333+
assert!(small_lookup.all_lte(limit), "Must be possible to submit a small lookup");
1334+
1335+
let medium_lookup = lookup_weight(1024);
1336+
assert!(medium_lookup.all_lte(limit), "Must be possible to submit a medium lookup");
1337+
1338+
let large_lookup = lookup_weight(1024 * 1024);
1339+
assert!(large_lookup.all_lte(limit), "Must be possible to submit a large lookup");
1340+
}

system-parachains/collectives/collectives-polkadot/src/weights/pallet_scheduler.rs

Lines changed: 60 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)