Add debugging info for StorageWeightReclaim#5594
Conversation
StorageWeightReclaim
| _len: usize, | ||
| ) -> Result<Self::Pre, sp_runtime::transaction_validity::TransactionValidityError> { | ||
| Ok(get_proof_size()) | ||
| Ok((get_proof_size(), call.clone())) |
There was a problem hiding this comment.
Cloning the entire call is a little bit too expensive.
There was a problem hiding this comment.
What about adding the GetCallMetadata to T::RuntimeCall and debugging the corresponding CallMetadata? We'd miss the call arguments, but at least it already points in the right direction. In that case we could also add the extrinsic number, as you suggested.
There was a problem hiding this comment.
You can just see the transaction with all its arguments in the block explorer. I don't see any need to log them.
There was a problem hiding this comment.
Alright, I just pushed the changes as per your suggestion.
| 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. call: {call:?} benchmarked: {benchmarked_weight} consumed: {consumed_weight} unspent: {unspent}" |
There was a problem hiding this comment.
Instead of the call we could print the frame_system::Pallet::extrinsic_count(). Then you have the index of the transaction.
There was a problem hiding this comment.
I find that less straightforward. You might check the logs at a later point in time, when the state could, for instance, have been pruned. In that scenario you wouldn't be able to retrieve the block (after taking the time to inspect the block in PolkadotJS).
Also, it'd take more time to figure out which extrinsic is. My purpose is to increase as much as possible developer productivity, and the most go-to way I found is this one.
That being said, I understand passing the call and printing its debug information has a performance penalty. Still, I think it'd be better off with the proposed changes, as a small performance penalty could potentially save hours of debugging and improve overall productivity.
Still... if you think otherwise, I'll change it as per your suggestion. But I'd prefer to softly push for the proposed solution, as in my opinion it represents the best trade-off.
EDIT: besides, looking at the implementation of extrinsic_count():
/// Gets extrinsics count.
pub fn extrinsic_count() -> u32 {
ExtrinsicCount::<T>::get().unwrap_or_default()
}It does access an storage item. Wouldn't that introduce a higher performance penalty than the proposed solution?
There was a problem hiding this comment.
You might check the logs at a later point in time, when the state could, for instance, have been pruned. In that scenario you wouldn't be able to retrieve the block (after taking the time to inspect the block in PolkadotJS).
State pruning is different to blocks pruning. Block pruning needs to be enabled directly.
We don't have that much memory and wasting the memory just for some debugging which is only required in 0.01% of the cases is not a good idea.
It does access an storage item. Wouldn't that introduce a higher performance penalty than the proposed solution?
The storage item will only be accessed when the log level is enabled . For the release build on chain logging should be disabled any way. Thus, this should not lead to any performance impacts on production networks.
There was a problem hiding this comment.
some debugging which is only required in 0.01% of the cases is not a good idea.
I'd say an incorrectly benchmarked custom pallet in a parachain is much more common than that. Still, I implemented it as per your suggestion.
There was a problem hiding this comment.
Just take all the nodes into account that need to execute the block and that are not used for debugging. Debugging is a small fraction and you get the index of the transaction and that gives you all the information for free.
There was a problem hiding this comment.
@bkchr please double check, but to me it looks like ExtrinsicCount is not updated on the fly, but only at the end of the block here (also in line with the docs):
polkadot-sdk/substrate/frame/system/src/lib.rs
Lines 2048 to 2054 in fcea4ff
I think we should use extrinsic_index() instead which seems to be updated after every xt.
polkadot-sdk/substrate/frame/system/src/lib.rs
Line 2042 in fcea4ff
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)
|
Successfully created backport PR for |
|
Successfully created backport PR for |
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)
Backport #5594 into `stable2407` 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>
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>
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.