Introduce MaxParachainBlockWeight and related functionality#10315
Introduce MaxParachainBlockWeight and related functionality#10315
MaxParachainBlockWeight and related functionality#10315Conversation
This pull request introduces `MaxParachainBlockWeight` to calculate the max weight per parachain block. This is a preparation for [Block Bundling](#6495) which requires that the maximum block weight is dynamic. Block bundling requires a dynamic maximum block weight because it bundles multiple blocks into one `PoV`. Each `PoV` gets `2s` of execution time and `10MiB` of proof size. These resources need to be split up between all the blocks of one `PoV`. This doesn't require the weight to be dynamic. However, it gets complicated when a transaction should be applied that requires more resources than what one of these blocks can provide, e.g. for doing a runtime upgrade. In this case `MaxParachainBlockWeight` supports to increase the block weight of one block to take up the weight of the full `PoV`. The feature will not only be useful for things like runtime upgrade, but also could enable users to pay for running some huge contracts or whatever. For more information, please refer to the docs provided in the code of this pull request. For `MaxParachainBlockWeight` to work correctly, it provides a pre-inherent hook and a transaction extension. Both are required to track the weight correctly.
…extension.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
…extension.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
ggwpez
left a comment
There was a problem hiding this comment.
Seems quite complex to me, maybe we should do a tentative deployment to Westend from this branch with the extension included before merging.
| //! The [`MaxParachainBlockWeight`] provides a [`Get`] implementation that will return the max block | ||
| //! weight as determined by the [`DynamicMaxBlockWeight`] transaction extension. | ||
| //! | ||
| //! [`DynamicMaxBlockWeightHooks`] needs to be registered as a pre-inherent hook. It is used to |
There was a problem hiding this comment.
Maybe we can somehow test this in the runtime integrity check, like the migrations pallet does for the MultiBlockMigrator hook.
There was a problem hiding this comment.
Yeah I thought about this as well, but did not came up with any proper implementation I'm happy with.
| /// Transaction extension that dynamically changes the max block weight. | ||
| /// | ||
| /// With block bundling, parachains are running with block weights that may not allow certain | ||
| /// transactions to be applied, e.g. a runtime upgrade. To ensure that these transactions can still |
There was a problem hiding this comment.
If I want to send a big transaction, how do I tell the node to put into the first block of a batch? Or will it do that automatically?
There was a problem hiding this comment.
The node is ordering based on priority. The runtime lays out priority based on the fees that you are going to pay. Fees are based on weight. There is generally no guarantee for the ordering. If a transaction does not fit, it will be tried at the next block.
| /// The current block weight mode. | ||
| /// | ||
| /// This is used to determine what is the maximum allowed block weight, for more information see | ||
| /// [`block_weight`]. |
There was a problem hiding this comment.
Can you please explain here when it is set and when it is removed?
| .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) | ||
| } | ||
| fn block_weight_tx_extension_max_weight() -> Weight { | ||
| Weight::zero() |
| pub number_of_cores: Compact<u16>, | ||
| } | ||
|
|
||
| impl core::hash::Hash for CoreInfo { |
I don't want to directly deploy this to production. :) Not sure what you want to test there on Westend. I have also more tests in another branch where zombienet tests are running based on this stuff. |
…tion.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
…ck-weight' into bkchr-parachain-block-weight
|
/cmd fmt |
|
/cmd fmt |
|
/cmd fmt |
57f8c74 to
3f04aaf
Compare
This implements Block bundling aka 500ms on the node side. Right now the pull request also contains the runtime changes, but this is already its [own pull request](#10315). The main changes are in the slot-based collator. Instead of building one block per core, blocks will be build as requested and distributed over the available cores. Closes: #9080 Closes: #8963 Closes: #6495 --------- Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com> Co-authored-by: Sebastian Kunert <mail@skunert.dev> Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
This pull request introduces
MaxParachainBlockWeightto calculate the max weight per parachain block. This is a preparation for Block Bundling which requires that the maximum block weight is dynamic. Block bundling requires a dynamic maximum block weight because it bundles multiple blocks into onePoV. EachPoVgets2sof execution time and10MiBof proof size. These resources need to be split up between all the blocks of onePoV. This doesn't require the weight to be dynamic. However, it gets complicated when a transaction should be applied that requires more resources than what one of these blocks can provide, e.g. for doing a runtime upgrade. In this caseMaxParachainBlockWeightsupports to increase the block weight of one block to take up the weight of the fullPoV. The feature will not only be useful for things like runtime upgrade, but also could enable users to pay for running some huge contracts or whatever. For more information, please refer to the docs provided in the code of this pull request.For
MaxParachainBlockWeightto work correctly, it provides a pre-inherent hook and a transaction extension. Both are required to track the weight correctly.