Skip to content
Snippets Groups Projects
Unverified Commit 6b980646 authored by girazoki's avatar girazoki Committed by GitHub
Browse files

Make pallet-transaction-payment-benchmark work with ed 0 (#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.
parent d532437a
Branches
No related merge requests found
Pipeline #518292 waiting for manual action with stages
in 1 hour, 29 minutes, and 21 seconds
title: 'Make pallet-transaction-payment-benchmark work with ed 0'
doc:
- audience: Runtime Dev
description: |
Make it possible to use the transaction-payment work with existential deposit 0
crates:
- name: pallet-transaction-payment
bump: minor
\ No newline at end of file
...@@ -45,11 +45,18 @@ mod benchmarks { ...@@ -45,11 +45,18 @@ mod benchmarks {
#[benchmark] #[benchmark]
fn charge_transaction_payment() { fn charge_transaction_payment() {
let caller: T::AccountId = account("caller", 0, 0); let caller: T::AccountId = account("caller", 0, 0);
<T::OnChargeTransaction as OnChargeTransaction<T>>::endow_account( let existential_deposit =
&caller, <T::OnChargeTransaction as OnChargeTransaction<T>>::minimum_balance();
<T::OnChargeTransaction as OnChargeTransaction<T>>::minimum_balance() * 1000u32.into(),
); let (amount_to_endow, tip) = if existential_deposit.is_zero() {
let tip = <T::OnChargeTransaction as OnChargeTransaction<T>>::minimum_balance(); let min_tip: <<T as pallet::Config>::OnChargeTransaction as payment::OnChargeTransaction<T>>::Balance = 1_000_000_000u32.into();
(min_tip * 1000u32.into(), min_tip)
} else {
(existential_deposit * 1000u32.into(), existential_deposit)
};
<T::OnChargeTransaction as OnChargeTransaction<T>>::endow_account(&caller, amount_to_endow);
let ext: ChargeTransactionPayment<T> = ChargeTransactionPayment::from(tip); let ext: ChargeTransactionPayment<T> = ChargeTransactionPayment::from(tip);
let inner = frame_system::Call::remark { remark: alloc::vec![] }; let inner = frame_system::Call::remark { remark: alloc::vec![] };
let call = T::RuntimeCall::from(inner); let call = T::RuntimeCall::from(inner);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment