diff --git a/runtime/altair/src/migrations.rs b/runtime/altair/src/migrations.rs index be9703e6e3..72fc136cac 100644 --- a/runtime/altair/src/migrations.rs +++ b/runtime/altair/src/migrations.rs @@ -9,19 +9,7 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use cfg_primitives::Balance; -use cfg_types::{ - tokens::{CrossChainTransferability, CurrencyId}, - xcm::XcmMetadata, -}; -use codec::{Decode, Encode}; -#[cfg(feature = "try-runtime")] -use frame_support::ensure; use frame_support::{traits::OnRuntimeUpgrade, weights::Weight}; -use sp_std::{vec, vec::Vec}; -use xcm::{v3::prelude::*, VersionedMultiLocation}; - -use crate::{RocksDbWeight, Runtime}; /// The migration set for Altair 1031 @ Kusama. It includes all the migrations /// that have to be applied on that chain, which includes migrations that have @@ -31,13 +19,13 @@ pub type UpgradeAltair1031 = ( // FIXME: This migration fails to decode 4 entries against Altair // orml_tokens_migration::CurrencyIdRefactorMigration, // At minimum, bumps storage version from 1 to 2 - runtime_common::migrations::nuke::Migration, + runtime_common::migrations::nuke::Migration, // At minimum, bumps storage version from 0 to 3 - runtime_common::migrations::nuke::Migration, + runtime_common::migrations::nuke::Migration, // At minimum, bumps storage version from 0 to 1 - runtime_common::migrations::nuke::Migration, + runtime_common::migrations::nuke::Migration, // At minimum, bumps storage version from 0 to 1 - runtime_common::migrations::nuke::Migration, + runtime_common::migrations::nuke::Migration, // Funds pallet_rewards::Instance2 account with existential deposit pallet_rewards::migrations::new_instance::FundExistentialDeposit< crate::Runtime, @@ -71,9 +59,9 @@ pub type UpgradeAltair1031 = ( #[cfg(feature = "testnet-runtime")] pub type UpgradeAltair1031 = ( // At minimum, bumps storage version from 0 to 1 - runtime_common::migrations::nuke::Migration, + runtime_common::migrations::nuke::Migration, // At minimum, bump storage version from 0 to 1 - runtime_common::migrations::nuke::Migration, + runtime_common::migrations::nuke::Migration, runtime_common::migrations::asset_registry_xcmv3::Migration< crate::Runtime, asset_registry::metadata_xcmv3::AltairAssets, @@ -88,13 +76,14 @@ pub type UpgradeAltair1031 = ( xcm_v2_to_v3::SetSafeXcmVersion, ); -const DEPRECATED_AUSD_CURRENCY_ID: CurrencyId = CurrencyId::AUSD; -const NEW_AUSD_CURRENCY_ID: CurrencyId = CurrencyId::ForeignAsset(2); - mod asset_registry { - use cfg_types::tokens::CustomMetadata; - - use super::*; + use cfg_primitives::Balance; + use cfg_types::{ + tokens::{CrossChainTransferability, CurrencyId, CustomMetadata}, + xcm::XcmMetadata, + }; + use sp_std::{vec, vec::Vec}; + use xcm::{v3::prelude::*, VersionedMultiLocation}; pub const ALTAIR_ASSET_LOC_COUNT: u32 = 5; pub const ALTAIR_ASSET_METADATA_COUNT: u32 = 5; @@ -477,10 +466,19 @@ mod asset_registry { } mod orml_tokens_migration { - use cfg_primitives::AccountId; + use cfg_primitives::{AccountId, Balance}; + use cfg_types::tokens::CurrencyId; + use codec::{Decode, Encode}; + #[cfg(feature = "try-runtime")] + use frame_support::ensure; use orml_tokens::AccountData; + use sp_std::vec::Vec; use super::*; + use crate::Runtime; + + const DEPRECATED_AUSD_CURRENCY_ID: CurrencyId = CurrencyId::AUSD; + const NEW_AUSD_CURRENCY_ID: CurrencyId = CurrencyId::ForeignAsset(2); /// As we dropped `CurrencyId::KSM` and `CurrencyId::AUSD`, we need to /// migrate the balances under the dropped variants in favour of the new, @@ -609,7 +607,7 @@ mod xcm_v2_to_v3 { ) .unwrap_or_else(|_| log::error!("Failed to set safe XCM version on runtime upgrade, requires manual call via governance")); - RocksDbWeight::get().writes(1) + crate::RocksDbWeight::get().writes(1) } } } diff --git a/runtime/centrifuge/src/migrations.rs b/runtime/centrifuge/src/migrations.rs index 3147441c61..3a73e44f71 100644 --- a/runtime/centrifuge/src/migrations.rs +++ b/runtime/centrifuge/src/migrations.rs @@ -9,22 +9,7 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use cfg_primitives::Balance; -use cfg_types::{ - tokens::{ - lp_eth_usdc_metadata, CrossChainTransferability, CurrencyId, ETHEREUM_MAINNET_CHAIN_ID, - ETHEREUM_USDC, LP_ETH_USDC_CURRENCY_ID, - }, - xcm::XcmMetadata, -}; -use frame_support::{ - traits::{Len, OnRuntimeUpgrade}, - weights::Weight, -}; -use sp_std::vec; -use xcm::{v3::prelude::*, VersionedMultiLocation}; - -use crate::{LiquidityPoolsPalletIndex, RocksDbWeight, Runtime}; +use frame_support::{traits::OnRuntimeUpgrade, weights::Weight}; pub type UpgradeCentrifuge1020 = ( // Removes metadata containing xcm_v1 locations of registered assets and sets to hardcoded ones @@ -38,13 +23,13 @@ pub type UpgradeCentrifuge1020 = ( 3, >, // At minimum, bumps storage version from 1 to 2 - runtime_common::migrations::nuke::Migration, + runtime_common::migrations::nuke::Migration, // At minimum, bumps storage version from 0 to 3 - runtime_common::migrations::nuke::Migration, + runtime_common::migrations::nuke::Migration, // At minimum, bumps storage version from 0 to 1 - runtime_common::migrations::nuke::Migration, + runtime_common::migrations::nuke::Migration, // At minimum, bumps storage version from 0 to 1 - runtime_common::migrations::nuke::Migration, + runtime_common::migrations::nuke::Migration, // Funds pallet_rewards::Instance2 account with existential deposit pallet_rewards::migrations::new_instance::FundExistentialDeposit< crate::Runtime, @@ -63,10 +48,17 @@ pub type UpgradeCentrifuge1020 = ( ); mod asset_registry { - use cfg_types::tokens::CustomMetadata; - use frame_support::inherent::Vec; + use cfg_primitives::Balance; + use cfg_types::{ + tokens::{ + lp_eth_usdc_metadata, CrossChainTransferability, CurrencyId, CustomMetadata, + ETHEREUM_MAINNET_CHAIN_ID, ETHEREUM_USDC, LP_ETH_USDC_CURRENCY_ID, + }, + xcm::XcmMetadata, + }; + use sp_std::{vec, vec::Vec}; + use xcm::{v3::prelude::*, VersionedMultiLocation}; - use super::*; use crate::ParachainInfo; pub const CENTRIFUGE_ASSET_LOC_COUNT: u32 = 6; @@ -93,10 +85,7 @@ mod asset_registry { (loc, meta) if (loc, meta) == (CATALYST_ASSET_LOC_COUNT, CATALYST_ASSET_METADATA_COUNT) => { - Self::get_centrifuge_assets() - .into_iter() - .chain(Self::get_catalyst_assets().into_iter()) - .collect() + Self::get_catalyst_assets() } _ => vec![], } @@ -272,7 +261,7 @@ mod asset_registry { ( LP_ETH_USDC_CURRENCY_ID, lp_eth_usdc_metadata( - LiquidityPoolsPalletIndex::get(), + crate::LiquidityPoolsPalletIndex::get(), ETHEREUM_MAINNET_CHAIN_ID, ETHEREUM_USDC, ), @@ -301,6 +290,33 @@ mod asset_registry { tranche_id[..tranche_id_bytes.len()].copy_from_slice(tranche_id_bytes); vec![ + ( + CurrencyId::Native, + orml_asset_registry::AssetMetadata { + decimals: 18, + name: b"Centrifuge".to_vec(), + symbol: b"CFG".to_vec(), + existential_deposit: 1_000_000_000_000u128, + location: Some(VersionedMultiLocation::V3(MultiLocation::new( + 1, + Junctions::X2( + Parachain(ParachainInfo::parachain_id().into()), + GeneralKey { + length: 2, + data: gk, + }, + ), + ))), + additional: CustomMetadata { + mintable: false, + permissioned: false, + pool_currency: false, + transferability: CrossChainTransferability::Xcm(XcmMetadata { + fee_per_second: None, + }), + }, + }, + ), ( CurrencyId::ForeignAsset(41), orml_asset_registry::AssetMetadata { @@ -388,7 +404,7 @@ mod xcm_v2_to_v3 { ) .unwrap_or_else(|_| log::error!("Failed to set safe XCM version on runtime upgrade, requires manual call via governance")); - RocksDbWeight::get().writes(1) + crate::RocksDbWeight::get().writes(1) } } } diff --git a/runtime/common/src/migrations/asset_registry_xcmv3.rs b/runtime/common/src/migrations/asset_registry_xcmv3.rs index 4ddfb46a26..5b10f12dad 100644 --- a/runtime/common/src/migrations/asset_registry_xcmv3.rs +++ b/runtime/common/src/migrations/asset_registry_xcmv3.rs @@ -21,6 +21,7 @@ use frame_support::{ StoragePrefixedMap, }; use orml_traits::asset_registry::AssetMetadata; +#[cfg(feature = "try-runtime")] use sp_arithmetic::traits::Zero; use sp_std::vec::Vec; @@ -188,10 +189,10 @@ impl< // let meta_count = orml_asset_registry::Metadata::::iter_keys().count() as // u32; let loc_count = Self::count_storage_keys( - &orml_asset_registry::LocationToAssetId::::final_prefix().to_vec(), + orml_asset_registry::LocationToAssetId::::final_prefix().as_ref(), ); let meta_count = - Self::count_storage_keys(&orml_asset_registry::Metadata::::final_prefix().to_vec()); + Self::count_storage_keys(orml_asset_registry::Metadata::::final_prefix().as_ref()); log::info!( "💎 AssetRegistryMultilocationToXCMV3: Found {} LocationToAssetId keys ",