From 5c1eccd6f12da4d0c5381aac69704449963d9079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sun, 29 Dec 2024 23:04:31 +0100 Subject: [PATCH 1/3] pallet-bounties: Fix benchmarks for 0 ED --- substrate/frame/bounties/src/benchmarking.rs | 24 ++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/substrate/frame/bounties/src/benchmarking.rs b/substrate/frame/bounties/src/benchmarking.rs index 1e931958898d..b5155909e3cd 100644 --- a/substrate/frame/bounties/src/benchmarking.rs +++ b/substrate/frame/bounties/src/benchmarking.rs @@ -15,9 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! bounties pallet benchmarking. - -#![cfg(feature = "runtime-benchmarks")] +//! Bounties pallet benchmarking. use super::*; @@ -37,6 +35,16 @@ fn set_block_number, I: 'static>(n: BlockNumberFor) { >::BlockNumberProvider::set_block_number(n); } +fn minimum_balance, I: 'static>() -> BalanceOf { + let minimum_balance = T::Currency::minimum_balance(); + + if minimum_balance.is_zero() { + 1u32.into() + } else { + minimum_balance + } +} + // Create bounties that are approved for use in `on_initialize`. fn create_approved_bounties, I: 'static>(n: u32) -> Result<(), BenchmarkError> { for i in 0..n { @@ -62,12 +70,10 @@ fn setup_bounty, I: 'static>( let fee = value / 2u32.into(); let deposit = T::BountyDepositBase::get() + T::DataDepositPerByte::get() * T::MaximumReasonLength::get().into(); - let _ = T::Currency::make_free_balance_be(&caller, deposit + T::Currency::minimum_balance()); + let _ = T::Currency::make_free_balance_be(&caller, deposit + minimum_balance::()); let curator = account("curator", u, SEED); - let _ = T::Currency::make_free_balance_be( - &curator, - fee / 2u32.into() + T::Currency::minimum_balance(), - ); + let _ = + T::Currency::make_free_balance_be(&curator, fee / 2u32.into() + minimum_balance::()); let reason = vec![0; d as usize]; (caller, curator, fee, value, reason) } @@ -91,7 +97,7 @@ fn create_bounty, I: 'static>( fn setup_pot_account, I: 'static>() { let pot_account = Bounties::::account_id(); - let value = T::Currency::minimum_balance().saturating_mul(1_000_000_000u32.into()); + let value = minimum_balance::().saturating_mul(1_000_000_000u32.into()); let _ = T::Currency::make_free_balance_be(&pot_account, value); } From e99df24aa383d5bd52bf5c3950edfe604a1bae4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sun, 29 Dec 2024 23:05:51 +0100 Subject: [PATCH 2/3] Ups --- substrate/frame/bounties/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/substrate/frame/bounties/src/lib.rs b/substrate/frame/bounties/src/lib.rs index 729c76b5cc75..d9accc5061cf 100644 --- a/substrate/frame/bounties/src/lib.rs +++ b/substrate/frame/bounties/src/lib.rs @@ -84,6 +84,7 @@ #![cfg_attr(not(feature = "std"), no_std)] +#[cfg(feature = "runtime-benchmarks")] mod benchmarking; pub mod migrations; mod tests; From 8f8e482753cae831f22c706788891be88793b287 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 30 Dec 2024 10:00:31 +0000 Subject: [PATCH 3/3] Update from bkchr running command 'prdoc --audience runtime_dev --bump patch' --- prdoc/pr_7013.prdoc | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 prdoc/pr_7013.prdoc diff --git a/prdoc/pr_7013.prdoc b/prdoc/pr_7013.prdoc new file mode 100644 index 000000000000..138fa7f23102 --- /dev/null +++ b/prdoc/pr_7013.prdoc @@ -0,0 +1,7 @@ +title: 'pallet-bounties: Fix benchmarks for 0 ED' +doc: +- audience: Runtime Dev + description: 'Closes: https://github.com/paritytech/polkadot-sdk/issues/7009' +crates: +- name: pallet-bounties + bump: patch