mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 12:11:09 +00:00
Runtime dependent weights (#5064)
* Copy Substrate weights into each runtime Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Define weights per runtime Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Do the same for test-runtime Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix CI Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Generate multiplier tests via macro Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix CI Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix imports Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix imports Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Change rococo tests to use ExtrinsicBaseWeight Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix imports Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Spellcheck on Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Spellcheck on Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Spellcheck Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Re-Export weight constants in the runtime Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Prepare for cumulus companion Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
committed by
GitHub
parent
078bf68037
commit
2b8f6e9d0a
@@ -16,33 +16,35 @@
|
||||
|
||||
//! Code for elections.
|
||||
|
||||
use super::{BlockExecutionWeight, BlockLength, BlockWeights};
|
||||
use frame_election_provider_support::SortedListProvider;
|
||||
use frame_support::{
|
||||
parameter_types,
|
||||
weights::{DispatchClass, Weight},
|
||||
};
|
||||
use sp_runtime::Perbill;
|
||||
use sp_std::{boxed::Box, convert::From, marker::PhantomData};
|
||||
use sp_std::{boxed::Box, marker::PhantomData};
|
||||
|
||||
parameter_types! {
|
||||
/// A limit for off-chain phragmen unsigned solution submission.
|
||||
///
|
||||
/// We want to keep it as high as possible, but can't risk having it reject,
|
||||
/// so we always subtract the base block execution weight.
|
||||
pub OffchainSolutionWeightLimit: Weight = BlockWeights::get()
|
||||
.get(DispatchClass::Normal)
|
||||
.max_extrinsic
|
||||
.expect("Normal extrinsics have weight limit configured by default; qed")
|
||||
.saturating_sub(BlockExecutionWeight::get());
|
||||
/// Implements the weight types for the elections module and a specific
|
||||
/// runtime.
|
||||
/// This macro should not be called directly; use [`impl_runtime_weights`] instead.
|
||||
#[macro_export]
|
||||
macro_rules! impl_elections_weights {
|
||||
($runtime:ident) => {
|
||||
parameter_types! {
|
||||
/// A limit for off-chain phragmen unsigned solution submission.
|
||||
///
|
||||
/// We want to keep it as high as possible, but can't risk having it reject,
|
||||
/// so we always subtract the base block execution weight.
|
||||
pub OffchainSolutionWeightLimit: Weight = BlockWeights::get()
|
||||
.get(DispatchClass::Normal)
|
||||
.max_extrinsic
|
||||
.expect("Normal extrinsics have weight limit configured by default; qed")
|
||||
.saturating_sub($runtime::weights::BlockExecutionWeight::get());
|
||||
|
||||
/// A limit for off-chain phragmen unsigned solution length.
|
||||
///
|
||||
/// We allow up to 90% of the block's size to be consumed by the solution.
|
||||
pub OffchainSolutionLengthLimit: u32 = Perbill::from_rational(90_u32, 100) *
|
||||
*BlockLength::get()
|
||||
.max
|
||||
.get(DispatchClass::Normal);
|
||||
/// A limit for off-chain phragmen unsigned solution length.
|
||||
///
|
||||
/// We allow up to 90% of the block's size to be consumed by the solution.
|
||||
pub OffchainSolutionLengthLimit: u32 = Perbill::from_rational(90_u32, 100) *
|
||||
*BlockLength::get()
|
||||
.max
|
||||
.get(DispatchClass::Normal);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// The numbers configured here could always be more than the the maximum limits of staking pallet
|
||||
|
||||
Reference in New Issue
Block a user