mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 01:41:03 +00:00
Asset Conversion: Pool Account ID derivation with additional Pallet ID seed (#3250)
Introduce `PalletId` as an additional seed parameter for pool's account id derivation. The PR also introduces the `pallet_asset_conversion_ops` pallet with a call to migrate a given pool to thew new account. Additionally `fungibles::lifetime::ResetTeam` and `fungible::lifetime::Refund` traits, to facilitate the migration of pools. --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -25,6 +25,7 @@ frame-system-rpc-runtime-api = { path = "../../../../../substrate/frame/system/r
|
||||
frame-try-runtime = { path = "../../../../../substrate/frame/try-runtime", default-features = false, optional = true }
|
||||
pallet-asset-conversion-tx-payment = { path = "../../../../../substrate/frame/transaction-payment/asset-conversion-tx-payment", default-features = false }
|
||||
pallet-assets = { path = "../../../../../substrate/frame/assets", default-features = false }
|
||||
pallet-asset-conversion-ops = { path = "../../../../../substrate/frame/asset-conversion/ops", default-features = false }
|
||||
pallet-asset-conversion = { path = "../../../../../substrate/frame/asset-conversion", default-features = false }
|
||||
pallet-aura = { path = "../../../../../substrate/frame/aura", default-features = false }
|
||||
pallet-authorship = { path = "../../../../../substrate/frame/authorship", default-features = false }
|
||||
@@ -120,6 +121,7 @@ runtime-benchmarks = [
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system-benchmarking/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"pallet-asset-conversion-ops/runtime-benchmarks",
|
||||
"pallet-asset-conversion/runtime-benchmarks",
|
||||
"pallet-assets/runtime-benchmarks",
|
||||
"pallet-balances/runtime-benchmarks",
|
||||
@@ -153,6 +155,7 @@ try-runtime = [
|
||||
"frame-support/try-runtime",
|
||||
"frame-system/try-runtime",
|
||||
"frame-try-runtime/try-runtime",
|
||||
"pallet-asset-conversion-ops/try-runtime",
|
||||
"pallet-asset-conversion-tx-payment/try-runtime",
|
||||
"pallet-asset-conversion/try-runtime",
|
||||
"pallet-assets/try-runtime",
|
||||
@@ -201,6 +204,7 @@ std = [
|
||||
"frame-system/std",
|
||||
"frame-try-runtime?/std",
|
||||
"log/std",
|
||||
"pallet-asset-conversion-ops/std",
|
||||
"pallet-asset-conversion-tx-payment/std",
|
||||
"pallet-asset-conversion/std",
|
||||
"pallet-assets/std",
|
||||
|
||||
@@ -333,6 +333,11 @@ pub type NativeAndAssets = fungible::UnionOf<
|
||||
AccountId,
|
||||
>;
|
||||
|
||||
pub type PoolIdToAccountId = pallet_asset_conversion::AccountIdConverter<
|
||||
AssetConversionPalletId,
|
||||
(xcm::v3::Location, xcm::v3::Location),
|
||||
>;
|
||||
|
||||
impl pallet_asset_conversion::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Balance = Balance;
|
||||
@@ -340,8 +345,12 @@ impl pallet_asset_conversion::Config for Runtime {
|
||||
type AssetKind = xcm::v3::Location;
|
||||
type Assets = NativeAndAssets;
|
||||
type PoolId = (Self::AssetKind, Self::AssetKind);
|
||||
type PoolLocator =
|
||||
pallet_asset_conversion::WithFirstAsset<TokenLocationV3, AccountId, Self::AssetKind>;
|
||||
type PoolLocator = pallet_asset_conversion::WithFirstAsset<
|
||||
TokenLocationV3,
|
||||
AccountId,
|
||||
Self::AssetKind,
|
||||
PoolIdToAccountId,
|
||||
>;
|
||||
type PoolAssetId = u32;
|
||||
type PoolAssets = PoolAssets;
|
||||
type PoolSetupFee = ConstU128<0>; // Asset class deposit fees are sufficient to prevent spam
|
||||
@@ -362,6 +371,18 @@ impl pallet_asset_conversion::Config for Runtime {
|
||||
>;
|
||||
}
|
||||
|
||||
impl pallet_asset_conversion_ops::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type PriorAccountIdConverter = pallet_asset_conversion::AccountIdConverterNoSeed<
|
||||
<Runtime as pallet_asset_conversion::Config>::PoolId,
|
||||
>;
|
||||
type AssetsRefund = <Runtime as pallet_asset_conversion::Config>::Assets;
|
||||
type PoolAssetsRefund = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
|
||||
type PoolAssetsTeam = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
|
||||
type DepositAsset = Balances;
|
||||
type WeightInfo = weights::pallet_asset_conversion_ops::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// we just reuse the same deposits
|
||||
pub const ForeignAssetsAssetDeposit: Balance = AssetDeposit::get();
|
||||
@@ -934,6 +955,10 @@ construct_runtime!(
|
||||
|
||||
#[cfg(feature = "state-trie-version-1")]
|
||||
StateTrieMigration: pallet_state_trie_migration = 70,
|
||||
|
||||
// TODO: the pallet instance should be removed once all pools have migrated
|
||||
// to the new account IDs.
|
||||
AssetConversionMigration: pallet_asset_conversion_ops = 200,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -961,6 +986,7 @@ pub type SignedExtra = (
|
||||
pub type UncheckedExtrinsic =
|
||||
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
|
||||
/// Migrations to apply on runtime upgrade.
|
||||
#[allow(deprecated)]
|
||||
pub type Migrations = (
|
||||
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
|
||||
InitStorageVersions,
|
||||
@@ -1054,6 +1080,7 @@ mod benches {
|
||||
[cumulus_pallet_parachain_system, ParachainSystem]
|
||||
[cumulus_pallet_xcmp_queue, XcmpQueue]
|
||||
[pallet_xcm_bridge_hub_router, ToWestend]
|
||||
[pallet_asset_conversion_ops, AssetConversionMigration]
|
||||
// XCM
|
||||
[pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
|
||||
// NOTE: Make sure you point to the individual modules below.
|
||||
|
||||
@@ -20,6 +20,7 @@ pub mod cumulus_pallet_xcmp_queue;
|
||||
pub mod extrinsic_weights;
|
||||
pub mod frame_system;
|
||||
pub mod pallet_asset_conversion;
|
||||
pub mod pallet_asset_conversion_ops;
|
||||
pub mod pallet_assets_foreign;
|
||||
pub mod pallet_assets_local;
|
||||
pub mod pallet_assets_pool;
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Cumulus is distributed in the hope that it will be useful,
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `pallet_asset_conversion_ops`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2024-02-15, STEPS: `10`, REPEAT: `2`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `cob`, CPU: `<UNKNOWN>`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-rococo-dev")`, DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./target/debug/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain=asset-hub-rococo-dev
|
||||
// --steps=10
|
||||
// --repeat=2
|
||||
// --pallet=pallet-asset-conversion-ops
|
||||
// --extrinsic=*
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --output=./cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions for `pallet_asset_conversion_ops`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> pallet_asset_conversion_ops::WeightInfo for WeightInfo<T> {
|
||||
/// Storage: `AssetConversion::Pools` (r:1 w:0)
|
||||
/// Proof: `AssetConversion::Pools` (`max_values`: None, `max_size`: Some(1224), added: 3699, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:2 w:2)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `ForeignAssets::Account` (r:2 w:2)
|
||||
/// Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`)
|
||||
/// Storage: `PoolAssets::Account` (r:2 w:2)
|
||||
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `PoolAssets::Asset` (r:1 w:1)
|
||||
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `ForeignAssets::Asset` (r:1 w:1)
|
||||
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
|
||||
fn migrate_to_new_account() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `1105`
|
||||
// Estimated: `7404`
|
||||
// Minimum execution time: 2_323_000_000 picoseconds.
|
||||
Weight::from_parts(2_404_000_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 7404))
|
||||
.saturating_add(T::DbWeight::get().reads(9))
|
||||
.saturating_add(T::DbWeight::get().writes(8))
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ frame-system = { path = "../../../../../substrate/frame/system", default-feature
|
||||
frame-system-benchmarking = { path = "../../../../../substrate/frame/system/benchmarking", default-features = false, optional = true }
|
||||
frame-system-rpc-runtime-api = { path = "../../../../../substrate/frame/system/rpc/runtime-api", default-features = false }
|
||||
frame-try-runtime = { path = "../../../../../substrate/frame/try-runtime", default-features = false, optional = true }
|
||||
pallet-asset-conversion-ops = { path = "../../../../../substrate/frame/asset-conversion/ops", default-features = false }
|
||||
pallet-asset-conversion-tx-payment = { path = "../../../../../substrate/frame/transaction-payment/asset-conversion-tx-payment", default-features = false }
|
||||
pallet-assets = { path = "../../../../../substrate/frame/assets", default-features = false }
|
||||
pallet-asset-conversion = { path = "../../../../../substrate/frame/asset-conversion", default-features = false }
|
||||
@@ -111,6 +112,7 @@ runtime-benchmarks = [
|
||||
"frame-system-benchmarking/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"hex-literal",
|
||||
"pallet-asset-conversion-ops/runtime-benchmarks",
|
||||
"pallet-asset-conversion/runtime-benchmarks",
|
||||
"pallet-assets/runtime-benchmarks",
|
||||
"pallet-balances/runtime-benchmarks",
|
||||
@@ -142,6 +144,7 @@ try-runtime = [
|
||||
"frame-support/try-runtime",
|
||||
"frame-system/try-runtime",
|
||||
"frame-try-runtime/try-runtime",
|
||||
"pallet-asset-conversion-ops/try-runtime",
|
||||
"pallet-asset-conversion-tx-payment/try-runtime",
|
||||
"pallet-asset-conversion/try-runtime",
|
||||
"pallet-assets/try-runtime",
|
||||
@@ -189,6 +192,7 @@ std = [
|
||||
"frame-system/std",
|
||||
"frame-try-runtime?/std",
|
||||
"log/std",
|
||||
"pallet-asset-conversion-ops/std",
|
||||
"pallet-asset-conversion-tx-payment/std",
|
||||
"pallet-asset-conversion/std",
|
||||
"pallet-assets/std",
|
||||
|
||||
@@ -315,6 +315,11 @@ pub type NativeAndAssets = fungible::UnionOf<
|
||||
AccountId,
|
||||
>;
|
||||
|
||||
pub type PoolIdToAccountId = pallet_asset_conversion::AccountIdConverter<
|
||||
AssetConversionPalletId,
|
||||
(xcm::v3::Location, xcm::v3::Location),
|
||||
>;
|
||||
|
||||
impl pallet_asset_conversion::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Balance = Balance;
|
||||
@@ -322,8 +327,12 @@ impl pallet_asset_conversion::Config for Runtime {
|
||||
type AssetKind = xcm::v3::Location;
|
||||
type Assets = NativeAndAssets;
|
||||
type PoolId = (Self::AssetKind, Self::AssetKind);
|
||||
type PoolLocator =
|
||||
pallet_asset_conversion::WithFirstAsset<WestendLocationV3, AccountId, Self::AssetKind>;
|
||||
type PoolLocator = pallet_asset_conversion::WithFirstAsset<
|
||||
WestendLocationV3,
|
||||
AccountId,
|
||||
Self::AssetKind,
|
||||
PoolIdToAccountId,
|
||||
>;
|
||||
type PoolAssetId = u32;
|
||||
type PoolAssets = PoolAssets;
|
||||
type PoolSetupFee = ConstU128<0>; // Asset class deposit fees are sufficient to prevent spam
|
||||
@@ -344,6 +353,18 @@ impl pallet_asset_conversion::Config for Runtime {
|
||||
>;
|
||||
}
|
||||
|
||||
impl pallet_asset_conversion_ops::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type PriorAccountIdConverter = pallet_asset_conversion::AccountIdConverterNoSeed<
|
||||
<Runtime as pallet_asset_conversion::Config>::PoolId,
|
||||
>;
|
||||
type AssetsRefund = <Runtime as pallet_asset_conversion::Config>::Assets;
|
||||
type PoolAssetsRefund = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
|
||||
type PoolAssetsTeam = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
|
||||
type DepositAsset = Balances;
|
||||
type WeightInfo = weights::pallet_asset_conversion_ops::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// we just reuse the same deposits
|
||||
pub const ForeignAssetsAssetDeposit: Balance = AssetDeposit::get();
|
||||
@@ -906,6 +927,10 @@ construct_runtime!(
|
||||
NftFractionalization: pallet_nft_fractionalization = 54,
|
||||
PoolAssets: pallet_assets::<Instance3> = 55,
|
||||
AssetConversion: pallet_asset_conversion = 56,
|
||||
|
||||
// TODO: the pallet instance should be removed once all pools have migrated
|
||||
// to the new account IDs.
|
||||
AssetConversionMigration: pallet_asset_conversion_ops = 200,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1085,6 +1110,7 @@ mod benches {
|
||||
[cumulus_pallet_parachain_system, ParachainSystem]
|
||||
[cumulus_pallet_xcmp_queue, XcmpQueue]
|
||||
[pallet_xcm_bridge_hub_router, ToRococo]
|
||||
[pallet_asset_conversion_ops, AssetConversionMigration]
|
||||
// XCM
|
||||
[pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
|
||||
// NOTE: Make sure you point to the individual modules below.
|
||||
|
||||
@@ -19,6 +19,7 @@ pub mod cumulus_pallet_xcmp_queue;
|
||||
pub mod extrinsic_weights;
|
||||
pub mod frame_system;
|
||||
pub mod pallet_asset_conversion;
|
||||
pub mod pallet_asset_conversion_ops;
|
||||
pub mod pallet_assets_foreign;
|
||||
pub mod pallet_assets_local;
|
||||
pub mod pallet_assets_pool;
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Cumulus is distributed in the hope that it will be useful,
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `pallet_asset_conversion_ops`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2024-02-15, STEPS: `10`, REPEAT: `2`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `cob`, CPU: `<UNKNOWN>`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-westend-dev")`, DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./target/debug/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain=asset-hub-westend-dev
|
||||
// --steps=10
|
||||
// --repeat=2
|
||||
// --pallet=pallet-asset-conversion-ops
|
||||
// --extrinsic=*
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions for `pallet_asset_conversion_ops`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> pallet_asset_conversion_ops::WeightInfo for WeightInfo<T> {
|
||||
/// Storage: `AssetConversion::Pools` (r:1 w:0)
|
||||
/// Proof: `AssetConversion::Pools` (`max_values`: None, `max_size`: Some(1224), added: 3699, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:2 w:2)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `ForeignAssets::Account` (r:2 w:2)
|
||||
/// Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`)
|
||||
/// Storage: `PoolAssets::Account` (r:2 w:2)
|
||||
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `PoolAssets::Asset` (r:1 w:1)
|
||||
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `ForeignAssets::Asset` (r:1 w:1)
|
||||
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
|
||||
fn migrate_to_new_account() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `1105`
|
||||
// Estimated: `7404`
|
||||
// Minimum execution time: 2_216_000_000 picoseconds.
|
||||
Weight::from_parts(2_379_000_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 7404))
|
||||
.saturating_add(T::DbWeight::get().reads(9))
|
||||
.saturating_add(T::DbWeight::get().writes(8))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user