Implement AliasOrigin processing in XCVM (#7245)

* Implement AliasOrigin processing in XCVM

* add builder types and first test

* switch to more general builder types

* clone target for RemovePrefixAccountId32

* change builder types

* change AliasForeignAccountId32 and add test for AliasCase

* add Aliasers type to xcm configs

* add benchmark

* benchmark fix

* add benchmark function for runtimes

* fix alias_origin result types

* fix benchmark test

* add runtime-benchmarks feature in pallet-xcm-benchmarks

* fmt

* remove AliasCase, add test and fmt

* address feedback

* ".git/.scripts/commands/bench/bench.sh" xcm kusama pallet_xcm_benchmarks::generic

* ".git/.scripts/commands/bench/bench.sh" xcm westend pallet_xcm_benchmarks::generic

* ".git/.scripts/commands/bench/bench.sh" xcm rococo pallet_xcm_benchmarks::generic

* address feedback

* lock

* ".git/.scripts/commands/bench/bench.sh" xcm kusama pallet_xcm_benchmarks::generic

* ".git/.scripts/commands/bench/bench.sh" xcm westend pallet_xcm_benchmarks::generic

* ".git/.scripts/commands/bench/bench.sh" xcm rococo pallet_xcm_benchmarks::generic

* change doc

* fmt

---------

Co-authored-by: Just van Stam <just.van.stam@gmail.com>
Co-authored-by: Just van Stam <vstam1@users.noreply.github.com>
Co-authored-by: command-bot <>
This commit is contained in:
Keith Yeung
2023-06-05 22:39:01 +08:00
committed by GitHub
parent c8f9b1b7a0
commit f2fe05a757
29 changed files with 397 additions and 184 deletions
@@ -19,7 +19,7 @@
use crate::{generic, mock::*, *};
use codec::Decode;
use frame_support::{
parameter_types,
match_types, parameter_types,
traits::{Everything, OriginTrait},
weights::Weight,
};
@@ -33,7 +33,7 @@ use xcm_builder::{
Assets, TestAssetExchanger, TestAssetLocker, TestAssetTrap, TestSubscriptionService,
TestUniversalAliases,
},
AllowUnpaidExecutionFrom,
AliasForeignAccountId32, AllowUnpaidExecutionFrom,
};
use xcm_executor::traits::ConvertOrigin;
@@ -105,6 +105,13 @@ parameter_types! {
pub const MaxAssetsIntoHolding: u32 = 64;
}
match_types! {
pub type OnlyParachains: impl Contains<MultiLocation> = {
MultiLocation { parents: 0, interior: X1(Parachain(_)) }
};
}
type Aliasers = AliasForeignAccountId32<OnlyParachains>;
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
@@ -131,6 +138,7 @@ impl xcm_executor::Config for XcmConfig {
type UniversalAliases = TestUniversalAliases;
type CallDispatcher = RuntimeCall;
type SafeCallFilter = Everything;
type Aliasers = Aliasers;
}
impl crate::Config for Test {
@@ -191,6 +199,13 @@ impl generic::Config for Test {
// No MessageExporter in tests
Err(BenchmarkError::Skip)
}
fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError> {
let origin: MultiLocation =
(Parachain(1), AccountId32 { network: None, id: [0; 32] }).into();
let target: MultiLocation = AccountId32 { network: None, id: [0; 32] }.into();
Ok((origin, target))
}
}
#[cfg(feature = "runtime-benchmarks")]