Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Create sp-weights crate to store weight primitives #12219

Merged
merged 35 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6e10966
Create sp-weights crate to store weight primitives
KiChjang Sep 7, 2022
5e4dd1d
Merge remote-tracking branch 'origin/master' into kckyeung/sp-weights
KiChjang Sep 8, 2022
43ab5e6
Fix templates
KiChjang Sep 8, 2022
e5bace0
Fix templates
KiChjang Sep 8, 2022
87a1ff4
Fixes
KiChjang Sep 8, 2022
6b1c48c
Fixes
KiChjang Sep 8, 2022
f17e1b2
cargo fmt
KiChjang Sep 8, 2022
48a88cc
Fixes
KiChjang Sep 8, 2022
19ae7dd
Fixes
KiChjang Sep 8, 2022
4728a95
Use deprecated type alias instead of deprecated unit types
KiChjang Sep 8, 2022
70b56ec
Use deprecated subtraits instead of deprecated hollow new traits
KiChjang Sep 8, 2022
8415f32
Fixes
KiChjang Sep 8, 2022
39ba7b9
Allow deprecation in macro expansion
KiChjang Sep 8, 2022
d7bcf1f
Add missing where clause during call macro expansion
KiChjang Sep 9, 2022
fb468e9
cargo fmt
KiChjang Sep 9, 2022
c51cde5
Fixes
KiChjang Sep 9, 2022
e4c44fa
cargo fmt
KiChjang Sep 9, 2022
ef1be20
Fixes
KiChjang Sep 9, 2022
12c3e06
Fixes
KiChjang Sep 9, 2022
1937813
Fixes
KiChjang Sep 9, 2022
531986c
Fixes
KiChjang Sep 9, 2022
51b7b21
Move FRAME-specific weight files back to frame_support
KiChjang Sep 12, 2022
d43dd83
Fixes
KiChjang Sep 12, 2022
88223b7
Merge branch 'master' into kckyeung/sp-weights
shawntabrizi Sep 12, 2022
d029aa4
Update frame/support/src/dispatch.rs
KiChjang Sep 13, 2022
029f121
Update frame/support/src/dispatch.rs
KiChjang Sep 13, 2022
f6dc099
Update frame/support/src/dispatch.rs
KiChjang Sep 13, 2022
56407a5
Add missing header
KiChjang Sep 13, 2022
3c5455a
Rewrite module docs
KiChjang Sep 13, 2022
eca462f
Merge remote-tracking branch 'origin/master' into kckyeung/sp-weights
KiChjang Sep 13, 2022
3f8e33f
Fixes
KiChjang Sep 13, 2022
785fe95
Fixes
KiChjang Sep 13, 2022
8bcc6f1
Fixes
KiChjang Sep 13, 2022
9e235f9
Fixes
KiChjang Sep 13, 2022
1880f7a
cargo fmt
KiChjang Sep 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ members = [
"primitives/version",
"primitives/version/proc-macro",
"primitives/wasm-interface",
"primitives/weights",
"test-utils/client",
"test-utils/derive",
"test-utils/runtime",
Expand Down
3 changes: 2 additions & 1 deletion bin/node/executor/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

use codec::{Decode, Encode, Joiner};
use frame_support::{
dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo},
traits::Currency,
weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Weight},
weights::Weight,
};
use frame_system::{self, AccountInfo, EventRecord, Phase};
use sp_core::{storage::well_known_keys, traits::Externalities};
Expand Down
3 changes: 2 additions & 1 deletion bin/node/executor/tests/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

