Skip to content

Commit

Permalink
migrations prelude and remove of try runtime one
Browse files Browse the repository at this point in the history
  • Loading branch information
PolkadotDom committed Jan 11, 2025
1 parent 738282a commit 17bf92a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
6 changes: 3 additions & 3 deletions substrate/frame/multisig/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// Migrations for Multisig Pallet

use crate::*;
use frame::prelude::*;
use frame::migrations_prelude::*;

pub mod v1 {
use super::*;
Expand All @@ -36,7 +36,7 @@ pub mod v1 {
pub struct MigrateToV1<T>(core::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, frame::try_runtime::TryRuntimeError> {
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
log!(info, "Number of calls to refund and delete: {}", Calls::<T>::iter().count());

Ok(Vec::new())
Expand Down Expand Up @@ -69,7 +69,7 @@ pub mod v1 {
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), frame::try_runtime::TryRuntimeError> {
fn post_upgrade(_state: Vec<u8>) -> Result<(), TryRuntimeError> {
ensure!(
Calls::<T>::iter().count() == 0,
"there are some dangling calls that need to be destroyed and refunded"
Expand Down
26 changes: 23 additions & 3 deletions substrate/frame/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
//!
//! This crate is organized into 3 stages:
//!
//! 1. preludes: `prelude`, `testing_prelude` and `runtime::prelude`, `benchmarking`,
//! `weights_prelude`, `try_runtime`.
//! 1. preludes: `prelude`, `testing_prelude`, `runtime::prelude`, `benchmarking`,
//! `weights_prelude`, `migrations_prelude`, and `try_runtime`.
//! 2. domain-specific modules: `traits`, `hashing`, `arithmetic` and `derive`.
//! 3. Accessing frame/substrate dependencies directly: `deps`.
//!
Expand Down Expand Up @@ -152,6 +152,8 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg(feature = "experimental")]

extern crate alloc;

#[doc(no_inline)]
pub use frame_support::pallet;

Expand Down Expand Up @@ -207,7 +209,7 @@ pub mod prelude {
defensive, defensive_assert,
traits::{
Contains, EitherOf, EstimateNextSessionRotation, IsSubType, MapSuccess, NoOpPoll,
OnRuntimeUpgrade, OneSessionHandler, RankedMembers, RankedMembersSwapHandler,
OneSessionHandler, RankedMembers, RankedMembersSwapHandler,
},
};

Expand Down Expand Up @@ -334,6 +336,24 @@ pub mod testing_prelude {

/// Commonly used runtime traits for testing.
pub use sp_runtime::{traits::BadOrigin, StateVersion};

#[cfg(any(feature = "try-runtime", test))]
pub use sp_runtime::TryRuntimeError;
}

/// Prelude to be included in the `migration.rs` of each pallet.
///
/// ```
/// pub use polkadot_sdk_frame::migrations_prelude::*;
/// ```
pub mod migrations_prelude {
pub use super::traits::UncheckedOnRuntimeUpgrade;
pub use frame_support::{migrations::*, storage_alias, traits::OnRuntimeUpgrade};

#[cfg(feature = "try-runtime")]
pub use alloc::vec::Vec;
#[cfg(feature = "try-runtime")]
pub use sp_runtime::TryRuntimeError;
}

/// All of the types and tools needed to build FRAME-based runtimes.
Expand Down

0 comments on commit 17bf92a

Please sign in to comment.