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
@@ -18,7 +18,7 @@
use sp_runtime::{generic, traits::{BlakeTwo256, Block as _, Verify}, DispatchError};
use sp_core::{H256, sr25519};
use frame_support::weights::MINIMUM_WEIGHT;
mod system;
@@ -33,7 +33,7 @@ mod module1 {
pub struct Module<T: Trait<I>, I: Instance = DefaultInstance> for enum Call
where origin: <T as system::Trait>::Origin
{
#[weight = MINIMUM_WEIGHT]
#[weight = 0]
pub fn fail(_origin) -> frame_support::dispatch::DispatchResult {
Err(Error::<T, I>::Something.into())
}
@@ -60,7 +60,7 @@ mod module2 {
pub struct Module<T: Trait> for enum Call
where origin: <T as system::Trait>::Origin
{
#[weight = MINIMUM_WEIGHT]
#[weight = 0]
pub fn fail(_origin) -> frame_support::dispatch::DispatchResult {
Err(Error::<T>::Something.into())
}
@@ -23,7 +23,6 @@ use frame_support::{
DecodeDifferent, StorageMetadata, StorageEntryModifier, StorageEntryType, DefaultByteGetter,
StorageEntryMetadata, StorageHasher,
},
weights::MINIMUM_WEIGHT,
StorageValue, StorageMap, StorageDoubleMap,
};
use sp_inherents::{ProvideInherent, InherentData, InherentIdentifier, MakeFatalError};
@@ -56,7 +55,7 @@ mod module1 {
fn deposit_event() = default;
#[weight = MINIMUM_WEIGHT]
#[weight = 0]
fn one(origin) {
system::ensure_root(origin)?;
Self::deposit_event(RawEvent::AnotherVariant(3));
@@ -2,7 +2,7 @@ macro_rules! reserved {
($($reserved:ident)*) => {
$(
mod $reserved {
pub use frame_support::{dispatch, weights::MINIMUM_WEIGHT};
pub use frame_support::dispatch;
pub trait Trait {
type Origin;
@@ -19,7 +19,7 @@ macro_rules! reserved {
frame_support::decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
#[weight = MINIMUM_WEIGHT]
#[weight = 0]
fn $reserved(_origin) -> dispatch::DispatchResult { unreachable!() }
}
}