Skip to content

Commit

Permalink
Use aggregated types for RuntimeFreezeReason and better examples of…
Browse files Browse the repository at this point in the history
… `MaxFreezes` (paritytech#4615)

This PR aligns the settings for `MaxFreezes`, `RuntimeFreezeReason`, and
`FreezeIdentifier`.

#### Future work and improvements
paritytech#2997 (remove
`MaxFreezes` and `FreezeIdentifier`)
  • Loading branch information
bkontur authored Jun 13, 2024
1 parent eca1052 commit 988103d
Show file tree
Hide file tree
Showing 85 changed files with 177 additions and 885 deletions.
1 change: 0 additions & 1 deletion bridges/modules/messages/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ impl frame_system::Config for TestRuntime {

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for TestRuntime {
type ReserveIdentifier = [u8; 8];
type AccountStore = System;
}

Expand Down
11 changes: 1 addition & 10 deletions bridges/snowbridge/pallets/inbound-queue/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,11 @@ parameter_types! {
pub const ExistentialDeposit: u128 = 1;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type Balance = Balance;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type RuntimeHoldReason = ();
type RuntimeFreezeReason = ();
}

parameter_types! {
Expand Down
11 changes: 1 addition & 10 deletions bridges/snowbridge/pallets/system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,11 @@ impl frame_system::Config for Test {
type Block = Block;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type Balance = Balance;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ConstU128<1>;
type AccountStore = System;
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type RuntimeHoldReason = ();
type RuntimeFreezeReason = ();
}

impl pallet_xcm_origin::Config for Test {
Expand Down
13 changes: 1 addition & 12 deletions cumulus/pallets/collator-selection/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,12 @@ impl system::Config for Test {

parameter_types! {
pub const ExistentialDeposit: u64 = 5;
pub const MaxReserves: u32 = 50;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type Balance = u64;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
type MaxLocks = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<0>;
}

pub struct Author4;
Expand Down
13 changes: 1 addition & 12 deletions cumulus/pallets/xcmp-queue/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,14 @@ impl frame_system::Config for Test {

parameter_types! {
pub const ExistentialDeposit: u64 = 5;
pub const MaxReserves: u32 = 50;
}

pub type Balance = u64;

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type Balance = Balance;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
type MaxLocks = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<0>;
}

impl cumulus_pallet_parachain_system::Config for Test {
Expand Down
16 changes: 2 additions & 14 deletions cumulus/parachains/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ mod tests {
use frame_system::{limits, EnsureRoot};
use pallet_collator_selection::IdentityCollator;
use polkadot_primitives::AccountId;
use sp_core::{ConstU64, H256};
use sp_core::H256;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage, Perbill,
Expand All @@ -224,7 +224,6 @@ mod tests {
parameter_types! {
pub BlockLength: limits::BlockLength = limits::BlockLength::max(2 * 1024);
pub const AvailableBlockRatio: Perbill = Perbill::one();
pub const MaxReserves: u32 = 50;
}

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

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type Balance = u64;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type MaxLocks = ();
type WeightInfo = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<1>;
}

pub struct OneAuthor;
Expand Down
17 changes: 1 addition & 16 deletions polkadot/runtime/common/src/assigned_slots/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,24 +698,9 @@ mod tests {
type MaxConsumers = frame_support::traits::ConstU32<16>;
}

parameter_types! {
pub const ExistentialDeposit: u64 = 1;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type Balance = u64;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<1>;
}

impl parachains_configuration::Config for Test {
Expand Down
26 changes: 6 additions & 20 deletions polkadot/runtime/common/src/auctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ mod tests {
use frame_support::{
assert_noop, assert_ok, assert_storage_noop, derive_impl, ord_parameter_types,
parameter_types,
traits::{ConstU32, EitherOfDiverse, OnFinalize, OnInitialize},
traits::{EitherOfDiverse, OnFinalize, OnInitialize},
};
use frame_system::{EnsureRoot, EnsureSignedBy};
use pallet_balances;
Expand Down Expand Up @@ -725,25 +725,9 @@ mod tests {
type MaxConsumers = frame_support::traits::ConstU32<16>;
}

parameter_types! {
pub const ExistentialDeposit: u64 = 1;
pub const MaxReserves: u32 = 50;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type Balance = u64;
type DustRemoval = ();
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
type MaxLocks = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<1>;
}

#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug)]
Expand Down Expand Up @@ -1426,7 +1410,8 @@ mod tests {
#[test]
fn initialize_winners_in_ending_period_works() {
new_test_ext().execute_with(|| {
assert_eq!(<Test as pallet_balances::Config>::ExistentialDeposit::get(), 1);
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
assert_eq!(ed, 1);
run_to_block(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 1));
let para_1 = ParaId::from(1_u32);
Expand Down Expand Up @@ -1539,7 +1524,8 @@ mod tests {
#[test]
fn less_winning_samples_work() {
new_test_ext().execute_with(|| {
assert_eq!(<Test as pallet_balances::Config>::ExistentialDeposit::get(), 1);
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
assert_eq!(ed, 1);
EndingPeriod::set(30);
SampleLength::set(10);

Expand Down
19 changes: 2 additions & 17 deletions polkadot/runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ mod tests {
assert_err, assert_noop, assert_ok, derive_impl,
dispatch::{GetDispatchInfo, Pays},
ord_parameter_types, parameter_types,
traits::{ConstU32, ExistenceRequirement, WithdrawReasons},
traits::{ExistenceRequirement, WithdrawReasons},
};
use pallet_balances;
use sp_runtime::{
Expand Down Expand Up @@ -738,24 +738,9 @@ mod tests {
type MaxConsumers = frame_support::traits::ConstU32<16>;
}

parameter_types! {
pub const ExistentialDeposit: u64 = 1;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type Balance = u64;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<1>;
}

parameter_types! {
Expand Down
24 changes: 5 additions & 19 deletions polkadot/runtime/common/src/crowdloan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ mod tests {

use frame_support::{
assert_noop, assert_ok, derive_impl, parameter_types,
traits::{ConstU32, OnFinalize, OnInitialize},
traits::{OnFinalize, OnInitialize},
};
use polkadot_primitives::Id as ParaId;
use sp_core::H256;
Expand Down Expand Up @@ -918,24 +918,9 @@ mod tests {
type MaxConsumers = frame_support::traits::ConstU32<16>;
}

parameter_types! {
pub const ExistentialDeposit: u64 = 1;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type Balance = u64;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<1>;
}

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
Expand Down Expand Up @@ -980,7 +965,7 @@ mod tests {
let fund = Funds::<Test>::get(para).unwrap();
let account_id = Crowdloan::fund_account_id(fund.fund_index);
if winner {
let ed = <Test as pallet_balances::Config>::ExistentialDeposit::get();
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
let free_balance = Balances::free_balance(&account_id);
Balances::reserve(&account_id, free_balance - ed)
.expect("should be able to reserve free balance minus ED");
Expand Down Expand Up @@ -1815,7 +1800,8 @@ mod tests {
#[test]
fn withdraw_from_finished_works() {
new_test_ext().execute_with(|| {
assert_eq!(<Test as pallet_balances::Config>::ExistentialDeposit::get(), 1);
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
assert_eq!(ed, 1);
let para = new_para();
let index = NextFundIndex::<Test>::get();
let account_id = Crowdloan::fund_account_id(index);
Expand Down
15 changes: 2 additions & 13 deletions polkadot/runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ mod tests {
parameter_types,
traits::{
tokens::{PayFromAccount, UnityAssetBalanceConversion},
ConstU32, FindAuthor,
FindAuthor,
},
weights::Weight,
PalletId,
Expand Down Expand Up @@ -315,20 +315,9 @@ mod tests {
type MaxConsumers = frame_support::traits::ConstU32<16>;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type Balance = u64;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<1>;
}

parameter_types! {
Expand Down
13 changes: 1 addition & 12 deletions polkadot/runtime/common/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,12 @@ impl pallet_timestamp::Config for Test {

parameter_types! {
pub static ExistentialDeposit: Balance = 1;
pub const MaxReserves: u32 = 50;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type MaxLocks = ();
type Balance = Balance;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<0>;
}

impl configuration::Config for Test {
Expand Down
Loading

0 comments on commit 988103d

Please sign in to comment.