This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Introduce BlockExecutionWeight and ExtrinsicBaseWeight
#5722
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kianenigma
reviewed
Apr 22, 2020
kianenigma
reviewed
Apr 22, 2020
kianenigma
reviewed
Apr 22, 2020
kianenigma
reviewed
Apr 22, 2020
shawntabrizi
commented
Apr 22, 2020
shawntabrizi
commented
Apr 22, 2020
athei
reviewed
Apr 24, 2020
gavofyork
approved these changes
Apr 24, 2020
athei
reviewed
Apr 24, 2020
athei
approved these changes
Apr 24, 2020
Contributor
|
bot merge |
1 similar comment
Member
Author
|
bot merge |
|
Cannot merge; please ensure the pull request is mergeable and has approval from the project owner or at least 2 core devs. |
|
bot merge cancel |
|
bot merge |
|
bot merge complete |
This was referenced Apr 25, 2020
sorpaas
pushed a commit
that referenced
this pull request
Nov 20, 2020
* Introduce `BlockExectionWeight` and `ExtrinsicBaseWeight` * Add new traits everywhere * Missed one update * fix tests * Update `check_weight` logic * introduce `max_extrinsic_weight` function * fix + add tests * format nits * remove println * make test a bit more clear * Remove minimum weight * newlines left over from find/replace * Fix test, improve clarity * Fix executor tests * Extrinsic base weight same as old `MINIMUM_WEIGHT` * fix example test * Expose constants * Add test for full block with operational and normal * Initiate test environment with `BlockExecutionWeight` weight * format nit * Update frame/system/src/lib.rs Co-Authored-By: Kian Paimani <[email protected]> * Replace `TransactionBaseFee` with `ExtrinsicBaseWeight` (#5761) * Replace `TransactionBaseFee` with `ExtrinsicBaseFee` * Fix stuff * Fix and make tests better * Forgot to update this test * Fix priority number in test * Remove minimum weight from merge * Fix weight in contracts * remove `TransactionBaseFee` from contract tests * Let `register_extra_weight_unchecked` go past `MaximumBlockWeight` * address feedback Co-authored-by: Kian Paimani <[email protected]>
This pull request was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces the following concepts:
Every extrinsic has some base weight for existing in a block. For example, Reading/Writing from the sender account in storage, signature verification, etc...
Every block has some base weight independent of the included extrinsics.
To account for this, we make the following changes:
New System Traits
We introduce 2 new system configuration traits to account for all weights in the block execution process.
BlockExecutionWeight: A fixed value that takes into account any overhead introduced by simply executing a block, not including the execution of the transactions themselves.So the stuff above minus
execute_extrinsics_with_book_keepingExtrinsicBaseWeight: A fixed value that takes into account any overhead introduced by simply including an extrinsic in a block. Measured by executing manyno-opextrinsics and deriving the individual cost of one such extrinsic.These two weights will automatically be included through the block execution process when defined in the runtime.
We also replace the notion of
TransactionBaseFeewithExtrinsicBaseWeight*WeightToFee.New Weight Logic
Before this PR (and the larger goal of updating all extrinsic weights), all weights were constant. As a result, we assumed that no weight would be too big for a single block.
Now that extrinsic weights could be represented by formulas, and the input to an extrinsic could be beyond the capabilities of the blockchain. So we introduce the following new behavior:
ExhaustedResources.DispatchClass::Mandatory, which will be allowed in a block no matter what. This may cause the weight of a block to be larger thanMaximumBlockWeight.This weight pipeline needs to take into account the new traits we defined, so to make it a bit more ergonomic to define weights, we also introduce a new System function
max_extrinsic_weight, which takes aDispatchClassand returns the max weight allowed for an extrinsic in a block. Only one such extrinsic like this could exist in a block.This PR also removed
MINIMUM_WEIGHT, since that concept is basically replaced withExtrinsicBaseWeightnow.