Skip to content

Commit

Permalink
asset-hubs: simplify xcm-config (paritytech#6222)
Browse files Browse the repository at this point in the history
`ForeignCreatorsSovereignAccountOf` is used by `ForeignCreators` filter
to convert location to `AccountId`, _after_ `ForeignCreators::IsForeign`
filter passes for an (asset, location) pair.

The `IsForeign` filter is the actual differentiator, so if a location
passes it, we should support converting it to an `AccountId`.

As such, this commit replaces `ForeignCreatorsSovereignAccountOf`
converter with the more general `LocationToAccountId` converter.

Signed-off-by: Adrian Catangiu <[email protected]>
  • Loading branch information
acatangiu authored and mordamax committed Oct 29, 2024
1 parent 2421880 commit 3719063
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ use parachains_common::{
use sp_runtime::{Perbill, RuntimeDebug};
use testnet_parachains_constants::rococo::{consensus::*, currency::*, fee::WeightToFee, time::*};
use xcm_config::{
ForeignAssetsConvertedConcreteId, ForeignCreatorsSovereignAccountOf, GovernanceLocation,
ForeignAssetsConvertedConcreteId, GovernanceLocation, LocationToAccountId,
PoolAssetsConvertedConcreteId, TokenLocation, TrustBackedAssetsConvertedConcreteId,
TrustBackedAssetsPalletLocation,
};
Expand Down Expand Up @@ -424,7 +424,7 @@ impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
FromNetwork<xcm_config::UniversalLocation, EthereumNetwork, xcm::v4::Location>,
xcm_config::bridging::to_westend::WestendOrEthereumAssetFromAssetHubWestend,
),
ForeignCreatorsSovereignAccountOf,
LocationToAccountId,
AccountId,
xcm::v4::Location,
>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,14 +512,6 @@ impl cumulus_pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
}

pub type ForeignCreatorsSovereignAccountOf = (
SiblingParachainConvertsVia<Sibling, AccountId>,
AccountId32Aliases<RelayNetwork, AccountId>,
ParentIsPreset<AccountId>,
GlobalConsensusEthereumConvertsFor<AccountId>,
GlobalConsensusParachainConvertsFor<UniversalLocation, AccountId>,
);

/// Simple conversion of `u32` into an `AssetId` for use in benchmarking.
pub struct XcmBenchmarkHelper;
#[cfg(feature = "runtime-benchmarks")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use asset_hub_rococo_runtime::{
xcm_config,
xcm_config::{
bridging, AssetFeeAsExistentialDepositMultiplierFeeCharger, CheckingAccount,
ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger, ForeignCreatorsSovereignAccountOf,
LocationToAccountId, StakingPot, TokenLocation, TrustBackedAssetsPalletLocation, XcmConfig,
ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger, LocationToAccountId, StakingPot,
TokenLocation, TrustBackedAssetsPalletLocation, XcmConfig,
},
AllPalletsWithoutSystem, AssetConversion, AssetDeposit, Assets, Balances, CollatorSelection,
ExistentialDeposit, ForeignAssets, ForeignAssetsInstance, MetadataDepositBase,
Expand Down Expand Up @@ -941,7 +941,7 @@ asset_test_utils::include_teleports_for_foreign_assets_works!(
CheckingAccount,
WeightToFee,
ParachainSystem,
ForeignCreatorsSovereignAccountOf,
LocationToAccountId,
ForeignAssetsInstance,
collator_session_keys(),
slot_durations(),
Expand Down Expand Up @@ -1015,7 +1015,7 @@ asset_test_utils::include_create_and_manage_foreign_assets_for_local_consensus_p
Runtime,
XcmConfig,
WeightToFee,
ForeignCreatorsSovereignAccountOf,
LocationToAccountId,
ForeignAssetsInstance,
Location,
WithLatestLocationConverter<Location>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ use testnet_parachains_constants::westend::{
consensus::*, currency::*, fee::WeightToFee, snowbridge::EthereumNetwork, time::*,
};
use xcm_config::{
ForeignAssetsConvertedConcreteId, ForeignCreatorsSovereignAccountOf,
PoolAssetsConvertedConcreteId, TrustBackedAssetsConvertedConcreteId,
TrustBackedAssetsPalletLocation, WestendLocation, XcmOriginToTransactDispatchOrigin,
ForeignAssetsConvertedConcreteId, LocationToAccountId, PoolAssetsConvertedConcreteId,
TrustBackedAssetsConvertedConcreteId, TrustBackedAssetsPalletLocation, WestendLocation,
XcmOriginToTransactDispatchOrigin,
};

#[cfg(any(feature = "std", test))]
Expand Down Expand Up @@ -423,7 +423,7 @@ impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
FromNetwork<xcm_config::UniversalLocation, EthereumNetwork, xcm::v4::Location>,
xcm_config::bridging::to_rococo::RococoAssetFromAssetHubRococo,
),
ForeignCreatorsSovereignAccountOf,
LocationToAccountId,
AccountId,
xcm::v4::Location,
>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,6 @@ impl cumulus_pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
}

pub type ForeignCreatorsSovereignAccountOf = (
SiblingParachainConvertsVia<Sibling, AccountId>,
AccountId32Aliases<RelayNetwork, AccountId>,
ParentIsPreset<AccountId>,
GlobalConsensusEthereumConvertsFor<AccountId>,
GlobalConsensusParachainConvertsFor<UniversalLocation, AccountId>,
);

/// Simple conversion of `u32` into an `AssetId` for use in benchmarking.
pub struct XcmBenchmarkHelper;
#[cfg(feature = "runtime-benchmarks")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ use asset_hub_westend_runtime::{
xcm_config,
xcm_config::{
bridging, AssetFeeAsExistentialDepositMultiplierFeeCharger, CheckingAccount,
ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger, ForeignCreatorsSovereignAccountOf,
LocationToAccountId, StakingPot, TrustBackedAssetsPalletLocation, WestendLocation,
XcmConfig,
ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger, LocationToAccountId, StakingPot,
TrustBackedAssetsPalletLocation, WestendLocation, XcmConfig,
},
AllPalletsWithoutSystem, Assets, Balances, ExistentialDeposit, ForeignAssets,
ForeignAssetsInstance, MetadataDepositBase, MetadataDepositPerByte, ParachainSystem,
Expand Down Expand Up @@ -966,7 +965,7 @@ asset_test_utils::include_teleports_for_foreign_assets_works!(
CheckingAccount,
WeightToFee,
ParachainSystem,
ForeignCreatorsSovereignAccountOf,
LocationToAccountId,
ForeignAssetsInstance,
collator_session_keys(),
slot_durations(),
Expand Down Expand Up @@ -1044,7 +1043,7 @@ asset_test_utils::include_create_and_manage_foreign_assets_for_local_consensus_p
Runtime,
XcmConfig,
WeightToFee,
ForeignCreatorsSovereignAccountOf,
LocationToAccountId,
ForeignAssetsInstance,
xcm::v4::Location,
WithLatestLocationConverter<xcm::v4::Location>,
Expand Down

0 comments on commit 3719063

Please sign in to comment.