Create sp-weights crate to store weight primitives (#12219)

* Create sp-weights crate to store weight primitives

* Fix templates

* Fix templates

* Fixes

* Fixes

* cargo fmt

* Fixes

* Fixes

* Use deprecated type alias instead of deprecated unit types

* Use deprecated subtraits instead of deprecated hollow new traits

* Fixes

* Allow deprecation in macro expansion

* Add missing where clause during call macro expansion

* cargo fmt

* Fixes

* cargo fmt

* Fixes

* Fixes

* Fixes

* Fixes

* Move FRAME-specific weight files back to frame_support

* Fixes

* Update frame/support/src/dispatch.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/support/src/dispatch.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/support/src/dispatch.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Add missing header

* Rewrite module docs

* Fixes

* Fixes

* Fixes

* Fixes

* cargo fmt

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
Keith Yeung
2022-09-13 21:23:44 +08:00
committed by GitHub
parent 214eb25f87
commit 30e7b1e8cd
69 changed files with 1316 additions and 1225 deletions
@@ -101,7 +101,10 @@ impl<T: Config + Send + Sync> SignedExtension for CheckMortality<T> {
mod tests {
use super::*;
use crate::mock::{new_test_ext, System, Test, CALL};
use frame_support::weights::{DispatchClass, DispatchInfo, Pays, Weight};
use frame_support::{
dispatch::{DispatchClass, DispatchInfo, Pays},
weights::Weight,
};
use sp_core::H256;
#[test]
@@ -17,7 +17,7 @@
use crate::Config;
use codec::{Decode, Encode};
use frame_support::weights::DispatchInfo;
use frame_support::dispatch::DispatchInfo;
use scale_info::TypeInfo;
use sp_runtime::{
traits::{DispatchInfoOf, Dispatchable, SignedExtension},
@@ -17,7 +17,7 @@
use crate::Config;
use codec::{Decode, Encode};
use frame_support::weights::DispatchInfo;
use frame_support::dispatch::DispatchInfo;
use scale_info::TypeInfo;
use sp_runtime::{
traits::{DispatchInfoOf, Dispatchable, One, SignedExtension},
@@ -18,8 +18,8 @@
use crate::{limits::BlockWeights, Config, Pallet};
use codec::{Decode, Encode};
use frame_support::{
dispatch::{DispatchClass, DispatchInfo, PostDispatchInfo},
traits::Get,
weights::{DispatchClass, DispatchInfo, PostDispatchInfo, Weight},
};
use scale_info::TypeInfo;
use sp_runtime::{
@@ -27,6 +27,7 @@ use sp_runtime::{
transaction_validity::{InvalidTransaction, TransactionValidity, TransactionValidityError},
DispatchResult,
};
use sp_weights::Weight;
/// Block resource (weight) limit check.
///
@@ -269,10 +270,7 @@ mod tests {
mock::{new_test_ext, System, Test, CALL},
AllExtrinsicsLen, BlockWeight,
};
use frame_support::{
assert_err, assert_ok,
weights::{Pays, Weight},
};
use frame_support::{assert_err, assert_ok, dispatch::Pays, weights::Weight};
use sp_std::marker::PhantomData;
fn block_weights() -> crate::limits::BlockWeights {
+5 -5
View File
@@ -84,20 +84,20 @@ use sp_version::RuntimeVersion;
use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen};
use frame_support::{
dispatch::{DispatchResult, DispatchResultWithPostInfo},
dispatch::{
extract_actual_pays_fee, extract_actual_weight, DispatchClass, DispatchInfo,
DispatchResult, DispatchResultWithPostInfo, PerDispatchClass,
},
storage,
traits::{
ConstU32, Contains, EnsureOrigin, Get, HandleLifetime, OnKilledAccount, OnNewAccount,
OriginTrait, PalletInfo, SortedMembers, StoredMap, TypedGet,
},
weights::{
extract_actual_pays_fee, extract_actual_weight, DispatchClass, DispatchInfo,
PerDispatchClass, RuntimeDbWeight, Weight,
},
Parameter,
};
use scale_info::TypeInfo;
use sp_core::storage::well_known_keys;
use sp_weights::{RuntimeDbWeight, Weight};
#[cfg(feature = "std")]
use frame_support::traits::GenesisBuild;
+4 -1
View File
@@ -25,7 +25,10 @@
//! `DispatchClass`. This module contains configuration object for both resources,
//! which should be passed to `frame_system` configuration when runtime is being set up.
use frame_support::weights::{constants, DispatchClass, OneOrMany, PerDispatchClass, Weight};
use frame_support::{
dispatch::{DispatchClass, OneOrMany, PerDispatchClass},
weights::{constants, Weight},
};
use scale_info::TypeInfo;
use sp_runtime::{traits::Bounded, Perbill, RuntimeDebug};
+1 -2
View File
@@ -18,8 +18,7 @@
use crate::*;
use frame_support::{
assert_noop, assert_ok,
dispatch::PostDispatchInfo,
weights::{Pays, WithPostDispatchInfo},
dispatch::{Pays, PostDispatchInfo, WithPostDispatchInfo},
};
use mock::{Origin, *};
use sp_core::H256;