Skip to content

Commit

Permalink
Fix for the breaking change from polkadot v1.1.0 (Moonsong-Labs#10)
Browse files Browse the repository at this point in the history
* Fix for the breaking change from polkadot v1.1.0

The pre/post_upgrade methods of a tuple of migrations should not be called directly.

* Fix formatting

* Adds cleanup action

* Adds cleanup action

* Adds cleanup action

* Adds cleanup action
  • Loading branch information
Cem Eliguzel authored and fgamundi committed Nov 10, 2023
1 parent 5990e88 commit 78d147a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,21 @@ jobs:
CARGO_INCREMENTAL: "0"
SCCACHE_CACHE_SIZE: "100GB"
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.3.0
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: true
swap-storage: true
- name: Checkout
uses: actions/checkout@v3
with:
Expand Down
19 changes: 5 additions & 14 deletions pallets/maintenance-mode/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ use frame_support::{
weights::Weight,
};
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;
use sp_std::marker::PhantomData;

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> {
if Pallet::<T>::maintenance_mode() {
T::MaintenanceExecutiveHooks::pre_upgrade()
} else {
T::NormalExecutiveHooks::pre_upgrade()
}
}

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

0 comments on commit 78d147a

Please sign in to comment.