-
Notifications
You must be signed in to change notification settings - Fork 804
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
Migrate pallet-migrations to use umbrella crate #7209
base: master
Are you sure you want to change the base?
Changes from 4 commits
5bae259
3ae8c49
c5aff5f
a7a17d6
1573d3d
5e64154
c3b35f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,19 +158,9 @@ pub use weights::WeightInfo; | |
use alloc::vec::Vec; | ||
use codec::{Decode, Encode, MaxEncodedLen}; | ||
use core::ops::ControlFlow; | ||
use frame_support::{ | ||
defensive, defensive_assert, | ||
migrations::*, | ||
pallet_prelude::*, | ||
traits::Get, | ||
weights::{Weight, WeightMeter}, | ||
BoundedVec, | ||
}; | ||
use frame_system::{ | ||
pallet_prelude::{BlockNumberFor, *}, | ||
Pallet as System, | ||
}; | ||
use sp_runtime::Saturating; | ||
use frame::prelude::*; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove this, |
||
use frame::testing_prelude::*; | ||
|
||
|
||
/// Points to the next migration to execute. | ||
#[derive(Debug, Clone, Eq, PartialEq, Encode, Decode, scale_info::TypeInfo, MaxEncodedLen)] | ||
|
@@ -290,11 +280,11 @@ struct PreUpgradeBytesWrapper(pub Vec<u8>); | |
/// | ||
/// Define this outside of the pallet so it is not confused with actual storage. | ||
#[cfg(feature = "try-runtime")] | ||
#[frame_support::storage_alias] | ||
#[frame::storage_alias] | ||
type PreUpgradeBytes<T: Config> = | ||
StorageMap<Pallet<T>, Twox64Concat, IdentifierOf<T>, PreUpgradeBytesWrapper, ValueQuery>; | ||
|
||
#[frame_support::pallet] | ||
#[frame::pallet] | ||
pub mod pallet { | ||
use super::*; | ||
|
||
|
@@ -354,12 +344,8 @@ pub mod pallet { | |
/// Default implementations of [`DefaultConfig`], which can be used to implement [`Config`]. | ||
pub mod config_preludes { | ||
use super::{inject_runtime_type, DefaultConfig}; | ||
use frame_support::{ | ||
derive_impl, | ||
migrations::FreezeChainOnFailedMigration, | ||
pallet_prelude::{ConstU32, *}, | ||
}; | ||
use frame_system::limits::BlockWeights; | ||
|
||
// use frame_system::limits::BlockWeights; | ||
|
||
/// Provides a viable default config that can be used with | ||
/// [`derive_impl`](`frame_support::derive_impl`) to derive a testing pallet config | ||
|
@@ -369,15 +355,15 @@ pub mod pallet { | |
/// a downstream user of this particular `TestDefaultConfig` | ||
pub struct TestDefaultConfig; | ||
|
||
frame_support::parameter_types! { | ||
parameter_types! { | ||
/// Maximal weight per block that can be spent on migrations in tests. | ||
pub TestMaxServiceWeight: Weight = <<TestDefaultConfig as frame_system::DefaultConfig>::BlockWeights as Get<BlockWeights>>::get().max_block.div(2); | ||
} | ||
|
||
#[derive_impl(frame_system::config_preludes::TestDefaultConfig, no_aggregated_types)] | ||
impl frame_system::DefaultConfig for TestDefaultConfig {} | ||
|
||
#[frame_support::register_default_impl(TestDefaultConfig)] | ||
#[register_default_impl(TestDefaultConfig)] | ||
impl DefaultConfig for TestDefaultConfig { | ||
#[inject_runtime_type] | ||
type RuntimeEvent = (); | ||
|
@@ -474,7 +460,7 @@ pub mod pallet { | |
#[cfg(feature = "std")] | ||
fn integrity_test() { | ||
// Check that the migrations tuple is legit. | ||
frame_support::assert_ok!(T::Migrations::integrity_test()); | ||
assert_ok!(T::Migrations::integrity_test()); | ||
|
||
// Very important! Ensure that the pallet is configured in `System::Config`. | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,9 @@ | |
|
||
use alloc::{vec, vec::Vec}; | ||
use codec::{Decode, Encode}; | ||
use frame_support::{ | ||
migrations::*, | ||
weights::{Weight, WeightMeter}, | ||
}; | ||
use sp_core::ConstU32; | ||
use sp_runtime::BoundedVec; | ||
use frame::testing_prelude::*; | ||
use frame::deps::sp_core::ConstU32; | ||
use frame::deps::sp_runtime::BoundedVec; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They're still there |
||
|
||
/// Opaque identifier of a migration. | ||
pub type MockedIdentifier = BoundedVec<u8, ConstU32<256>>; | ||
|
@@ -57,7 +54,7 @@ pub fn mocked_id(kind: MockedMigrationKind, steps: u32) -> MockedIdentifier { | |
(b"MockedMigration", kind, steps).encode().try_into().unwrap() | ||
} | ||
|
||
frame_support::parameter_types! { | ||
parameter_types! { | ||
/// The configs for the migrations to run. | ||
storage MIGRATIONS: Vec<(MockedMigrationKind, u32)> = vec![]; | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.