Skip to content

Commit 0788d9c

Browse files
tomusdrwkianenigmashawntabrizignunicorngui1117
authored
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>
1 parent 9f55e69 commit 0788d9c

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/tests.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use frame_support::{
3030
storage,
3131
};
3232
use sp_core::H256;
33-
use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header};
33+
use sp_runtime::{traits::{BlakeTwo256, IdentityLookup}, testing::Header};
3434
use crate as utility;
3535

3636
// example module to test behaviors.
@@ -93,12 +93,14 @@ impl_outer_dispatch! {
9393
pub struct Test;
9494
parameter_types! {
9595
pub const BlockHashCount: u64 = 250;
96-
pub const MaximumBlockWeight: Weight = Weight::max_value();
97-
pub const MaximumBlockLength: u32 = 2 * 1024;
98-
pub const AvailableBlockRatio: Perbill = Perbill::one();
96+
pub BlockWeights: frame_system::limits::BlockWeights =
97+
frame_system::limits::BlockWeights::simple_max(Weight::max_value());
9998
}
10099
impl frame_system::Config for Test {
101100
type BaseCallFilter = TestBaseCallFilter;
101+
type BlockWeights = BlockWeights;
102+
type BlockLength = ();
103+
type DbWeight = ();
102104
type Origin = Origin;
103105
type Index = u64;
104106
type BlockNumber = u64;
@@ -110,13 +112,6 @@ impl frame_system::Config for Test {
110112
type Header = Header;
111113
type Event = TestEvent;
112114
type BlockHashCount = BlockHashCount;
113-
type MaximumBlockWeight = MaximumBlockWeight;
114-
type DbWeight = ();
115-
type BlockExecutionWeight = ();
116-
type ExtrinsicBaseWeight = ();
117-
type MaximumExtrinsicWeight = MaximumBlockWeight;
118-
type MaximumBlockLength = MaximumBlockLength;
119-
type AvailableBlockRatio = AvailableBlockRatio;
120115
type Version = ();
121116
type PalletInfo = ();
122117
type AccountData = pallet_balances::AccountData<u64>;
@@ -350,6 +345,7 @@ fn batch_early_exit_works() {
350345

351346
#[test]
352347
fn batch_weight_calculation_doesnt_overflow() {
348+
use sp_runtime::Perbill;
353349
new_test_ext().execute_with(|| {
354350
let big_call = Call::System(SystemCall::fill_block(Perbill::from_percent(50)));
355351
assert_eq!(big_call.get_dispatch_info().weight, Weight::max_value() / 2);

0 commit comments

Comments
 (0)