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:
Muharem
2024-04-17 12:39:23 +02:00
committed by GitHub
parent e6f3106d89
commit 4e10d3b0a6
31 changed files with 1647 additions and 39 deletions
+29 -3
View File
@@ -63,7 +63,7 @@ use frame_system::{
};
pub use node_primitives::{AccountId, Signature};
use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Moment, Nonce};
use pallet_asset_conversion::{Ascending, Chain, WithFirstAsset};
use pallet_asset_conversion::{AccountIdConverter, Ascending, Chain, WithFirstAsset};
use pallet_broker::{CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600};
use pallet_election_provider_multi_phase::{GeometricDepositBase, SolutionAccuracyOf};
use pallet_identity::legacy::IdentityInfo;
@@ -1710,8 +1710,17 @@ impl pallet_asset_conversion::Config for Runtime {
type Assets = UnionOf<Balances, Assets, NativeFromLeft, NativeOrWithId<u32>, AccountId>;
type PoolId = (Self::AssetKind, Self::AssetKind);
type PoolLocator = Chain<
WithFirstAsset<Native, AccountId, NativeOrWithId<u32>>,
Ascending<AccountId, NativeOrWithId<u32>>,
WithFirstAsset<
Native,
AccountId,
NativeOrWithId<u32>,
AccountIdConverter<AssetConversionPalletId, Self::PoolId>,
>,
Ascending<
AccountId,
NativeOrWithId<u32>,
AccountIdConverter<AssetConversionPalletId, Self::PoolId>,
>,
>;
type PoolAssetId = <Self as pallet_assets::Config<Instance2>>::AssetId;
type PoolAssets = PoolAssets;
@@ -1728,6 +1737,19 @@ impl pallet_asset_conversion::Config for Runtime {
type BenchmarkHelper = ();
}
impl pallet_asset_conversion_ops::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type PriorAccountIdConverter = pallet_asset_conversion::AccountIdConverterNoSeed<(
NativeOrWithId<u32>,
NativeOrWithId<u32>,
)>;
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 = pallet_asset_conversion_ops::weights::SubstrateWeight<Runtime>;
}
parameter_types! {
pub const QueueCount: u32 = 300;
pub const MaxQueueLen: u32 = 1000;
@@ -2474,6 +2496,9 @@ mod runtime {
#[runtime::pallet_index(78)]
pub type PalletExampleMbms = pallet_example_mbm;
#[runtime::pallet_index(79)]
pub type AssetConversionMigration = pallet_asset_conversion_ops;
}
/// The address format for describing accounts.
@@ -2633,6 +2658,7 @@ mod benches {
[pallet_tx_pause, TxPause]
[pallet_safe_mode, SafeMode]
[pallet_example_mbm, PalletExampleMbms]
[pallet_asset_conversion_ops, AssetConversionMigration]
);
}