Skip to content

Commit

Permalink
Remove long deprecated AllPalletsWithoutSystemReversed (paritytech#…
Browse files Browse the repository at this point in the history
…2509)

Remove deprecated `AllPalletsXY` types.

They have been deprecated for nearly 1.5 years now, I think its fine to
remove them.
If anyone feels like we should first put a date on the deprecation as
stated in the deprecation guideline, feel free to speak up. To me it
looks like this has been forgotten and can be directly removed.
  • Loading branch information
skunert authored Nov 28, 2023
1 parent 62d6f29 commit 2566569
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 175 deletions.
6 changes: 2 additions & 4 deletions substrate/frame/executive/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ The default Substrate node template declares the
`Executive` type declaration from the node template.

```rust
#
/// Executive: handles dispatch to the various modules.
pub type Executive = executive::Executive<
Runtime,
Block,
Context,
Runtime,
AllPallets,
AllPalletsWithSystem,
>;
```

Expand All @@ -51,7 +50,6 @@ You can add custom logic that should be called in your runtime on a runtime upgr
generic parameter. The custom logic will be called before the on runtime upgrade logic of all modules is called.

```rust
#
struct CustomOnRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
Expand All @@ -65,7 +63,7 @@ pub type Executive = executive::Executive<
Block,
Context,
Runtime,
AllPallets,
AllPalletsWithSystem,
CustomOnRuntimeUpgrade,
>;
```
Expand Down
54 changes: 0 additions & 54 deletions substrate/frame/support/procedural/src/construct_runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,66 +600,12 @@ fn decl_all_pallets<'a>(
}
});

