-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat: remove old storage migrations #643
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,23 @@ | ||
use super::*; | ||
|
||
use frame_support::{ | ||
log, migration::storage_key_iter, pallet_prelude::*, traits::OnRuntimeUpgrade, weights::Weight, StoragePrefixedMap, | ||
}; | ||
use pallet_asset_registry::{AssetLocations, LocationAssets}; | ||
use polkadot_xcm::v3::MultiLocation; | ||
use frame_support::{traits::OnRuntimeUpgrade, weights::Weight}; | ||
|
||
pub struct OnRuntimeUpgradeMigration; | ||
impl OnRuntimeUpgrade for OnRuntimeUpgradeMigration { | ||
#[cfg(feature = "try-runtime")] | ||
fn pre_upgrade() -> Result<Vec<u8>, &'static str> { | ||
frame_support::log::info!("PreMigrate Duster Pallet start"); | ||
pallet_duster::migration::v1::pre_migrate::<Runtime, Duster>(); | ||
frame_support::log::info!("PreMigrate Duster Pallet end"); | ||
// TODO: include migrations for transaction pause and collator rewards pallets in the next release | ||
// (not in the 106 release, because we don't use the latest pallet versions there). | ||
|
||
Ok(vec![]) | ||
} | ||
|
||
fn on_runtime_upgrade() -> Weight { | ||
let mut weight: Weight = Weight::zero(); | ||
|
||
frame_support::log::info!("Migrate Scheduler Pallet to v4 start"); | ||
weight = weight.saturating_add(Scheduler::migrate_v1_to_v4()); | ||
frame_support::log::info!("Migrate Scheduler Pallet to v4 end"); | ||
|
||
frame_support::log::info!("Migrate Duster Pallet to v1 start"); | ||
weight = weight.saturating_add(pallet_duster::migration::v1::migrate::<Runtime, Duster>( | ||
get_all_module_accounts(), | ||
TreasuryAccount::get(), | ||
TreasuryAccount::get(), | ||
)); | ||
frame_support::log::info!("Migrate Duster Pallet to v1 end"); | ||
|
||
weight | ||
} | ||
|
||
#[cfg(feature = "try-runtime")] | ||
fn post_upgrade(_state: Vec<u8>) -> Result<(), &'static str> { | ||
frame_support::log::info!("PostMigrate Duster Pallet start"); | ||
pallet_duster::migration::v1::post_migrate::<Runtime, Duster>(); | ||
frame_support::log::info!("PostMigrate Duster Pallet end"); | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)] | ||
pub struct AssetLocationV2(pub polkadot_xcm::v2::MultiLocation); | ||
|
||
pub struct MigrateRegistryLocationToV3<T>(PhantomData<T>); | ||
impl<T: pallet_asset_registry::Config> OnRuntimeUpgrade for MigrateRegistryLocationToV3<T> | ||
where | ||
AssetLocation: Into<T::AssetNativeLocation>, | ||
{ | ||
fn on_runtime_upgrade() -> Weight { | ||
log::info!( | ||
target: "runtime::asset-registry", | ||
"MigrateRegistryLocationToV3::on_runtime_upgrade: migrating asset locations to v3" | ||
); | ||
|
||
let mut weight: Weight = Weight::zero(); | ||
|
||
AssetLocations::<T>::translate(|_asset_id, old_location: AssetLocationV2| { | ||
weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); | ||
let new_multi_loc: MultiLocation = old_location.0.try_into().expect("xcm::v1::MultiLocation"); | ||
let new_location: T::AssetNativeLocation = AssetLocation(new_multi_loc).into(); | ||
Some(new_location) | ||
}); | ||
|
||
let module_prefix = LocationAssets::<T>::module_prefix(); | ||
let storage_prefix = LocationAssets::<T>::storage_prefix(); | ||
let old_data = storage_key_iter::<AssetLocationV2, T::AssetId, Blake2_128Concat>(module_prefix, storage_prefix) | ||
.drain() | ||
.collect::<Vec<_>>(); | ||
for (old_location, asset_id) in old_data { | ||
weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); | ||
let new_multi_loc: MultiLocation = old_location.0.try_into().expect("xcm::v1::MultiLocation"); | ||
let new_location: T::AssetNativeLocation = AssetLocation(new_multi_loc).into(); | ||
LocationAssets::<T>::insert(new_location, asset_id); | ||
} | ||
weight | ||
} | ||
} | ||
|
||
pub struct XcmRateLimitMigration; | ||
impl OnRuntimeUpgrade for XcmRateLimitMigration { | ||
#[cfg(feature = "try-runtime")] | ||
fn pre_upgrade() -> Result<Vec<u8>, &'static str> { | ||
frame_support::log::info!("PreMigrate Asset Registry Pallet start"); | ||
pallet_asset_registry::migration::v1::pre_migrate::<Runtime>(); | ||
frame_support::log::info!("PreMigrate Asset Registry Pallet end"); | ||
|
||
Ok(vec![]) | ||
} | ||
|
||
fn on_runtime_upgrade() -> Weight { | ||
log::info!( | ||
target: "runtime::asset-registry", | ||
"XcmRateLimitMigration::on_runtime_upgrade: migrating asset details to include xcm rate limit" | ||
); | ||
|
||
pallet_asset_registry::migration::v1::migrate::<Runtime>() | ||
Weight::zero() | ||
} | ||
|
||
#[cfg(feature = "try-runtime")] | ||
fn post_upgrade(_state: Vec<u8>) -> Result<(), &'static str> { | ||
frame_support::log::info!("PostMigrate Asset Registry Pallet start"); | ||
pallet_asset_registry::migration::v1::post_migrate::<Runtime>(); | ||
frame_support::log::info!("PostMigrate Asset Registry Pallet end"); | ||
Ok(()) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@Roznovjak shouldn't it be included in this PR then?
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.
The pallet versions/revisions used in the master have not yet been updated to the latest version that contain the migrations. Updating dependencies probably deserves own PR.