From 4b889e2f950a178bfc94e1dfc056437ee6f502ef Mon Sep 17 00:00:00 2001 From: Nathy-bajo Date: Fri, 17 Jan 2025 14:27:26 +0100 Subject: [PATCH 1/5] migrate pallet-examples-split to use umbrella crate --- Cargo.lock | 6 +---- substrate/frame/examples/split/Cargo.toml | 24 ++++--------------- .../frame/examples/split/src/benchmarking.rs | 3 +-- substrate/frame/examples/split/src/events.rs | 1 - substrate/frame/examples/split/src/lib.rs | 6 ++--- substrate/frame/examples/split/src/mock.rs | 8 +++---- substrate/frame/examples/split/src/tests.rs | 2 +- substrate/frame/examples/split/src/weights.rs | 2 +- substrate/frame/src/lib.rs | 4 ++-- 9 files changed, 17 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 42ed88fb0d06d..ced40b82eab6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13610,14 +13610,10 @@ dependencies = [ name = "pallet-example-split" version = "10.0.0" dependencies = [ - "frame-benchmarking 28.0.0", - "frame-support 28.0.0", - "frame-system 28.0.0", "log", "parity-scale-codec", + "polkadot-sdk-frame 0.1.0", "scale-info", - "sp-core 28.0.0", - "sp-io 30.0.0", ] [[package]] diff --git a/substrate/frame/examples/split/Cargo.toml b/substrate/frame/examples/split/Cargo.toml index 22cd8116f670c..802c2952759d2 100644 --- a/substrate/frame/examples/split/Cargo.toml +++ b/substrate/frame/examples/split/Cargo.toml @@ -20,32 +20,18 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { workspace = true } log = { workspace = true } scale-info = { features = ["derive"], workspace = true } +frame = { workspace = true, features = ["experimental", "runtime"]} -frame-support = { workspace = true } -frame-system = { workspace = true } - -sp-io = { workspace = true } - -frame-benchmarking = { optional = true, workspace = true } - -[dev-dependencies] -sp-core = { workspace = true } [features] default = ["std"] std = [ "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", "log/std", "scale-info/std", - "sp-core/std", - "sp-io/std", + "frame/std", ] -runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + +try-runtime = [ + "frame/try-runtime", ] -try-runtime = ["frame-support/try-runtime", "frame-system/try-runtime"] diff --git a/substrate/frame/examples/split/src/benchmarking.rs b/substrate/frame/examples/split/src/benchmarking.rs index 5a50300937203..5ffe891390314 100644 --- a/substrate/frame/examples/split/src/benchmarking.rs +++ b/substrate/frame/examples/split/src/benchmarking.rs @@ -23,8 +23,7 @@ use super::*; #[allow(unused)] use crate::Pallet as Template; -use frame_benchmarking::v2::*; -use frame_system::RawOrigin; +use frame::benchmarking::prelude::*; #[benchmarks] mod benchmarks { diff --git a/substrate/frame/examples/split/src/events.rs b/substrate/frame/examples/split/src/events.rs index 7560766bacb33..262bb42dadc9a 100644 --- a/substrate/frame/examples/split/src/events.rs +++ b/substrate/frame/examples/split/src/events.rs @@ -15,7 +15,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use frame_support::pallet_macros::*; /// A [`pallet_section`] that defines the events for a pallet. /// This can later be imported into the pallet using [`import_section`]. diff --git a/substrate/frame/examples/split/src/lib.rs b/substrate/frame/examples/split/src/lib.rs index 5245d90e390cf..45745863fa251 100644 --- a/substrate/frame/examples/split/src/lib.rs +++ b/substrate/frame/examples/split/src/lib.rs @@ -41,16 +41,14 @@ mod events; pub mod weights; pub use weights::*; -use frame_support::pallet_macros::*; +use frame::prelude::*; /// Imports a [`pallet_section`] defined at [`events::events`]. /// This brings the events defined in that section into the pallet's namespace. #[import_section(events::events)] -#[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; - use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); diff --git a/substrate/frame/examples/split/src/mock.rs b/substrate/frame/examples/split/src/mock.rs index 5bf414ee24133..26ffce6672577 100644 --- a/substrate/frame/examples/split/src/mock.rs +++ b/substrate/frame/examples/split/src/mock.rs @@ -16,12 +16,12 @@ // limitations under the License. use crate as pallet_template; -use frame_support::{derive_impl, sp_runtime::BuildStorage}; +use frame::testing_prelude::*; -type Block = frame_system::mocking::MockBlock; +type Block = MockBlock; // Configure a mock runtime to test the pallet. -frame_support::construct_runtime!( +construct_runtime!( pub enum Test { System: frame_system, @@ -42,6 +42,6 @@ impl pallet_template::Config for Test { } // Build genesis storage according to the mock runtime. -pub fn new_test_ext() -> sp_io::TestExternalities { +pub fn new_test_ext() -> TestState { frame_system::GenesisConfig::::default().build_storage().unwrap().into() } diff --git a/substrate/frame/examples/split/src/tests.rs b/substrate/frame/examples/split/src/tests.rs index 1d4b6dfcff9d5..12eb650b8d825 100644 --- a/substrate/frame/examples/split/src/tests.rs +++ b/substrate/frame/examples/split/src/tests.rs @@ -16,7 +16,7 @@ // limitations under the License. use crate::{mock::*, Error, Event, Something}; -use frame_support::{assert_noop, assert_ok}; +use frame::testing_prelude::*; #[test] fn it_works_for_default_value() { diff --git a/substrate/frame/examples/split/src/weights.rs b/substrate/frame/examples/split/src/weights.rs index 58b9e2af43a1c..164e67e9439cc 100644 --- a/substrate/frame/examples/split/src/weights.rs +++ b/substrate/frame/examples/split/src/weights.rs @@ -46,7 +46,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame::weights_prelude::*; use core::marker::PhantomData; /// Weight functions needed for pallet_template. diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index e3e58fc01b5fa..895adae7e637b 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -231,10 +231,10 @@ pub mod prelude { /// Runtime traits #[doc(no_inline)] - pub use sp_runtime::traits::{ + pub use sp_runtime::{traits::{ BlockNumberProvider, Bounded, Convert, DispatchInfoOf, Dispatchable, ReduceBy, ReplaceWithDefault, SaturatedConversion, Saturating, StaticLookup, TrailingZeroInput, - }; + }, BuildStorage}; /// Other error/result types for runtime #[doc(no_inline)] pub use sp_runtime::{ From 0a460866e278a23dd971e8d35f07ee2d81115292 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Fri, 17 Jan 2025 13:42:07 +0000 Subject: [PATCH 2/5] Update from franciscoaguirre running command 'prdoc --audience runtime_dev --bump minor' --- prdoc/pr_7224.prdoc | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 prdoc/pr_7224.prdoc diff --git a/prdoc/pr_7224.prdoc b/prdoc/pr_7224.prdoc new file mode 100644 index 0000000000000..7489314413748 --- /dev/null +++ b/prdoc/pr_7224.prdoc @@ -0,0 +1,7 @@ +title: Migrate pallet-examples-split to use umbrella crate +doc: +- audience: Runtime Dev + description: Part of https://github.com/paritytech/polkadot-sdk/issues/6504 +crates: +- name: polkadot-sdk-frame + bump: minor From 92b756fae0a64540a08f33b8e0dc87f681565e43 Mon Sep 17 00:00:00 2001 From: Nathy-bajo Date: Sat, 18 Jan 2025 18:29:06 +0100 Subject: [PATCH 3/5] remove experimental feature flag from Cargo.toml --- prdoc/pr_7224.prdoc | 14 ++++++++++---- substrate/frame/examples/split/Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/prdoc/pr_7224.prdoc b/prdoc/pr_7224.prdoc index 7489314413748..f79f95f742a04 100644 --- a/prdoc/pr_7224.prdoc +++ b/prdoc/pr_7224.prdoc @@ -1,7 +1,13 @@ -title: Migrate pallet-examples-split to use umbrella crate +title: '[pallet-examples-split] Migrate to using frame umbrella crate' + doc: - audience: Runtime Dev - description: Part of https://github.com/paritytech/polkadot-sdk/issues/6504 + description: This PR migrates the pallet-examples-split 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: polkadot-sdk-frame - bump: minor + - name: pallet-examples-split + bump: minor + - name: polkadot-sdk-frame + bump: minor \ No newline at end of file diff --git a/substrate/frame/examples/split/Cargo.toml b/substrate/frame/examples/split/Cargo.toml index 802c2952759d2..296b8d26746d3 100644 --- a/substrate/frame/examples/split/Cargo.toml +++ b/substrate/frame/examples/split/Cargo.toml @@ -20,7 +20,7 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { workspace = true } log = { workspace = true } scale-info = { features = ["derive"], workspace = true } -frame = { workspace = true, features = ["experimental", "runtime"]} +frame = { workspace = true, features = ["runtime"]} [features] From ebc068c32e6ef9d0f37a1ce80f9b4be0126da436 Mon Sep 17 00:00:00 2001 From: Nathy-bajo Date: Wed, 22 Jan 2025 07:36:57 +0100 Subject: [PATCH 4/5] add frame pallet_section --- substrate/frame/examples/split/src/events.rs | 2 +- substrate/frame/src/lib.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/substrate/frame/examples/split/src/events.rs b/substrate/frame/examples/split/src/events.rs index 262bb42dadc9a..8bb6c0d472e1a 100644 --- a/substrate/frame/examples/split/src/events.rs +++ b/substrate/frame/examples/split/src/events.rs @@ -18,7 +18,7 @@ /// A [`pallet_section`] that defines the events for a pallet. /// This can later be imported into the pallet using [`import_section`]. -#[pallet_section] +#[frame::pallet_section] mod events { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 88c70c6c51887..b2f7c9d0d2053 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -235,7 +235,6 @@ pub mod prelude { BlockNumberProvider, Bounded, Convert, DispatchInfoOf, Dispatchable, ReduceBy, ReplaceWithDefault, SaturatedConversion, Saturating, StaticLookup, TrailingZeroInput, }, BuildStorage}; - }; /// Bounded storage related types. pub use sp_runtime::{BoundedSlice, BoundedVec}; From f3d05bbb2a3027737e823aa2ed0874545229db7d Mon Sep 17 00:00:00 2001 From: Nathy-bajo Date: Sun, 26 Jan 2025 23:08:13 +0100 Subject: [PATCH 5/5] more changes --- substrate/frame/examples/split/Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/substrate/frame/examples/split/Cargo.toml b/substrate/frame/examples/split/Cargo.toml index 296b8d26746d3..1ce526e05bae3 100644 --- a/substrate/frame/examples/split/Cargo.toml +++ b/substrate/frame/examples/split/Cargo.toml @@ -32,6 +32,10 @@ std = [ "frame/std", ] +runtime-benchmarks = [ + "frame/runtime-benchmarks", +] + try-runtime = [ "frame/try-runtime", ]