Companion for #6629 (weight params refactor) (#1420)

* Change branch.

* Update runtime.

* Revert "Change branch."

This reverts commit 841c59f3398136c27cc235a29d7d459e8a4c8ce0.

* Update substrate.

* Fix tests.

* Fix compilation.

* Fix frame system imports.

* Fix usages of system

* Fix stuff.

* Fix compilation.

* Fixes.

* Fix block_weight usage.

* Bump substrate.
This commit is contained in:
Tomasz Drwięga
2020-12-08 13:55:57 +01:00
committed by GitHub
parent 48746afd6a
commit f28333aedb
18 changed files with 298 additions and 332 deletions
+7 -6
View File
@@ -87,8 +87,8 @@ pub mod fee {
#[cfg(test)]
mod tests {
use frame_support::weights::WeightToFeePolynomial;
use runtime_common::{MaximumBlockWeight, ExtrinsicBaseWeight};
use frame_support::weights::{WeightToFeePolynomial, DispatchClass};
use runtime_common::BlockWeights;
use super::fee::WeightToFee;
use super::currency::{CENTS, DOLLARS, MILLICENTS};
@@ -96,8 +96,8 @@ mod tests {
// This function tests that the fee for `MaximumBlockWeight` of weight is correct
fn full_block_fee_is_correct() {
// A full block should cost 16 DOLLARS
println!("Base: {}", ExtrinsicBaseWeight::get());
let x = WeightToFee::calc(&MaximumBlockWeight::get());
println!("Base: {}", BlockWeights::get().get(DispatchClass::Normal).base_extrinsic);
let x = WeightToFee::calc(&BlockWeights::get().max_block);
let y = 16 * DOLLARS;
assert!(x.max(y) - x.min(y) < MILLICENTS);
}
@@ -106,8 +106,9 @@ mod tests {
// This function tests that the fee for `ExtrinsicBaseWeight` of weight is correct
fn extrinsic_base_fee_is_correct() {
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
println!("Base: {}", ExtrinsicBaseWeight::get());
let x = WeightToFee::calc(&ExtrinsicBaseWeight::get());
let base_weight = BlockWeights::get().get(DispatchClass::Normal).base_extrinsic;
println!("Base: {}", base_weight);
let x = WeightToFee::calc(&base_weight);
let y = CENTS / 10;
assert!(x.max(y) - x.min(y) < MILLICENTS);
}
+6 -11
View File
@@ -33,8 +33,7 @@ use primitives::v1::{
use runtime_common::{
SlowAdjustingFeeUpdate,
impls::ToAuthor,
BlockHashCount, MaximumBlockWeight, AvailableBlockRatio, MaximumBlockLength,
BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, MaximumExtrinsicWeight,
BlockHashCount, BlockWeights, BlockLength, RocksDbWeight, OffchainSolutionWeightLimit,
};
use runtime_parachains::{
self,
@@ -212,6 +211,9 @@ parameter_types! {
impl frame_system::Config for Runtime {
type BaseCallFilter = BaseFilter;
type BlockWeights = BlockWeights;
type BlockLength = BlockLength;
type DbWeight = RocksDbWeight;
type Origin = Origin;
type Call = Call;
type Index = Nonce;
@@ -223,13 +225,6 @@ impl frame_system::Config for Runtime {
type Header = generic::Header<BlockNumber, BlakeTwo256>;
type Event = Event;
type BlockHashCount = BlockHashCount;
type MaximumBlockWeight = MaximumBlockWeight;
type DbWeight = RocksDbWeight;
type BlockExecutionWeight = BlockExecutionWeight;
type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = Version;
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
@@ -364,7 +359,7 @@ impl pallet_staking::Config for Runtime {
type Call = Call;
type UnsignedPriority = StakingUnsignedPriority;
type MaxIterations = MaxIterations;
type OffchainSolutionWeightLimit = MaximumBlockWeight;
type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit;
type MinSolutionScoreBump = MinSolutionScoreBump;
type WeightInfo = ();
}
@@ -398,7 +393,7 @@ parameter_types! {
}
parameter_types! {
pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * BlockWeights::get().max_block;
}
impl pallet_offences::Config for Runtime {