use codec::{Encode, Joiner};
use frame_support::{
dispatch::GetDispatchInfo,
traits::Currency,
weights::{constants::ExtrinsicBaseWeight, GetDispatchInfo, IdentityFee, WeightToFee},
weights::{constants::ExtrinsicBaseWeight, IdentityFee, WeightToFee},
};
use kitchensink_runtime::{
constants::{currency::*, time::SLOT_DURATION},
Expand Down
5 changes: 4 additions & 1 deletion bin/node/runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ mod multiplier_tests {
AdjustmentVariable, MinimumMultiplier, Runtime, RuntimeBlockWeights as BlockWeights,
System, TargetBlockFullness, TransactionPayment,
};
use frame_support::weights::{DispatchClass, Weight, WeightToFee};
use frame_support::{
dispatch::DispatchClass,
weights::{Weight, WeightToFee},
};

fn max_normal() -> Weight {
BlockWeights::get()
Expand Down
3 changes: 2 additions & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use frame_election_provider_support::{
};
use frame_support::{
construct_runtime,
dispatch::DispatchClass,
pallet_prelude::Get,
parameter_types,
traits::{
Expand All @@ -37,7 +38,7 @@ use frame_support::{
},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
ConstantMultiplier, DispatchClass, IdentityFee, Weight,
ConstantMultiplier, IdentityFee, Weight,
},
PalletId, RuntimeDebug,
};
Expand Down
4 changes: 2 additions & 2 deletions frame/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

use codec::{Decode, Encode};
use frame_support::{
dispatch::DispatchResultWithPostInfo,
dispatch::{DispatchResultWithPostInfo, Pays},
ensure,
traits::{
ConstU32, DisabledValidators, FindAuthor, Get, KeyOwnerProofSystem, OnTimestampSet,
OneSessionHandler,
},
weights::{Pays, Weight},
weights::Weight,
BoundedVec, WeakBoundedVec,
};
use sp_application_crypto::ByteArray;
Expand Down
2 changes: 1 addition & 1 deletion frame/babe/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
use super::{Call, *};
use frame_support::{
assert_err, assert_noop, assert_ok,
dispatch::{GetDispatchInfo, Pays},
traits::{Currency, EstimateNextSessionRotation, OnFinalize},
weights::{GetDispatchInfo, Pays},
};
use mock::*;
use pallet_session::ShouldEndSession;
Expand Down
3 changes: 2 additions & 1 deletion frame/balances/src/tests_composite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

use crate::{self as pallet_balances, decl_tests, Config, Pallet};
use frame_support::{
dispatch::DispatchInfo,
parameter_types,
traits::{ConstU32, ConstU64, ConstU8},
weights::{DispatchInfo, IdentityFee, Weight},
weights::{IdentityFee, Weight},
};
use pallet_transaction_payment::CurrencyAdapter;
use sp_core::H256;
Expand Down
3 changes: 2 additions & 1 deletion frame/balances/src/tests_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

use crate::{self as pallet_balances, decl_tests, Config, Pallet};
use frame_support::{
dispatch::DispatchInfo,
parameter_types,
traits::{ConstU32, ConstU64, ConstU8, StorageMapShim},
weights::{DispatchInfo, IdentityFee, Weight},
weights::{IdentityFee, Weight},
};
use pallet_transaction_payment::CurrencyAdapter;
use sp_core::H256;
Expand Down
7 changes: 5 additions & 2 deletions frame/collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ use sp_std::{marker::PhantomData, prelude::*, result};

use frame_support::{
codec::{Decode, Encode, MaxEncodedLen},
dispatch::{DispatchError, DispatchResultWithPostInfo, Dispatchable, PostDispatchInfo},
dispatch::{
DispatchError, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo, Pays,
PostDispatchInfo,
},
ensure,
traits::{
Backing, ChangeMembers, EnsureOrigin, Get, GetBacking, InitializeMembers, StorageVersion,
},
weights::{GetDispatchInfo, Pays, Weight},
weights::Weight,
};

#[cfg(test)]
Expand Down
5 changes: 3 additions & 2 deletions frame/collective/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
use super::{Event as CollectiveEvent, *};
use crate as pallet_collective;
use frame_support::{
assert_noop, assert_ok, parameter_types,
assert_noop, assert_ok,
dispatch::Pays,
parameter_types,
traits::{ConstU32, ConstU64, GenesisBuild, StorageVersion},
weights::Pays,
Hashable,
};
use frame_system::{EventRecord, Phase};
Expand Down
4 changes: 2 additions & 2 deletions frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ use crate::{
};
use codec::{Encode, HasCompact};
use frame_support::{
dispatch::Dispatchable,
dispatch::{DispatchClass, Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo},
ensure,
traits::{ConstU32, Contains, Currency, Get, Randomness, ReservableCurrency, Time},
weights::{DispatchClass, GetDispatchInfo, Pays, PostDispatchInfo, Weight},
weights::Weight,
BoundedVec,
};
use frame_system::{limits::BlockWeights, Pallet as System};
Expand Down
4 changes: 2 additions & 2 deletions frame/contracts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ use assert_matches::assert_matches;
use codec::Encode;
use frame_support::{
assert_err, assert_err_ignore_postinfo, assert_noop, assert_ok,
dispatch::DispatchErrorWithPostInfo,
dispatch::{DispatchClass, DispatchErrorWithPostInfo, PostDispatchInfo},
parameter_types,
storage::child,
traits::{
BalanceStatus, ConstU32, ConstU64, Contains, Currency, Get, OnIdle, OnInitialize,
ReservableCurrency,
},
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, PostDispatchInfo, Weight},
weights::{constants::WEIGHT_PER_SECOND, Weight},
};
use frame_system::{self as system, EventRecord, Phase};
use pretty_assertions::{assert_eq, assert_ne};
Expand Down
2 changes: 1 addition & 1 deletion frame/contracts/src/wasm/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2314,7 +2314,7 @@ pub mod env {
call_ptr: u32,
call_len: u32,
) -> Result<ReturnCode, TrapReason> {
use frame_support::{dispatch::GetDispatchInfo, weights::extract_actual_weight};
use frame_support::dispatch::{extract_actual_weight, GetDispatchInfo};
ctx.charge_gas(RuntimeCosts::CopyFromContract(call_len))?;
let call: <E::T as Config>::RuntimeCall =
ctx.read_sandbox_memory_as_unbounded(call_ptr, call_len)?;
Expand Down
3 changes: 2 additions & 1 deletion frame/election-provider-multi-phase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,10 @@ use frame_election_provider_support::{
ElectionDataProvider, ElectionProvider, InstantElectionProvider, NposSolution,
};
use frame_support::{
dispatch::DispatchClass,
ensure,
traits::{Currency, Get, OnUnbalanced, ReservableCurrency},
weights::{DispatchClass, Weight},
weights::Weight,
};
use frame_system::{ensure_none, offchain::SendTransactionTypes};
use scale_info::TypeInfo;
Expand Down
2 changes: 1 addition & 1 deletion frame/election-provider-support/src/onchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use crate::{
Debug, ElectionDataProvider, ElectionProvider, InstantElectionProvider, NposSolver, WeightInfo,
};
use frame_support::{traits::Get, weights::DispatchClass};
use frame_support::{dispatch::DispatchClass, traits::Get};
use sp_npos_elections::*;
use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData, prelude::*};

Expand Down
4 changes: 2 additions & 2 deletions frame/examples/basic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@

use codec::{Decode, Encode};
use frame_support::{
dispatch::DispatchResult,
dispatch::{ClassifyDispatch, DispatchClass, DispatchResult, Pays, PaysFee, WeighData},
traits::IsSubType,
weights::{ClassifyDispatch, DispatchClass, Pays, PaysFee, WeighData, Weight},
weights::Weight,
};
use frame_system::ensure_signed;
use log::info;
Expand Down
5 changes: 3 additions & 2 deletions frame/examples/basic/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

use crate::*;
use frame_support::{
assert_ok, parameter_types,
assert_ok,
dispatch::{DispatchInfo, GetDispatchInfo},
parameter_types,
traits::{ConstU64, OnInitialize},
weights::{DispatchInfo, GetDispatchInfo},
};
use sp_core::H256;
// The testing primitives are very useful for avoiding having to work with signatures
Expand Down
4 changes: 2 additions & 2 deletions frame/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@

use codec::{Codec, Encode};
use frame_support::{
dispatch::PostDispatchInfo,
dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo, PostDispatchInfo},
traits::{
EnsureInherentsAreFirst, ExecuteBlock, OffchainWorker, OnFinalize, OnIdle, OnInitialize,
OnRuntimeUpgrade,
},
weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Weight},
weights::Weight,
};
use sp_runtime::{
generic::Digest,
Expand Down
4 changes: 2 additions & 2 deletions frame/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ use fg_primitives::{
GRANDPA_ENGINE_ID,
};
use frame_support::{
dispatch::DispatchResultWithPostInfo,
dispatch::{DispatchResultWithPostInfo, Pays},
pallet_prelude::Get,
storage,
traits::{KeyOwnerProofSystem, OneSessionHandler},
weights::{Pays, Weight},
weights::Weight,
WeakBoundedVec,
};
use scale_info::TypeInfo;
Expand Down
2 changes: 1 addition & 1 deletion frame/grandpa/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use codec::Encode;
use fg_primitives::ScheduledChange;
use frame_support::{
assert_err, assert_noop, assert_ok,
dispatch::{GetDispatchInfo, Pays},
traits::{Currency, OnFinalize, OneSessionHandler},
weights::{GetDispatchInfo, Pays},
};
use frame_system::{EventRecord, Phase};
use sp_core::H256;
Expand Down
5 changes: 3 additions & 2 deletions frame/multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ pub mod weights;
use codec::{Decode, Encode};
use frame_support::{
dispatch::{
DispatchErrorWithPostInfo, DispatchResult, DispatchResultWithPostInfo, PostDispatchInfo,
DispatchErrorWithPostInfo, DispatchResult, DispatchResultWithPostInfo, GetDispatchInfo,
PostDispatchInfo,
},
ensure,
traits::{Currency, Get, ReservableCurrency, WrapperKeepOpaque},
weights::{GetDispatchInfo, Weight},
weights::Weight,
RuntimeDebug,
};
use frame_system::{self as system, RawOrigin};
Expand Down
2 changes: 1 addition & 1 deletion frame/preimage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ use sp_std::prelude::*;

use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{
dispatch::Pays,
ensure,
pallet_prelude::Get,
traits::{Currency, PreimageProvider, PreimageRecipient, ReservableCurrency},
weights::Pays,
BoundedVec,
};
use scale_info::TypeInfo;
Expand Down
3 changes: 1 addition & 2 deletions frame/proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ pub mod weights;

use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{
dispatch::DispatchError,
dispatch::{DispatchError, GetDispatchInfo},
ensure,
traits::{Currency, Get, InstanceFilter, IsSubType, IsType, OriginTrait, ReservableCurrency},
weights::GetDispatchInfo,
RuntimeDebug,
};
use frame_system::{self as system};
Expand Down
3 changes: 1 addition & 2 deletions frame/ranked-collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ use sp_std::{marker::PhantomData, prelude::*};

use frame_support::{
codec::{Decode, Encode, MaxEncodedLen},
dispatch::{DispatchError, DispatchResultWithPostInfo},
dispatch::{DispatchError, DispatchResultWithPostInfo, PostDispatchInfo},
ensure,
traits::{EnsureOrigin, PollStatus, Polling, VoteTally},
weights::PostDispatchInfo,
CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound,
};

Expand Down
3 changes: 1 addition & 2 deletions frame/recovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ use sp_runtime::traits::{CheckedAdd, CheckedMul, Dispatchable, SaturatedConversi
use sp_std::prelude::*;

use frame_support::{
dispatch::PostDispatchInfo,
dispatch::{GetDispatchInfo, PostDispatchInfo},
traits::{BalanceStatus, Currency, ReservableCurrency},
weights::GetDispatchInfo,
BoundedVec, RuntimeDebug,
};

Expand Down
4 changes: 2 additions & 2 deletions frame/scheduler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ pub mod weights;

use codec::{Codec, Decode, Encode};
use frame_support::{
dispatch::{DispatchError, DispatchResult, Dispatchable, Parameter},
dispatch::{DispatchError, DispatchResult, Dispatchable, GetDispatchInfo, Parameter},
traits::{
schedule::{self, DispatchTime, MaybeHashed},
EnsureOrigin, Get, IsType, OriginTrait, PalletInfoAccess, PrivilegeCmp, StorageVersion,
},
weights::{GetDispatchInfo, Weight},
weights::Weight,
};
use frame_system::{self as system, ensure_signed};
pub use pallet::*;
Expand Down
Loading