From e46aa951cc7d1f3f10309aa7481e46f60e569654 Mon Sep 17 00:00:00 2001 From: kris Date: Wed, 1 May 2024 12:42:48 -0500 Subject: [PATCH 1/5] llowed for 0 existential deposit in staking and balances benchmarks --- substrate/frame/balances/src/benchmarking.rs | 2 +- substrate/frame/staking/src/testing_utils.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/balances/src/benchmarking.rs b/substrate/frame/balances/src/benchmarking.rs index 0ce1240eb5d3..14f0ede5e0f2 100644 --- a/substrate/frame/balances/src/benchmarking.rs +++ b/substrate/frame/balances/src/benchmarking.rs @@ -44,7 +44,7 @@ mod benchmarks { let caller = whitelisted_caller(); // Give some multiple of the existential deposit - let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into()); + let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into()).max(1u32.into()); let _ = as Currency<_>>::make_free_balance_be(&caller, balance); // Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account, diff --git a/substrate/frame/staking/src/testing_utils.rs b/substrate/frame/staking/src/testing_utils.rs index 28e08230d701..75b2ca9055b4 100644 --- a/substrate/frame/staking/src/testing_utils.rs +++ b/substrate/frame/staking/src/testing_utils.rs @@ -77,7 +77,7 @@ pub fn create_stash_controller( destination: RewardDestination, ) -> Result<(T::AccountId, T::AccountId), &'static str> { let staker = create_funded_user::("stash", n, balance_factor); - let amount = T::Currency::minimum_balance() * (balance_factor / 10).max(1).into(); + let amount = T::Currency::minimum_balance().max(1u64.into()) * (balance_factor / 10).max(1).into(); Staking::::bond(RawOrigin::Signed(staker.clone()).into(), amount, destination)?; Ok((staker.clone(), staker)) } From 1aab4ff865591d0daeffe5d03464a03499ca5cec Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Thu, 2 May 2024 11:18:47 +0000 Subject: [PATCH 2/5] ".git/.scripts/commands/fmt/fmt.sh" --- substrate/frame/staking/src/testing_utils.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/substrate/frame/staking/src/testing_utils.rs b/substrate/frame/staking/src/testing_utils.rs index 75b2ca9055b4..d4938ea43ebe 100644 --- a/substrate/frame/staking/src/testing_utils.rs +++ b/substrate/frame/staking/src/testing_utils.rs @@ -77,7 +77,8 @@ pub fn create_stash_controller( destination: RewardDestination, ) -> Result<(T::AccountId, T::AccountId), &'static str> { let staker = create_funded_user::("stash", n, balance_factor); - let amount = T::Currency::minimum_balance().max(1u64.into()) * (balance_factor / 10).max(1).into(); + let amount = + T::Currency::minimum_balance().max(1u64.into()) * (balance_factor / 10).max(1).into(); Staking::::bond(RawOrigin::Signed(staker.clone()).into(), amount, destination)?; Ok((staker.clone(), staker)) } From 08d3cb92e879a9e806d67ed6bcc46e2550ac47a6 Mon Sep 17 00:00:00 2001 From: kris Date: Thu, 2 May 2024 10:59:41 -0500 Subject: [PATCH 3/5] Add PR doc --- prdoc/pr_4346.prdoc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 prdoc/pr_4346.prdoc diff --git a/prdoc/pr_4346.prdoc b/prdoc/pr_4346.prdoc new file mode 100644 index 000000000000..3337b0abe755 --- /dev/null +++ b/prdoc/pr_4346.prdoc @@ -0,0 +1,17 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Allow for 0 existential deposit in benchmarks for pallet_staking, pallet_session, and pallet_balances + +doc: + - audience: Runtime Dev + description: | + Changes were made to benchmarks for `pallet_staking`, `pallet_session`, and `pallet-balances` to accommodate runtimes with 0 existential deposit. This should not affect the vast majority of runtimes. + +crates: + - name: pallet-staking + bump: patch + - name: pallet-session + bump: patch + - name: pallet-balances + bump: patch From ef98de39ddde36d5b9f80ffac962cf3123b70393 Mon Sep 17 00:00:00 2001 From: kris Date: Thu, 2 May 2024 11:02:18 -0500 Subject: [PATCH 4/5] updated PR doc --- prdoc/pr_4346.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_4346.prdoc b/prdoc/pr_4346.prdoc index 3337b0abe755..538373d87324 100644 --- a/prdoc/pr_4346.prdoc +++ b/prdoc/pr_4346.prdoc @@ -6,7 +6,7 @@ title: Allow for 0 existential deposit in benchmarks for pallet_staking, pallet_ doc: - audience: Runtime Dev description: | - Changes were made to benchmarks for `pallet_staking`, `pallet_session`, and `pallet-balances` to accommodate runtimes with 0 existential deposit. This should not affect the vast majority of runtimes. + Changes were made to benchmarks for `pallet_staking`, `pallet_session`, and `pallet-balances` to accommodate runtimes with 0 existential deposit. This should not affect the vast majority of runtimes. For runtimes with 0 existential deposit, the benchmarks for `pallet_staking` and `pallet_session` will still fail when using `U128CurrencyToVote` in the `pallet-staking` config; developers can use or write another `CurrencyToVote` implementation for benchmarking to work around this. crates: - name: pallet-staking From 8cac1d57e2534154452861af2aa411a20d269c29 Mon Sep 17 00:00:00 2001 From: kris Date: Thu, 2 May 2024 13:14:14 -0500 Subject: [PATCH 5/5] updated PR doc --- prdoc/pr_4346.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_4346.prdoc b/prdoc/pr_4346.prdoc index 538373d87324..e222dec885ce 100644 --- a/prdoc/pr_4346.prdoc +++ b/prdoc/pr_4346.prdoc @@ -11,7 +11,7 @@ doc: crates: - name: pallet-staking bump: patch - - name: pallet-session + - name: pallet-session-benchmarking bump: patch - name: pallet-balances bump: patch