Introduce BlockExecutionWeight and ExtrinsicBaseWeight (#5722)

* 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 commit is contained in:
Shawn Tabrizi
2020-04-25 07:59:54 +02:00
committed by GitHub
parent 3793fbf9cc
commit 8a33c297b4
74 changed files with 518 additions and 301 deletions
+6 -6
View File
@@ -25,7 +25,7 @@ use sp_runtime::traits::{
StaticLookup, Member, LookupError, Zero, One, BlakeTwo256, Hash, Saturating, AtLeast32Bit
};
use frame_support::{Parameter, decl_module, decl_error, decl_event, decl_storage, ensure};
use frame_support::weights::{Weight, MINIMUM_WEIGHT};
use frame_support::weights::Weight;
use frame_support::dispatch::DispatchResult;
use frame_support::traits::{Currency, ReservableCurrency, Get, BalanceStatus::Reserved};
use frame_support::storage::migration::take_storage_value;
@@ -102,7 +102,7 @@ decl_module! {
fn on_initialize() -> Weight {
Self::migrations();
MINIMUM_WEIGHT
0
}
/// Assign an previously unassigned index.
@@ -121,7 +121,7 @@ decl_module! {
/// - One reserve operation.
/// - One event.
/// # </weight>
#[weight = MINIMUM_WEIGHT]
#[weight = 0]
fn claim(origin, index: T::AccountIndex) {
let who = ensure_signed(origin)?;
@@ -149,7 +149,7 @@ decl_module! {
/// - One transfer operation.
/// - One event.
/// # </weight>
#[weight = MINIMUM_WEIGHT]
#[weight = 0]
fn transfer(origin, new: T::AccountId, index: T::AccountIndex) {
let who = ensure_signed(origin)?;
ensure!(who != new, Error::<T>::NotTransfer);
@@ -180,7 +180,7 @@ decl_module! {
/// - One reserve operation.
/// - One event.
/// # </weight>
#[weight = MINIMUM_WEIGHT]
#[weight = 0]
fn free(origin, index: T::AccountIndex) {
let who = ensure_signed(origin)?;
@@ -209,7 +209,7 @@ decl_module! {
/// - Up to one reserve operation.
/// - One event.
/// # </weight>
#[weight = MINIMUM_WEIGHT]
#[weight = 0]
fn force_transfer(origin, new: T::AccountId, index: T::AccountIndex) {
ensure_root(origin)?;
+2
View File
@@ -62,6 +62,8 @@ impl frame_system::Trait for Test {
type BlockHashCount = BlockHashCount;
type MaximumBlockWeight = MaximumBlockWeight;
type DbWeight = ();
type BlockExecutionWeight = ();
type ExtrinsicBaseWeight = ();
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();