3

I have noticed on Moonbeam that the Normal system.blockWeight is often much higher than the sum of Normal class extrinsics included in the block. Example:

https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fwss.api.moonbeam.network#/explorer/query/0x438d0a0323d6434a5426ec02dfbfe1847cbfafcf05517c1515029428e5f5b85d

(block 1813141 / 0x438d0a0323d6434a5426ec02dfbfe1847cbfafcf05517c1515029428e5f5b85d)

This block includes some ethereum.transact transactions totaling 14_967_850_000 Normal weight, but the system.blockWeight Normal class for the same block is 221_040_085_000.

It is common for these to be different, although the two numbers are sometimes identical as well. Sometimes they are both 0 for a block.

Where could this discrepancy be coming from?

EDIT: This question led to both this issue: https://github.com/paritytech/substrate/issues/12252 and this fix: https://github.com/paritytech/frontier/pull/851

3
  • Good catch! Something is def. wrong here. The ExtrinsicBaseWeight is missing as well in PolkadotJS. Sep 9, 2022 at 14:05
  • Yea fees work, but look at how much weight PolkadotJS reports for a System.Remark. I can bring that down to zero, def. not enough. Sep 9, 2022 at 16:06
  • 1
    Thanks, @OliverTale-Yazdi. The main issue turned out to be a bug in frontier where weight was not refunded in post-dispatch (link in my edit above), but it looks like your issue is also relevant. Thanks for digging in!
    – notlesh
    Sep 19, 2022 at 16:09

1 Answer 1

2

The total weight of the block comes from the sum of:

  1. work done in on_initialize, which is done before extrinsics
  2. work done in extrinsics
  3. work done in on_finalize, which is done after extrinsics

Doing heavy work in on_finalize is discouraged, because the block may already be filled with extrinsics. In fact, the on_initialize function of pallets is supposed to estimate the weight of both on_initialize and on_finalize in order to prevent the block from being filled with too many extrinsics.

1
  • Thanks, @rob, but this was asking about Normal weight and a discrepancy seen in the accounting for it.
    – notlesh
    Sep 19, 2022 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.