Streamline frame_system weight parametrization (#6629)

* Basic weights builder.

* Fixing WiP

* Make the tests work.

* Fix weights in node/runtime.

* WiP.

* Update pallets with new weights parameters.

* Validate returns a Result now.

* Count mandatory weight separately.

* DRY

* BREAKING: Updating state root, because of the left-over weight-tracking stuff

* Update tests affected by Mandatory tracking.

* Fixing tests.

* Fix defaults for simple_max

* Update frame/system/src/weights.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Rework the API a bit.

* Fix compilation & tests.

* Apply suggestions from code review

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Add extra docs & rename few things.

* Fix whitespace in ASCII art.

* Update frame/system/src/limits.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Fix max_extrinsic calculations.

* Fix conflicts.

* Fix compilation.

* Fix new code.

* re-remove generic asset

* Fix usage.

* Update state root.

* Update proxy.

* Fix tests.

* Move weights validity to integrity_test

* Remove redundant BlockWeights.

* Add all/non_mandatory comment

* Add test.

* Remove fn block_weights

* Make the macro prettier.

* Fix some docs.

* Make max_total behave more predictabily.

* Add BlockWeights to metadata.

* fix balances test

* Fix utility test.

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Benjamin Kampmann <ben@gnunicorn.org>
Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Tomasz Drwięga
2020-12-08 13:18:34 +01:00
committed by GitHub
parent f6198b4c1b
commit 39a776cd00
66 changed files with 1275 additions and 929 deletions
+12 -2
View File
@@ -521,7 +521,12 @@ benchmarks! {
compact,
score,
size
) = offchain_election::prepare_submission::<T>(assignments, winners, false, T::MaximumBlockWeight::get()).unwrap();
) = offchain_election::prepare_submission::<T>(
assignments,
winners,
false,
T::BlockWeights::get().max_block,
).unwrap();
assert_eq!(
winners.len(), compact.unique_targets().len(),
@@ -589,7 +594,12 @@ benchmarks! {
compact,
score,
size
) = offchain_election::prepare_submission::<T>(assignments, winners, false, T::MaximumBlockWeight::get()).unwrap();
) = offchain_election::prepare_submission::<T>(
assignments,
winners,
false,
T::BlockWeights::get().max_block,
).unwrap();
assert_eq!(
winners.len(), compact.unique_targets().len(),
+8 -11
View File
@@ -129,9 +129,10 @@ pub struct Test;
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: Weight = frame_support::weights::constants::WEIGHT_PER_SECOND * 2;
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(
frame_support::weights::constants::WEIGHT_PER_SECOND * 2
);
pub const MaxLocks: u32 = 1024;
pub static SessionsPerEra: SessionIndex = 3;
pub static ExistentialDeposit: Balance = 0;
@@ -143,6 +144,9 @@ parameter_types! {
impl frame_system::Config for Test {
type BaseCallFilter = ();
type BlockWeights = ();
type BlockLength = ();
type DbWeight = RocksDbWeight;
type Origin = Origin;
type Index = AccountIndex;
type BlockNumber = BlockNumber;
@@ -154,13 +158,6 @@ impl frame_system::Config for Test {
type Header = Header;
type Event = MetaEvent;
type BlockHashCount = BlockHashCount;
type MaximumBlockWeight = MaximumBlockWeight;
type DbWeight = RocksDbWeight;
type BlockExecutionWeight = ();
type ExtrinsicBaseWeight = ();
type MaximumExtrinsicWeight = MaximumBlockWeight;
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<Balance>;
@@ -235,7 +232,7 @@ parameter_types! {
pub const MaxNominatorRewardedPerValidator: u32 = 64;
pub const UnsignedPriority: u64 = 1 << 20;
pub const MinSolutionScoreBump: Perbill = Perbill::zero();
pub const OffchainSolutionWeightLimit: Weight = MaximumBlockWeight::get();
pub OffchainSolutionWeightLimit: Weight = BlockWeights::get().max_block;
}
thread_local! {
+1 -1
View File
@@ -301,7 +301,7 @@ pub fn get_seq_phragmen_solution<T: Config>(
assignments,
winners,
do_reduce,
T::MaximumBlockWeight::get(),
T::BlockWeights::get().max_block,
)
.unwrap()
}