diff --git a/pallets/asset-manager/src/benchmarks.rs b/pallets/asset-manager/src/benchmarks.rs index c3ca585faf..a444a0ae1b 100644 --- a/pallets/asset-manager/src/benchmarks.rs +++ b/pallets/asset-manager/src/benchmarks.rs @@ -16,33 +16,11 @@ #![cfg(feature = "runtime-benchmarks")] -use crate::{pallet::LocalAssetIdCreator, Call, Config, DepositBalanceOf, Pallet}; -use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite}; -use frame_support::traits::{Currency, Get}; +use crate::{Call, Config, Pallet}; +use frame_benchmarking::{benchmarks, impl_benchmark_test_suite}; use frame_system::RawOrigin; use xcm::v3::prelude::*; -///RLocal asset deposit amount -fn min_candidate_stk() -> DepositBalanceOf { - <::LocalAssetDeposit as Get>>::get() -} - -/// Create a funded user. -/// Used for generating the necessary amount for local assets -fn create_funded_user( - string: &'static str, - n: u32, - extra: DepositBalanceOf, -) -> (T::AccountId, DepositBalanceOf) { - const SEED: u32 = 0; - let user = account(string, n, SEED); - let min_reserve_amount = min_candidate_stk::(); - let total = min_reserve_amount + extra; - T::Currency::make_free_balance_be(&user, total); - T::Currency::issue(total); - (user, total) -} - benchmarks! { // This where clause allows us to create ForeignAssetTypes where_clause { where T::ForeignAssetType: From } @@ -154,26 +132,6 @@ benchmarks! { assert_eq!(Pallet::::asset_type_units_per_second(asset_type_to_be_removed), None); } - register_local_asset { - const USER_SEED: u32 = 1; - let (caller, deposit_amount) = create_funded_user::("caller", USER_SEED, 0u32.into()); - let asset_id = T::LocalAssetIdCreator::create_asset_id_from_metadata(0); - let owner: T::AccountId = account("account id", 1u32, 0u32); - let current_local_counter: u128 =Pallet::::local_asset_counter(); - let min_balance: T::Balance = 1u32.into(); - - }: _( - RawOrigin::Root, - caller.clone(), - owner.clone(), - true, - min_balance.clone() - ) - verify { - assert_eq!(Pallet::::local_asset_counter(), current_local_counter+1); - assert!(Pallet::::local_asset_deposit(asset_id).is_some()); - - } remove_existing_asset_type { // We make it dependent on the number of existing assets already // Worst case is we need to remove it from SupportedAAssetsFeePayment too diff --git a/pallets/asset-manager/src/lib.rs b/pallets/asset-manager/src/lib.rs index da324a5afa..f72b6ac543 100644 --- a/pallets/asset-manager/src/lib.rs +++ b/pallets/asset-manager/src/lib.rs @@ -18,16 +18,12 @@ //! //! This pallet allows to register new assets if certain conditions are met //! The main goal of this pallet is to allow moonbeam to register XCM assets -//! and control the creation of local assets //! The assumption is we work with AssetTypes, which can then be compared to AssetIds //! //! This pallet has five storage items: AssetIdType, which holds a mapping from AssetId->AssetType //! AssetTypeUnitsPerSecond: an AssetType->u128 mapping that holds how much each AssetType should //! be charged per unit of second, in the case such an Asset is received as a XCM asset. Finally, -//! AssetTypeId holds a mapping from AssetType -> AssetId. LocalAssetCounter -//! which holds the counter of local assets that have been created so far. And LocalAssetDeposit, -//! which holds a mapping between assetId and assetInfo, i.e., the asset creator (from which -//! we take the deposit) and the deposit amount itself. +//! AssetTypeId holds a mapping from AssetType -> AssetId. //! //! This pallet has eight extrinsics: register_foreign_asset, which registers a foreign //! asset in this pallet and creates the asset as dictated by the AssetRegistrar trait. @@ -37,9 +33,7 @@ //! AssetType //! remove_supported_asset: which removes an asset from the supported assets for fee payment //! remove_existing_asset_type: which removes a mapping from a foreign asset to an assetId -//! register_local_asset: which creates a local asset with a specific owner //! destroy_foreign_asset: which destroys a foreign asset and all its associated data -//! destroy_local_asset: which destroys a local asset and all its associated data #![cfg_attr(not(feature = "std"), no_std)] @@ -59,11 +53,7 @@ pub use crate::weights::WeightInfo; #[pallet] pub mod pallet { use super::*; - use frame_support::{ - pallet_prelude::*, - traits::{Currency, ReservableCurrency}, - PalletId, - }; + use frame_support::{pallet_prelude::*, PalletId}; use frame_system::pallet_prelude::*; use parity_scale_codec::HasCompact; use sp_runtime::traits::{AccountIdConversion, AtLeast32BitUnsigned}; @@ -76,16 +66,6 @@ pub mod pallet { /// The AssetManagers's pallet id pub const PALLET_ID: PalletId = PalletId(*b"asstmngr"); - pub(crate) type DepositBalanceOf = - <::Currency as Currency<::AccountId>>::Balance; - - #[derive(Default, Clone, Encode, Decode, RuntimeDebug, PartialEq, scale_info::TypeInfo)] - #[scale_info(skip_type_params(T))] - pub struct AssetInfo { - pub creator: T::AccountId, - pub deposit: DepositBalanceOf, - } - // The registrar trait. We need to comply with this pub trait AssetRegistrar { // How to create a foreign asset, meaning an asset whose reserve chain @@ -100,39 +80,15 @@ pub mod pallet { unimplemented!() } - // Create a local asset, meaning an asset whose reserve chain is our chain - // These are created as non-sufficent by default - fn create_local_asset( - _asset: T::AssetId, - _account: T::AccountId, - _min_balance: T::Balance, - _is_sufficient: bool, - _owner: T::AccountId, - ) -> DispatchResult { - unimplemented!() - } - // How to destroy a foreign asset fn destroy_foreign_asset(_asset: T::AssetId) -> DispatchResult { unimplemented!() } - // How to destroy a local asset - fn destroy_local_asset(_asset: T::AssetId) -> DispatchResult { - unimplemented!() - } - // Get destroy asset weight dispatch info fn destroy_asset_dispatch_info_weight(_asset: T::AssetId) -> Weight; } - // The local asset id creator. We cannot let users choose assetIds for their assets - // because they can look for collisions in the EVM. - pub trait LocalAssetIdCreator { - // How to create an assetId from the local asset counter - fn create_asset_id_from_metadata(local_asset_counter: u128) -> T::AssetId; - } - // We implement this trait to be able to get the AssetType and units per second registered impl xcm_primitives::AssetTypeGetter for Pallet { fn get_asset_type(asset_id: T::AssetId) -> Option { @@ -195,19 +151,6 @@ pub mod pallet { /// Origin that is allowed to create and modify asset information for foreign assets type ForeignAssetModifierOrigin: EnsureOrigin; - /// Origin that is allowed to create and modify asset information for local assets - type LocalAssetModifierOrigin: EnsureOrigin; - - /// Ways of creating local asset Ids - type LocalAssetIdCreator: LocalAssetIdCreator; - - /// The currency mechanism in which we reserve deposits for local assets. - type Currency: ReservableCurrency; - - /// The basic amount of funds that must be reserved for a local asset. - #[pallet::constant] - type LocalAssetDeposit: Get>; - type WeightInfo: WeightInfo; } @@ -250,12 +193,6 @@ pub mod pallet { }, /// Supported asset type for fee payment removed SupportedAssetRemoved { asset_type: T::ForeignAssetType }, - /// Local asset was created - LocalAssetRegistered { - asset_id: T::AssetId, - creator: T::AccountId, - owner: T::AccountId, - }, /// Removed all information related to an assetId and destroyed asset ForeignAssetDestroyed { asset_id: T::AssetId, @@ -290,24 +227,6 @@ pub mod pallet { pub type AssetTypeUnitsPerSecond = StorageMap<_, Blake2_128Concat, T::ForeignAssetType, u128>; - /// Stores the counter of the number of local assets that have been - /// created so far - /// This value can be used to salt the creation of an assetId, e.g., - /// by hashing it. This is particularly useful for cases like moonbeam - /// where letting users choose their assetId would result in collision - /// in the evm side. - #[pallet::storage] - #[pallet::getter(fn local_asset_counter)] - pub type LocalAssetCounter = StorageValue<_, u128, ValueQuery>; - - /// Local asset deposits, a mapping from assetId to a struct - /// holding the creator (from which the deposit was reserved) and - /// the deposit amount - #[pallet::storage] - #[pallet::getter(fn local_asset_deposit)] - pub type LocalAssetDeposit = - StorageMap<_, Blake2_128Concat, T::AssetId, AssetInfo>; - // Supported fee asset payments #[pallet::storage] #[pallet::getter(fn supported_fee_payment_assets)] @@ -529,75 +448,6 @@ pub mod pallet { Ok(()) } - /// Register a new local asset - /// No information is stored in this pallet about the local asset - /// The reason is that we dont need to hold a mapping between the multilocation - /// and the local asset, as this conversion is deterministic - /// Further, we dont allow xcm fee payment in local assets - #[pallet::call_index(5)] - #[pallet::weight(T::WeightInfo::register_local_asset())] - pub fn register_local_asset( - origin: OriginFor, - creator: T::AccountId, - owner: T::AccountId, - is_sufficient: bool, - min_balance: T::Balance, - ) -> DispatchResult { - T::LocalAssetModifierOrigin::ensure_origin(origin)?; - - // Get the deposit amount - let deposit = T::LocalAssetDeposit::get(); - - // Verify we can reserve - T::Currency::can_reserve(&creator, deposit) - .then(|| true) - .ok_or(Error::::NotSufficientDeposit)?; - - // Read Local Asset Counter - let mut local_asset_counter = LocalAssetCounter::::get(); - - // Create the assetId with LocalAssetIdCreator - let asset_id = - T::LocalAssetIdCreator::create_asset_id_from_metadata(local_asset_counter); - - // Increment the counter - local_asset_counter = local_asset_counter - .checked_add(1) - .ok_or(Error::::LocalAssetLimitReached)?; - - // Create local asset - T::AssetRegistrar::create_local_asset( - asset_id, - creator.clone(), - min_balance, - is_sufficient, - owner.clone(), - ) - .map_err(|_| Error::::ErrorCreatingAsset)?; - - // Reserve the deposit, we verified we can do this - T::Currency::reserve(&creator, deposit)?; - - // Update assetInfo - LocalAssetDeposit::::insert( - asset_id, - AssetInfo { - creator: creator.clone(), - deposit, - }, - ); - - // Update local asset counter - LocalAssetCounter::::put(local_asset_counter); - - Self::deposit_event(Event::LocalAssetRegistered { - asset_id, - creator, - owner, - }); - Ok(()) - } - /// Destroy a given foreign assetId /// The weight in this case is the one returned by the trait /// plus the db writes and reads from removing all the associated @@ -651,38 +501,6 @@ pub mod pallet { }); Ok(()) } - - /// Destroy a given local assetId - /// We do not store anything related to local assets in this pallet other than the counter - /// and the counter is not used for destroying the asset, so no additional db reads/writes - /// to be counter here - #[pallet::call_index(7)] - #[pallet::weight({ - T::AssetRegistrar::destroy_asset_dispatch_info_weight( - *asset_id - ) - .saturating_add(T::DbWeight::get().reads_writes(2, 2)) - })] - pub fn destroy_local_asset(origin: OriginFor, asset_id: T::AssetId) -> DispatchResult { - T::LocalAssetModifierOrigin::ensure_origin(origin)?; - - // Get asset creator and deposit amount - let asset_info = - LocalAssetDeposit::::get(asset_id).ok_or(Error::::NonExistentLocalAsset)?; - - // Destroy local asset - T::AssetRegistrar::destroy_local_asset(asset_id) - .map_err(|_| Error::::ErrorDestroyingAsset)?; - - // Unreserve deposit - T::Currency::unreserve(&asset_info.creator, asset_info.deposit); - - // Remove asset info - LocalAssetDeposit::::remove(asset_id); - - Self::deposit_event(Event::LocalAssetDestroyed { asset_id }); - Ok(()) - } } impl Pallet { diff --git a/pallets/asset-manager/src/mock.rs b/pallets/asset-manager/src/mock.rs index c324c480ad..7cc246463c 100644 --- a/pallets/asset-manager/src/mock.rs +++ b/pallets/asset-manager/src/mock.rs @@ -158,42 +158,15 @@ impl AssetRegistrar for MockAssetPalletRegistrar { Ok(()) } - fn create_local_asset( - _asset: u128, - _account: u64, - _min_balance: u64, - _is_sufficient: bool, - _owner: u64, - ) -> sp_runtime::DispatchResult { - Ok(()) - } - fn destroy_foreign_asset(_asset: u128) -> Result<(), DispatchError> { Ok(()) } - fn destroy_local_asset(_asset: u128) -> Result<(), DispatchError> { - Ok(()) - } - fn destroy_asset_dispatch_info_weight(_asset: u128) -> Weight { Weight::from_parts(0, 0) } } -pub struct MockLocalAssetIdCreator; -impl pallet_asset_manager::LocalAssetIdCreator for MockLocalAssetIdCreator { - fn create_asset_id_from_metadata(local_asset_counter: u128) -> AssetId { - // Our means of converting a creator to an assetId - // We basically hash nonce+account - local_asset_counter - } -} - -parameter_types! { - pub const LocalAssetDeposit: u64 = 1; -} - impl Config for Test { type RuntimeEvent = RuntimeEvent; type Balance = u64; @@ -202,10 +175,6 @@ impl Config for Test { type ForeignAssetType = MockAssetType; type AssetRegistrar = MockAssetPalletRegistrar; type ForeignAssetModifierOrigin = EnsureRoot; - type LocalAssetModifierOrigin = EnsureRoot; - type LocalAssetIdCreator = MockLocalAssetIdCreator; - type Currency = Balances; - type LocalAssetDeposit = LocalAssetDeposit; type WeightInfo = (); } @@ -221,10 +190,6 @@ impl Default for ExtBuilder { } impl ExtBuilder { - pub(crate) fn with_balances(mut self, balances: Vec<(AccountId, Balance)>) -> Self { - self.balances = balances; - self - } pub(crate) fn build(self) -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default() .build_storage() diff --git a/pallets/asset-manager/src/tests.rs b/pallets/asset-manager/src/tests.rs index 6fb10f0b72..71bffc3c16 100644 --- a/pallets/asset-manager/src/tests.rs +++ b/pallets/asset-manager/src/tests.rs @@ -47,39 +47,6 @@ fn registering_foreign_works() { }); } -#[test] -fn registering_local_works() { - ExtBuilder::default() - .with_balances(vec![(1, 20)]) - .build() - .execute_with(|| { - let asset_id = MockLocalAssetIdCreator::create_asset_id_from_metadata(0); - - assert_ok!(AssetManager::register_local_asset( - RuntimeOrigin::root(), - 1u64, - 1u64, - true, - 0u32.into(), - )); - - assert_eq!(AssetManager::local_asset_counter(), 1); - assert_eq!( - AssetManager::local_asset_deposit(asset_id), - Some(AssetInfo { - creator: 1, - deposit: 1 - }) - ); - - expect_events(vec![crate::Event::LocalAssetRegistered { - asset_id, - creator: 1, - owner: 1, - }]) - }); -} - #[test] fn test_asset_exists_error() { ExtBuilder::default().build().execute_with(|| { @@ -530,41 +497,3 @@ fn test_destroy_foreign_asset_also_removes_everything() { ]) }); } - -#[test] -fn test_destroy_local_asset_works() { - ExtBuilder::default() - .with_balances(vec![(1, 20)]) - .build() - .execute_with(|| { - let asset_id = MockLocalAssetIdCreator::create_asset_id_from_metadata(0); - - assert_ok!(AssetManager::register_local_asset( - RuntimeOrigin::root(), - 1u64, - 1u64, - true, - 0u32.into(), - )); - assert_eq!( - AssetManager::local_asset_deposit(asset_id), - Some(AssetInfo { - creator: 1, - deposit: 1 - }) - ); - - assert_ok!(AssetManager::destroy_local_asset(RuntimeOrigin::root(), 0,)); - - assert_eq!(AssetManager::local_asset_counter(), 1); - assert_eq!(AssetManager::local_asset_deposit(asset_id), None); - expect_events(vec![ - crate::Event::LocalAssetRegistered { - asset_id, - creator: 1, - owner: 1, - }, - crate::Event::LocalAssetDestroyed { asset_id }, - ]); - }); -} diff --git a/pallets/asset-manager/src/weights.rs b/pallets/asset-manager/src/weights.rs index 49bf7afdbd..6d4fb9e6f8 100644 --- a/pallets/asset-manager/src/weights.rs +++ b/pallets/asset-manager/src/weights.rs @@ -56,7 +56,6 @@ pub trait WeightInfo { fn set_asset_units_per_second(x: u32, ) -> Weight; fn change_existing_asset_type(x: u32, ) -> Weight; fn remove_supported_asset(x: u32, ) -> Weight; - fn register_local_asset() -> Weight; fn remove_existing_asset_type(x: u32, ) -> Weight; } @@ -137,25 +136,6 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 10).saturating_mul(x.into())) } - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: AssetManager LocalAssetCounter (r:1 w:1) - /// Proof Skipped: AssetManager LocalAssetCounter (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: LocalAssets Asset (r:1 w:1) - /// Proof: LocalAssets Asset (max_values: None, max_size: Some(174), added: 2649, mode: MaxEncodedLen) - /// Storage: EVM AccountCodes (r:0 w:1) - /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) - /// Storage: AssetManager LocalAssetDeposit (r:0 w:1) - /// Proof Skipped: AssetManager LocalAssetDeposit (max_values: None, max_size: None, mode: Measured) - fn register_local_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `310` - // Estimated: `9635` - // Minimum execution time: 59_851_000 picoseconds. - Weight::from_parts(60_452_000, 9635) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) - } /// Storage: AssetManager SupportedFeePaymentAssets (r:1 w:1) /// Proof Skipped: AssetManager SupportedFeePaymentAssets (max_values: Some(1), max_size: None, mode: Measured) /// Storage: AssetManager AssetIdType (r:1 w:1) @@ -255,25 +235,6 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 10).saturating_mul(x.into())) } - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: AssetManager LocalAssetCounter (r:1 w:1) - /// Proof Skipped: AssetManager LocalAssetCounter (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: LocalAssets Asset (r:1 w:1) - /// Proof: LocalAssets Asset (max_values: None, max_size: Some(174), added: 2649, mode: MaxEncodedLen) - /// Storage: EVM AccountCodes (r:0 w:1) - /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) - /// Storage: AssetManager LocalAssetDeposit (r:0 w:1) - /// Proof Skipped: AssetManager LocalAssetDeposit (max_values: None, max_size: None, mode: Measured) - fn register_local_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `310` - // Estimated: `9635` - // Minimum execution time: 59_851_000 picoseconds. - Weight::from_parts(60_452_000, 9635) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - } /// Storage: AssetManager SupportedFeePaymentAssets (r:1 w:1) /// Proof Skipped: AssetManager SupportedFeePaymentAssets (max_values: Some(1), max_size: None, mode: Measured) /// Storage: AssetManager AssetIdType (r:1 w:1) diff --git a/runtime/common/src/weights/pallet_asset_manager.rs b/runtime/common/src/weights/pallet_asset_manager.rs index 8d822dfa97..f444e41a00 100644 --- a/runtime/common/src/weights/pallet_asset_manager.rs +++ b/runtime/common/src/weights/pallet_asset_manager.rs @@ -123,26 +123,6 @@ impl pallet_asset_manager::WeightInfo for WeightInfo .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 5).saturating_mul(x.into())) } - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: AssetManager LocalAssetCounter (r:1 w:1) - /// Proof Skipped: AssetManager LocalAssetCounter (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: LocalAssets Asset (r:1 w:1) - /// Proof: LocalAssets Asset (max_values: None, max_size: Some(174), added: 2649, mode: MaxEncodedLen) - /// Storage: EVM AccountCodes (r:0 w:1) - /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) - /// Storage: AssetManager LocalAssetDeposit (r:0 w:1) - /// Proof Skipped: AssetManager LocalAssetDeposit (max_values: None, max_size: None, mode: Measured) - fn register_local_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `310` - // Estimated: `3639` - // Minimum execution time: 24_699_000 picoseconds. - Weight::from_parts(25_397_000, 0) - .saturating_add(Weight::from_parts(0, 3639)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(5)) - } /// Storage: AssetManager SupportedFeePaymentAssets (r:1 w:1) /// Proof Skipped: AssetManager SupportedFeePaymentAssets (max_values: Some(1), max_size: None, mode: Measured) /// Storage: AssetManager AssetIdType (r:1 w:1) diff --git a/runtime/moonbase/src/asset_config.rs b/runtime/moonbase/src/asset_config.rs index b02cfaccf6..9040423eef 100644 --- a/runtime/moonbase/src/asset_config.rs +++ b/runtime/moonbase/src/asset_config.rs @@ -26,7 +26,6 @@ use super::{ use moonbeam_runtime_common::weights as moonbeam_weights; use pallet_evm_precompileset_assets_erc20::AccountIdAssetIdConversion; -use sp_runtime::traits::Hash as THash; use frame_support::{ dispatch::GetDispatchInfo, @@ -38,7 +37,7 @@ use frame_support::{ use frame_system::{EnsureNever, EnsureRoot}; use parity_scale_codec::{Compact, Decode, Encode}; use scale_info::TypeInfo; -use sp_core::{H160, H256}; +use sp_core::H160; use sp_std::{ convert::{From, Into}, @@ -59,8 +58,6 @@ pub type ForeignAssetInstance = (); // For foreign assets, these parameters dont matter much // as this will only be called by root with the forced arguments // No deposit is substracted with those methods -// For local assets, they do matter. We use similar parameters -// to those in statemine (except for approval) parameter_types! { pub const AssetDeposit: Balance = 100 * currency::UNIT * currency::SUPPLY_FACTOR; pub const ApprovalDeposit: Balance = 0; @@ -166,19 +163,6 @@ impl pallet_asset_manager::AssetRegistrar for AssetRegistrar { } } -pub struct LocalAssetIdCreator; -impl pallet_asset_manager::LocalAssetIdCreator for LocalAssetIdCreator { - fn create_asset_id_from_metadata(local_asset_counter: u128) -> AssetId { - // Our means of converting a local asset counter to an assetId - // We basically hash (local asset counter) - let mut result: [u8; 16] = [0u8; 16]; - let hash: H256 = - local_asset_counter.using_encoded(::Hashing::hash); - result.copy_from_slice(&hash.as_fixed_bytes()[0..16]); - u128::from_le_bytes(result) - } -} - #[derive(Clone, Default, Eq, Debug, PartialEq, Ord, PartialOrd, Encode, Decode, TypeInfo)] pub struct AssetRegistrarMetadata { pub name: Vec, @@ -206,10 +190,6 @@ impl pallet_asset_manager::Config for Runtime { type ForeignAssetType = xcm_config::AssetType; type AssetRegistrar = AssetRegistrar; type ForeignAssetModifierOrigin = ForeignAssetModifierOrigin; - type LocalAssetModifierOrigin = LocalAssetModifierOrigin; - type LocalAssetIdCreator = LocalAssetIdCreator; - type Currency = Balances; - type LocalAssetDeposit = AssetDeposit; type WeightInfo = moonbeam_weights::pallet_asset_manager::WeightInfo; } diff --git a/runtime/moonbase/src/xcm_config.rs b/runtime/moonbase/src/xcm_config.rs index fd34bd6d8c..4c438a17ff 100644 --- a/runtime/moonbase/src/xcm_config.rs +++ b/runtime/moonbase/src/xcm_config.rs @@ -163,7 +163,6 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< // These correspond to // SelfReserve asset, both pre and post 0.9.16 // Foreign assets -// Local assets, both pre and post 0.9.16 // We can remove the Old reanchor once // we import https://github.com/open-web3-stack/open-runtime-module-library/pull/708 pub type AssetTransactors = ( @@ -493,8 +492,6 @@ pub enum CurrencyId { SelfReserve, // Assets representing other chains native tokens ForeignAsset(AssetId), - // Our local assets - DeprecatedLocalAssetReserve(AssetId), // Erc20 token Erc20 { contract_address: H160 }, } @@ -532,7 +529,6 @@ where Some(multi) } CurrencyId::ForeignAsset(asset) => AssetXConverter::convert_back(&asset), - CurrencyId::DeprecatedLocalAssetReserve(_) => None, CurrencyId::Erc20 { contract_address } => { let mut location = Erc20XcmBridgePalletLocation::get(); location diff --git a/runtime/moonbase/tests/common/mod.rs b/runtime/moonbase/tests/common/mod.rs index e715e7a609..416e9a000d 100644 --- a/runtime/moonbase/tests/common/mod.rs +++ b/runtime/moonbase/tests/common/mod.rs @@ -114,8 +114,6 @@ pub struct XcmAssetInitialization { pub struct ExtBuilder { // endowed accounts with balances balances: Vec<(AccountId, Balance)>, - // [asset, Vec, owner] - local_assets: Vec<(AssetId, Vec<(AccountId, Balance)>, AccountId)>, // [collator, amount] collators: Vec<(AccountId, Balance)>, // [delegator, collator, nomination_amount] @@ -140,7 +138,6 @@ impl Default for ExtBuilder { ExtBuilder { balances: vec![], delegations: vec![], - local_assets: vec![], collators: vec![], inflation: InflationInfo { expect: Range { diff --git a/runtime/moonbase/tests/xcm_mock/parachain.rs b/runtime/moonbase/tests/xcm_mock/parachain.rs index 10c384737e..6ef68c0e9f 100644 --- a/runtime/moonbase/tests/xcm_mock/parachain.rs +++ b/runtime/moonbase/tests/xcm_mock/parachain.rs @@ -805,19 +805,6 @@ pub struct AssetMetadata { pub decimals: u8, } -pub struct LocalAssetIdCreator; -impl pallet_asset_manager::LocalAssetIdCreator for LocalAssetIdCreator { - fn create_asset_id_from_metadata(local_asset_counter: u128) -> AssetId { - // Our means of converting a local asset counter to an assetId - // We basically hash (local asset counter) - let mut result: [u8; 16] = [0u8; 16]; - let hash: H256 = - local_asset_counter.using_encoded(::Hashing::hash); - result.copy_from_slice(&hash.as_fixed_bytes()[0..16]); - u128::from_le_bytes(result) - } -} - impl pallet_asset_manager::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Balance = Balance; @@ -826,10 +813,6 @@ impl pallet_asset_manager::Config for Runtime { type ForeignAssetType = AssetType; type AssetRegistrar = AssetRegistrar; type ForeignAssetModifierOrigin = EnsureRoot; - type LocalAssetModifierOrigin = EnsureRoot; - type LocalAssetIdCreator = LocalAssetIdCreator; - type Currency = Balances; - type LocalAssetDeposit = AssetDeposit; type WeightInfo = (); } diff --git a/runtime/moonbeam/src/asset_config.rs b/runtime/moonbeam/src/asset_config.rs index c53b19184a..439b7c055b 100644 --- a/runtime/moonbeam/src/asset_config.rs +++ b/runtime/moonbeam/src/asset_config.rs @@ -31,10 +31,9 @@ use frame_support::{ }; use moonbeam_runtime_common::weights as moonbeam_weights; use pallet_evm_precompileset_assets_erc20::AccountIdAssetIdConversion; -use sp_runtime::traits::Hash as THash; use frame_system::{EnsureNever, EnsureRoot}; -use sp_core::{H160, H256}; +use sp_core::H160; use parity_scale_codec::{Compact, Decode, Encode}; use scale_info::TypeInfo; @@ -58,8 +57,6 @@ pub type ForeignAssetInstance = (); // For foreign assets, these parameters dont matter much // as this will only be called by root with the forced arguments // No deposit is substracted with those methods -// For local assets, they do matter. We use similar parameters -// to those in statemine (except for approval) parameter_types! { pub const AssetDeposit: Balance = 100 * currency::GLMR * currency::SUPPLY_FACTOR; pub const ApprovalDeposit: Balance = 0; @@ -165,19 +162,6 @@ impl pallet_asset_manager::AssetRegistrar for AssetRegistrar { } } -pub struct LocalAssetIdCreator; -impl pallet_asset_manager::LocalAssetIdCreator for LocalAssetIdCreator { - fn create_asset_id_from_metadata(local_asset_counter: u128) -> AssetId { - // Our means of converting a local asset counter to an assetId - // We basically hash (local asset counter) - let mut result: [u8; 16] = [0u8; 16]; - let hash: H256 = - local_asset_counter.using_encoded(::Hashing::hash); - result.copy_from_slice(&hash.as_fixed_bytes()[0..16]); - u128::from_le_bytes(result) - } -} - #[derive(Clone, Default, Eq, Debug, PartialEq, Ord, PartialOrd, Encode, Decode, TypeInfo)] pub struct AssetRegistrarMetadata { pub name: Vec, @@ -204,10 +188,6 @@ impl pallet_asset_manager::Config for Runtime { type ForeignAssetType = xcm_config::AssetType; type AssetRegistrar = AssetRegistrar; type ForeignAssetModifierOrigin = ForeignAssetModifierOrigin; - type LocalAssetModifierOrigin = LocalAssetModifierOrigin; - type LocalAssetIdCreator = LocalAssetIdCreator; - type Currency = Balances; - type LocalAssetDeposit = AssetDeposit; type WeightInfo = moonbeam_weights::pallet_asset_manager::WeightInfo; } diff --git a/runtime/moonbeam/src/xcm_config.rs b/runtime/moonbeam/src/xcm_config.rs index 6325b3ba87..d4646f650d 100644 --- a/runtime/moonbeam/src/xcm_config.rs +++ b/runtime/moonbeam/src/xcm_config.rs @@ -485,8 +485,6 @@ pub enum CurrencyId { SelfReserve, // Assets representing other chains native tokens ForeignAsset(AssetId), - // Our local assets - DeprecatedLocalAssetReserve(AssetId), // Erc20 token Erc20 { contract_address: H160 }, } @@ -524,7 +522,6 @@ where Some(multi) } CurrencyId::ForeignAsset(asset) => AssetXConverter::convert_back(&asset), - CurrencyId::DeprecatedLocalAssetReserve(_) => None, CurrencyId::Erc20 { contract_address } => { let mut location = Erc20XcmBridgePalletLocation::get(); location diff --git a/runtime/moonbeam/tests/common/mod.rs b/runtime/moonbeam/tests/common/mod.rs index 1db8374af5..9b382cf46c 100644 --- a/runtime/moonbeam/tests/common/mod.rs +++ b/runtime/moonbeam/tests/common/mod.rs @@ -119,8 +119,6 @@ pub struct XcmAssetInitialization { } pub struct ExtBuilder { - // [asset, Vec, owner] - local_assets: Vec<(AssetId, Vec<(AccountId, Balance)>, AccountId)>, // endowed accounts with balances balances: Vec<(AccountId, Balance)>, // [collator, amount] @@ -145,7 +143,6 @@ pub struct ExtBuilder { impl Default for ExtBuilder { fn default() -> ExtBuilder { ExtBuilder { - local_assets: vec![], balances: vec![], delegations: vec![], collators: vec![], diff --git a/runtime/moonbeam/tests/xcm_mock/parachain.rs b/runtime/moonbeam/tests/xcm_mock/parachain.rs index bff719f23c..b1e0e16728 100644 --- a/runtime/moonbeam/tests/xcm_mock/parachain.rs +++ b/runtime/moonbeam/tests/xcm_mock/parachain.rs @@ -765,19 +765,6 @@ pub struct AssetMetadata { pub decimals: u8, } -pub struct LocalAssetIdCreator; -impl pallet_asset_manager::LocalAssetIdCreator for LocalAssetIdCreator { - fn create_asset_id_from_metadata(local_asset_counter: u128) -> AssetId { - // Our means of converting a local asset counter to an assetId - // We basically hash (local asset counter) - let mut result: [u8; 16] = [0u8; 16]; - let hash: H256 = - local_asset_counter.using_encoded(::Hashing::hash); - result.copy_from_slice(&hash.as_fixed_bytes()[0..16]); - u128::from_le_bytes(result) - } -} - impl pallet_asset_manager::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Balance = Balance; @@ -786,10 +773,6 @@ impl pallet_asset_manager::Config for Runtime { type ForeignAssetType = AssetType; type AssetRegistrar = AssetRegistrar; type ForeignAssetModifierOrigin = EnsureRoot; - type LocalAssetModifierOrigin = EnsureRoot; - type LocalAssetIdCreator = LocalAssetIdCreator; - type Currency = Balances; - type LocalAssetDeposit = AssetDeposit; type WeightInfo = (); } diff --git a/runtime/moonriver/src/asset_config.rs b/runtime/moonriver/src/asset_config.rs index 1b44d41469..ca1cce4d39 100644 --- a/runtime/moonriver/src/asset_config.rs +++ b/runtime/moonriver/src/asset_config.rs @@ -25,7 +25,6 @@ use super::{ use moonbeam_runtime_common::weights as moonbeam_weights; use pallet_evm_precompileset_assets_erc20::AccountIdAssetIdConversion; -use sp_runtime::traits::Hash as THash; use frame_support::{ dispatch::GetDispatchInfo, @@ -34,7 +33,7 @@ use frame_support::{ weights::Weight, }; use frame_system::{EnsureNever, EnsureRoot}; -use sp_core::{H160, H256}; +use sp_core::H160; use parity_scale_codec::{Compact, Decode, Encode}; use scale_info::TypeInfo; @@ -58,8 +57,6 @@ pub type ForeignAssetInstance = (); // For foreign assets, these parameters dont matter much // as this will only be called by root with the forced arguments // No deposit is substracted with those methods -// For local assets, they do matter. We use similar parameters -// to those in statemine (except for approval) parameter_types! { pub const AssetDeposit: Balance = 100 * currency::MOVR * currency::SUPPLY_FACTOR; pub const ApprovalDeposit: Balance = 0; @@ -165,19 +162,6 @@ impl pallet_asset_manager::AssetRegistrar for AssetRegistrar { } } -pub struct LocalAssetIdCreator; -impl pallet_asset_manager::LocalAssetIdCreator for LocalAssetIdCreator { - fn create_asset_id_from_metadata(local_asset_counter: u128) -> AssetId { - // Our means of converting a local asset counter to an assetId - // We basically hash (local asset counter) - let mut result: [u8; 16] = [0u8; 16]; - let hash: H256 = - local_asset_counter.using_encoded(::Hashing::hash); - result.copy_from_slice(&hash.as_fixed_bytes()[0..16]); - u128::from_le_bytes(result) - } -} - #[derive(Clone, Default, Eq, Debug, PartialEq, Ord, PartialOrd, Encode, Decode, TypeInfo)] pub struct AssetRegistrarMetadata { pub name: Vec, @@ -204,10 +188,6 @@ impl pallet_asset_manager::Config for Runtime { type ForeignAssetType = xcm_config::AssetType; type AssetRegistrar = AssetRegistrar; type ForeignAssetModifierOrigin = ForeignAssetModifierOrigin; - type LocalAssetModifierOrigin = LocalAssetModifierOrigin; - type LocalAssetIdCreator = LocalAssetIdCreator; - type Currency = Balances; - type LocalAssetDeposit = AssetDeposit; type WeightInfo = moonbeam_weights::pallet_asset_manager::WeightInfo; } diff --git a/runtime/moonriver/src/xcm_config.rs b/runtime/moonriver/src/xcm_config.rs index 1cec5c258b..8cbe08114b 100644 --- a/runtime/moonriver/src/xcm_config.rs +++ b/runtime/moonriver/src/xcm_config.rs @@ -493,8 +493,6 @@ pub enum CurrencyId { SelfReserve, // Assets representing other chains native tokens ForeignAsset(AssetId), - // Our local assets - DeprecatedLocalAssetReserve(AssetId), // Erc20 token Erc20 { contract_address: H160 }, } @@ -537,7 +535,6 @@ where Some(multi) } CurrencyId::ForeignAsset(asset) => AssetXConverter::convert_back(&asset), - CurrencyId::DeprecatedLocalAssetReserve(_) => None, CurrencyId::Erc20 { contract_address } => { let mut location = Erc20XcmBridgePalletLocation::get(); location diff --git a/runtime/moonriver/tests/common/mod.rs b/runtime/moonriver/tests/common/mod.rs index 626c2e9a3f..2fbe123635 100644 --- a/runtime/moonriver/tests/common/mod.rs +++ b/runtime/moonriver/tests/common/mod.rs @@ -120,8 +120,6 @@ pub struct XcmAssetInitialization { } pub struct ExtBuilder { - // [asset, Vec, owner] - local_assets: Vec<(AssetId, Vec<(AccountId, Balance)>, AccountId)>, // endowed accounts with balances balances: Vec<(AccountId, Balance)>, // [collator, amount] @@ -146,7 +144,6 @@ pub struct ExtBuilder { impl Default for ExtBuilder { fn default() -> ExtBuilder { ExtBuilder { - local_assets: vec![], balances: vec![], delegations: vec![], collators: vec![], diff --git a/runtime/moonriver/tests/xcm_mock/parachain.rs b/runtime/moonriver/tests/xcm_mock/parachain.rs index 32666e5be7..ac8b749c8a 100644 --- a/runtime/moonriver/tests/xcm_mock/parachain.rs +++ b/runtime/moonriver/tests/xcm_mock/parachain.rs @@ -769,18 +769,6 @@ pub struct AssetMetadata { pub symbol: Vec, pub decimals: u8, } -pub struct LocalAssetIdCreator; -impl pallet_asset_manager::LocalAssetIdCreator for LocalAssetIdCreator { - fn create_asset_id_from_metadata(local_asset_counter: u128) -> AssetId { - // Our means of converting a creator to an assetId - // We basically hash (local asset counter) - let mut result: [u8; 16] = [0u8; 16]; - let hash: H256 = - local_asset_counter.using_encoded(::Hashing::hash); - result.copy_from_slice(&hash.as_fixed_bytes()[0..16]); - u128::from_le_bytes(result) - } -} impl pallet_asset_manager::Config for Runtime { type RuntimeEvent = RuntimeEvent; @@ -790,10 +778,6 @@ impl pallet_asset_manager::Config for Runtime { type ForeignAssetType = AssetType; type AssetRegistrar = AssetRegistrar; type ForeignAssetModifierOrigin = EnsureRoot; - type LocalAssetModifierOrigin = EnsureRoot; - type LocalAssetIdCreator = LocalAssetIdCreator; - type Currency = Balances; - type LocalAssetDeposit = AssetDeposit; type WeightInfo = (); } diff --git a/test/suites/smoke/test-foreign-asset-consistency.ts b/test/suites/smoke/test-foreign-asset-consistency.ts index df7587a792..de37683f0a 100644 --- a/test/suites/smoke/test-foreign-asset-consistency.ts +++ b/test/suites/smoke/test-foreign-asset-consistency.ts @@ -64,7 +64,7 @@ describeSuite({ test: async function () { expect( foreignXcmAcceptedAssets.length, - `Number of local asset deposits does not much number of local assets` + `Number of foreign asset deposits does not match the number of foreign assets` ).to.be.lessThanOrEqual(Object.keys(foreignAssetIdType).length); log(