Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove long deprecated AllPalletsWithoutSystemReversed #2509

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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