Skip to content

Fix scheduler weight and add test #614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 4, 2025
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Changelog for the runtimes governed by the Polkadot Fellowship.

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

## [Unreleased]

### Fixed

- Correct weights of the scheduler pallet to avoid failing fellowship proposals ([polkadot-fellows/runtimes#614](https://github.com/polkadot-fellows/runtimes/pull/614))

## [1.4.1] 26.02.2025

### Fixed
Expand Down
27 changes: 27 additions & 0 deletions system-parachains/collectives/collectives-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1311,3 +1311,30 @@ fn test_transasction_byte_fee_is_one_twentieth_of_relay() {
let parachain_tbf = TransactionByteFee::get();
assert_eq!(relay_tbf / 20, parachain_tbf);
}

#[test]
fn scheduler_weight_is_sane() {
use pallet_scheduler::WeightInfo;
type W = <Runtime as pallet_scheduler::Config>::WeightInfo;

fn lookup_weight(s: u32) -> Weight {
W::service_agendas_base() +
W::service_agenda_base(
<Runtime as pallet_scheduler::Config>::MaxScheduledPerBlock::get(),
) + W::service_task_base() +
W::service_task_fetched(s) +
W::service_task_named() +
W::service_task_periodic()
}

let limit = Perbill::from_percent(90) * MaximumSchedulerWeight::get();

let small_lookup = lookup_weight(128);
assert!(small_lookup.all_lte(limit), "Must be possible to submit a small lookup");

let medium_lookup = lookup_weight(1024);
assert!(medium_lookup.all_lte(limit), "Must be possible to submit a medium lookup");

let large_lookup = lookup_weight(1024 * 1024);
assert!(large_lookup.all_lte(limit), "Must be possible to submit a large lookup");
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading