From aaf788a4d3ee6096824cac0e739ed26f123eb8b7 Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Sun, 17 Nov 2024 12:34:18 -0800 Subject: [PATCH 1/8] frame-whitelist --- Cargo.lock | 8 +----- substrate/frame/whitelist/Cargo.toml | 26 +++---------------- substrate/frame/whitelist/src/benchmarking.rs | 4 ++- substrate/frame/whitelist/src/lib.rs | 10 +++++-- substrate/frame/whitelist/src/mock.rs | 8 +++--- substrate/frame/whitelist/src/tests.rs | 3 +++ substrate/frame/whitelist/src/weights.rs | 3 ++- 7 files changed, 26 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 182d8f6bacad..04c7b3da3102 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15828,17 +15828,11 @@ dependencies = [ name = "pallet-whitelist" version = "27.0.0" dependencies = [ - "frame-benchmarking 28.0.0", - "frame-support 28.0.0", - "frame-system 28.0.0", "pallet-balances 28.0.0", "pallet-preimage 28.0.0", "parity-scale-codec", + "polkadot-sdk-frame 0.1.0", "scale-info", - "sp-api 26.0.0", - "sp-core 28.0.0", - "sp-io 30.0.0", - "sp-runtime 31.0.1", ] [[package]] diff --git a/substrate/frame/whitelist/Cargo.toml b/substrate/frame/whitelist/Cargo.toml index a347174ed2eb..baeafedf701d 100644 --- a/substrate/frame/whitelist/Cargo.toml +++ b/substrate/frame/whitelist/Cargo.toml @@ -17,46 +17,28 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { features = ["derive", "max-encoded-len"], workspace = true } scale-info = { features = ["derive"], workspace = true } -frame-benchmarking = { optional = true, workspace = true } -frame-support = { workspace = true } -frame-system = { workspace = true } -sp-api = { workspace = true } -sp-runtime = { workspace = true } +frame = { workspace = true, features = ["experimental", "runtime"] } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } pallet-preimage = { workspace = true, default-features = true } -sp-core = { workspace = true, default-features = true } -sp-io = { workspace = true, default-features = true } [features] default = ["std"] std = [ "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", + "frame/std", "pallet-balances/std", "pallet-preimage/std", "scale-info/std", - "sp-api/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", ] runtime-benchmarks = [ - "frame-benchmarking", - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", ] try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", + "frame/try-runtime", "pallet-balances/try-runtime", "pallet-preimage/try-runtime", - "sp-runtime/try-runtime", ] diff --git a/substrate/frame/whitelist/src/benchmarking.rs b/substrate/frame/whitelist/src/benchmarking.rs index 0d7605d9752b..58c6056a2358 100644 --- a/substrate/frame/whitelist/src/benchmarking.rs +++ b/substrate/frame/whitelist/src/benchmarking.rs @@ -20,9 +20,11 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; +/* use frame_benchmarking::v2::*; use frame_support::traits::EnsureOrigin; - +*/ +use frame::benchmarking::prelude::*; #[cfg(test)] use crate::Pallet as Whitelist; diff --git a/substrate/frame/whitelist/src/lib.rs b/substrate/frame/whitelist/src/lib.rs index 28887e0ca4ac..617c19ceb6f0 100644 --- a/substrate/frame/whitelist/src/lib.rs +++ b/substrate/frame/whitelist/src/lib.rs @@ -44,22 +44,28 @@ extern crate alloc; use alloc::boxed::Box; use codec::{DecodeLimit, Encode, FullCodec}; +/* use frame_support::{ dispatch::{GetDispatchInfo, PostDispatchInfo}, ensure, traits::{QueryPreimage, StorePreimage}, weights::Weight, }; +*/ use scale_info::TypeInfo; -use sp_runtime::traits::{Dispatchable, Hash}; +// use sp_runtime::traits::{Dispatchable, Hash}; +use frame::{prelude::*, traits::{QueryPreimage, StorePreimage}, deps::sp_api}; pub use pallet::*; -#[frame_support::pallet] +// #[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; + /* use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; + */ #[pallet::config] pub trait Config: frame_system::Config { diff --git a/substrate/frame/whitelist/src/mock.rs b/substrate/frame/whitelist/src/mock.rs index 0a97d1c2df54..d88543b9f0fe 100644 --- a/substrate/frame/whitelist/src/mock.rs +++ b/substrate/frame/whitelist/src/mock.rs @@ -21,10 +21,12 @@ use crate as pallet_whitelist; +/* use frame_support::{construct_runtime, derive_impl}; use frame_system::EnsureRoot; use sp_runtime::BuildStorage; - +*/ +use frame::{testing_prelude::*, pallet_macros::derive_impl}; type Block = frame_system::mocking::MockBlock; construct_runtime!( @@ -65,9 +67,9 @@ impl pallet_whitelist::Config for Test { type WeightInfo = (); } -pub fn new_test_ext() -> sp_io::TestExternalities { +pub fn new_test_ext() -> TestExternalities { let t = RuntimeGenesisConfig::default().build_storage().unwrap(); - let mut ext = sp_io::TestExternalities::new(t); + let mut ext = TestExternalities::new(t); ext.execute_with(|| System::set_block_number(1)); ext } diff --git a/substrate/frame/whitelist/src/tests.rs b/substrate/frame/whitelist/src/tests.rs index b53cc93b1953..62a1e0ee7983 100644 --- a/substrate/frame/whitelist/src/tests.rs +++ b/substrate/frame/whitelist/src/tests.rs @@ -19,6 +19,7 @@ use crate::mock::*; use codec::Encode; +/* use frame_support::{ assert_noop, assert_ok, dispatch::GetDispatchInfo, @@ -26,6 +27,8 @@ use frame_support::{ weights::Weight, }; use sp_runtime::{traits::Hash, DispatchError}; +*/ +use frame::{testing_prelude::*, traits::{StorePreimage, QueryPreimage}}; #[test] fn test_whitelist_call_and_remove() { diff --git a/substrate/frame/whitelist/src/weights.rs b/substrate/frame/whitelist/src/weights.rs index 12a18a8f0107..462844612a07 100644 --- a/substrate/frame/whitelist/src/weights.rs +++ b/substrate/frame/whitelist/src/weights.rs @@ -46,7 +46,8 @@ #![allow(unused_imports)] #![allow(missing_docs)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +// use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame::weights_prelude::*; use core::marker::PhantomData; /// Weight functions needed for `pallet_whitelist`. From 7c3419a561bdcca466a6bd3c900286a67b271038 Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Sun, 24 Nov 2024 12:23:26 -0800 Subject: [PATCH 2/8] cargo +nightly fmt, add prdoc --- prdoc/pr_6514.prdoc | 14 ++++++++++++++ substrate/frame/whitelist/src/benchmarking.rs | 6 +----- substrate/frame/whitelist/src/lib.rs | 16 +++------------- substrate/frame/whitelist/src/mock.rs | 7 +------ substrate/frame/whitelist/src/tests.rs | 10 ++-------- substrate/frame/whitelist/src/weights.rs | 1 - 6 files changed, 21 insertions(+), 33 deletions(-) create mode 100644 prdoc/pr_6514.prdoc diff --git a/prdoc/pr_6514.prdoc b/prdoc/pr_6514.prdoc new file mode 100644 index 000000000000..feac177d916d --- /dev/null +++ b/prdoc/pr_6514.prdoc @@ -0,0 +1,14 @@ +# 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: migrate pallet-whitelist to umbrella crate + +doc: + - audience: Runtime Dev + description: | + This pull request adapts the frame umbrella crate into pallet-whitelist + by importing existing system into the pallet. + +crates: + - name: pallet-whitelist + bump: minor diff --git a/substrate/frame/whitelist/src/benchmarking.rs b/substrate/frame/whitelist/src/benchmarking.rs index 58c6056a2358..46a310cb4073 100644 --- a/substrate/frame/whitelist/src/benchmarking.rs +++ b/substrate/frame/whitelist/src/benchmarking.rs @@ -20,13 +20,9 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -/* -use frame_benchmarking::v2::*; -use frame_support::traits::EnsureOrigin; -*/ -use frame::benchmarking::prelude::*; #[cfg(test)] use crate::Pallet as Whitelist; +use frame::benchmarking::prelude::*; #[benchmarks] mod benchmarks { diff --git a/substrate/frame/whitelist/src/lib.rs b/substrate/frame/whitelist/src/lib.rs index 617c19ceb6f0..6612fe9706c0 100644 --- a/substrate/frame/whitelist/src/lib.rs +++ b/substrate/frame/whitelist/src/lib.rs @@ -44,28 +44,18 @@ extern crate alloc; use alloc::boxed::Box; use codec::{DecodeLimit, Encode, FullCodec}; -/* -use frame_support::{ - dispatch::{GetDispatchInfo, PostDispatchInfo}, - ensure, +use frame::{ + deps::sp_api, + prelude::*, traits::{QueryPreimage, StorePreimage}, - weights::Weight, }; -*/ use scale_info::TypeInfo; -// use sp_runtime::traits::{Dispatchable, Hash}; -use frame::{prelude::*, traits::{QueryPreimage, StorePreimage}, deps::sp_api}; pub use pallet::*; -// #[frame_support::pallet] #[frame::pallet] pub mod pallet { use super::*; - /* - use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; - */ #[pallet::config] pub trait Config: frame_system::Config { diff --git a/substrate/frame/whitelist/src/mock.rs b/substrate/frame/whitelist/src/mock.rs index d88543b9f0fe..352129810a34 100644 --- a/substrate/frame/whitelist/src/mock.rs +++ b/substrate/frame/whitelist/src/mock.rs @@ -21,12 +21,7 @@ use crate as pallet_whitelist; -/* -use frame_support::{construct_runtime, derive_impl}; -use frame_system::EnsureRoot; -use sp_runtime::BuildStorage; -*/ -use frame::{testing_prelude::*, pallet_macros::derive_impl}; +use frame::{pallet_macros::derive_impl, testing_prelude::*}; type Block = frame_system::mocking::MockBlock; construct_runtime!( diff --git a/substrate/frame/whitelist/src/tests.rs b/substrate/frame/whitelist/src/tests.rs index 62a1e0ee7983..4e591339a4c3 100644 --- a/substrate/frame/whitelist/src/tests.rs +++ b/substrate/frame/whitelist/src/tests.rs @@ -19,16 +19,10 @@ use crate::mock::*; use codec::Encode; -/* -use frame_support::{ - assert_noop, assert_ok, - dispatch::GetDispatchInfo, +use frame::{ + testing_prelude::*, traits::{QueryPreimage, StorePreimage}, - weights::Weight, }; -use sp_runtime::{traits::Hash, DispatchError}; -*/ -use frame::{testing_prelude::*, traits::{StorePreimage, QueryPreimage}}; #[test] fn test_whitelist_call_and_remove() { diff --git a/substrate/frame/whitelist/src/weights.rs b/substrate/frame/whitelist/src/weights.rs index 462844612a07..50e211c1e979 100644 --- a/substrate/frame/whitelist/src/weights.rs +++ b/substrate/frame/whitelist/src/weights.rs @@ -46,7 +46,6 @@ #![allow(unused_imports)] #![allow(missing_docs)] -// use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use frame::weights_prelude::*; use core::marker::PhantomData; From 21c4170fdfd770c2d22219da5900d55a6aeb1712 Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Fri, 6 Dec 2024 02:32:55 -0800 Subject: [PATCH 3/8] modify prelude --- substrate/frame/whitelist/src/lib.rs | 3 +-- substrate/frame/whitelist/src/mock.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/substrate/frame/whitelist/src/lib.rs b/substrate/frame/whitelist/src/lib.rs index 6612fe9706c0..54f91af7c575 100644 --- a/substrate/frame/whitelist/src/lib.rs +++ b/substrate/frame/whitelist/src/lib.rs @@ -45,7 +45,6 @@ extern crate alloc; use alloc::boxed::Box; use codec::{DecodeLimit, Encode, FullCodec}; use frame::{ - deps::sp_api, prelude::*, traits::{QueryPreimage, StorePreimage}, }; @@ -168,7 +167,7 @@ pub mod pallet { .map_err(|_| Error::::UnavailablePreImage)?; let call = ::RuntimeCall::decode_all_with_depth_limit( - sp_api::MAX_EXTRINSIC_DEPTH, + frame::deps::sp_api::MAX_EXTRINSIC_DEPTH, &mut &call[..], ) .map_err(|_| Error::::UndecodableCall)?; diff --git a/substrate/frame/whitelist/src/mock.rs b/substrate/frame/whitelist/src/mock.rs index 352129810a34..a71f3efb7ae0 100644 --- a/substrate/frame/whitelist/src/mock.rs +++ b/substrate/frame/whitelist/src/mock.rs @@ -21,7 +21,7 @@ use crate as pallet_whitelist; -use frame::{pallet_macros::derive_impl, testing_prelude::*}; +use frame::testing_prelude::*; type Block = frame_system::mocking::MockBlock; construct_runtime!( From c693fd02fe692ffc01797e8db55b358b15ae38cb Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Wed, 11 Dec 2024 19:49:51 -0800 Subject: [PATCH 4/8] remove prdoc --- prdoc/pr_6514.prdoc | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 prdoc/pr_6514.prdoc diff --git a/prdoc/pr_6514.prdoc b/prdoc/pr_6514.prdoc deleted file mode 100644 index feac177d916d..000000000000 --- a/prdoc/pr_6514.prdoc +++ /dev/null @@ -1,14 +0,0 @@ -# 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: migrate pallet-whitelist to umbrella crate - -doc: - - audience: Runtime Dev - description: | - This pull request adapts the frame umbrella crate into pallet-whitelist - by importing existing system into the pallet. - -crates: - - name: pallet-whitelist - bump: minor From 6785b70096b56ebddfd9c9f6077d39d0c5c926fd Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Sun, 29 Dec 2024 11:59:55 +0100 Subject: [PATCH 5/8] nit --- substrate/frame/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 03d815e349df..8031ddf96e6a 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -391,7 +391,7 @@ pub mod runtime { LOCAL_TESTNET_RUNTIME_PRESET, }; pub use sp_inherents::{CheckInherentsResult, InherentData}; - pub use sp_keyring::AccountKeyring; + pub use sp_keyring::Sr25519Keyring; pub use sp_runtime::{ApplyExtrinsicResult, ExtrinsicInclusionMode}; } From 6704ca8e280bb05f9d10d8f7748803a1b930a386 Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Sun, 29 Dec 2024 21:56:06 +0100 Subject: [PATCH 6/8] frame_system::mocking is already in the prelude --- substrate/frame/whitelist/src/mock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/whitelist/src/mock.rs b/substrate/frame/whitelist/src/mock.rs index a71f3efb7ae0..73e991e0766d 100644 --- a/substrate/frame/whitelist/src/mock.rs +++ b/substrate/frame/whitelist/src/mock.rs @@ -22,7 +22,7 @@ use crate as pallet_whitelist; use frame::testing_prelude::*; -type Block = frame_system::mocking::MockBlock; +type Block = MockBlock; construct_runtime!( pub enum Test From 6cd9cf87aed335c111f21695d1c3a653ad46fe2e Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Sun, 19 Jan 2025 04:14:22 +0100 Subject: [PATCH 7/8] remove experimental --- substrate/frame/whitelist/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/whitelist/Cargo.toml b/substrate/frame/whitelist/Cargo.toml index baeafedf701d..d89aee385b46 100644 --- a/substrate/frame/whitelist/Cargo.toml +++ b/substrate/frame/whitelist/Cargo.toml @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { features = ["derive", "max-encoded-len"], workspace = true } scale-info = { features = ["derive"], workspace = true } -frame = { workspace = true, features = ["experimental", "runtime"] } +frame = { workspace = true, features = ["runtime"] } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } From 45ec3b1156383beefefc9a73f65618b29a66e9fa Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Sun, 19 Jan 2025 04:18:17 +0100 Subject: [PATCH 8/8] taplo --- substrate/frame/whitelist/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/whitelist/Cargo.toml b/substrate/frame/whitelist/Cargo.toml index d89aee385b46..61ce3353267c 100644 --- a/substrate/frame/whitelist/Cargo.toml +++ b/substrate/frame/whitelist/Cargo.toml @@ -16,8 +16,8 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { features = ["derive", "max-encoded-len"], workspace = true } -scale-info = { features = ["derive"], workspace = true } frame = { workspace = true, features = ["runtime"] } +scale-info = { features = ["derive"], workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true }