From c9fbeb72a797c1b8420d7c9c69eebe58c023bc29 Mon Sep 17 00:00:00 2001
From: "paritytech-cmd-bot-polkadot-sdk[bot]"
 <179002856+paritytech-cmd-bot-polkadot-sdk[bot]@users.noreply.github.com>
Date: Thu, 19 Sep 2024 10:36:47 +0200
Subject: [PATCH] [stable2409] Backport #5594 (#5767)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Backport #5594 into `stable2409` from Moliholy.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

Co-authored-by: José Molina Colmenero <jose@blockdeep.io>
---
 .../primitives/storage-weight-reclaim/src/lib.rs    |  6 ++++--
 prdoc/pr_5594.prdoc                                 | 13 +++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
 create mode 100644 prdoc/pr_5594.prdoc

diff --git a/cumulus/primitives/storage-weight-reclaim/src/lib.rs b/cumulus/primitives/storage-weight-reclaim/src/lib.rs
index a557e881e26..2529297691e 100644
--- a/cumulus/primitives/storage-weight-reclaim/src/lib.rs
+++ b/cumulus/primitives/storage-weight-reclaim/src/lib.rs
@@ -183,13 +183,15 @@ where
 			if consumed_weight > benchmarked_weight {
 				log::error!(
 					target: LOG_TARGET,
-					"Benchmarked storage weight smaller than consumed storage weight. benchmarked: {benchmarked_weight} consumed: {consumed_weight} unspent: {unspent}"
+					"Benchmarked storage weight smaller than consumed storage weight. extrinsic: {} benchmarked: {benchmarked_weight} consumed: {consumed_weight} unspent: {unspent}",
+					frame_system::Pallet::<T>::extrinsic_index().unwrap_or(0)
 				);
 				current.accrue(Weight::from_parts(0, storage_size_diff), info.class)
 			} else {
 				log::trace!(
 					target: LOG_TARGET,
-					"Reclaiming storage weight. benchmarked: {benchmarked_weight}, consumed: {consumed_weight} unspent: {unspent}"
+					"Reclaiming storage weight. extrinsic: {} benchmarked: {benchmarked_weight} consumed: {consumed_weight} unspent: {unspent}",
+					frame_system::Pallet::<T>::extrinsic_index().unwrap_or(0)
 				);
 				current.reduce(Weight::from_parts(0, storage_size_diff), info.class)
 			}
diff --git a/prdoc/pr_5594.prdoc b/prdoc/pr_5594.prdoc
new file mode 100644
index 00000000000..dbdc7937b73
--- /dev/null
+++ b/prdoc/pr_5594.prdoc
@@ -0,0 +1,13 @@
+# 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: "Add debugging info for `StorageWeightReclaim`"
+
+doc:
+  - audience: Runtime Dev
+    description: |
+      - Includes extrinsic index to be displayed in the logs when the consumed weight is higher than the measured one.
+
+crates:
+  - name: cumulus-primitives-storage-weight-reclaim
+    bump: patch
-- 
GitLab