Skip to content

Commit 6b98064

Browse files
authored
Make pallet-transaction-payment-benchmark work with ed 0 (paritytech#7820)
# Description Chains like moonbeam work with an ED deposit of 0 (insecure-ed-0) which is unsable with the current pallet-transaction-payment benchmark. This PR adds an if-else case in case the existential deposit found is 0.
1 parent d532437 commit 6b98064

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

prdoc/pr_7820.prdoc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
title: 'Make pallet-transaction-payment-benchmark work with ed 0'
2+
doc:
3+
- audience: Runtime Dev
4+
description: |
5+
Make it possible to use the transaction-payment work with existential deposit 0
6+
crates:
7+
- name: pallet-transaction-payment
8+
bump: minor

substrate/frame/transaction-payment/src/benchmarking.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,18 @@ mod benchmarks {
4545
#[benchmark]
4646
fn charge_transaction_payment() {
4747
let caller: T::AccountId = account("caller", 0, 0);
48-
<T::OnChargeTransaction as OnChargeTransaction<T>>::endow_account(
49-
&caller,
50-
<T::OnChargeTransaction as OnChargeTransaction<T>>::minimum_balance() * 1000u32.into(),
51-
);
52-
let tip = <T::OnChargeTransaction as OnChargeTransaction<T>>::minimum_balance();
48+
let existential_deposit =
49+
<T::OnChargeTransaction as OnChargeTransaction<T>>::minimum_balance();
50+
51+
let (amount_to_endow, tip) = if existential_deposit.is_zero() {
52+
let min_tip: <<T as pallet::Config>::OnChargeTransaction as payment::OnChargeTransaction<T>>::Balance = 1_000_000_000u32.into();
53+
(min_tip * 1000u32.into(), min_tip)
54+
} else {
55+
(existential_deposit * 1000u32.into(), existential_deposit)
56+
};
57+
58+
<T::OnChargeTransaction as OnChargeTransaction<T>>::endow_account(&caller, amount_to_endow);
59+
5360
let ext: ChargeTransactionPayment<T> = ChargeTransactionPayment::from(tip);
5461
let inner = frame_system::Call::remark { remark: alloc::vec![] };
5562
let call = T::RuntimeCall::from(inner);

0 commit comments

Comments
 (0)