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

Runtime dependent weights #5064

Merged
merged 20 commits into from
Mar 11, 2022
Merged

Runtime dependent weights #5064

merged 20 commits into from
Mar 11, 2022

Conversation

ggwpez
Copy link
Member

@ggwpez ggwpez commented Mar 9, 2022

This MR makes the BlockExecution, ExtrinsicBase, RocksDb and ParityDb Weights runtime dependent.
Later on paritytech/substrate#10977 will be used to generate weights for each runtime instead of using the Substrate defaults.

Changes:

  • Copy the Substrate weights from frame_support into each *_runtime_constants module
  • Move the parameter weight types out of runtime_common into each runtime with a new impl_runtime_weights! macro
  • Make NORMAL_DISPATCH_RATIO public since it is mentioned in the doc of TargetBlockFullness. Can make it private again if that is better.
  • Fix some test in rococo

I checked that the runtime did not change: #5064 (comment), CI confirmation would still be appreciated.

cumulus companion: paritytech/cumulus#1076

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
@ggwpez ggwpez added I8-refactor Code needs refactoring. A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit. labels Mar 9, 2022
@ggwpez ggwpez requested a review from shawntabrizi March 9, 2022 11:45
@ggwpez ggwpez added the B0-silent Changes should not be mentioned in any release notes label Mar 9, 2022
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
@@ -71,53 +64,76 @@ pub type NegativeImbalance<T> = <pallet_balances::Pallet<T> as Currency<
pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(1);
/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used
/// by Operational extrinsics.
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
Copy link
Member Author

@ggwpez ggwpez Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only intended logic change.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
println!("Base: {}", BlockWeights::get().get(DispatchClass::Normal).base_extrinsic);
let x = WeightToFee::calc(&BlockWeights::get().max_block);
println!("Base: {}", ExtrinsicBaseWeight::get());
let x = WeightToFee::calc(&MAXIMUM_BLOCK_WEIGHT);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test here looks weird so I changed it to look like in the other runtimes; in polkadot, kusama and westend it is all done this way.
Could also be macro generated 🤷

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
ggwpez and others added 2 commits March 9, 2022 20:19
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
@shawntabrizi
Copy link
Member

would be good to sanity check the metadata constants have not changed with regard to these weight parameters.

@ggwpez
Copy link
Member Author

ggwpez commented Mar 9, 2022

Waiting for this to be resolved, since cumulus should 🤞 already build with this version: #5037 (comment)

would be good to sanity check the metadata constants have not changed with regard to these weight parameters.

I will extract the metadata manually and check but CI would be much preferred.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
@ggwpez
Copy link
Member Author

ggwpez commented Mar 10, 2022

I wrote a small script to compare the metadata between branches and there is no change for kusama-dev, westend-dev,
polkadot-dev, rococo-dev. compare.sh.txt maybe the CI devs can reuse that somehow.

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't look at the whole diff, but sounds right to me, and much cleaner now 👍

@ggwpez
Copy link
Member Author

ggwpez commented Mar 11, 2022

bot merge

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit. I8-refactor Code needs refactoring.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants