paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.com/
1.89k stars 696 forks source link

pallet-message-queue: Fix max message size calculation #6205

Closed bkchr closed 3 weeks ago

bkchr commented 3 weeks ago

The max size of a message should not depend on the weight left in a given execution context. Instead the max message size depends on the service weights configured for the pallet. A message that may does not fit into on_idle is not automatically overweight, because it may can be executed successfully in on_initialize or in another block in on_idle when there is more weight left.

bkchr commented 3 weeks ago

The hotfix looks correct, but the assumption that it will retry in the next context is not that great, since it could also retry in the same context and then keep looping around a bit...

How could it retry in the same context again?

ggwpez commented 3 weeks ago

How could it retry in the same context again?

I guess eventually it should resolve if there is any on_idle weight. If the chain is constantly at 100% then dont know.

Quite a few chains seem to use it currently: https://github.com/search?q=%22IdleMaxServiceWeight+%3D%22&type=code
I will query the datalake tomorrow for OverweightEnqueued events by parachain.

bkchr commented 3 weeks ago

I guess eventually it should resolve if there is any on_idle weight. If the chain is constantly at 100% then dont know.

The problem is OnIdle, that when you have not enough weight left. Right now the message is seen as constantly overweight, but with my fix here it is only pushed back and retried in the next block. A further optimization could be that we try other messages if they may fit.

bkchr commented 3 weeks ago

/cmd prdoc --bump patch --audience runtime-dev

github-actions[bot] commented 3 weeks ago

Command "prdoc --bump patch --audience runtime-dev" has failed ❌! See logs here

bkchr commented 3 weeks ago

/cmd prdoc --bump patch --audience runtime_dev

paritytech-cmd-bot-polkadot-sdk[bot] commented 3 weeks ago

Successfully created backport PR for stable2407:

paritytech-cmd-bot-polkadot-sdk[bot] commented 3 weeks ago

Successfully created backport PR for stable2409: