From 215252e7b55a3239a4f0b6b86aa03e9946c7ae2e Mon Sep 17 00:00:00 2001 From: "Shoyu Vanilla (Flint)" Date: Mon, 7 Oct 2024 23:46:47 +0900 Subject: [PATCH] [FRAME] fix: Do not emit `Issued { amount: 0 }` event (#5946) closes #5942 Couldn't find any emissions of `Event::Issued` without amount check other than in this PR. Currently, we have; https://github.com/paritytech/polkadot-sdk/blob/4bda956d2c635c3926578741a19fbcc3de69cbb8/substrate/frame/balances/src/impl_currency.rs#L212-L220 and https://github.com/paritytech/polkadot-sdk/blob/4bda956d2c635c3926578741a19fbcc3de69cbb8/substrate/frame/balances/src/impl_currency.rs#L293-L306 --- prdoc/pr_5946.prdoc | 15 +++++++++++++++ substrate/frame/balances/src/impl_fungible.rs | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 prdoc/pr_5946.prdoc diff --git a/prdoc/pr_5946.prdoc b/prdoc/pr_5946.prdoc new file mode 100644 index 000000000000..9a858c980a19 --- /dev/null +++ b/prdoc/pr_5946.prdoc @@ -0,0 +1,15 @@ +# 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: "[FRAME] fix: Do not emit `Issued { amount: 0 }` event" + +doc: + - audience: + - Runtime Dev + - Runtime User + description: | + Filter out `Issued` events in `pallet-balances` module when its balance amount is zero. + +crates: + - name: pallet-balances + bump: patch diff --git a/substrate/frame/balances/src/impl_fungible.rs b/substrate/frame/balances/src/impl_fungible.rs index cf95a97d191f..4470c3cc9eb1 100644 --- a/substrate/frame/balances/src/impl_fungible.rs +++ b/substrate/frame/balances/src/impl_fungible.rs @@ -354,7 +354,9 @@ impl, I: 'static> fungible::Balanced for Pallet Self::deposit_event(Event::::Withdraw { who: who.clone(), amount }); } fn done_issue(amount: Self::Balance) { - Self::deposit_event(Event::::Issued { amount }); + if !amount.is_zero() { + Self::deposit_event(Event::::Issued { amount }); + } } fn done_rescind(amount: Self::Balance) { Self::deposit_event(Event::::Rescinded { amount });