diff --git a/pallets/capacity/src/tests/mock.rs b/pallets/capacity/src/tests/mock.rs index ea2299d9c0..edeca1a26f 100644 --- a/pallets/capacity/src/tests/mock.rs +++ b/pallets/capacity/src/tests/mock.rs @@ -77,7 +77,7 @@ impl pallet_balances::Config for Test { type Balance = u64; type RuntimeEvent = RuntimeEvent; type DustRemoval = (); - type ExistentialDeposit = ConstU64<1>; + type ExistentialDeposit = ConstU64<10>; type AccountStore = System; type WeightInfo = (); type FreezeIdentifier = RuntimeFreezeReason; @@ -228,7 +228,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![ - (50, 5), + (50, 15), (100, 100), (200, 200), (300, 300), diff --git a/pallets/capacity/src/tests/stake_and_deposit_tests.rs b/pallets/capacity/src/tests/stake_and_deposit_tests.rs index 80183e6cd1..83fe996c54 100644 --- a/pallets/capacity/src/tests/stake_and_deposit_tests.rs +++ b/pallets/capacity/src/tests/stake_and_deposit_tests.rs @@ -296,7 +296,7 @@ fn stake_when_staking_amount_is_less_than_min_token_balance_it_errors() { register_provider(target, String::from("Foo")); let account = 50; // An amount that leaves less than the minimum token balance - let amount = 4; + let amount = 11; assert_noop!( Capacity::stake(RuntimeOrigin::signed(account), target, amount), diff --git a/pallets/time-release/src/benchmarking.rs b/pallets/time-release/src/benchmarking.rs index ccb23fc527..d6e454b562 100644 --- a/pallets/time-release/src/benchmarking.rs +++ b/pallets/time-release/src/benchmarking.rs @@ -11,6 +11,7 @@ extern crate alloc; use alloc::vec; pub const DOLLARS: u32 = 10u32.saturating_pow(8u32); +pub const EXISTENTIAL_DEPOSIT: u32 = 10u32.saturating_pow(6u32); pub use crate::types::ReleaseSchedule; pub type Schedule = ReleaseSchedule, BalanceOf>; @@ -51,11 +52,15 @@ mod benchmarks { let to: T::AccountId = account("to", 1, SEED); let to_lookup = lookup_of_account::(to.clone()); + set_balance::(&to, EXISTENTIAL_DEPOSIT.into()); #[extrinsic_call] _(RawOrigin::Signed(from), to_lookup, schedule.clone()); - assert_eq!(T::Currency::total_balance(&to), schedule.total_amount().unwrap()); + assert_eq!( + T::Currency::total_balance(&to), + schedule.total_amount().unwrap() + EXISTENTIAL_DEPOSIT.into() + ); Ok(()) } @@ -136,6 +141,7 @@ mod benchmarks { let to: T::AccountId = whitelisted_caller(); let to_lookup = lookup_of_account::(to.clone()); + set_balance::(&to, EXISTENTIAL_DEPOSIT.into()); for _ in 0..i { schedule.start = i.into(); @@ -152,7 +158,7 @@ mod benchmarks { assert_eq!( T::Currency::balance(&to), - schedule.total_amount().unwrap() * BalanceOf::::from(i), + schedule.total_amount().unwrap() * BalanceOf::::from(i) + EXISTENTIAL_DEPOSIT.into(), ); Ok(()) } @@ -169,7 +175,10 @@ mod benchmarks { }; let to: T::AccountId = account("to", 0, SEED); - set_balance::(&to, schedule.total_amount().unwrap() * BalanceOf::::from(i)); + set_balance::( + &to, + schedule.total_amount().unwrap() * BalanceOf::::from(i) + EXISTENTIAL_DEPOSIT.into(), + ); let to_lookup = lookup_of_account::(to.clone()); let mut schedules = vec![]; @@ -183,7 +192,7 @@ mod benchmarks { assert_eq!( T::Currency::balance(&to), - schedule.total_amount().unwrap() * BalanceOf::::from(i) + schedule.total_amount().unwrap() * BalanceOf::::from(i) + EXISTENTIAL_DEPOSIT.into() ); Ok(()) } diff --git a/pallets/time-release/src/mock.rs b/pallets/time-release/src/mock.rs index d585b10c9c..7a823f2e73 100644 --- a/pallets/time-release/src/mock.rs +++ b/pallets/time-release/src/mock.rs @@ -54,7 +54,7 @@ impl pallet_balances::Config for Test { type Balance = Balance; type DustRemoval = (); type RuntimeEvent = RuntimeEvent; - type ExistentialDeposit = ConstU64<1>; + type ExistentialDeposit = ConstU64<10>; type AccountStore = frame_system::Pallet; type MaxLocks = (); type MaxReserves = (); diff --git a/pallets/time-release/src/tests.rs b/pallets/time-release/src/tests.rs index 5616906130..009b265605 100644 --- a/pallets/time-release/src/tests.rs +++ b/pallets/time-release/src/tests.rs @@ -28,26 +28,51 @@ fn time_release_from_chain_spec_works() { assert_eq!( ReleaseSchedules::::get(CHARLIE), vec![ - ReleaseSchedule { start: 2u32, period: 3u32, period_count: 1u32, per_period: 5u64 }, + ReleaseSchedule { start: 2u32, period: 3u32, period_count: 1u32, per_period: 5u64 }, // unlocks 5 at block 5 ReleaseSchedule { - start: 2u32 + 3u32, - period: 3u32, - period_count: 3u32, - per_period: 5u64, + // unlocks 5, 8, 11, 14 + start: 2u32 + 3u32, // starts at 5 + period: 3u32, // every 3 blocks .... + period_count: 3u32, // repeats 3 times + per_period: 5u64, // ... we add 5 tokens } ] ); - MockBlockNumberProvider::set(13); + MockBlockNumberProvider::set(2); + // before anything is released + // 10 = 10(free) - 10(ExistentialDeposit) + 10(cancelled ED because frozen > 10) + // balance = 20(frozen) + 0(free) + assert_ok!(TimeRelease::claim(RuntimeOrigin::signed(CHARLIE))); + assert_eq!(PalletBalances::can_withdraw(&CHARLIE, 10), WithdrawConsequence::Success); + assert_eq!(PalletBalances::can_withdraw(&CHARLIE, 11), WithdrawConsequence::Frozen); + + MockBlockNumberProvider::set(5); + // 5 tokens will be released after 5 blocks + // 15 = 15(free) - 10(ExistentialDeposit) + 10(cancelled ED because frozen > 10) + // balance = 15(frozen) + 0(free) + assert_ok!(TimeRelease::claim(RuntimeOrigin::signed(CHARLIE))); + assert_eq!(PalletBalances::can_withdraw(&CHARLIE, 15), WithdrawConsequence::Success); + assert_eq!(PalletBalances::can_withdraw(&CHARLIE, 16), WithdrawConsequence::Frozen); + + MockBlockNumberProvider::set(8); + // 10 tokens will be released after 8 blocks + // 20 = 20(free) - 10(ExistentialDeposit) + 10(cancelled ED because frozen > 10) + // balance = 10(frozen) + 0(free) + // This is the max this account can withdraw while leaving an ED + assert_ok!(TimeRelease::claim(RuntimeOrigin::signed(CHARLIE))); + assert_eq!(PalletBalances::can_withdraw(&CHARLIE, 20), WithdrawConsequence::Success); + assert_eq!(PalletBalances::can_withdraw(&CHARLIE, 21), WithdrawConsequence::Frozen); - // 15 tokens will be released after 13 blocks - // 25 = 10(free) + 15(released) + MockBlockNumberProvider::set(11); + // 15 tokens will be released after 11 blocks + // balance = 5(frozen) + 0(free) + // ED no longer covered by the frozen balance becuase frozen = 5 < ED = 10 assert_ok!(TimeRelease::claim(RuntimeOrigin::signed(CHARLIE))); - assert_eq!(PalletBalances::can_withdraw(&CHARLIE, 25), WithdrawConsequence::Success); - assert_eq!(PalletBalances::can_withdraw(&CHARLIE, 26), WithdrawConsequence::Frozen); + assert_eq!(PalletBalances::can_withdraw(&CHARLIE, 20), WithdrawConsequence::Success); + assert_eq!(PalletBalances::can_withdraw(&CHARLIE, 21), WithdrawConsequence::Frozen); MockBlockNumberProvider::set(14); - // The final 5 tokens are released after 14 = (5[start] + 3[period] x 3[period count]) blocks assert_ok!(TimeRelease::claim(RuntimeOrigin::signed(CHARLIE))); @@ -57,7 +82,6 @@ fn time_release_from_chain_spec_works() { PalletBalances::can_withdraw(&CHARLIE, 30), WithdrawConsequence::ReducedToZero(0) ); - assert_eq!(PalletBalances::can_withdraw(&CHARLIE, 29), WithdrawConsequence::Success); }); } @@ -327,7 +351,7 @@ fn update_release_schedules_works() { #[test] fn update_release_schedules_fails_if_unexpected_existing_freezes() { ExtBuilder::build().execute_with(|| { - assert_ok!(PalletBalances::transfer_allow_death(RuntimeOrigin::signed(ALICE), BOB, 1)); + assert_ok!(PalletBalances::transfer_allow_death(RuntimeOrigin::signed(ALICE), BOB, 11)); let _ = ::Currency::set_freeze( &FreezeReason::TimeReleaseVesting.into(), &BOB, diff --git a/pallets/time-release/src/weights.rs b/pallets/time-release/src/weights.rs index c45cf0720d..862a0b1520 100644 --- a/pallets/time-release/src/weights.rs +++ b/pallets/time-release/src/weights.rs @@ -1,8 +1,8 @@ //! Autogenerated weights for `pallet_time_release` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 47.2.0 -//! DATE: 2025-07-15, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 49.1.0 +//! DATE: 2025-10-07, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `ip-10-173-5-194`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` @@ -58,10 +58,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `253` + // Measured: `283` // Estimated: `5409` - // Minimum execution time: 71_952_000 picoseconds. - Weight::from_parts(73_546_000, 5409) + // Minimum execution time: 77_002_000 picoseconds. + Weight::from_parts(77_730_000, 5409) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -72,13 +72,13 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Scheduler::Lookup` (r:1 w:1) /// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Scheduler::Agenda` (r:1 w:1) - /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(10463), added: 12938, mode: `MaxEncodedLen`) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) fn schedule_named_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `252` - // Estimated: `14423` - // Minimum execution time: 60_547_000 picoseconds. - Weight::from_parts(62_503_000, 14423) + // Measured: `148` + // Estimated: `42923` + // Minimum execution time: 64_191_000 picoseconds. + Weight::from_parts(66_997_000, 42923) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -100,10 +100,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `TimeRelease::ScheduleReservedAmounts` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) fn execute_scheduled_named_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `308` + // Measured: `203` // Estimated: `5409` - // Minimum execution time: 78_492_000 picoseconds. - Weight::from_parts(81_685_000, 5409) + // Minimum execution time: 80_798_000 picoseconds. + Weight::from_parts(83_197_000, 5409) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -118,12 +118,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[1, 50]`. fn claim(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `313 + i * (16 ±0)` + // Measured: `208 + i * (16 ±0)` // Estimated: `5409 + i * (16 ±0)` - // Minimum execution time: 37_476_000 picoseconds. - Weight::from_parts(38_473_330, 5409) - // Standard Error: 3_037 - .saturating_add(Weight::from_parts(53_821, 0).saturating_mul(i.into())) + // Minimum execution time: 37_619_000 picoseconds. + Weight::from_parts(38_720_305, 5409) + // Standard Error: 4_197 + .saturating_add(Weight::from_parts(58_166, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 16).saturating_mul(i.into())) @@ -141,17 +141,17 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `141` // Estimated: `5259` - // Minimum execution time: 29_893_000 picoseconds. - Weight::from_parts(30_944_262, 5259) - // Standard Error: 7_288 - .saturating_add(Weight::from_parts(53_136, 0).saturating_mul(i.into())) + // Minimum execution time: 30_489_000 picoseconds. + Weight::from_parts(31_643_560, 5259) + // Standard Error: 6_467 + .saturating_add(Weight::from_parts(50_705, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: `Scheduler::Lookup` (r:1 w:1) /// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Scheduler::Agenda` (r:1 w:1) - /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(10463), added: 12938, mode: `MaxEncodedLen`) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) /// Storage: `TimeRelease::ScheduleReservedAmounts` (r:1 w:1) /// Proof: `TimeRelease::ScheduleReservedAmounts` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:1) @@ -163,12 +163,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[1, 50]`. fn cancel_scheduled_named_transfer(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `967 + i * (170 ±0)` - // Estimated: `14423` - // Minimum execution time: 62_337_000 picoseconds. - Weight::from_parts(66_290_742, 14423) - // Standard Error: 14_458 - .saturating_add(Weight::from_parts(849_779, 0).saturating_mul(i.into())) + // Measured: `863 + i * (170 ±0)` + // Estimated: `42923` + // Minimum execution time: 63_440_000 picoseconds. + Weight::from_parts(68_097_172, 42923) + // Standard Error: 9_791 + .saturating_add(Weight::from_parts(814_164, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -190,10 +190,10 @@ impl WeightInfo for () { /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `253` + // Measured: `283` // Estimated: `5409` - // Minimum execution time: 71_952_000 picoseconds. - Weight::from_parts(73_546_000, 5409) + // Minimum execution time: 77_002_000 picoseconds. + Weight::from_parts(77_730_000, 5409) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -204,13 +204,13 @@ impl WeightInfo for () { /// Storage: `Scheduler::Lookup` (r:1 w:1) /// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Scheduler::Agenda` (r:1 w:1) - /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(10463), added: 12938, mode: `MaxEncodedLen`) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) fn schedule_named_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `252` - // Estimated: `14423` - // Minimum execution time: 60_547_000 picoseconds. - Weight::from_parts(62_503_000, 14423) + // Measured: `148` + // Estimated: `42923` + // Minimum execution time: 64_191_000 picoseconds. + Weight::from_parts(66_997_000, 42923) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -232,10 +232,10 @@ impl WeightInfo for () { /// Proof: `TimeRelease::ScheduleReservedAmounts` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) fn execute_scheduled_named_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `308` + // Measured: `203` // Estimated: `5409` - // Minimum execution time: 78_492_000 picoseconds. - Weight::from_parts(81_685_000, 5409) + // Minimum execution time: 80_798_000 picoseconds. + Weight::from_parts(83_197_000, 5409) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -250,12 +250,12 @@ impl WeightInfo for () { /// The range of component `i` is `[1, 50]`. fn claim(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `313 + i * (16 ±0)` + // Measured: `208 + i * (16 ±0)` // Estimated: `5409 + i * (16 ±0)` - // Minimum execution time: 37_476_000 picoseconds. - Weight::from_parts(38_473_330, 5409) - // Standard Error: 3_037 - .saturating_add(Weight::from_parts(53_821, 0).saturating_mul(i.into())) + // Minimum execution time: 37_619_000 picoseconds. + Weight::from_parts(38_720_305, 5409) + // Standard Error: 4_197 + .saturating_add(Weight::from_parts(58_166, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 16).saturating_mul(i.into())) @@ -273,17 +273,17 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `141` // Estimated: `5259` - // Minimum execution time: 29_893_000 picoseconds. - Weight::from_parts(30_944_262, 5259) - // Standard Error: 7_288 - .saturating_add(Weight::from_parts(53_136, 0).saturating_mul(i.into())) + // Minimum execution time: 30_489_000 picoseconds. + Weight::from_parts(31_643_560, 5259) + // Standard Error: 6_467 + .saturating_add(Weight::from_parts(50_705, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: `Scheduler::Lookup` (r:1 w:1) /// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Scheduler::Agenda` (r:1 w:1) - /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(10463), added: 12938, mode: `MaxEncodedLen`) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) /// Storage: `TimeRelease::ScheduleReservedAmounts` (r:1 w:1) /// Proof: `TimeRelease::ScheduleReservedAmounts` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:1) @@ -295,12 +295,12 @@ impl WeightInfo for () { /// The range of component `i` is `[1, 50]`. fn cancel_scheduled_named_transfer(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `967 + i * (170 ±0)` - // Estimated: `14423` - // Minimum execution time: 62_337_000 picoseconds. - Weight::from_parts(66_290_742, 14423) - // Standard Error: 14_458 - .saturating_add(Weight::from_parts(849_779, 0).saturating_mul(i.into())) + // Measured: `863 + i * (170 ±0)` + // Estimated: `42923` + // Minimum execution time: 63_440_000 picoseconds. + Weight::from_parts(68_097_172, 42923) + // Standard Error: 9_791 + .saturating_add(Weight::from_parts(814_164, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -350,7 +350,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 14423 + > 42923 ); } #[test] @@ -398,7 +398,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 14423 + > 42923 ); } }