From 1bf72c48f489f020578ea61a5fde64d52f1f3bbc Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 1 Jan 2025 18:32:41 +0530 Subject: [PATCH 01/32] salary pallet migration to umbrella crate --- Cargo.lock | 6 +--- substrate/frame/salary/Cargo.toml | 22 +++----------- substrate/frame/salary/src/benchmarking.rs | 5 ++-- substrate/frame/salary/src/lib.rs | 11 ++++--- .../frame/salary/src/tests/integration.rs | 29 +++++++++---------- substrate/frame/salary/src/tests/unit.rs | 5 +--- substrate/frame/salary/src/weights.rs | 3 +- 7 files changed, 31 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6151ed33c5b6..a12a71bf8983 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15170,17 +15170,13 @@ dependencies = [ name = "pallet-salary" version = "13.0.0" dependencies = [ - "frame-benchmarking 28.0.0", - "frame-support 28.0.0", - "frame-system 28.0.0", "log", "pallet-ranked-collective 28.0.0", "parity-scale-codec", + "polkadot-sdk-frame 0.1.0", "scale-info", "sp-arithmetic 23.0.0", "sp-core 28.0.0", - "sp-io 30.0.0", - "sp-runtime 31.0.1", ] [[package]] diff --git a/substrate/frame/salary/Cargo.toml b/substrate/frame/salary/Cargo.toml index b3ed95bf1de5..b7c8a7e5202b 100644 --- a/substrate/frame/salary/Cargo.toml +++ b/substrate/frame/salary/Cargo.toml @@ -17,43 +17,29 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { features = ["derive"], workspace = true } -frame-benchmarking = { optional = true, workspace = true } -frame-support = { workspace = true } -frame-system = { workspace = true } log = { workspace = true } pallet-ranked-collective = { optional = true, workspace = true } scale-info = { features = ["derive"], workspace = true } sp-arithmetic = { workspace = true } sp-core = { workspace = true } -sp-io = { workspace = true } -sp-runtime = { workspace = true } +frame = { workspace = true, features = ["experimental", "runtime"] } [features] default = ["std"] std = [ "codec/std", - "frame-benchmarking?/std", - "frame-support/experimental", - "frame-support/std", - "frame-system/std", "log/std", "pallet-ranked-collective/std", "scale-info/std", "sp-arithmetic/std", "sp-core/std", - "sp-io/std", - "sp-runtime/std", + "frame/std", ] runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", "pallet-ranked-collective/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", + "frame/runtime-benchmarks", ] try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", "pallet-ranked-collective?/try-runtime", - "sp-runtime/try-runtime", + "frame/try-runtime", ] diff --git a/substrate/frame/salary/src/benchmarking.rs b/substrate/frame/salary/src/benchmarking.rs index aeae8d2d67f8..51c3dbb7b9f9 100644 --- a/substrate/frame/salary/src/benchmarking.rs +++ b/substrate/frame/salary/src/benchmarking.rs @@ -22,10 +22,9 @@ use super::*; use crate::Pallet as Salary; -use frame_benchmarking::v2::*; -use frame_system::{Pallet as System, RawOrigin}; use sp_core::Get; - +#[allow(deprecated)] +use frame::benchmarking::v1::*; const SEED: u32 = 0; fn ensure_member_with_salary, I: 'static>(who: &T::AccountId) { diff --git a/substrate/frame/salary/src/lib.rs b/substrate/frame/salary/src/lib.rs index efb4f5d3c542..48d1e80303a8 100644 --- a/substrate/frame/salary/src/lib.rs +++ b/substrate/frame/salary/src/lib.rs @@ -19,16 +19,18 @@ #![cfg_attr(not(feature = "std"), no_std)] -use codec::{Decode, Encode, MaxEncodedLen}; use core::marker::PhantomData; -use scale_info::TypeInfo; -use sp_arithmetic::traits::{Saturating, Zero}; -use sp_runtime::{Perbill, RuntimeDebug}; + use frame_support::{ defensive, dispatch::DispatchResultWithPostInfo, ensure, + +}; +use frame::{ + hashing::blake2_256, + prelude::*, traits::{ tokens::{GetSalary, Pay, PaymentStatus}, RankedMembers, RankedMembersSwapHandler, @@ -75,6 +77,7 @@ pub enum ClaimState { } use ClaimState::*; +use frame::deps::frame_support; /// The status of a single payee/claimant. #[derive(Encode, Decode, Eq, PartialEq, Clone, TypeInfo, MaxEncodedLen, RuntimeDebug)] diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index 0c1fb8bbdcba..21b2582ef32d 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -19,24 +19,23 @@ use crate as pallet_salary; use crate::*; -use frame_support::{ - assert_noop, assert_ok, derive_impl, hypothetically, - pallet_prelude::Weight, - parameter_types, - traits::{ConstU64, EitherOf, MapSuccess, NoOpPoll}, -}; + +use frame::{prelude::*, runtime::prelude::*, testing_prelude::*, + traits::{ConstU64, EitherOf, MapSuccess, NoOpPoll, + Convert, ReduceBy, ReplaceWithDefault}, + deps::{ + sp_io::{self, MultiRemovalResults}, + sp_runtime, + }}; use pallet_ranked_collective::{EnsureRanked, Geometric}; use sp_core::{ConstU16, Get}; -use sp_runtime::{ - traits::{Convert, ReduceBy, ReplaceWithDefault}, - BuildStorage, -}; +use crate::tests::integration::sp_api_hidden_includes_construct_runtime::hidden_include::hypothetically; type Rank = u16; type Block = frame_system::mocking::MockBlock; -frame_support::construct_runtime!( - pub enum Test +construct_runtime!( + pub struct Test { System: frame_system, Salary: pallet_salary, @@ -145,9 +144,9 @@ impl pallet_ranked_collective::Config for Test { type BenchmarkSetup = Salary; } -pub fn new_test_ext() -> sp_io::TestExternalities { +pub fn new_test_ext() -> TestState{ let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - let mut ext = sp_io::TestExternalities::new(t); + let mut ext = TestState::new(t); ext.execute_with(|| System::set_block_number(1)); ext } @@ -194,7 +193,7 @@ fn swap_exhaustive_works() { // The events mess up the storage root: System::reset_events(); - sp_io::storage::root(sp_runtime::StateVersion::V1) + sp_io::storage::root( frame::deps::sp_runtime::StateVersion::V1) }); let root_swap = hypothetically!({ diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index db1c8b947ef5..45f0fb065455 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -20,10 +20,7 @@ use std::collections::BTreeMap; use core::cell::RefCell; -use frame_support::{ - assert_noop, assert_ok, derive_impl, - pallet_prelude::Weight, - parameter_types, +use frame::{prelude::*, runtime::prelude::*, testing_prelude::*, traits::{tokens::ConvertRank, ConstU64}, }; use sp_runtime::{traits::Identity, BuildStorage, DispatchResult}; diff --git a/substrate/frame/salary/src/weights.rs b/substrate/frame/salary/src/weights.rs index f1cdaaa225a4..d091df9556eb 100644 --- a/substrate/frame/salary/src/weights.rs +++ b/substrate/frame/salary/src/weights.rs @@ -46,7 +46,8 @@ #![allow(unused_imports)] #![allow(missing_docs)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use crate::*; +use frame::prelude::*; use core::marker::PhantomData; /// Weight functions needed for `pallet_salary`. From 81ef8c3e8de0225b18f067793417e5ad31b7a68d Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Mon, 6 Jan 2025 12:37:10 +0530 Subject: [PATCH 02/32] selectiv changes for salary pallet from cargo fmt --- substrate/frame/salary/src/benchmarking.rs | 4 +-- substrate/frame/salary/src/lib.rs | 17 ++++-------- .../frame/salary/src/tests/integration.rs | 26 ++++++++++--------- substrate/frame/salary/src/tests/unit.rs | 5 +++- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/substrate/frame/salary/src/benchmarking.rs b/substrate/frame/salary/src/benchmarking.rs index 51c3dbb7b9f9..397386487135 100644 --- a/substrate/frame/salary/src/benchmarking.rs +++ b/substrate/frame/salary/src/benchmarking.rs @@ -22,9 +22,9 @@ use super::*; use crate::Pallet as Salary; -use sp_core::Get; #[allow(deprecated)] use frame::benchmarking::v1::*; +use sp_core::Get; const SEED: u32 = 0; fn ensure_member_with_salary, I: 'static>(who: &T::AccountId) { @@ -36,7 +36,7 @@ fn ensure_member_with_salary, I: 'static>(who: &T::AccountId) { for _ in 0..255 { let r = T::Members::rank_of(who).expect("prior guard ensures `who` is a member; qed"); if !T::Salary::get_salary(r, &who).is_zero() { - break + break; } T::Members::promote(who).unwrap(); } diff --git a/substrate/frame/salary/src/lib.rs b/substrate/frame/salary/src/lib.rs index 48d1e80303a8..46ef20075465 100644 --- a/substrate/frame/salary/src/lib.rs +++ b/substrate/frame/salary/src/lib.rs @@ -21,13 +21,6 @@ use core::marker::PhantomData; - -use frame_support::{ - defensive, - dispatch::DispatchResultWithPostInfo, - ensure, - -}; use frame::{ hashing::blake2_256, prelude::*, @@ -36,6 +29,7 @@ use frame::{ RankedMembers, RankedMembersSwapHandler, }, }; +use frame_support::{defensive, dispatch::DispatchResultWithPostInfo, ensure}; #[cfg(test)] mod tests; @@ -76,8 +70,8 @@ pub enum ClaimState { Attempted { registered: Option, id: Id, amount: Balance }, } -use ClaimState::*; use frame::deps::frame_support; +use ClaimState::*; /// The status of a single payee/claimant. #[derive(Encode, Decode, Eq, PartialEq, Clone, TypeInfo, MaxEncodedLen, RuntimeDebug)] @@ -91,8 +85,7 @@ pub struct ClaimantStatus { #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::{dispatch::Pays, pallet_prelude::*}; - use frame_system::pallet_prelude::*; + use frame::prelude::*; #[pallet::pallet] pub struct Pallet(PhantomData<(T, I)>); @@ -463,11 +456,11 @@ impl, I: 'static> ) { if who == new_who { defensive!("Should not try to swap with self"); - return + return; } if Claimant::::contains_key(new_who) { defensive!("Should not try to overwrite existing claimant"); - return + return; } let Some(claimant) = Claimant::::take(who) else { diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index 21b2582ef32d..5df05200a717 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -20,23 +20,25 @@ use crate as pallet_salary; use crate::*; -use frame::{prelude::*, runtime::prelude::*, testing_prelude::*, - traits::{ConstU64, EitherOf, MapSuccess, NoOpPoll, - Convert, ReduceBy, ReplaceWithDefault}, - deps::{ - sp_io::{self, MultiRemovalResults}, - sp_runtime, - }}; +use crate::tests::integration::sp_api_hidden_includes_construct_runtime::hidden_include::hypothetically; +use frame::{ + deps::{ + sp_io::{self, MultiRemovalResults}, + sp_runtime, + }, + prelude::*, + runtime::prelude::*, + testing_prelude::*, + traits::{ConstU64, Convert, EitherOf, MapSuccess, NoOpPoll, ReduceBy, ReplaceWithDefault}, +}; use pallet_ranked_collective::{EnsureRanked, Geometric}; use sp_core::{ConstU16, Get}; -use crate::tests::integration::sp_api_hidden_includes_construct_runtime::hidden_include::hypothetically; type Rank = u16; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub struct Test - { + pub struct Test { System: frame_system, Salary: pallet_salary, Club: pallet_ranked_collective, @@ -144,7 +146,7 @@ impl pallet_ranked_collective::Config for Test { type BenchmarkSetup = Salary; } -pub fn new_test_ext() -> TestState{ +pub fn new_test_ext() -> TestState { let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext = TestState::new(t); ext.execute_with(|| System::set_block_number(1)); @@ -193,7 +195,7 @@ fn swap_exhaustive_works() { // The events mess up the storage root: System::reset_events(); - sp_io::storage::root( frame::deps::sp_runtime::StateVersion::V1) + sp_io::storage::root(frame::deps::sp_runtime::StateVersion::V1) }); let root_swap = hypothetically!({ diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 45f0fb065455..92f590fbd218 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -20,7 +20,10 @@ use std::collections::BTreeMap; use core::cell::RefCell; -use frame::{prelude::*, runtime::prelude::*, testing_prelude::*, +use frame::{ + prelude::*, + runtime::prelude::*, + testing_prelude::*, traits::{tokens::ConvertRank, ConstU64}, }; use sp_runtime::{traits::Identity, BuildStorage, DispatchResult}; From 12b503568beed3d2d47efec708e6da2bed0251a2 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Sun, 5 Jan 2025 17:18:48 +0530 Subject: [PATCH 03/32] optimisations to salary pallet to use umbrella crate --- Cargo.lock | 2 -- substrate/frame/salary/Cargo.toml | 4 ---- substrate/frame/salary/src/benchmarking.rs | 4 ++-- substrate/frame/salary/src/lib.rs | 10 +++++----- substrate/frame/salary/src/tests/integration.rs | 7 +++---- substrate/frame/salary/src/tests/unit.rs | 2 -- substrate/frame/salary/src/weights.rs | 1 + substrate/frame/src/lib.rs | 11 +++++++---- substrate/frame/support/src/traits.rs | 13 +++++++------ 9 files changed, 25 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a12a71bf8983..ded165252971 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15175,8 +15175,6 @@ dependencies = [ "parity-scale-codec", "polkadot-sdk-frame 0.1.0", "scale-info", - "sp-arithmetic 23.0.0", - "sp-core 28.0.0", ] [[package]] diff --git a/substrate/frame/salary/Cargo.toml b/substrate/frame/salary/Cargo.toml index b7c8a7e5202b..8a67c57a2dc9 100644 --- a/substrate/frame/salary/Cargo.toml +++ b/substrate/frame/salary/Cargo.toml @@ -20,8 +20,6 @@ codec = { features = ["derive"], workspace = true } log = { workspace = true } pallet-ranked-collective = { optional = true, workspace = true } scale-info = { features = ["derive"], workspace = true } -sp-arithmetic = { workspace = true } -sp-core = { workspace = true } frame = { workspace = true, features = ["experimental", "runtime"] } [features] @@ -31,8 +29,6 @@ std = [ "log/std", "pallet-ranked-collective/std", "scale-info/std", - "sp-arithmetic/std", - "sp-core/std", "frame/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/salary/src/benchmarking.rs b/substrate/frame/salary/src/benchmarking.rs index 397386487135..7e23ac08f517 100644 --- a/substrate/frame/salary/src/benchmarking.rs +++ b/substrate/frame/salary/src/benchmarking.rs @@ -23,8 +23,8 @@ use super::*; use crate::Pallet as Salary; #[allow(deprecated)] -use frame::benchmarking::v1::*; -use sp_core::Get; +use frame::benchmarking::prelude::*; +use frame::deps::sp_core::Get; const SEED: u32 = 0; fn ensure_member_with_salary, I: 'static>(who: &T::AccountId) { diff --git a/substrate/frame/salary/src/lib.rs b/substrate/frame/salary/src/lib.rs index 46ef20075465..ad66c8e2cba2 100644 --- a/substrate/frame/salary/src/lib.rs +++ b/substrate/frame/salary/src/lib.rs @@ -22,14 +22,14 @@ use core::marker::PhantomData; use frame::{ - hashing::blake2_256, prelude::*, traits::{ tokens::{GetSalary, Pay, PaymentStatus}, RankedMembers, RankedMembersSwapHandler, }, }; -use frame_support::{defensive, dispatch::DispatchResultWithPostInfo, ensure}; +use frame::arithmetic::Perbill; + #[cfg(test)] mod tests; @@ -70,8 +70,8 @@ pub enum ClaimState { Attempted { registered: Option, id: Id, amount: Balance }, } -use frame::deps::frame_support; use ClaimState::*; +use frame::deps::frame_support; /// The status of a single payee/claimant. #[derive(Encode, Decode, Eq, PartialEq, Clone, TypeInfo, MaxEncodedLen, RuntimeDebug)] @@ -82,7 +82,7 @@ pub struct ClaimantStatus { status: ClaimState, } -#[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; use frame::prelude::*; @@ -464,7 +464,7 @@ impl, I: 'static> } let Some(claimant) = Claimant::::take(who) else { - frame_support::defensive!("Claimant should exist when swapping"); + frame::prelude::defensive!("Claimant should exist when swapping"); return; }; diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index 5df05200a717..655ead60e76a 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -20,19 +20,18 @@ use crate as pallet_salary; use crate::*; -use crate::tests::integration::sp_api_hidden_includes_construct_runtime::hidden_include::hypothetically; +use frame::deps::frame_support::hypothetically; use frame::{ deps::{ sp_io::{self, MultiRemovalResults}, sp_runtime, }, prelude::*, - runtime::prelude::*, + runtime_prelude::*, testing_prelude::*, - traits::{ConstU64, Convert, EitherOf, MapSuccess, NoOpPoll, ReduceBy, ReplaceWithDefault}, + traits::Convert, }; use pallet_ranked_collective::{EnsureRanked, Geometric}; -use sp_core::{ConstU16, Get}; type Rank = u16; type Block = frame_system::mocking::MockBlock; diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 92f590fbd218..dc640a386dff 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -21,8 +21,6 @@ use std::collections::BTreeMap; use core::cell::RefCell; use frame::{ - prelude::*, - runtime::prelude::*, testing_prelude::*, traits::{tokens::ConvertRank, ConstU64}, }; diff --git a/substrate/frame/salary/src/weights.rs b/substrate/frame/salary/src/weights.rs index d091df9556eb..0d9951debacd 100644 --- a/substrate/frame/salary/src/weights.rs +++ b/substrate/frame/salary/src/weights.rs @@ -49,6 +49,7 @@ use crate::*; use frame::prelude::*; use core::marker::PhantomData; +use frame::weights_prelude::*; /// Weight functions needed for `pallet_salary`. pub trait WeightInfo { diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 8031ddf96e6a..fae0af2a7128 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -203,7 +203,10 @@ pub mod prelude { /// Dispatch types from `frame-support`, other fundamental traits #[doc(no_inline)] pub use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; - pub use frame_support::traits::{Contains, IsSubType, OnRuntimeUpgrade}; + pub use frame_support::traits::{ + Contains, EitherOf, IsSubType, MapSuccess, NoOpPoll, OnRuntimeUpgrade, + }; + pub use frame_support::{defensive_assert, defensive}; /// Pallet prelude of `frame-system`. #[doc(no_inline)] @@ -220,12 +223,12 @@ pub mod prelude { #[doc(no_inline)] pub use sp_runtime::traits::{ BlockNumberProvider, Bounded, DispatchInfoOf, Dispatchable, SaturatedConversion, - Saturating, StaticLookup, TrailingZeroInput, + Saturating, StaticLookup, TrailingZeroInput, ReduceBy, Convert, ReplaceWithDefault, }; - /// Other error/result types for runtime #[doc(no_inline)] - pub use sp_runtime::{DispatchErrorWithPostInfo, DispatchResultWithInfo, TokenError}; + pub use sp_runtime::{DispatchErrorWithPostInfo, DispatchResultWithInfo, TokenError + }; } #[cfg(any(feature = "try-runtime", test))] diff --git a/substrate/frame/support/src/traits.rs b/substrate/frame/support/src/traits.rs index 728426cc84c7..ab5d60079980 100644 --- a/substrate/frame/support/src/traits.rs +++ b/substrate/frame/support/src/traits.rs @@ -58,12 +58,13 @@ mod misc; pub use misc::{ defensive_prelude::{self, *}, AccountTouch, Backing, ConstBool, ConstI128, ConstI16, ConstI32, ConstI64, ConstI8, ConstInt, - ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, ConstUint, DefensiveMax, DefensiveMin, - DefensiveSaturating, DefensiveTruncateFrom, EnsureInherentsAreFirst, EqualPrivilegeOnly, - EstimateCallFee, ExecuteBlock, ExtrinsicCall, Get, GetBacking, GetDefault, HandleLifetime, - InherentBuilder, IsInherent, IsSubType, IsType, Len, OffchainWorker, OnKilledAccount, - OnNewAccount, PrivilegeCmp, SameOrOther, SignedTransactionBuilder, Time, TryCollect, TryDrop, - TypedGet, UnixTime, VariantCount, VariantCountOf, WrapperKeepOpaque, WrapperOpaque, + ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, ConstUint, DefensiveMax, + DefensiveMin, DefensiveSaturating, DefensiveTruncateFrom, EnsureInherentsAreFirst, + EqualPrivilegeOnly, EstimateCallFee, ExecuteBlock, ExtrinsicCall, Get, GetBacking, GetDefault, + HandleLifetime, InherentBuilder, IsInherent, IsSubType, IsType, Len, OffchainWorker, + OnKilledAccount, OnNewAccount, PrivilegeCmp, SameOrOther, + SignedTransactionBuilder, Time, TryCollect, TryDrop, TypedGet, UnixTime, VariantCount, + VariantCountOf, WrapperKeepOpaque, WrapperOpaque, }; #[allow(deprecated)] pub use misc::{PreimageProvider, PreimageRecipient}; From 9b5c229acd6e536071081cc632f5f2c2906c01e5 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Mon, 6 Jan 2025 19:08:51 +0530 Subject: [PATCH 04/32] changes to unit testing for migration to umbrella crate --- substrate/frame/salary/src/tests/integration.rs | 3 +-- substrate/frame/salary/src/tests/unit.rs | 11 +++++------ substrate/frame/src/lib.rs | 3 ++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index 655ead60e76a..68c7280306ab 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -20,7 +20,6 @@ use crate as pallet_salary; use crate::*; -use frame::deps::frame_support::hypothetically; use frame::{ deps::{ sp_io::{self, MultiRemovalResults}, @@ -194,7 +193,7 @@ fn swap_exhaustive_works() { // The events mess up the storage root: System::reset_events(); - sp_io::storage::root(frame::deps::sp_runtime::StateVersion::V1) + sp_io::storage::root(sp_runtime::StateVersion::V1) }); let root_swap = hypothetically!({ diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index dc640a386dff..8167a9e399e6 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -24,14 +24,13 @@ use frame::{ testing_prelude::*, traits::{tokens::ConvertRank, ConstU64}, }; -use sp_runtime::{traits::Identity, BuildStorage, DispatchResult}; use crate as pallet_salary; use crate::*; -type Block = frame_system::mocking::MockBlock; +type Block = MockBlock; -frame_support::construct_runtime!( +construct_runtime!( pub enum Test { System: frame_system, @@ -122,7 +121,7 @@ impl RankedMembers for TestClub { } fn demote(who: &Self::AccountId) -> DispatchResult { CLUB.with(|club| match club.borrow().get(who) { - None => Err(sp_runtime::DispatchError::Unavailable), + None => Err(DispatchError::Unavailable), Some(&0) => { club.borrow_mut().remove(&who); Ok(()) @@ -154,9 +153,9 @@ impl Config for Test { type Budget = Budget; } -pub fn new_test_ext() -> sp_io::TestExternalities { +pub fn new_test_ext() -> TestState { let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - let mut ext = sp_io::TestExternalities::new(t); + let mut ext = TestState::new(t); ext.execute_with(|| System::set_block_number(1)); ext } diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index fae0af2a7128..ef5e803a3b46 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -311,7 +311,7 @@ pub mod testing_prelude { /// Other helper macros from `frame_support` that help with asserting in tests. pub use frame_support::{ assert_err, assert_err_ignore_postinfo, assert_error_encoded_size, assert_noop, assert_ok, - assert_storage_noop, storage_alias, + assert_storage_noop, storage_alias, construct_runtime }; pub use frame_system::{self, mocking::*}; @@ -497,6 +497,7 @@ pub mod runtime { pub mod testing_prelude { pub use sp_core::storage::Storage; pub use sp_runtime::BuildStorage; + pub use sp_runtime::DispatchError::Unavailable; } } From 6a6a009692bd8e5322cb1dba6605873df8667284 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Mon, 6 Jan 2025 20:30:28 +0530 Subject: [PATCH 05/32] Revision 5 addressing comments for umbrella crate migration --- substrate/frame/salary/src/benchmarking.rs | 5 ++--- substrate/frame/salary/src/lib.rs | 3 ++- substrate/frame/salary/src/tests/integration.rs | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/substrate/frame/salary/src/benchmarking.rs b/substrate/frame/salary/src/benchmarking.rs index 7e23ac08f517..a13cce0bd452 100644 --- a/substrate/frame/salary/src/benchmarking.rs +++ b/substrate/frame/salary/src/benchmarking.rs @@ -22,9 +22,8 @@ use super::*; use crate::Pallet as Salary; -#[allow(deprecated)] -use frame::benchmarking::prelude::*; -use frame::deps::sp_core::Get; +use frame::{benchmarking::prelude::*, + deps::sp_core::Get}; const SEED: u32 = 0; fn ensure_member_with_salary, I: 'static>(who: &T::AccountId) { diff --git a/substrate/frame/salary/src/lib.rs b/substrate/frame/salary/src/lib.rs index ad66c8e2cba2..ecf91bf4af51 100644 --- a/substrate/frame/salary/src/lib.rs +++ b/substrate/frame/salary/src/lib.rs @@ -71,6 +71,7 @@ pub enum ClaimState { } use ClaimState::*; +//https://github.com/paritytech/polkadot-sdk/issues/7054 frame_support needs to be used until this issue is resolved use frame::deps::frame_support; /// The status of a single payee/claimant. @@ -464,7 +465,7 @@ impl, I: 'static> } let Some(claimant) = Claimant::::take(who) else { - frame::prelude::defensive!("Claimant should exist when swapping"); + defensive!("Claimant should exist when swapping"); return; }; diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index 68c7280306ab..9ad21adfc5da 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -25,8 +25,6 @@ use frame::{ sp_io::{self, MultiRemovalResults}, sp_runtime, }, - prelude::*, - runtime_prelude::*, testing_prelude::*, traits::Convert, }; From b015e26e743104197b1faf6cdd2b14ad51209e3c Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Mon, 6 Jan 2025 20:36:21 +0530 Subject: [PATCH 06/32] remove formatting from traits --- substrate/frame/support/src/traits.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/substrate/frame/support/src/traits.rs b/substrate/frame/support/src/traits.rs index ab5d60079980..728426cc84c7 100644 --- a/substrate/frame/support/src/traits.rs +++ b/substrate/frame/support/src/traits.rs @@ -58,13 +58,12 @@ mod misc; pub use misc::{ defensive_prelude::{self, *}, AccountTouch, Backing, ConstBool, ConstI128, ConstI16, ConstI32, ConstI64, ConstI8, ConstInt, - ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, ConstUint, DefensiveMax, - DefensiveMin, DefensiveSaturating, DefensiveTruncateFrom, EnsureInherentsAreFirst, - EqualPrivilegeOnly, EstimateCallFee, ExecuteBlock, ExtrinsicCall, Get, GetBacking, GetDefault, - HandleLifetime, InherentBuilder, IsInherent, IsSubType, IsType, Len, OffchainWorker, - OnKilledAccount, OnNewAccount, PrivilegeCmp, SameOrOther, - SignedTransactionBuilder, Time, TryCollect, TryDrop, TypedGet, UnixTime, VariantCount, - VariantCountOf, WrapperKeepOpaque, WrapperOpaque, + ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, ConstUint, DefensiveMax, DefensiveMin, + DefensiveSaturating, DefensiveTruncateFrom, EnsureInherentsAreFirst, EqualPrivilegeOnly, + EstimateCallFee, ExecuteBlock, ExtrinsicCall, Get, GetBacking, GetDefault, HandleLifetime, + InherentBuilder, IsInherent, IsSubType, IsType, Len, OffchainWorker, OnKilledAccount, + OnNewAccount, PrivilegeCmp, SameOrOther, SignedTransactionBuilder, Time, TryCollect, TryDrop, + TypedGet, UnixTime, VariantCount, VariantCountOf, WrapperKeepOpaque, WrapperOpaque, }; #[allow(deprecated)] pub use misc::{PreimageProvider, PreimageRecipient}; From 3291d1eb19c1bf6fd69f59e74081d11b9cb9593f Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Mon, 6 Jan 2025 22:20:11 +0530 Subject: [PATCH 07/32] using defensive as part of prelude instead of frame_support --- substrate/frame/salary/src/lib.rs | 2 +- substrate/frame/support/src/traits/misc.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/substrate/frame/salary/src/lib.rs b/substrate/frame/salary/src/lib.rs index ecf91bf4af51..f8c1c4a6f80f 100644 --- a/substrate/frame/salary/src/lib.rs +++ b/substrate/frame/salary/src/lib.rs @@ -72,7 +72,7 @@ pub enum ClaimState { use ClaimState::*; //https://github.com/paritytech/polkadot-sdk/issues/7054 frame_support needs to be used until this issue is resolved -use frame::deps::frame_support; +// use frame::deps::frame_support; /// The status of a single payee/claimant. #[derive(Encode, Decode, Eq, PartialEq, Clone, TypeInfo, MaxEncodedLen, RuntimeDebug)] diff --git a/substrate/frame/support/src/traits/misc.rs b/substrate/frame/support/src/traits/misc.rs index 0dc3abdce956..9fef4383ad67 100644 --- a/substrate/frame/support/src/traits/misc.rs +++ b/substrate/frame/support/src/traits/misc.rs @@ -66,7 +66,7 @@ impl Get for VariantCountOf { #[macro_export] macro_rules! defensive { () => { - frame_support::__private::log::error!( + $crate::__private::log::error!( target: "runtime::defensive", "{}", $crate::traits::DEFENSIVE_OP_PUBLIC_ERROR @@ -74,7 +74,7 @@ macro_rules! defensive { debug_assert!(false, "{}", $crate::traits::DEFENSIVE_OP_INTERNAL_ERROR); }; ($error:expr $(,)?) => { - frame_support::__private::log::error!( + $crate::__private::log::error!( target: "runtime::defensive", "{}: {:?}", $crate::traits::DEFENSIVE_OP_PUBLIC_ERROR, @@ -83,7 +83,7 @@ macro_rules! defensive { debug_assert!(false, "{}: {:?}", $crate::traits::DEFENSIVE_OP_INTERNAL_ERROR, $error); }; ($error:expr, $proof:expr $(,)?) => { - frame_support::__private::log::error!( + $crate::__private::log::error!( target: "runtime::defensive", "{}: {:?}: {:?}", $crate::traits::DEFENSIVE_OP_PUBLIC_ERROR, From 3dc4d8b5d7917161bc2b22342ceb2427ea8ce49b Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Tue, 7 Jan 2025 12:40:14 +0530 Subject: [PATCH 08/32] updating salary pallet migration to umbrella crate --- substrate/frame/salary/src/benchmarking.rs | 3 +-- substrate/frame/salary/src/lib.rs | 6 +----- .../frame/salary/src/tests/integration.rs | 1 - substrate/frame/salary/src/tests/unit.rs | 5 +---- substrate/frame/src/lib.rs | 18 +++++++++--------- 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/substrate/frame/salary/src/benchmarking.rs b/substrate/frame/salary/src/benchmarking.rs index a13cce0bd452..6dfd6f6dd488 100644 --- a/substrate/frame/salary/src/benchmarking.rs +++ b/substrate/frame/salary/src/benchmarking.rs @@ -22,8 +22,7 @@ use super::*; use crate::Pallet as Salary; -use frame::{benchmarking::prelude::*, - deps::sp_core::Get}; +use frame::benchmarking::prelude::*; const SEED: u32 = 0; fn ensure_member_with_salary, I: 'static>(who: &T::AccountId) { diff --git a/substrate/frame/salary/src/lib.rs b/substrate/frame/salary/src/lib.rs index f8c1c4a6f80f..4c0fba2dff89 100644 --- a/substrate/frame/salary/src/lib.rs +++ b/substrate/frame/salary/src/lib.rs @@ -22,14 +22,13 @@ use core::marker::PhantomData; use frame::{ + arithmetic::Perbill, prelude::*, traits::{ tokens::{GetSalary, Pay, PaymentStatus}, RankedMembers, RankedMembersSwapHandler, }, }; -use frame::arithmetic::Perbill; - #[cfg(test)] mod tests; @@ -71,8 +70,6 @@ pub enum ClaimState { } use ClaimState::*; -//https://github.com/paritytech/polkadot-sdk/issues/7054 frame_support needs to be used until this issue is resolved -// use frame::deps::frame_support; /// The status of a single payee/claimant. #[derive(Encode, Decode, Eq, PartialEq, Clone, TypeInfo, MaxEncodedLen, RuntimeDebug)] @@ -86,7 +83,6 @@ pub struct ClaimantStatus { #[frame::pallet] pub mod pallet { use super::*; - use frame::prelude::*; #[pallet::pallet] pub struct Pallet(PhantomData<(T, I)>); diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index 9ad21adfc5da..2fe0e6d5626a 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -26,7 +26,6 @@ use frame::{ sp_runtime, }, testing_prelude::*, - traits::Convert, }; use pallet_ranked_collective::{EnsureRanked, Geometric}; diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 8167a9e399e6..dbfc2a356fbc 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -20,10 +20,7 @@ use std::collections::BTreeMap; use core::cell::RefCell; -use frame::{ - testing_prelude::*, - traits::{tokens::ConvertRank, ConstU64}, -}; +use frame::testing_prelude::*; use crate as pallet_salary; use crate::*; diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index e43144dee00d..de4da99071d9 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -204,10 +204,10 @@ pub mod prelude { #[doc(no_inline)] pub use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; pub use frame_support::traits::{ - Contains, EitherOf, EstimateNextSessionRotation, IsSubType, MapSuccess, NoOpPoll, OnRuntimeUpgrade, OneSessionHandler, + tokens::ConvertRank, Contains, EitherOf, EstimateNextSessionRotation, IsSubType, + MapSuccess, NoOpPoll, OnRuntimeUpgrade, OneSessionHandler, }; - pub use frame_support::{defensive_assert, defensive}; - + pub use frame_support::{defensive, defensive_assert}; /// Pallet prelude of `frame-system`. #[doc(no_inline)] @@ -230,12 +230,13 @@ pub mod prelude { /// Runtime traits #[doc(no_inline)] pub use sp_runtime::traits::{ - BlockNumberProvider, Bounded, DispatchInfoOf, Dispatchable, SaturatedConversion, - Saturating, StaticLookup, TrailingZeroInput, ReduceBy, Convert, ReplaceWithDefault, + BlockNumberProvider, Bounded, Convert, DispatchInfoOf, Dispatchable, ReduceBy, + ReplaceWithDefault, SaturatedConversion, Saturating, StaticLookup, TrailingZeroInput, }; /// Other error/result types for runtime #[doc(no_inline)] - pub use sp_runtime::{BoundToRuntimeAppPublic, DispatchErrorWithPostInfo, DispatchResultWithInfo, TokenError, + pub use sp_runtime::{ + BoundToRuntimeAppPublic, DispatchErrorWithPostInfo, DispatchResultWithInfo, TokenError, }; } @@ -319,7 +320,7 @@ pub mod testing_prelude { /// Other helper macros from `frame_support` that help with asserting in tests. pub use frame_support::{ assert_err, assert_err_ignore_postinfo, assert_error_encoded_size, assert_noop, assert_ok, - assert_storage_noop, storage_alias, construct_runtime + assert_storage_noop, construct_runtime, storage_alias, }; pub use frame_system::{self, mocking::*}; @@ -505,8 +506,7 @@ pub mod runtime { #[cfg(feature = "std")] pub mod testing_prelude { pub use sp_core::storage::Storage; - pub use sp_runtime::BuildStorage; - pub use sp_runtime::DispatchError::Unavailable; + pub use sp_runtime::{BuildStorage, DispatchError::Unavailable}; } } From bf3302b4ac8b44bd96b8b741a57d9854e65b951e Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Tue, 7 Jan 2025 14:45:36 +0530 Subject: [PATCH 09/32] run taplo and night fmt --- substrate/frame/salary/Cargo.toml | 19 ++++++++----------- substrate/frame/src/lib.rs | 10 ++++++---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/substrate/frame/salary/Cargo.toml b/substrate/frame/salary/Cargo.toml index 8a67c57a2dc9..619383a5af63 100644 --- a/substrate/frame/salary/Cargo.toml +++ b/substrate/frame/salary/Cargo.toml @@ -25,17 +25,14 @@ frame = { workspace = true, features = ["experimental", "runtime"] } [features] default = ["std"] std = [ - "codec/std", - "log/std", - "pallet-ranked-collective/std", - "scale-info/std", - "frame/std", + "codec/std", + "log/std", + "pallet-ranked-collective/std", + "scale-info/std", + "frame/std", ] runtime-benchmarks = [ - "pallet-ranked-collective/runtime-benchmarks", - "frame/runtime-benchmarks", -] -try-runtime = [ - "pallet-ranked-collective?/try-runtime", - "frame/try-runtime", + "pallet-ranked-collective/runtime-benchmarks", + "frame/runtime-benchmarks", ] +try-runtime = ["pallet-ranked-collective?/try-runtime", "frame/try-runtime"] diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index de4da99071d9..ca0dc43b0039 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -203,11 +203,13 @@ pub mod prelude { /// Dispatch types from `frame-support`, other fundamental traits #[doc(no_inline)] pub use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; - pub use frame_support::traits::{ - tokens::ConvertRank, Contains, EitherOf, EstimateNextSessionRotation, IsSubType, - MapSuccess, NoOpPoll, OnRuntimeUpgrade, OneSessionHandler, + pub use frame_support::{ + defensive, defensive_assert, + traits::{ + tokens::ConvertRank, Contains, EitherOf, EstimateNextSessionRotation, IsSubType, + MapSuccess, NoOpPoll, OnRuntimeUpgrade, OneSessionHandler, + }, }; - pub use frame_support::{defensive, defensive_assert}; /// Pallet prelude of `frame-system`. #[doc(no_inline)] From 8db080b3450933890b60c033014041d925226fc1 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Tue, 7 Jan 2025 15:13:22 +0530 Subject: [PATCH 10/32] add prdoc --- prdoc/pr_7048.prdoc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 prdoc/pr_7048.prdoc diff --git a/prdoc/pr_7048.prdoc b/prdoc/pr_7048.prdoc new file mode 100644 index 000000000000..a55d3e56f306 --- /dev/null +++ b/prdoc/pr_7048.prdoc @@ -0,0 +1,21 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: '[pallet-salary] Migrate to using frame umbrella crate' + +doc: + - audience: Runtime Dev + description: + This PR migrates the pallet-salary to use the frame umbrella crate. + This is part of the ongoing effort to migrate all pallets to use the frame umbrella crate. + The effort is tracked [here](https://github.com/paritytech/polkadot-sdk/issues/6504). + + +crates: +- name: pallet-salary + bump: minor +- name: polkadot-sdk-frame + bump: minor +- name: traits-misc + bump: minor + From b8c19854e57f81b6897e16de63e62e7157db8d35 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Tue, 7 Jan 2025 21:01:48 +0530 Subject: [PATCH 11/32] cleaning unused imports --- substrate/frame/salary/src/lib.rs | 2 -- substrate/frame/salary/src/tests/integration.rs | 2 -- substrate/frame/salary/src/tests/unit.rs | 3 +-- substrate/frame/salary/src/weights.rs | 2 -- substrate/frame/src/lib.rs | 6 +++--- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/substrate/frame/salary/src/lib.rs b/substrate/frame/salary/src/lib.rs index 4c0fba2dff89..9f16ce4adc17 100644 --- a/substrate/frame/salary/src/lib.rs +++ b/substrate/frame/salary/src/lib.rs @@ -20,7 +20,6 @@ #![cfg_attr(not(feature = "std"), no_std)] use core::marker::PhantomData; - use frame::{ arithmetic::Perbill, prelude::*, @@ -83,7 +82,6 @@ pub struct ClaimantStatus { #[frame::pallet] pub mod pallet { use super::*; - #[pallet::pallet] pub struct Pallet(PhantomData<(T, I)>); diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index 2fe0e6d5626a..3f62b4070e15 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -19,11 +19,9 @@ use crate as pallet_salary; use crate::*; - use frame::{ deps::{ sp_io::{self, MultiRemovalResults}, - sp_runtime, }, testing_prelude::*, }; diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index dbfc2a356fbc..56a09eddf11f 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -18,10 +18,9 @@ //! The crate's tests. use std::collections::BTreeMap; - use core::cell::RefCell; use frame::testing_prelude::*; - +use frame::traits::tokens::ConvertRank; use crate as pallet_salary; use crate::*; diff --git a/substrate/frame/salary/src/weights.rs b/substrate/frame/salary/src/weights.rs index 0d9951debacd..43c001b30d33 100644 --- a/substrate/frame/salary/src/weights.rs +++ b/substrate/frame/salary/src/weights.rs @@ -46,8 +46,6 @@ #![allow(unused_imports)] #![allow(missing_docs)] -use crate::*; -use frame::prelude::*; use core::marker::PhantomData; use frame::weights_prelude::*; diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index ca0dc43b0039..3e803e393f9b 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -206,7 +206,7 @@ pub mod prelude { pub use frame_support::{ defensive, defensive_assert, traits::{ - tokens::ConvertRank, Contains, EitherOf, EstimateNextSessionRotation, IsSubType, + Contains, EitherOf, EstimateNextSessionRotation, IsSubType, MapSuccess, NoOpPoll, OnRuntimeUpgrade, OneSessionHandler, }, }; @@ -322,7 +322,7 @@ pub mod testing_prelude { /// Other helper macros from `frame_support` that help with asserting in tests. pub use frame_support::{ assert_err, assert_err_ignore_postinfo, assert_error_encoded_size, assert_noop, assert_ok, - assert_storage_noop, construct_runtime, storage_alias, + assert_storage_noop, storage_alias, }; pub use frame_system::{self, mocking::*}; @@ -508,7 +508,7 @@ pub mod runtime { #[cfg(feature = "std")] pub mod testing_prelude { pub use sp_core::storage::Storage; - pub use sp_runtime::{BuildStorage, DispatchError::Unavailable}; + pub use sp_runtime::{BuildStorage, DispatchError}; } } From 52a019bfad4d29a77ef49d12990cdec1a805e435 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Tue, 7 Jan 2025 21:14:35 +0530 Subject: [PATCH 12/32] cargo fmt --- substrate/frame/salary/src/tests/integration.rs | 4 +--- substrate/frame/salary/src/tests/unit.rs | 7 +++---- substrate/frame/src/lib.rs | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index 3f62b4070e15..c32bbe7221d4 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -20,9 +20,7 @@ use crate as pallet_salary; use crate::*; use frame::{ - deps::{ - sp_io::{self, MultiRemovalResults}, - }, + deps::sp_io::{self, MultiRemovalResults}, testing_prelude::*, }; use pallet_ranked_collective::{EnsureRanked, Geometric}; diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 56a09eddf11f..6bdd86ddef91 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -17,12 +17,11 @@ //! The crate's tests. -use std::collections::BTreeMap; -use core::cell::RefCell; -use frame::testing_prelude::*; -use frame::traits::tokens::ConvertRank; use crate as pallet_salary; use crate::*; +use core::cell::RefCell; +use frame::{testing_prelude::*, traits::tokens::ConvertRank}; +use std::collections::BTreeMap; type Block = MockBlock; diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 3e803e393f9b..a38d6cf712cf 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -206,8 +206,8 @@ pub mod prelude { pub use frame_support::{ defensive, defensive_assert, traits::{ - Contains, EitherOf, EstimateNextSessionRotation, IsSubType, - MapSuccess, NoOpPoll, OnRuntimeUpgrade, OneSessionHandler, + Contains, EitherOf, EstimateNextSessionRotation, IsSubType, MapSuccess, NoOpPoll, + OnRuntimeUpgrade, OneSessionHandler, }, }; From f1e14085b1b1e320458703c1e389f761e437c644 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Tue, 7 Jan 2025 23:25:03 +0530 Subject: [PATCH 13/32] remove arithmetic from salary as it is already in the prelude --- substrate/frame/salary/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/substrate/frame/salary/src/lib.rs b/substrate/frame/salary/src/lib.rs index 9f16ce4adc17..256d1ad0cdf6 100644 --- a/substrate/frame/salary/src/lib.rs +++ b/substrate/frame/salary/src/lib.rs @@ -21,7 +21,6 @@ use core::marker::PhantomData; use frame::{ - arithmetic::Perbill, prelude::*, traits::{ tokens::{GetSalary, Pay, PaymentStatus}, From 023c3fe51fa4fbf9ff8e9a8aed06cff44a2ec4f6 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Tue, 7 Jan 2025 23:36:01 +0530 Subject: [PATCH 14/32] reverting taplo format changes from cargo.toml in salary pallet --- substrate/frame/salary/Cargo.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/substrate/frame/salary/Cargo.toml b/substrate/frame/salary/Cargo.toml index 619383a5af63..837239e1bba9 100644 --- a/substrate/frame/salary/Cargo.toml +++ b/substrate/frame/salary/Cargo.toml @@ -35,4 +35,7 @@ runtime-benchmarks = [ "pallet-ranked-collective/runtime-benchmarks", "frame/runtime-benchmarks", ] -try-runtime = ["pallet-ranked-collective?/try-runtime", "frame/try-runtime"] +try-runtime = [ + "pallet-ranked-collective?/try-runtime", + "frame/try-runtime", +] From 6e839544e720a3e4af1f5ae2149205f39626a195 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Tue, 7 Jan 2025 23:38:11 +0530 Subject: [PATCH 15/32] re formatting cargo.toml --- substrate/frame/salary/Cargo.toml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/substrate/frame/salary/Cargo.toml b/substrate/frame/salary/Cargo.toml index 837239e1bba9..be42f519f705 100644 --- a/substrate/frame/salary/Cargo.toml +++ b/substrate/frame/salary/Cargo.toml @@ -25,17 +25,17 @@ frame = { workspace = true, features = ["experimental", "runtime"] } [features] default = ["std"] std = [ - "codec/std", - "log/std", - "pallet-ranked-collective/std", - "scale-info/std", - "frame/std", + "codec/std", + "log/std", + "pallet-ranked-collective/std", + "scale-info/std", + "frame/std", ] runtime-benchmarks = [ - "pallet-ranked-collective/runtime-benchmarks", - "frame/runtime-benchmarks", + "pallet-ranked-collective/runtime-benchmarks", + "frame/runtime-benchmarks", ] try-runtime = [ - "pallet-ranked-collective?/try-runtime", - "frame/try-runtime", + "pallet-ranked-collective?/try-runtime", + "frame/try-runtime", ] From eeb1fc56a49d4ff54b5f5af26d41ec454caf77a6 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Tue, 7 Jan 2025 23:39:22 +0530 Subject: [PATCH 16/32] re fixing cargo.toml spacing --- substrate/frame/salary/Cargo.toml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/substrate/frame/salary/Cargo.toml b/substrate/frame/salary/Cargo.toml index be42f519f705..2288e393da1f 100644 --- a/substrate/frame/salary/Cargo.toml +++ b/substrate/frame/salary/Cargo.toml @@ -25,17 +25,17 @@ frame = { workspace = true, features = ["experimental", "runtime"] } [features] default = ["std"] std = [ - "codec/std", - "log/std", - "pallet-ranked-collective/std", - "scale-info/std", - "frame/std", + "codec/std", + "log/std", + "pallet-ranked-collective/std", + "scale-info/std", + "frame/std", ] runtime-benchmarks = [ - "pallet-ranked-collective/runtime-benchmarks", - "frame/runtime-benchmarks", + "pallet-ranked-collective/runtime-benchmarks", + "frame/runtime-benchmarks", ] try-runtime = [ - "pallet-ranked-collective?/try-runtime", - "frame/try-runtime", + "pallet-ranked-collective?/try-runtime", + "frame/try-runtime", ] From efeb7e62bacbd52739b4c8df9d59ff337149be50 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 00:18:07 +0530 Subject: [PATCH 17/32] running taplo format --config .config/taplo.toml substrate/frame/salary/Cargo.toml to pass taplo check --- substrate/frame/salary/Cargo.toml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/substrate/frame/salary/Cargo.toml b/substrate/frame/salary/Cargo.toml index 2288e393da1f..626993a0547b 100644 --- a/substrate/frame/salary/Cargo.toml +++ b/substrate/frame/salary/Cargo.toml @@ -17,25 +17,25 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { features = ["derive"], workspace = true } +frame = { workspace = true, features = ["experimental", "runtime"] } log = { workspace = true } pallet-ranked-collective = { optional = true, workspace = true } scale-info = { features = ["derive"], workspace = true } -frame = { workspace = true, features = ["experimental", "runtime"] } [features] default = ["std"] std = [ - "codec/std", - "log/std", - "pallet-ranked-collective/std", - "scale-info/std", - "frame/std", + "codec/std", + "frame/std", + "log/std", + "pallet-ranked-collective/std", + "scale-info/std", ] runtime-benchmarks = [ - "pallet-ranked-collective/runtime-benchmarks", - "frame/runtime-benchmarks", + "frame/runtime-benchmarks", + "pallet-ranked-collective/runtime-benchmarks", ] try-runtime = [ - "pallet-ranked-collective?/try-runtime", - "frame/try-runtime", + "frame/try-runtime", + "pallet-ranked-collective?/try-runtime", ] From 3f30ef6677e839a01058b94b6276e2ad5cb7c4cc Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 01:21:39 +0530 Subject: [PATCH 18/32] changes for failing System and hypothetical import --- substrate/frame/salary/src/tests/unit.rs | 2 +- substrate/frame/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 6bdd86ddef91..5e7883203b54 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -20,7 +20,7 @@ use crate as pallet_salary; use crate::*; use core::cell::RefCell; -use frame::{testing_prelude::*, traits::tokens::ConvertRank}; +use frame::testing_prelude::*; use std::collections::BTreeMap; type Block = MockBlock; diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 2d0ded4f0646..75283d4f6571 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -265,7 +265,7 @@ pub mod benchmarking { pub use frame_benchmarking::benchmarking::*; // The system origin, which is very often needed in benchmarking code. Might be tricky only // if the pallet defines its own `#[pallet::origin]` and call it `RawOrigin`. - pub use frame_system::RawOrigin; + pub use frame_system::{Pallet as System, RawOrigin}; } #[deprecated( @@ -322,7 +322,7 @@ pub mod testing_prelude { /// Other helper macros from `frame_support` that help with asserting in tests. pub use frame_support::{ assert_err, assert_err_ignore_postinfo, assert_error_encoded_size, assert_noop, assert_ok, - assert_storage_noop, storage_alias, + assert_storage_noop, storage_alias, hypothetically, traits::tokens::ConvertRank, }; pub use frame_system::{self, mocking::*}; From 4595acf0b0a5f0bc4d2cebf1d605820863fa2a1e Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 01:58:03 +0530 Subject: [PATCH 19/32] cargo fmt + applied patch on umbrella crate --- substrate/frame/salary/src/tests/integration.rs | 2 +- substrate/frame/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index c32bbe7221d4..f74c569f1dd1 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -186,7 +186,7 @@ fn swap_exhaustive_works() { // The events mess up the storage root: System::reset_events(); - sp_io::storage::root(sp_runtime::StateVersion::V1) + sp_io::storage::root(StateVersion::V1) }); let root_swap = hypothetically!({ diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 75283d4f6571..665aa2e7db70 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -322,7 +322,7 @@ pub mod testing_prelude { /// Other helper macros from `frame_support` that help with asserting in tests. pub use frame_support::{ assert_err, assert_err_ignore_postinfo, assert_error_encoded_size, assert_noop, assert_ok, - assert_storage_noop, storage_alias, hypothetically, traits::tokens::ConvertRank, + assert_storage_noop, hypothetically, storage_alias, traits::tokens::ConvertRank, }; pub use frame_system::{self, mocking::*}; From 49fb576efcd147194c0ce8a7ff58e1ae67e4fde7 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 02:49:05 +0530 Subject: [PATCH 20/32] fixing stateversion and convertrank imports --- substrate/frame/salary/src/tests/integration.rs | 9 +++++++-- substrate/frame/salary/src/tests/unit.rs | 2 +- substrate/frame/src/lib.rs | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index f74c569f1dd1..d257588f1443 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -18,9 +18,14 @@ //! The crate's tests. use crate as pallet_salary; -use crate::*; +use crate::{ + tests::integration::sp_api_hidden_includes_construct_runtime::hidden_include::sp_runtime, *, +}; use frame::{ - deps::sp_io::{self, MultiRemovalResults}, + deps::{ + sp_io::{self, MultiRemovalResults}, + sp_runtime::StateVersion, + }, testing_prelude::*, }; use pallet_ranked_collective::{EnsureRanked, Geometric}; diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 5e7883203b54..6bdd86ddef91 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -20,7 +20,7 @@ use crate as pallet_salary; use crate::*; use core::cell::RefCell; -use frame::testing_prelude::*; +use frame::{testing_prelude::*, traits::tokens::ConvertRank}; use std::collections::BTreeMap; type Block = MockBlock; diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 665aa2e7db70..dba039bee248 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -322,7 +322,7 @@ pub mod testing_prelude { /// Other helper macros from `frame_support` that help with asserting in tests. pub use frame_support::{ assert_err, assert_err_ignore_postinfo, assert_error_encoded_size, assert_noop, assert_ok, - assert_storage_noop, hypothetically, storage_alias, traits::tokens::ConvertRank, + assert_storage_noop, hypothetically, storage_alias, }; pub use frame_system::{self, mocking::*}; From 63b251c7d604d0213260cf72f78e616987f963d5 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 03:05:51 +0530 Subject: [PATCH 21/32] moving back convertrank to be handled in a separate issue --- substrate/frame/salary/src/tests/unit.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 6bdd86ddef91..109151cb6e80 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -20,7 +20,8 @@ use crate as pallet_salary; use crate::*; use core::cell::RefCell; -use frame::{testing_prelude::*, traits::tokens::ConvertRank}; +use frame::testing_prelude::*; +use fram_support::traits::tokens::ConvertRank; use std::collections::BTreeMap; type Block = MockBlock; From 8da372ea62b245f14a96d14b2a8b460282364747 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 03:07:01 +0530 Subject: [PATCH 22/32] fixing typo --- substrate/frame/salary/src/tests/unit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 109151cb6e80..07a954fdd744 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -21,7 +21,7 @@ use crate as pallet_salary; use crate::*; use core::cell::RefCell; use frame::testing_prelude::*; -use fram_support::traits::tokens::ConvertRank; +use frame_support::traits::tokens::ConvertRank; use std::collections::BTreeMap; type Block = MockBlock; From a2cf83308aa24416aa5ebc07b45ccb60ed866174 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 12:26:29 +0530 Subject: [PATCH 23/32] importing back convertrank --- substrate/frame/salary/src/tests/unit.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 07a954fdd744..06cfd0b87d95 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -20,9 +20,12 @@ use crate as pallet_salary; use crate::*; use core::cell::RefCell; -use frame::testing_prelude::*; -use frame_support::traits::tokens::ConvertRank; +use frame::{ + testing_prelude::*, + deps::frame_support::traits::tokens::ConvertRank, +}; use std::collections::BTreeMap; +use frame::deps::frame_support; type Block = MockBlock; From dcf39956eaeebb7bfdffa7efef77252ea3aeb538 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 13:59:43 +0530 Subject: [PATCH 24/32] cargo fmt nightly --- substrate/frame/salary/src/tests/unit.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 06cfd0b87d95..8da4d2728087 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -20,12 +20,8 @@ use crate as pallet_salary; use crate::*; use core::cell::RefCell; -use frame::{ - testing_prelude::*, - deps::frame_support::traits::tokens::ConvertRank, -}; +use frame::{deps::frame_support::traits::tokens::ConvertRank, testing_prelude::*}; use std::collections::BTreeMap; -use frame::deps::frame_support; type Block = MockBlock; From 5900660111c32550e886e0a201cd1a398a1e5344 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 14:18:04 +0530 Subject: [PATCH 25/32] extracting convert to implement separately later --- substrate/frame/salary/src/tests/integration.rs | 2 +- substrate/frame/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index d257588f1443..56709c9cf7c5 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -24,7 +24,7 @@ use crate::{ use frame::{ deps::{ sp_io::{self, MultiRemovalResults}, - sp_runtime::StateVersion, + sp_runtime::{traits::Convert, StateVersion}, }, testing_prelude::*, }; diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index dba039bee248..69ea283df930 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -232,8 +232,8 @@ pub mod prelude { /// Runtime traits #[doc(no_inline)] pub use sp_runtime::traits::{ - BlockNumberProvider, Bounded, Convert, DispatchInfoOf, Dispatchable, ReduceBy, - ReplaceWithDefault, SaturatedConversion, Saturating, StaticLookup, TrailingZeroInput, + BlockNumberProvider, Bounded, DispatchInfoOf, Dispatchable, ReduceBy, ReplaceWithDefault, + SaturatedConversion, Saturating, StaticLookup, TrailingZeroInput, }; /// Other error/result types for runtime #[doc(no_inline)] From b427d2a17687729c0685d00d6b23cc7a32db90c6 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 15:17:35 +0530 Subject: [PATCH 26/32] re importing convert and convertrank to run successful tests --- substrate/frame/salary/src/tests/integration.rs | 3 ++- substrate/frame/salary/src/tests/unit.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index 56709c9cf7c5..b88dd2100f70 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -24,9 +24,10 @@ use crate::{ use frame::{ deps::{ sp_io::{self, MultiRemovalResults}, - sp_runtime::{traits::Convert, StateVersion}, + sp_runtime::StateVersion, }, testing_prelude::*, + traits::Convert, }; use pallet_ranked_collective::{EnsureRanked, Geometric}; diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 8da4d2728087..3bb7bc4adf1e 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -20,7 +20,7 @@ use crate as pallet_salary; use crate::*; use core::cell::RefCell; -use frame::{deps::frame_support::traits::tokens::ConvertRank, testing_prelude::*}; +use frame::{deps::sp_runtime::traits::Identity, testing_prelude::*, traits::tokens::ConvertRank}; use std::collections::BTreeMap; type Block = MockBlock; From 557bc715c8f8ab66a68d9f3054f23087fcff4b0a Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 15:36:25 +0530 Subject: [PATCH 27/32] Moving convert to prelude --- substrate/frame/salary/src/tests/integration.rs | 1 - substrate/frame/src/lib.rs | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index b88dd2100f70..d257588f1443 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -27,7 +27,6 @@ use frame::{ sp_runtime::StateVersion, }, testing_prelude::*, - traits::Convert, }; use pallet_ranked_collective::{EnsureRanked, Geometric}; diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 69ea283df930..dba039bee248 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -232,8 +232,8 @@ pub mod prelude { /// Runtime traits #[doc(no_inline)] pub use sp_runtime::traits::{ - BlockNumberProvider, Bounded, DispatchInfoOf, Dispatchable, ReduceBy, ReplaceWithDefault, - SaturatedConversion, Saturating, StaticLookup, TrailingZeroInput, + BlockNumberProvider, Bounded, Convert, DispatchInfoOf, Dispatchable, ReduceBy, + ReplaceWithDefault, SaturatedConversion, Saturating, StaticLookup, TrailingZeroInput, }; /// Other error/result types for runtime #[doc(no_inline)] From de1b02fbbde6016fe8da4e077ea4cc10dd8fac05 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 15:48:54 +0530 Subject: [PATCH 28/32] removing unused import --- substrate/frame/salary/src/tests/integration.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index d257588f1443..92656d799782 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -22,10 +22,7 @@ use crate::{ tests::integration::sp_api_hidden_includes_construct_runtime::hidden_include::sp_runtime, *, }; use frame::{ - deps::{ - sp_io::{self, MultiRemovalResults}, - sp_runtime::StateVersion, - }, + deps::{sp_io, sp_runtime::StateVersion}, testing_prelude::*, }; use pallet_ranked_collective::{EnsureRanked, Geometric}; From ae9b6e279583573551f3b6a5729cf677435f355d Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 17:39:39 +0530 Subject: [PATCH 29/32] excluding sp_runtime outside of umbrella crate --- substrate/frame/salary/src/tests/integration.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index 92656d799782..6d38a1c9b0cf 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -18,9 +18,7 @@ //! The crate's tests. use crate as pallet_salary; -use crate::{ - tests::integration::sp_api_hidden_includes_construct_runtime::hidden_include::sp_runtime, *, -}; +use crate::*; use frame::{ deps::{sp_io, sp_runtime::StateVersion}, testing_prelude::*, @@ -201,7 +199,7 @@ fn swap_exhaustive_works() { // The events mess up the storage root: System::reset_events(); - sp_io::storage::root(sp_runtime::StateVersion::V1) + sp_io::storage::root(StateVersion::V1) }); assert_eq!(root_add, root_swap); From 22ff507a1b0a3df2060836ff1e580717d1d7db92 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Wed, 8 Jan 2025 21:27:07 +0530 Subject: [PATCH 30/32] patch applied from @kianenigma --- substrate/frame/salary/src/lib.rs | 5 +---- substrate/frame/salary/src/tests/integration.rs | 5 +---- substrate/frame/salary/src/tests/unit.rs | 2 +- substrate/frame/src/lib.rs | 6 +++--- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/substrate/frame/salary/src/lib.rs b/substrate/frame/salary/src/lib.rs index 256d1ad0cdf6..6a843625f4a7 100644 --- a/substrate/frame/salary/src/lib.rs +++ b/substrate/frame/salary/src/lib.rs @@ -22,10 +22,7 @@ use core::marker::PhantomData; use frame::{ prelude::*, - traits::{ - tokens::{GetSalary, Pay, PaymentStatus}, - RankedMembers, RankedMembersSwapHandler, - }, + traits::tokens::{GetSalary, Pay, PaymentStatus}, }; #[cfg(test)] diff --git a/substrate/frame/salary/src/tests/integration.rs b/substrate/frame/salary/src/tests/integration.rs index 6d38a1c9b0cf..e4e9c8f6a31b 100644 --- a/substrate/frame/salary/src/tests/integration.rs +++ b/substrate/frame/salary/src/tests/integration.rs @@ -19,10 +19,7 @@ use crate as pallet_salary; use crate::*; -use frame::{ - deps::{sp_io, sp_runtime::StateVersion}, - testing_prelude::*, -}; +use frame::{deps::sp_io, testing_prelude::*}; use pallet_ranked_collective::{EnsureRanked, Geometric}; type Rank = u16; diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 3bb7bc4adf1e..6bdd86ddef91 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -20,7 +20,7 @@ use crate as pallet_salary; use crate::*; use core::cell::RefCell; -use frame::{deps::sp_runtime::traits::Identity, testing_prelude::*, traits::tokens::ConvertRank}; +use frame::{testing_prelude::*, traits::tokens::ConvertRank}; use std::collections::BTreeMap; type Block = MockBlock; diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index dba039bee248..1795dfeb8114 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -207,7 +207,7 @@ pub mod prelude { defensive, defensive_assert, traits::{ Contains, EitherOf, EstimateNextSessionRotation, IsSubType, MapSuccess, NoOpPoll, - OnRuntimeUpgrade, OneSessionHandler, + OnRuntimeUpgrade, OneSessionHandler, RankedMembers, RankedMembersSwapHandler, }, }; @@ -232,7 +232,7 @@ pub mod prelude { /// Runtime traits #[doc(no_inline)] pub use sp_runtime::traits::{ - BlockNumberProvider, Bounded, Convert, DispatchInfoOf, Dispatchable, ReduceBy, + BlockNumberProvider, Bounded, Convert, DispatchInfoOf, Dispatchable, Identity, ReduceBy, ReplaceWithDefault, SaturatedConversion, Saturating, StaticLookup, TrailingZeroInput, }; /// Other error/result types for runtime @@ -333,7 +333,7 @@ pub mod testing_prelude { pub use sp_io::TestExternalities as TestState; /// Commonly used runtime traits for testing. - pub use sp_runtime::traits::BadOrigin; + pub use sp_runtime::{traits::BadOrigin, StateVersion}; } /// All of the types and tools needed to build FRAME-based runtimes. From 9302fdc0a74c32a5fa05a8ba42e4ee0877391703 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal Date: Thu, 9 Jan 2025 12:07:25 +0530 Subject: [PATCH 31/32] reverting identity to not be included in the umbrella crate --- substrate/frame/salary/src/tests/unit.rs | 2 +- substrate/frame/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 6bdd86ddef91..3bb7bc4adf1e 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -20,7 +20,7 @@ use crate as pallet_salary; use crate::*; use core::cell::RefCell; -use frame::{testing_prelude::*, traits::tokens::ConvertRank}; +use frame::{deps::sp_runtime::traits::Identity, testing_prelude::*, traits::tokens::ConvertRank}; use std::collections::BTreeMap; type Block = MockBlock; diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 1795dfeb8114..23d22683be2d 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -232,7 +232,7 @@ pub mod prelude { /// Runtime traits #[doc(no_inline)] pub use sp_runtime::traits::{ - BlockNumberProvider, Bounded, Convert, DispatchInfoOf, Dispatchable, Identity, ReduceBy, + BlockNumberProvider, Bounded, Convert, DispatchInfoOf, Dispatchable, ReduceBy, ReplaceWithDefault, SaturatedConversion, Saturating, StaticLookup, TrailingZeroInput, }; /// Other error/result types for runtime From e4722618b2ce952b5211528d977ec560c8ca6e49 Mon Sep 17 00:00:00 2001 From: seemantaggarwal <32275622+seemantaggarwal@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:26:21 +0530 Subject: [PATCH 32/32] Update pr_7048.prdoc --- prdoc/pr_7048.prdoc | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/prdoc/pr_7048.prdoc b/prdoc/pr_7048.prdoc index a55d3e56f306..0f3856bc1287 100644 --- a/prdoc/pr_7048.prdoc +++ b/prdoc/pr_7048.prdoc @@ -5,17 +5,13 @@ title: '[pallet-salary] Migrate to using frame umbrella crate' doc: - audience: Runtime Dev - description: - This PR migrates the pallet-salary to use the frame umbrella crate. - This is part of the ongoing effort to migrate all pallets to use the frame umbrella crate. - The effort is tracked [here](https://github.com/paritytech/polkadot-sdk/issues/6504). - + description: > + This PR migrates the `pallet-salary` to use the FRAME umbrella crate. + This is part of the ongoing effort to migrate all pallets to use the FRAME umbrella crate. + The effort is tracked [here](https://github.com/paritytech/polkadot-sdk/issues/6504). crates: -- name: pallet-salary - bump: minor -- name: polkadot-sdk-frame - bump: minor -- name: traits-misc - bump: minor - + - name: pallet-salary + bump: minor + - name: polkadot-sdk-frame + bump: minor