Skip to content

Commit

Permalink
Add debugging info for StorageWeightReclaim (#5594)
Browse files Browse the repository at this point in the history
When inspecting the logs we often encounter the following message:

`Benchmarked storage weight smaller than consumed storage weight.
benchmarked: {benchmarked_weight} consumed: {consumed_weight} unspent:
{unspent}`

However, it is very hard to guess which call is causing the issue.

With the changes proposed in this PR, information about the call is
provided so that we can easily identify the source of the problem
without further delay, and this way work more efficiently in solving the
issue.

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
(cherry picked from commit 016421a)
  • Loading branch information
Moliholy authored and github-actions[bot] committed Sep 19, 2024
1 parent 56ce901 commit f99678e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cumulus/primitives/storage-weight-reclaim/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
13 changes: 13 additions & 0 deletions prdoc/pr_5594.prdoc
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f99678e

Please sign in to comment.