Skip to content

Commit

Permalink
Fix for the breaking change from polkadot v1.1.0
Browse files Browse the repository at this point in the history
The pre/post_upgrade methods of a tuple of migrations should not be called directly.
  • Loading branch information
Cem Eliguzel committed Oct 13, 2023
1 parent b00476a commit 9007ac1
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions pallets/maintenance-mode/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use frame_support::{
use frame_system::pallet_prelude::BlockNumberFor as BlockNumberOf;
use sp_std::marker::PhantomData;
#[cfg(feature = "try-runtime")]
use sp_std::vec::Vec;
use sp_runtime::TryRuntimeError;

pub struct ExecutiveHooks<T>(PhantomData<T>);

Expand Down Expand Up @@ -94,20 +94,11 @@ where
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::DispatchError> {
fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, TryRuntimeError> {
if Pallet::<T>::maintenance_mode() {
T::MaintenanceExecutiveHooks::pre_upgrade()
T::MaintenanceExecutiveHooks::try_on_runtime_upgrade(checks)
} else {
T::NormalExecutiveHooks::pre_upgrade()
}
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
if Pallet::<T>::maintenance_mode() {
T::MaintenanceExecutiveHooks::post_upgrade(state)
} else {
T::NormalExecutiveHooks::post_upgrade(state)
T::NormalExecutiveHooks::try_on_runtime_upgrade(checks)
}
}
}
Expand Down

0 comments on commit 9007ac1

Please sign in to comment.