Skip to content

Commit 988103d

Browse files
authored
Use aggregated types for RuntimeFreezeReason and better examples of MaxFreezes (#4615)
This PR aligns the settings for `MaxFreezes`, `RuntimeFreezeReason`, and `FreezeIdentifier`. #### Future work and improvements #2997 (remove `MaxFreezes` and `FreezeIdentifier`)
1 parent eca1052 commit 988103d

File tree

85 files changed

+177
-885
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+177
-885
lines changed

bridges/modules/messages/src/mock.rs

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ impl frame_system::Config for TestRuntime {
8686

8787
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
8888
impl pallet_balances::Config for TestRuntime {
89-
type ReserveIdentifier = [u8; 8];
9089
type AccountStore = System;
9190
}
9291

bridges/snowbridge/pallets/inbound-queue/src/mock.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,11 @@ parameter_types! {
5353
pub const ExistentialDeposit: u128 = 1;
5454
}
5555

56+
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
5657
impl pallet_balances::Config for Test {
57-
type MaxLocks = ();
58-
type MaxReserves = ();
59-
type ReserveIdentifier = [u8; 8];
6058
type Balance = Balance;
61-
type RuntimeEvent = RuntimeEvent;
62-
type DustRemoval = ();
6359
type ExistentialDeposit = ExistentialDeposit;
6460
type AccountStore = System;
65-
type WeightInfo = ();
66-
type FreezeIdentifier = ();
67-
type MaxFreezes = ();
68-
type RuntimeHoldReason = ();
69-
type RuntimeFreezeReason = ();
7061
}
7162

7263
parameter_types! {

bridges/snowbridge/pallets/system/src/mock.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,11 @@ impl frame_system::Config for Test {
112112
type Block = Block;
113113
}
114114

115+
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
115116
impl pallet_balances::Config for Test {
116-
type MaxLocks = ();
117-
type MaxReserves = ();
118-
type ReserveIdentifier = [u8; 8];
119117
type Balance = Balance;
120-
type RuntimeEvent = RuntimeEvent;
121-
type DustRemoval = ();
122118
type ExistentialDeposit = ConstU128<1>;
123119
type AccountStore = System;
124-
type WeightInfo = ();
125-
type FreezeIdentifier = ();
126-
type MaxFreezes = ();
127-
type RuntimeHoldReason = ();
128-
type RuntimeFreezeReason = ();
129120
}
130121

131122
impl pallet_xcm_origin::Config for Test {

cumulus/pallets/collator-selection/src/mock.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,12 @@ impl system::Config for Test {
5353

5454
parameter_types! {
5555
pub const ExistentialDeposit: u64 = 5;
56-
pub const MaxReserves: u32 = 50;
5756
}
5857

58+
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
5959
impl pallet_balances::Config for Test {
60-
type Balance = u64;
61-
type RuntimeEvent = RuntimeEvent;
62-
type DustRemoval = ();
6360
type ExistentialDeposit = ExistentialDeposit;
6461
type AccountStore = System;
65-
type WeightInfo = ();
66-
type MaxLocks = ();
67-
type MaxReserves = MaxReserves;
68-
type ReserveIdentifier = [u8; 8];
69-
type RuntimeHoldReason = RuntimeHoldReason;
70-
type RuntimeFreezeReason = RuntimeFreezeReason;
71-
type FreezeIdentifier = ();
72-
type MaxFreezes = ConstU32<0>;
7362
}
7463

7564
pub struct Author4;

cumulus/pallets/xcmp-queue/src/mock.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,14 @@ impl frame_system::Config for Test {
8585

8686
parameter_types! {
8787
pub const ExistentialDeposit: u64 = 5;
88-
pub const MaxReserves: u32 = 50;
8988
}
9089

9190
pub type Balance = u64;
9291

92+
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
9393
impl pallet_balances::Config for Test {
94-
type Balance = Balance;
95-
type RuntimeEvent = RuntimeEvent;
96-
type DustRemoval = ();
9794
type ExistentialDeposit = ExistentialDeposit;
9895
type AccountStore = System;
99-
type WeightInfo = ();
100-
type MaxLocks = ();
101-
type MaxReserves = MaxReserves;
102-
type ReserveIdentifier = [u8; 8];
103-
type RuntimeHoldReason = RuntimeHoldReason;
104-
type RuntimeFreezeReason = RuntimeFreezeReason;
105-
type FreezeIdentifier = ();
106-
type MaxFreezes = ConstU32<0>;
10796
}
10897

10998
impl cumulus_pallet_parachain_system::Config for Test {

cumulus/parachains/common/src/impls.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ mod tests {
202202
use frame_system::{limits, EnsureRoot};
203203
use pallet_collator_selection::IdentityCollator;
204204
use polkadot_primitives::AccountId;
205-
use sp_core::{ConstU64, H256};
205+
use sp_core::H256;
206206
use sp_runtime::{
207207
traits::{BlakeTwo256, IdentityLookup},
208208
BuildStorage, Perbill,
@@ -224,7 +224,6 @@ mod tests {
224224
parameter_types! {
225225
pub BlockLength: limits::BlockLength = limits::BlockLength::max(2 * 1024);
226226
pub const AvailableBlockRatio: Perbill = Perbill::one();
227-
pub const MaxReserves: u32 = 50;
228227
}
229228

230229
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
@@ -253,20 +252,9 @@ mod tests {
253252
type MaxConsumers = frame_support::traits::ConstU32<16>;
254253
}
255254

255+
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
256256
impl pallet_balances::Config for Test {
257-
type Balance = u64;
258-
type RuntimeEvent = RuntimeEvent;
259-
type DustRemoval = ();
260-
type ExistentialDeposit = ConstU64<1>;
261257
type AccountStore = System;
262-
type MaxLocks = ();
263-
type WeightInfo = ();
264-
type MaxReserves = MaxReserves;
265-
type ReserveIdentifier = [u8; 8];
266-
type RuntimeHoldReason = RuntimeHoldReason;
267-
type RuntimeFreezeReason = RuntimeFreezeReason;
268-
type FreezeIdentifier = ();
269-
type MaxFreezes = ConstU32<1>;
270258
}
271259

272260
pub struct OneAuthor;

polkadot/runtime/common/src/assigned_slots/mod.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -698,24 +698,9 @@ mod tests {
698698
type MaxConsumers = frame_support::traits::ConstU32<16>;
699699
}
700700

701-
parameter_types! {
702-
pub const ExistentialDeposit: u64 = 1;
703-
}
704-
701+
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
705702
impl pallet_balances::Config for Test {
706-
type Balance = u64;
707-
type RuntimeEvent = RuntimeEvent;
708-
type DustRemoval = ();
709-
type ExistentialDeposit = ExistentialDeposit;
710703
type AccountStore = System;
711-
type WeightInfo = ();
712-
type MaxLocks = ();
713-
type MaxReserves = ();
714-
type ReserveIdentifier = [u8; 8];
715-
type RuntimeHoldReason = RuntimeHoldReason;
716-
type RuntimeFreezeReason = RuntimeFreezeReason;
717-
type FreezeIdentifier = ();
718-
type MaxFreezes = ConstU32<1>;
719704
}
720705

721706
impl parachains_configuration::Config for Test {

polkadot/runtime/common/src/auctions.rs

+6-20
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ mod tests {
674674
use frame_support::{
675675
assert_noop, assert_ok, assert_storage_noop, derive_impl, ord_parameter_types,
676676
parameter_types,
677-
traits::{ConstU32, EitherOfDiverse, OnFinalize, OnInitialize},
677+
traits::{EitherOfDiverse, OnFinalize, OnInitialize},
678678
};
679679
use frame_system::{EnsureRoot, EnsureSignedBy};
680680
use pallet_balances;
@@ -725,25 +725,9 @@ mod tests {
725725
type MaxConsumers = frame_support::traits::ConstU32<16>;
726726
}
727727

728-
parameter_types! {
729-
pub const ExistentialDeposit: u64 = 1;
730-
pub const MaxReserves: u32 = 50;
731-
}
732-
728+
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
733729
impl pallet_balances::Config for Test {
734-
type Balance = u64;
735-
type DustRemoval = ();
736-
type RuntimeEvent = RuntimeEvent;
737-
type ExistentialDeposit = ExistentialDeposit;
738730
type AccountStore = System;
739-
type WeightInfo = ();
740-
type MaxLocks = ();
741-
type MaxReserves = MaxReserves;
742-
type ReserveIdentifier = [u8; 8];
743-
type RuntimeHoldReason = RuntimeHoldReason;
744-
type RuntimeFreezeReason = RuntimeFreezeReason;
745-
type FreezeIdentifier = ();
746-
type MaxFreezes = ConstU32<1>;
747731
}
748732

749733
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug)]
@@ -1426,7 +1410,8 @@ mod tests {
14261410
#[test]
14271411
fn initialize_winners_in_ending_period_works() {
14281412
new_test_ext().execute_with(|| {
1429-
assert_eq!(<Test as pallet_balances::Config>::ExistentialDeposit::get(), 1);
1413+
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
1414+
assert_eq!(ed, 1);
14301415
run_to_block(1);
14311416
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 1));
14321417
let para_1 = ParaId::from(1_u32);
@@ -1539,7 +1524,8 @@ mod tests {
15391524
#[test]
15401525
fn less_winning_samples_work() {
15411526
new_test_ext().execute_with(|| {
1542-
assert_eq!(<Test as pallet_balances::Config>::ExistentialDeposit::get(), 1);
1527+
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
1528+
assert_eq!(ed, 1);
15431529
EndingPeriod::set(30);
15441530
SampleLength::set(10);
15451531

polkadot/runtime/common/src/claims.rs

+2-17
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ mod tests {
708708
assert_err, assert_noop, assert_ok, derive_impl,
709709
dispatch::{GetDispatchInfo, Pays},
710710
ord_parameter_types, parameter_types,
711-
traits::{ConstU32, ExistenceRequirement, WithdrawReasons},
711+
traits::{ExistenceRequirement, WithdrawReasons},
712712
};
713713
use pallet_balances;
714714
use sp_runtime::{
@@ -738,24 +738,9 @@ mod tests {
738738
type MaxConsumers = frame_support::traits::ConstU32<16>;
739739
}
740740

741-
parameter_types! {
742-
pub const ExistentialDeposit: u64 = 1;
743-
}
744-
741+
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
745742
impl pallet_balances::Config for Test {
746-
type Balance = u64;
747-
type RuntimeEvent = RuntimeEvent;
748-
type DustRemoval = ();
749-
type ExistentialDeposit = ExistentialDeposit;
750743
type AccountStore = System;
751-
type MaxLocks = ();
752-
type MaxReserves = ();
753-
type ReserveIdentifier = [u8; 8];
754-
type WeightInfo = ();
755-
type RuntimeHoldReason = RuntimeHoldReason;
756-
type RuntimeFreezeReason = RuntimeFreezeReason;
757-
type FreezeIdentifier = ();
758-
type MaxFreezes = ConstU32<1>;
759744
}
760745

761746
parameter_types! {

polkadot/runtime/common/src/crowdloan/mod.rs

+5-19
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ mod tests {
860860

861861
use frame_support::{
862862
assert_noop, assert_ok, derive_impl, parameter_types,
863-
traits::{ConstU32, OnFinalize, OnInitialize},
863+
traits::{OnFinalize, OnInitialize},
864864
};
865865
use polkadot_primitives::Id as ParaId;
866866
use sp_core::H256;
@@ -918,24 +918,9 @@ mod tests {
918918
type MaxConsumers = frame_support::traits::ConstU32<16>;
919919
}
920920

921-
parameter_types! {
922-
pub const ExistentialDeposit: u64 = 1;
923-
}
924-
921+
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
925922
impl pallet_balances::Config for Test {
926-
type Balance = u64;
927-
type RuntimeEvent = RuntimeEvent;
928-
type DustRemoval = ();
929-
type ExistentialDeposit = ExistentialDeposit;
930923
type AccountStore = System;
931-
type MaxLocks = ();
932-
type MaxReserves = ();
933-
type ReserveIdentifier = [u8; 8];
934-
type WeightInfo = ();
935-
type RuntimeHoldReason = RuntimeHoldReason;
936-
type RuntimeFreezeReason = RuntimeFreezeReason;
937-
type FreezeIdentifier = ();
938-
type MaxFreezes = ConstU32<1>;
939924
}
940925

941926
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
@@ -980,7 +965,7 @@ mod tests {
980965
let fund = Funds::<Test>::get(para).unwrap();
981966
let account_id = Crowdloan::fund_account_id(fund.fund_index);
982967
if winner {
983-
let ed = <Test as pallet_balances::Config>::ExistentialDeposit::get();
968+
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
984969
let free_balance = Balances::free_balance(&account_id);
985970
Balances::reserve(&account_id, free_balance - ed)
986971
.expect("should be able to reserve free balance minus ED");
@@ -1815,7 +1800,8 @@ mod tests {
18151800
#[test]
18161801
fn withdraw_from_finished_works() {
18171802
new_test_ext().execute_with(|| {
1818-
assert_eq!(<Test as pallet_balances::Config>::ExistentialDeposit::get(), 1);
1803+
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
1804+
assert_eq!(ed, 1);
18191805
let para = new_para();
18201806
let index = NextFundIndex::<Test>::get();
18211807
let account_id = Crowdloan::fund_account_id(index);

polkadot/runtime/common/src/impls.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ mod tests {
249249
parameter_types,
250250
traits::{
251251
tokens::{PayFromAccount, UnityAssetBalanceConversion},
252-
ConstU32, FindAuthor,
252+
FindAuthor,
253253
},
254254
weights::Weight,
255255
PalletId,
@@ -315,20 +315,9 @@ mod tests {
315315
type MaxConsumers = frame_support::traits::ConstU32<16>;
316316
}
317317

318+
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
318319
impl pallet_balances::Config for Test {
319-
type Balance = u64;
320-
type RuntimeEvent = RuntimeEvent;
321-
type DustRemoval = ();
322-
type ExistentialDeposit = ConstU64<1>;
323320
type AccountStore = System;
324-
type MaxLocks = ();
325-
type MaxReserves = ();
326-
type ReserveIdentifier = [u8; 8];
327-
type WeightInfo = ();
328-
type RuntimeHoldReason = RuntimeHoldReason;
329-
type RuntimeFreezeReason = RuntimeFreezeReason;
330-
type FreezeIdentifier = ();
331-
type MaxFreezes = ConstU32<1>;
332321
}
333322

334323
parameter_types! {

polkadot/runtime/common/src/integration_tests.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -173,23 +173,12 @@ impl pallet_timestamp::Config for Test {
173173

174174
parameter_types! {
175175
pub static ExistentialDeposit: Balance = 1;
176-
pub const MaxReserves: u32 = 50;
177176
}
178-
177+
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
179178
impl pallet_balances::Config for Test {
180-
type MaxLocks = ();
181179
type Balance = Balance;
182-
type RuntimeEvent = RuntimeEvent;
183-
type DustRemoval = ();
184180
type ExistentialDeposit = ExistentialDeposit;
185181
type AccountStore = System;
186-
type WeightInfo = ();
187-
type MaxReserves = MaxReserves;
188-
type ReserveIdentifier = [u8; 8];
189-
type RuntimeHoldReason = RuntimeHoldReason;
190-
type RuntimeFreezeReason = RuntimeFreezeReason;
191-
type FreezeIdentifier = ();
192-
type MaxFreezes = ConstU32<0>;
193182
}
194183

195184
impl configuration::Config for Test {

0 commit comments

Comments
 (0)