This repository has been 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.6k
Introduce BlockExecutionWeight
and ExtrinsicBaseWeight
#5722
Merged
Conversation
This file contains 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
shawntabrizi
requested review from
andresilva,
Demi-Marie,
kianenigma,
mxinden and
pepyakin
as code owners
April 21, 2020 13:42
shawntabrizi
added
the
A3-in_progress
Pull request is in progress. No review needed at this stage.
label
Apr 21, 2020
kianenigma
reviewed
Apr 22, 2020
kianenigma
reviewed
Apr 22, 2020
kianenigma
reviewed
Apr 22, 2020
kianenigma
reviewed
Apr 22, 2020
shawntabrizi
added
A0-please_review
Pull request needs code review.
and removed
A3-in_progress
Pull request is in progress. No review needed at this stage.
labels
Apr 22, 2020
shawntabrizi
commented
Apr 22, 2020
shawntabrizi
commented
Apr 22, 2020
shawntabrizi
removed request for
andresilva,
pepyakin,
sorpaas,
mxinden and
Demi-Marie
April 24, 2020 15:53
gavofyork
approved these changes
Apr 24, 2020
gavofyork
added
A8-mergeoncegreen
and removed
A0-please_review
Pull request needs code review.
labels
Apr 24, 2020
athei
reviewed
Apr 24, 2020
athei
approved these changes
Apr 24, 2020
bot merge |
1 similar comment
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 |
ghost
deleted the
shawntabrizi-additional-block-weights
branch
April 25, 2020 05:59
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 <5588131+kianenigma@users.noreply.github.com> * 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 <5588131+kianenigma@users.noreply.github.com>
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_keeping
ExtrinsicBaseWeight
: A fixed value that takes into account any overhead introduced by simply including an extrinsic in a block. Measured by executing manyno-op
extrinsics 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
TransactionBaseFee
withExtrinsicBaseWeight
*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 aDispatchClass
and 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 withExtrinsicBaseWeight
now.