diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 64932fb256c29..ac651a5c24203 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -394,6 +394,10 @@ decl_storage! { config(balances): Vec<(T::AccountId, T::Balance)>; // ^^ begin, length, amount liquid at genesis build(|config: &GenesisConfig| { + assert!( + >::ExistentialDeposit::get() > Zero::zero(), + "The existential deposit should be greater than zero." + ); for (_, balance) in &config.balances { assert!( *balance >= >::ExistentialDeposit::get(), diff --git a/frame/balances/src/mock.rs b/frame/balances/src/mock.rs index 5eb722733f464..8a651a0ff7967 100644 --- a/frame/balances/src/mock.rs +++ b/frame/balances/src/mock.rs @@ -103,7 +103,7 @@ pub struct ExtBuilder { impl Default for ExtBuilder { fn default() -> Self { Self { - existential_deposit: 0, + existential_deposit: 1, creation_fee: 0, monied: false, } @@ -120,9 +120,6 @@ impl ExtBuilder { } pub fn monied(mut self, monied: bool) -> Self { self.monied = monied; - if self.existential_deposit == 0 { - self.existential_deposit = 1; - } self } pub fn set_associated_consts(&self) { diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index d0033e0bd128a..e84fded920e5d 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1009,7 +1009,7 @@ mod tests { let mut gas_meter = GasMeter::::with_limit(1000, 1); - let result = ctx.instantiate(0, &mut gas_meter, &code, vec![]); + let result = ctx.instantiate(1, &mut gas_meter, &code, vec![]); assert_matches!(result, Ok(_)); let mut toks = gas_meter.tokens().iter(); @@ -1302,8 +1302,10 @@ mod tests { let cfg = Config::preload(); let mut ctx = ExecutionContext::top_level(ALICE, &cfg, &vm, &loader); + ctx.overlay.set_balance(&ALICE, 1); + let result = ctx.instantiate( - 0, + 1, &mut GasMeter::::with_limit(10000, 1), &input_data_ch, vec![1, 2, 3, 4], @@ -1348,6 +1350,7 @@ mod tests { ExtBuilder::default().build().execute_with(|| { let cfg = Config::preload(); let mut ctx = ExecutionContext::top_level(ALICE, &cfg, &vm, &loader); + ctx.overlay.set_balance(&BOB, 1); ctx.overlay.instantiate_contract(&BOB, recurse_ch).unwrap(); let result = ctx.call( @@ -1661,8 +1664,10 @@ mod tests { let cfg = Config::preload(); let mut ctx = ExecutionContext::top_level(ALICE, &cfg, &vm, &loader); + ctx.overlay.set_balance(&ALICE, 1); + let result = ctx.instantiate( - 0, + 1, &mut GasMeter::::with_limit(10000, 1), &rent_allowance_ch, vec![], diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 783eca02ca7cc..9ee44a767ad4a 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -235,7 +235,7 @@ pub struct ExtBuilder { impl Default for ExtBuilder { fn default() -> Self { Self { - existential_deposit: 0, + existential_deposit: 1, gas_price: 2, block_gas_limit: 100_000_000, transfer_fee: 0, diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 9bf08840f4c8d..d2033fa8b3723 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -1229,7 +1229,7 @@ mod tests { type ModuleToIndex = (); } parameter_types! { - pub const ExistentialDeposit: u64 = 0; + pub const ExistentialDeposit: u64 = 1; pub const CreationFee: u64 = 0; } impl pallet_balances::Trait for Test { diff --git a/frame/elections/src/mock.rs b/frame/elections/src/mock.rs index 3274dd57b4afa..7cef8e3bdb7bc 100644 --- a/frame/elections/src/mock.rs +++ b/frame/elections/src/mock.rs @@ -57,7 +57,7 @@ impl frame_system::Trait for Test { } parameter_types! { - pub const ExistentialDeposit: u64 = 0; + pub const ExistentialDeposit: u64 = 1; pub const CreationFee: u64 = 0; } impl pallet_balances::Trait for Test { diff --git a/frame/example/src/lib.rs b/frame/example/src/lib.rs index b3a86b6acd78e..b4e0f3d6578db 100644 --- a/frame/example/src/lib.rs +++ b/frame/example/src/lib.rs @@ -689,7 +689,7 @@ mod tests { type ModuleToIndex = (); } parameter_types! { - pub const ExistentialDeposit: u64 = 0; + pub const ExistentialDeposit: u64 = 1; pub const CreationFee: u64 = 0; } impl pallet_balances::Trait for Test { diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 93db1418561ec..72411c904b456 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -453,7 +453,7 @@ mod tests { type ModuleToIndex = (); } parameter_types! { - pub const ExistentialDeposit: u64 = 0; + pub const ExistentialDeposit: u64 = 1; pub const CreationFee: u64 = 0; } impl pallet_balances::Trait for Runtime { diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index c6fc0062be153..c69239350cab5 100644 --- a/frame/identity/src/lib.rs +++ b/frame/identity/src/lib.rs @@ -926,7 +926,7 @@ mod tests { type ModuleToIndex = (); } parameter_types! { - pub const ExistentialDeposit: u64 = 0; + pub const ExistentialDeposit: u64 = 1; pub const CreationFee: u64 = 0; } impl pallet_balances::Trait for Test { diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 82aea43ad45b8..814673a6ff9c8 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -287,7 +287,7 @@ mod tests { type ModuleToIndex = (); } parameter_types! { - pub const ExistentialDeposit: u64 = 0; + pub const ExistentialDeposit: u64 = 1; pub const CreationFee: u64 = 0; } impl pallet_balances::Trait for Test { diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index fa8b11e69ef31..58acc9c8d7ec4 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -46,7 +46,7 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); - pub const ExistentialDeposit: u64 = 0; + pub const ExistentialDeposit: u64 = 1; pub const CreationFee: u64 = 0; } ord_parameter_types! { diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 28220f1063714..0188ef7cb2aa5 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -263,7 +263,7 @@ use frame_support::{decl_error, decl_module, decl_storage, decl_event, ensure, d use frame_support::weights::SimpleDispatchInfo; use frame_support::traits::{ Currency, ReservableCurrency, Randomness, Get, ChangeMembers, - ExistenceRequirement::{KeepAlive, AllowDeath}, + ExistenceRequirement::AllowDeath, }; use frame_system::{self as system, ensure_signed, ensure_root}; @@ -788,7 +788,7 @@ decl_module! { let mut payouts = >::get(&who); if let Some((when, amount)) = payouts.first() { if when <= &>::block_number() { - T::Currency::transfer(&Self::payouts(), &who, *amount, KeepAlive)?; + T::Currency::transfer(&Self::payouts(), &who, *amount, AllowDeath)?; payouts.remove(0); if payouts.is_empty() { >::remove(&who); diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 5c772478c871c..9f202d6b17df6 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -50,7 +50,7 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); - pub const ExistentialDeposit: u64 = 0; + pub const ExistentialDeposit: u64 = 1; pub const CreationFee: u64 = 0; } diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 3b2443c2cec73..7da30300f0713 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -233,7 +233,7 @@ pub struct ExtBuilder { impl Default for ExtBuilder { fn default() -> Self { Self { - existential_deposit: 0, + existential_deposit: 1, validator_pool: false, nominate: true, validator_count: 2, @@ -290,7 +290,7 @@ impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { self.set_associated_consts(); let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); - let balance_factor = if self.existential_deposit > 0 { + let balance_factor = if self.existential_deposit > 1 { 256 } else { 1 diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index f62a58e20bb28..e59f211b87a68 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -2066,7 +2066,8 @@ fn slash_in_old_span_does_not_deselect() { ), reporters: vec![], }], - &[Perbill::from_percent(100)], + // NOTE: A 100% slash here would clean up the account, causing de-registration. + &[Perbill::from_percent(95)], 1, ); @@ -2272,7 +2273,7 @@ fn only_slash_for_max_in_era() { #[test] fn garbage_collection_after_slashing() { - ExtBuilder::default().existential_deposit(1).build().execute_with(|| { + ExtBuilder::default().existential_deposit(2).build().execute_with(|| { assert_eq!(Balances::free_balance(11), 256_000); on_offence_now( diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 645c3f8af5070..2b9637651d68d 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -306,7 +306,7 @@ mod tests { parameter_types! { pub const CreationFee: u64 = 0; - pub const ExistentialDeposit: u64 = 0; + pub const ExistentialDeposit: u64 = 1; } impl pallet_balances::Trait for Runtime { @@ -394,14 +394,18 @@ mod tests { self.set_constants(); let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); pallet_balances::GenesisConfig:: { - balances: vec![ - (1, 10 * self.balance_factor), - (2, 20 * self.balance_factor), - (3, 30 * self.balance_factor), - (4, 40 * self.balance_factor), - (5, 50 * self.balance_factor), - (6, 60 * self.balance_factor) - ], + balances: if self.balance_factor > 0 { + vec![ + (1, 10 * self.balance_factor), + (2, 20 * self.balance_factor), + (3, 30 * self.balance_factor), + (4, 40 * self.balance_factor), + (5, 50 * self.balance_factor), + (6, 60 * self.balance_factor) + ] + } else { + vec![] + }, }.assimilate_storage(&mut t).unwrap(); t.into() } diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index fcd340eef5557..72f35745a49a9 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -702,7 +702,7 @@ mod tests { type ModuleToIndex = (); } parameter_types! { - pub const ExistentialDeposit: u64 = 0; + pub const ExistentialDeposit: u64 = 1; pub const CreationFee: u64 = 0; } impl pallet_balances::Trait for Test {