Skip to content

Commit

Permalink
use AllPalletsWithSystem for hook order (moonbeam-foundation#1937)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaztec authored and imstar15 committed May 16, 2023
1 parent 697ec44 commit 48a0e45
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 47 deletions.
4 changes: 2 additions & 2 deletions pallets/maintenance-mode/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ pub mod pallet {
#[cfg(feature = "xcm-support")]
type MaintenanceDmpHandler: DmpMessageHandler;
/// The executive hooks that will be used in normal operating mode
/// Important: Use AllPalletsReversedWithSystemFirst here if you dont want to modify the
/// Important: Use AllPalletsWithSystem here if you dont want to modify the
/// hooks behaviour
type NormalExecutiveHooks: OnRuntimeUpgrade
+ OnInitialize<Self::BlockNumber>
+ OnIdle<Self::BlockNumber>
+ OnFinalize<Self::BlockNumber>
+ OffchainWorker<Self::BlockNumber>;
/// The executive hooks that will be used in maintenance mode
/// Important: Use AllPalletsReversedWithSystemFirst here if you dont want to modify the
/// Important: Use AllPalletsWithSystem here if you dont want to modify the
/// hooks behaviour
type MaintenanceExecutiveHooks: OnRuntimeUpgrade
+ OnInitialize<Self::BlockNumber>
Expand Down
23 changes: 8 additions & 15 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,7 @@ pub struct MaintenanceHooks;

impl OnInitialize<BlockNumber> for MaintenanceHooks {
fn on_initialize(n: BlockNumber) -> Weight {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::on_initialize(n)
AllPalletsWithSystem::on_initialize(n)
}
}

Expand All @@ -979,33 +978,28 @@ impl OnIdle<BlockNumber> for MaintenanceHooks {

impl OnRuntimeUpgrade for MaintenanceHooks {
fn on_runtime_upgrade() -> Weight {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::on_runtime_upgrade()
AllPalletsWithSystem::on_runtime_upgrade()
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::pre_upgrade()
AllPalletsWithSystem::pre_upgrade()
}

#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::post_upgrade()
AllPalletsWithSystem::post_upgrade()
}
}

impl OnFinalize<BlockNumber> for MaintenanceHooks {
fn on_finalize(n: BlockNumber) {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::on_finalize(n)
AllPalletsWithSystem::on_finalize(n)
}
}

impl OffchainWorker<BlockNumber> for MaintenanceHooks {
fn offchain_worker(n: BlockNumber) {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::offchain_worker(n)
AllPalletsWithSystem::offchain_worker(n)
}
}

Expand All @@ -1018,10 +1012,9 @@ impl pallet_maintenance_mode::Config for Runtime {
type XcmExecutionManager = XcmExecutionManager;
type NormalDmpHandler = DmpQueue;
type MaintenanceDmpHandler = MaintenanceDmpHandler;
// We use AllPalletsReversedWithSystemFirst because we dont want to change the hooks in normal
// We use AllPalletsWithSystem because we dont want to change the hooks in normal
// operation
#[allow(deprecated)]
type NormalExecutiveHooks = AllPalletsReversedWithSystemFirst;
type NormalExecutiveHooks = AllPalletsWithSystem;
type MaintenanceExecutiveHooks = MaintenanceHooks;
}

Expand Down
23 changes: 8 additions & 15 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,8 +1014,7 @@ pub struct MaintenanceHooks;

impl OnInitialize<BlockNumber> for MaintenanceHooks {
fn on_initialize(n: BlockNumber) -> Weight {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::on_initialize(n)
AllPalletsWithSystem::on_initialize(n)
}
}

Expand All @@ -1033,33 +1032,28 @@ impl OnIdle<BlockNumber> for MaintenanceHooks {

impl OnRuntimeUpgrade for MaintenanceHooks {
fn on_runtime_upgrade() -> Weight {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::on_runtime_upgrade()
AllPalletsWithSystem::on_runtime_upgrade()
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::pre_upgrade()
AllPalletsWithSystem::pre_upgrade()
}

#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::post_upgrade()
AllPalletsWithSystem::post_upgrade()
}
}

impl OnFinalize<BlockNumber> for MaintenanceHooks {
fn on_finalize(n: BlockNumber) {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::on_finalize(n)
AllPalletsWithSystem::on_finalize(n)
}
}

impl OffchainWorker<BlockNumber> for MaintenanceHooks {
fn offchain_worker(n: BlockNumber) {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::offchain_worker(n)
AllPalletsWithSystem::offchain_worker(n)
}
}

Expand All @@ -1072,10 +1066,9 @@ impl pallet_maintenance_mode::Config for Runtime {
type XcmExecutionManager = XcmExecutionManager;
type NormalDmpHandler = DmpQueue;
type MaintenanceDmpHandler = MaintenanceDmpHandler;
// We use AllPalletsReversedWithSystemFirst because we dont want to change the hooks in normal
// We use AllPalletsWithSystem because we dont want to change the hooks in normal
// operation
#[allow(deprecated)]
type NormalExecutiveHooks = AllPalletsReversedWithSystemFirst;
type NormalExecutiveHooks = AllPalletsWithSystem;
type MaintenanceExecutiveHooks = MaintenanceHooks;
}

Expand Down
23 changes: 8 additions & 15 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,7 @@ pub struct MaintenanceHooks;

impl OnInitialize<BlockNumber> for MaintenanceHooks {
fn on_initialize(n: BlockNumber) -> Weight {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::on_initialize(n)
AllPalletsWithSystem::on_initialize(n)
}
}

Expand All @@ -1034,33 +1033,28 @@ impl OnIdle<BlockNumber> for MaintenanceHooks {

impl OnRuntimeUpgrade for MaintenanceHooks {
fn on_runtime_upgrade() -> Weight {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::on_runtime_upgrade()
AllPalletsWithSystem::on_runtime_upgrade()
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::pre_upgrade()
AllPalletsWithSystem::pre_upgrade()
}

#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::post_upgrade()
AllPalletsWithSystem::post_upgrade()
}
}

impl OnFinalize<BlockNumber> for MaintenanceHooks {
fn on_finalize(n: BlockNumber) {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::on_finalize(n)
AllPalletsWithSystem::on_finalize(n)
}
}

impl OffchainWorker<BlockNumber> for MaintenanceHooks {
fn offchain_worker(n: BlockNumber) {
#[allow(deprecated)]
AllPalletsReversedWithSystemFirst::offchain_worker(n)
AllPalletsWithSystem::offchain_worker(n)
}
}

Expand All @@ -1073,10 +1067,9 @@ impl pallet_maintenance_mode::Config for Runtime {
type XcmExecutionManager = XcmExecutionManager;
type NormalDmpHandler = DmpQueue;
type MaintenanceDmpHandler = MaintenanceDmpHandler;
// We use AllPalletsReversedWithSystemFirst because we dont want to change the hooks in normal
// We use AllPalletsWithSystem because we dont want to change the hooks in normal
// operation
#[allow(deprecated)]
type NormalExecutiveHooks = AllPalletsReversedWithSystemFirst;
type NormalExecutiveHooks = AllPalletsWithSystem;
type MaintenanceExecutiveHooks = MaintenanceHooks;
}

Expand Down

0 comments on commit 48a0e45

Please sign in to comment.