let all_pallets_without_system_reversed = attribute_to_names.iter().map(|(attr, names)| {
let names = names.iter().filter(|n| **n != SYSTEM_PALLET_NAME).rev();
quote! {
#attr
/// All pallets included in the runtime as a nested tuple of types in reversed order.
/// Excludes the System pallet.
#[deprecated(note = "Using reverse pallet orders is deprecated. use only \
`AllPalletsWithSystem or AllPalletsWithoutSystem`")]
pub type AllPalletsWithoutSystemReversed = ( #(#names,)* );
}
});

let all_pallets_with_system_reversed = attribute_to_names.iter().map(|(attr, names)| {
let names = names.iter().rev();
quote! {
#attr
/// All pallets included in the runtime as a nested tuple of types in reversed order.
#[deprecated(note = "Using reverse pallet orders is deprecated. use only \
`AllPalletsWithSystem or AllPalletsWithoutSystem`")]
pub type AllPalletsWithSystemReversed = ( #(#names,)* );
}
});

let all_pallets_reversed_with_system_first = attribute_to_names.iter().map(|(attr, names)| {
let system = quote::format_ident!("{}", SYSTEM_PALLET_NAME);
let names = std::iter::once(&system)
.chain(names.iter().rev().filter(|n| **n != SYSTEM_PALLET_NAME).cloned());
quote! {
#attr
/// All pallets included in the runtime as a nested tuple of types in reversed order.
/// With the system pallet first.
#[deprecated(note = "Using reverse pallet orders is deprecated. use only \
`AllPalletsWithSystem or AllPalletsWithoutSystem`")]
pub type AllPalletsReversedWithSystemFirst = ( #(#names,)* );
}
});

quote!(
#types

/// All pallets included in the runtime as a nested tuple of types.
#[deprecated(note = "The type definition has changed from representing all pallets \
excluding system, in reversed order to become the representation of all pallets \
including system pallet in regular order. For this reason it is encouraged to use \
explicitly one of `AllPalletsWithSystem`, `AllPalletsWithoutSystem`, \
`AllPalletsWithSystemReversed`, `AllPalletsWithoutSystemReversed`. \
Note that the type `frame_executive::Executive` expects one of `AllPalletsWithSystem` \
, `AllPalletsWithSystemReversed`, `AllPalletsReversedWithSystemFirst`. More details in \
https://github.com/paritytech/substrate/pull/10043")]
pub type AllPallets = AllPalletsWithSystem;

#( #all_pallets_with_system )*

#( #all_pallets_without_system )*

#( #all_pallets_with_system_reversed )*

#( #all_pallets_without_system_reversed )*

#( #all_pallets_reversed_with_system_first )*
)
}
fn decl_pallet_runtime_setup(
Expand Down
117 changes: 0 additions & 117 deletions substrate/frame/support/test/tests/pallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1271,52 +1271,6 @@ fn pallet_hooks_expand() {
})
}

#[test]
fn all_pallets_type_reversed_order_is_correct() {
TestExternalities::default().execute_with(|| {
frame_system::Pallet::<Runtime>::set_block_number(1);

#[allow(deprecated)]
{
assert_eq!(
AllPalletsWithoutSystemReversed::on_initialize(1),
Weight::from_parts(10, 0)
);
AllPalletsWithoutSystemReversed::on_finalize(1);

assert_eq!(
AllPalletsWithoutSystemReversed::on_runtime_upgrade(),
Weight::from_parts(30, 0)
);
}

assert_eq!(
frame_system::Pallet::<Runtime>::events()[0].event,
RuntimeEvent::Example2(pallet2::Event::Something(11)),
);
assert_eq!(
frame_system::Pallet::<Runtime>::events()[1].event,
RuntimeEvent::Example(pallet::Event::Something(10)),
);
assert_eq!(
frame_system::Pallet::<Runtime>::events()[2].event,
RuntimeEvent::Example2(pallet2::Event::Something(21)),
);
assert_eq!(
frame_system::Pallet::<Runtime>::events()[3].event,
RuntimeEvent::Example(pallet::Event::Something(20)),
);
assert_eq!(
frame_system::Pallet::<Runtime>::events()[4].event,
RuntimeEvent::Example2(pallet2::Event::Something(31)),
);
assert_eq!(
frame_system::Pallet::<Runtime>::events()[5].event,
RuntimeEvent::Example(pallet::Event::Something(30)),
);
})
}

#[test]
fn pallet_on_genesis() {
TestExternalities::default().execute_with(|| {
Expand Down Expand Up @@ -2186,31 +2140,6 @@ fn test_storage_info() {
);
}

#[test]
fn assert_type_all_pallets_reversed_with_system_first_is_correct() {
// Just ensure the 2 types are same.
#[allow(deprecated)]
fn _a(_t: AllPalletsReversedWithSystemFirst) {}
#[cfg(all(not(feature = "frame-feature-testing"), not(feature = "frame-feature-testing-2")))]
fn _b(t: (System, Example4, Example2, Example)) {
_a(t)
}
#[cfg(all(feature = "frame-feature-testing", not(feature = "frame-feature-testing-2")))]
fn _b(t: (System, Example4, Example3, Example2, Example)) {
_a(t)
}

#[cfg(all(not(feature = "frame-feature-testing"), feature = "frame-feature-testing-2"))]
fn _b(t: (System, Example5, Example4, Example2, Example)) {
_a(t)
}

#[cfg(all(feature = "frame-feature-testing", feature = "frame-feature-testing-2"))]
fn _b(t: (System, Example5, Example4, Example3, Example2, Example)) {
_a(t)
}
}

#[test]
fn assert_type_all_pallets_with_system_is_correct() {
// Just ensure the 2 types are same.
Expand Down Expand Up @@ -2255,52 +2184,6 @@ fn assert_type_all_pallets_without_system_is_correct() {
}
}

#[test]
fn assert_type_all_pallets_with_system_reversed_is_correct() {
// Just ensure the 2 types are same.
#[allow(deprecated)]
fn _a(_t: AllPalletsWithSystemReversed) {}
#[cfg(all(not(feature = "frame-feature-testing"), not(feature = "frame-feature-testing-2")))]
fn _b(t: (Example4, Example2, Example, System)) {
_a(t)
}
#[cfg(all(feature = "frame-feature-testing", not(feature = "frame-feature-testing-2")))]
fn _b(t: (Example4, Example3, Example2, Example, System)) {
_a(t)
}
#[cfg(all(not(feature = "frame-feature-testing"), feature = "frame-feature-testing-2"))]
fn _b(t: (Example5, Example4, Example2, Example, System)) {
_a(t)
}
#[cfg(all(feature = "frame-feature-testing", feature = "frame-feature-testing-2"))]
fn _b(t: (Example5, Example4, Example3, Example2, Example, System)) {
_a(t)
}
}

#[test]
fn assert_type_all_pallets_without_system_reversed_is_correct() {
// Just ensure the 2 types are same.
#[allow(deprecated)]
fn _a(_t: AllPalletsWithoutSystemReversed) {}
#[cfg(all(not(feature = "frame-feature-testing"), not(feature = "frame-feature-testing-2")))]
fn _b(t: (Example4, Example2, Example)) {
_a(t)
}
#[cfg(all(feature = "frame-feature-testing", not(feature = "frame-feature-testing-2")))]
fn _b(t: (Example4, Example3, Example2, Example)) {
_a(t)
}
#[cfg(all(not(feature = "frame-feature-testing"), feature = "frame-feature-testing-2"))]
fn _b(t: (Example5, Example4, Example2, Example)) {
_a(t)
}
#[cfg(all(feature = "frame-feature-testing", feature = "frame-feature-testing-2"))]
fn _b(t: (Example5, Example4, Example3, Example2, Example)) {
_a(t)
}
}

#[test]
fn test_storage_alias() {
use frame_support::Twox64Concat;
Expand Down

0 comments on commit 2566569

Please sign in to comment.