From e306fb379c1c7472c30238291c802fb861fcf943 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Thu, 10 Jul 2025 19:14:30 +0100 Subject: [PATCH 1/5] emit ScoreUpdated event only if it has changed --- substrate/frame/bags-list/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/substrate/frame/bags-list/src/lib.rs b/substrate/frame/bags-list/src/lib.rs index f35f0a56d1787..b0ec62b6675a5 100644 --- a/substrate/frame/bags-list/src/lib.rs +++ b/substrate/frame/bags-list/src/lib.rs @@ -557,7 +557,9 @@ impl, I: 'static> Pallet { if let Some((from, to)) = maybe_movement { Self::deposit_event(Event::::Rebagged { who: account.clone(), from, to }); }; - Self::deposit_event(Event::::ScoreUpdated { who: account.clone(), new_score }); + if node.score != new_score { + Self::deposit_event(Event::::ScoreUpdated { who: account.clone(), new_score }); + } Ok(maybe_movement) } From 4b95fca1bafad72e1f45f229afbd64d173abbb74 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Thu, 10 Jul 2025 19:17:00 +0100 Subject: [PATCH 2/5] fix --- substrate/frame/bags-list/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/frame/bags-list/src/lib.rs b/substrate/frame/bags-list/src/lib.rs index b0ec62b6675a5..9ff37b4b1b149 100644 --- a/substrate/frame/bags-list/src/lib.rs +++ b/substrate/frame/bags-list/src/lib.rs @@ -553,13 +553,13 @@ impl, I: 'static> Pallet { ) -> Result, ListError> { // If no voter at that node, don't do anything. the caller just wasted the fee to call this. let node = list::Node::::get(&account).ok_or(ListError::NodeNotFound)?; + if node.score != new_score { + Self::deposit_event(Event::::ScoreUpdated { who: account.clone(), new_score }); + } let maybe_movement = List::update_position_for(node, new_score); if let Some((from, to)) = maybe_movement { Self::deposit_event(Event::::Rebagged { who: account.clone(), from, to }); }; - if node.score != new_score { - Self::deposit_event(Event::::ScoreUpdated { who: account.clone(), new_score }); - } Ok(maybe_movement) } From cb6884d91b07aeb3c397442adbde1e163ef21347 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 10 Jul 2025 18:20:13 +0000 Subject: [PATCH 3/5] Update from github-actions[bot] running command 'prdoc --bump patch' --- prdoc/pr_9166.prdoc | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 prdoc/pr_9166.prdoc diff --git a/prdoc/pr_9166.prdoc b/prdoc/pr_9166.prdoc new file mode 100644 index 0000000000000..1d504bc75c3ed --- /dev/null +++ b/prdoc/pr_9166.prdoc @@ -0,0 +1,8 @@ +title: 'pallet-bags-list: Emit `ScoreUpdated` event only if it has changed' +doc: +- audience: Todo + description: |- + quick follow-up to https://github.com/paritytech/polkadot-sdk/pull/8684, ensuring all blocks don't have x events when the feature is enabled (as it is now in WAH) +crates: +- name: pallet-bags-list + bump: patch From 6dcbc6fae017868f6c304a73eb0de8eef0625bde Mon Sep 17 00:00:00 2001 From: kianenigma Date: Thu, 10 Jul 2025 19:21:31 +0100 Subject: [PATCH 4/5] prdoc --- prdoc/pr_9166.prdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prdoc/pr_9166.prdoc b/prdoc/pr_9166.prdoc index 1d504bc75c3ed..a9ca451a38a01 100644 --- a/prdoc/pr_9166.prdoc +++ b/prdoc/pr_9166.prdoc @@ -1,8 +1,8 @@ title: 'pallet-bags-list: Emit `ScoreUpdated` event only if it has changed' doc: -- audience: Todo +- audience: Runtime Dev description: |- - quick follow-up to https://github.com/paritytech/polkadot-sdk/pull/8684, ensuring all blocks don't have x events when the feature is enabled (as it is now in WAH) + follow-up to https://github.com/paritytech/polkadot-sdk/pull/8684, ensuring all blocks don't have x events when auto-rebag feature is enabled. crates: - name: pallet-bags-list bump: patch From 35cf43836b21670eecab286b230b0109108cc261 Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Sat, 12 Jul 2025 16:43:56 +0100 Subject: [PATCH 5/5] fix node bench --- substrate/bin/node/bench/src/import.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/substrate/bin/node/bench/src/import.rs b/substrate/bin/node/bench/src/import.rs index db4f37af75e8f..ec112cfee80df 100644 --- a/substrate/bin/node/bench/src/import.rs +++ b/substrate/bin/node/bench/src/import.rs @@ -135,10 +135,9 @@ impl core::Benchmark for ImportBenchmark { // - 2x deposit (Balances::Deposit and Treasury::Deposit) for depositing // the transaction fee into the treasury // - extrinsic success - // +3 Bags List events from on_idle hook assert_eq!( kitchensink_runtime::System::events().len(), - (self.block.extrinsics.len() - 2) * 9 + 2 + 3, + (self.block.extrinsics.len() - 2) * 9 + 2, ); }, BlockType::Noop => {