diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 35dc79a4b5ef..aebc53fbec10 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -2202,6 +2202,11 @@ sp_api::impl_runtime_apis! { // Kusama doesn't support exporting messages Err(BenchmarkError::Skip) } + + fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError> { + // The XCM executor of Kusama doesn't have a configured `Aliasers` + Err(BenchmarkError::Skip) + } } let whitelist: Vec = vec![ diff --git a/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index e4790634faea..86932b997562 100644 --- a/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,7 +17,7 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -68,8 +68,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `211` // Estimated: `3676` - // Minimum execution time: 31_951_000 picoseconds. - Weight::from_parts(32_879_000, 3676) + // Minimum execution time: 32_102_000 picoseconds. + Weight::from_parts(33_749_000, 3676) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -77,8 +77,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_691_000 picoseconds. - Weight::from_parts(2_783_000, 0) + // Minimum execution time: 2_624_000 picoseconds. + Weight::from_parts(2_714_000, 0) } /// Storage: XcmPallet Queries (r:1 w:0) /// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured) @@ -86,58 +86,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `169` // Estimated: `3634` - // Minimum execution time: 10_819_000 picoseconds. - Weight::from_parts(11_035_000, 3634) + // Minimum execution time: 10_599_000 picoseconds. + Weight::from_parts(10_882_000, 3634) .saturating_add(T::DbWeight::get().reads(1)) } pub(crate) fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_035_000 picoseconds. - Weight::from_parts(12_454_000, 0) + // Minimum execution time: 11_985_000 picoseconds. + Weight::from_parts(12_274_000, 0) } pub(crate) fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_874_000 picoseconds. - Weight::from_parts(2_981_000, 0) + // Minimum execution time: 2_739_000 picoseconds. + Weight::from_parts(2_862_000, 0) } pub(crate) fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_632_000 picoseconds. - Weight::from_parts(2_703_000, 0) + // Minimum execution time: 2_533_000 picoseconds. + Weight::from_parts(2_646_000, 0) } pub(crate) fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_554_000 picoseconds. - Weight::from_parts(2_642_000, 0) + // Minimum execution time: 2_563_000 picoseconds. + Weight::from_parts(2_647_000, 0) } pub(crate) fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_642_000 picoseconds. - Weight::from_parts(2_761_000, 0) + // Minimum execution time: 2_512_000 picoseconds. + Weight::from_parts(2_574_000, 0) } pub(crate) fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_406_000 picoseconds. - Weight::from_parts(3_535_000, 0) + // Minimum execution time: 3_307_000 picoseconds. + Weight::from_parts(3_448_000, 0) } pub(crate) fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_568_000 picoseconds. - Weight::from_parts(2_647_000, 0) + // Minimum execution time: 2_524_000 picoseconds. + Weight::from_parts(2_614_000, 0) } /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) @@ -157,8 +157,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `211` // Estimated: `3676` - // Minimum execution time: 27_298_000 picoseconds. - Weight::from_parts(27_716_000, 3676) + // Minimum execution time: 27_275_000 picoseconds. + Weight::from_parts(27_861_000, 3676) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -168,8 +168,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `226` // Estimated: `3691` - // Minimum execution time: 14_960_000 picoseconds. - Weight::from_parts(15_461_000, 3691) + // Minimum execution time: 14_731_000 picoseconds. + Weight::from_parts(15_006_000, 3691) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -177,8 +177,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_667_000 picoseconds. - Weight::from_parts(2_736_000, 0) + // Minimum execution time: 2_446_000 picoseconds. + Weight::from_parts(2_581_000, 0) } /// Storage: XcmPallet VersionNotifyTargets (r:1 w:1) /// Proof Skipped: XcmPallet VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) @@ -200,8 +200,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `211` // Estimated: `3676` - // Minimum execution time: 34_532_000 picoseconds. - Weight::from_parts(35_207_000, 3676) + // Minimum execution time: 34_319_000 picoseconds. + Weight::from_parts(34_708_000, 3676) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -211,8 +211,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_196_000 picoseconds. - Weight::from_parts(5_283_000, 0) + // Minimum execution time: 4_974_000 picoseconds. + Weight::from_parts(5_155_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) @@ -233,8 +233,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `211` // Estimated: `3676` - // Minimum execution time: 31_259_000 picoseconds. - Weight::from_parts(31_897_000, 3676) + // Minimum execution time: 30_858_000 picoseconds. + Weight::from_parts(31_858_000, 3676) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -242,36 +242,36 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_102_000 picoseconds. - Weight::from_parts(4_197_000, 0) + // Minimum execution time: 4_059_000 picoseconds. + Weight::from_parts(4_125_000, 0) } pub(crate) fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_758_000 picoseconds. - Weight::from_parts(2_870_000, 0) + // Minimum execution time: 2_657_000 picoseconds. + Weight::from_parts(2_741_000, 0) } pub(crate) fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_629_000 picoseconds. - Weight::from_parts(2_755_000, 0) + // Minimum execution time: 2_585_000 picoseconds. + Weight::from_parts(2_653_000, 0) } pub(crate) fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_639_000 picoseconds. - Weight::from_parts(2_713_000, 0) + // Minimum execution time: 2_552_000 picoseconds. + Weight::from_parts(2_632_000, 0) } pub(crate) fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_842_000 picoseconds. - Weight::from_parts(2_928_000, 0) + // Minimum execution time: 2_682_000 picoseconds. + Weight::from_parts(2_763_000, 0) } /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) @@ -291,8 +291,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `211` // Estimated: `3676` - // Minimum execution time: 34_560_000 picoseconds. - Weight::from_parts(34_859_000, 3676) + // Minimum execution time: 34_316_000 picoseconds. + Weight::from_parts(34_682_000, 3676) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -300,8 +300,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_179_000 picoseconds. - Weight::from_parts(8_362_000, 0) + // Minimum execution time: 7_938_000 picoseconds. + Weight::from_parts(8_071_000, 0) } /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) @@ -321,8 +321,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `211` // Estimated: `3676` - // Minimum execution time: 27_036_000 picoseconds. - Weight::from_parts(27_743_000, 3676) + // Minimum execution time: 28_002_000 picoseconds. + Weight::from_parts(28_184_000, 3676) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -330,35 +330,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_614_000 picoseconds. - Weight::from_parts(2_688_000, 0) + // Minimum execution time: 2_520_000 picoseconds. + Weight::from_parts(2_617_000, 0) } pub(crate) fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_551_000 picoseconds. - Weight::from_parts(2_656_000, 0) + // Minimum execution time: 2_506_000 picoseconds. + Weight::from_parts(2_560_000, 0) } pub(crate) fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_597_000 picoseconds. - Weight::from_parts(2_708_000, 0) + // Minimum execution time: 2_503_000 picoseconds. + Weight::from_parts(2_605_000, 0) } pub(crate) fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_610_000 picoseconds. - Weight::from_parts(2_758_000, 0) + // Minimum execution time: 2_511_000 picoseconds. + Weight::from_parts(2_597_000, 0) } pub(crate) fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_766_000 picoseconds. - Weight::from_parts(3_372_000, 0) + // Minimum execution time: 2_617_000 picoseconds. + Weight::from_parts(2_715_000, 0) } } diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 28c65cdddbc9..c2fa52a59b4d 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -357,6 +357,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; type SafeCallFilter = SafeCallFilter; + type Aliasers = Nothing; } parameter_types! { diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index d154959781f9..54696f47ee6b 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -344,6 +344,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; type SafeCallFilter = SafeCallFilter; + type Aliasers = Nothing; } parameter_types! { diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 7614617d1738..e096a6642b4d 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -2299,6 +2299,11 @@ sp_api::impl_runtime_apis! { // Rococo doesn't support exporting messages Err(BenchmarkError::Skip) } + + fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError> { + // The XCM executor of Rococo doesn't have a configured `Aliasers` + Err(BenchmarkError::Skip) + } } let whitelist: Vec = vec![ diff --git a/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 1687fa44ed4a..11abc4666050 100644 --- a/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,7 +17,7 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 @@ -70,8 +70,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `565` // Estimated: `4030` - // Minimum execution time: 36_529_000 picoseconds. - Weight::from_parts(37_116_000, 4030) + // Minimum execution time: 36_305_000 picoseconds. + Weight::from_parts(37_096_000, 4030) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -79,8 +79,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_948_000 picoseconds. - Weight::from_parts(3_074_000, 0) + // Minimum execution time: 2_831_000 picoseconds. + Weight::from_parts(2_904_000, 0) } /// Storage: XcmPallet Queries (r:1 w:0) /// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured) @@ -88,58 +88,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `169` // Estimated: `3634` - // Minimum execution time: 12_012_000 picoseconds. - Weight::from_parts(12_426_000, 3634) + // Minimum execution time: 11_769_000 picoseconds. + Weight::from_parts(12_122_000, 3634) .saturating_add(T::DbWeight::get().reads(1)) } pub(crate) fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_498_000 picoseconds. - Weight::from_parts(12_765_000, 0) + // Minimum execution time: 12_293_000 picoseconds. + Weight::from_parts(12_522_000, 0) } pub(crate) fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_103_000 picoseconds. - Weight::from_parts(3_194_000, 0) + // Minimum execution time: 2_858_000 picoseconds. + Weight::from_parts(2_965_000, 0) } pub(crate) fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_827_000 picoseconds. - Weight::from_parts(2_925_000, 0) + // Minimum execution time: 2_623_000 picoseconds. + Weight::from_parts(2_774_000, 0) } pub(crate) fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_808_000 picoseconds. - Weight::from_parts(2_906_000, 0) + // Minimum execution time: 2_664_000 picoseconds. + Weight::from_parts(2_752_000, 0) } pub(crate) fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_857_000 picoseconds. - Weight::from_parts(2_904_000, 0) + // Minimum execution time: 2_646_000 picoseconds. + Weight::from_parts(2_709_000, 0) } pub(crate) fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_673_000 picoseconds. - Weight::from_parts(3_753_000, 0) + // Minimum execution time: 3_602_000 picoseconds. + Weight::from_parts(3_669_000, 0) } pub(crate) fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_803_000 picoseconds. - Weight::from_parts(2_888_000, 0) + // Minimum execution time: 2_609_000 picoseconds. + Weight::from_parts(2_721_000, 0) } /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) @@ -161,8 +161,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `565` // Estimated: `4030` - // Minimum execution time: 31_532_000 picoseconds. - Weight::from_parts(32_226_000, 4030) + // Minimum execution time: 31_776_000 picoseconds. + Weight::from_parts(32_354_000, 4030) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -172,8 +172,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `226` // Estimated: `3691` - // Minimum execution time: 15_956_000 picoseconds. - Weight::from_parts(16_320_000, 3691) + // Minimum execution time: 15_912_000 picoseconds. + Weight::from_parts(16_219_000, 3691) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -181,8 +181,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_846_000 picoseconds. - Weight::from_parts(2_928_000, 0) + // Minimum execution time: 2_704_000 picoseconds. + Weight::from_parts(2_777_000, 0) } /// Storage: XcmPallet VersionNotifyTargets (r:1 w:1) /// Proof Skipped: XcmPallet VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) @@ -206,8 +206,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `565` // Estimated: `4030` - // Minimum execution time: 38_534_000 picoseconds. - Weight::from_parts(39_292_000, 4030) + // Minimum execution time: 38_690_000 picoseconds. + Weight::from_parts(39_157_000, 4030) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -217,8 +217,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_212_000 picoseconds. - Weight::from_parts(5_337_000, 0) + // Minimum execution time: 4_943_000 picoseconds. + Weight::from_parts(5_128_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) @@ -241,8 +241,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `565` // Estimated: `4030` - // Minimum execution time: 35_468_000 picoseconds. - Weight::from_parts(35_805_000, 4030) + // Minimum execution time: 35_068_000 picoseconds. + Weight::from_parts(36_124_000, 4030) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -250,36 +250,36 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_606_000 picoseconds. - Weight::from_parts(4_706_000, 0) + // Minimum execution time: 6_438_000 picoseconds. + Weight::from_parts(6_500_000, 0) } pub(crate) fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_012_000 picoseconds. - Weight::from_parts(3_133_000, 0) + // Minimum execution time: 4_773_000 picoseconds. + Weight::from_parts(4_840_000, 0) } pub(crate) fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_926_000 picoseconds. - Weight::from_parts(3_038_000, 0) + // Minimum execution time: 2_818_000 picoseconds. + Weight::from_parts(2_893_000, 0) } pub(crate) fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_803_000 picoseconds. - Weight::from_parts(2_865_000, 0) + // Minimum execution time: 2_611_000 picoseconds. + Weight::from_parts(2_708_000, 0) } pub(crate) fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_037_000 picoseconds. - Weight::from_parts(3_124_000, 0) + // Minimum execution time: 2_870_000 picoseconds. + Weight::from_parts(2_958_000, 0) } /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) @@ -301,8 +301,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `565` // Estimated: `4030` - // Minimum execution time: 38_632_000 picoseconds. - Weight::from_parts(39_255_000, 4030) + // Minimum execution time: 40_735_000 picoseconds. + Weight::from_parts(66_023_000, 4030) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -310,8 +310,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_570_000 picoseconds. - Weight::from_parts(8_634_000, 0) + // Minimum execution time: 8_293_000 picoseconds. + Weight::from_parts(18_088_000, 0) } /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) @@ -333,8 +333,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `565` // Estimated: `4030` - // Minimum execution time: 31_792_000 picoseconds. - Weight::from_parts(32_271_000, 4030) + // Minimum execution time: 31_438_000 picoseconds. + Weight::from_parts(32_086_000, 4030) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -342,35 +342,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_861_000 picoseconds. - Weight::from_parts(2_967_000, 0) + // Minimum execution time: 2_676_000 picoseconds. + Weight::from_parts(2_746_000, 0) } pub(crate) fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_929_000 picoseconds. - Weight::from_parts(2_995_000, 0) + // Minimum execution time: 2_629_000 picoseconds. + Weight::from_parts(2_724_000, 0) } pub(crate) fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_861_000 picoseconds. - Weight::from_parts(2_961_000, 0) + // Minimum execution time: 2_602_000 picoseconds. + Weight::from_parts(2_671_000, 0) } pub(crate) fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_826_000 picoseconds. - Weight::from_parts(2_901_000, 0) + // Minimum execution time: 2_681_000 picoseconds. + Weight::from_parts(2_768_000, 0) } pub(crate) fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_603_000 picoseconds. - Weight::from_parts(4_653_000, 0) + // Minimum execution time: 2_764_000 picoseconds. + Weight::from_parts(2_865_000, 0) } } diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index e0e73bf3c4a3..b488ba73e6a7 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -331,6 +331,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; type SafeCallFilter = SafeCallFilter; + type Aliasers = Nothing; } parameter_types! { diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index 8d7c57224ea6..45e7956d45ba 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -115,6 +115,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = super::RuntimeCall; type SafeCallFilter = Everything; + type Aliasers = Nothing; } #[cfg(feature = "runtime-benchmarks")] diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 7963e911d010..d7850dcdd27d 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1989,6 +1989,11 @@ sp_api::impl_runtime_apis! { // Westend doesn't support exporting messages Err(BenchmarkError::Skip) } + + fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError> { + // The XCM executor of Westend doesn't have a configured `Aliasers` + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index d125e8bf88f9..7cf3f50bde6a 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,7 +17,7 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 @@ -68,8 +68,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `169` // Estimated: `3634` - // Minimum execution time: 31_799_000 picoseconds. - Weight::from_parts(32_268_000, 3634) + // Minimum execution time: 30_790_000 picoseconds. + Weight::from_parts(31_265_000, 3634) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -77,8 +77,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_114_000 picoseconds. - Weight::from_parts(3_209_000, 0) + // Minimum execution time: 2_741_000 picoseconds. + Weight::from_parts(2_823_000, 0) } /// Storage: XcmPallet Queries (r:1 w:0) /// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured) @@ -86,58 +86,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `169` // Estimated: `3634` - // Minimum execution time: 11_350_000 picoseconds. - Weight::from_parts(11_664_000, 3634) + // Minimum execution time: 10_848_000 picoseconds. + Weight::from_parts(11_183_000, 3634) .saturating_add(T::DbWeight::get().reads(1)) } pub(crate) fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_740_000 picoseconds. - Weight::from_parts(12_997_000, 0) + // Minimum execution time: 12_145_000 picoseconds. + Weight::from_parts(12_366_000, 0) } pub(crate) fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_182_000 picoseconds. - Weight::from_parts(3_258_000, 0) + // Minimum execution time: 2_837_000 picoseconds. + Weight::from_parts(2_939_000, 0) } pub(crate) fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_909_000 picoseconds. - Weight::from_parts(2_973_000, 0) + // Minimum execution time: 2_526_000 picoseconds. + Weight::from_parts(2_622_000, 0) } pub(crate) fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_967_000 picoseconds. - Weight::from_parts(3_042_000, 0) + // Minimum execution time: 2_603_000 picoseconds. + Weight::from_parts(2_642_000, 0) } pub(crate) fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_980_000 picoseconds. - Weight::from_parts(3_041_000, 0) + // Minimum execution time: 2_500_000 picoseconds. + Weight::from_parts(2_573_000, 0) } pub(crate) fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_798_000 picoseconds. - Weight::from_parts(3_877_000, 0) + // Minimum execution time: 3_323_000 picoseconds. + Weight::from_parts(3_401_000, 0) } pub(crate) fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_884_000 picoseconds. - Weight::from_parts(2_951_000, 0) + // Minimum execution time: 2_557_000 picoseconds. + Weight::from_parts(2_620_000, 0) } /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) @@ -157,8 +157,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `169` // Estimated: `3634` - // Minimum execution time: 26_538_000 picoseconds. - Weight::from_parts(27_107_000, 3634) + // Minimum execution time: 25_828_000 picoseconds. + Weight::from_parts(26_318_000, 3634) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -168,8 +168,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `226` // Estimated: `3691` - // Minimum execution time: 15_633_000 picoseconds. - Weight::from_parts(15_851_000, 3691) + // Minimum execution time: 14_794_000 picoseconds. + Weight::from_parts(15_306_000, 3691) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -177,8 +177,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_873_000 picoseconds. - Weight::from_parts(2_998_000, 0) + // Minimum execution time: 2_534_000 picoseconds. + Weight::from_parts(2_574_000, 0) } /// Storage: XcmPallet VersionNotifyTargets (r:1 w:1) /// Proof Skipped: XcmPallet VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) @@ -200,8 +200,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `169` // Estimated: `3634` - // Minimum execution time: 33_283_000 picoseconds. - Weight::from_parts(33_682_000, 3634) + // Minimum execution time: 32_218_000 picoseconds. + Weight::from_parts(32_945_000, 3634) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -211,8 +211,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_240_000 picoseconds. - Weight::from_parts(5_345_000, 0) + // Minimum execution time: 4_983_000 picoseconds. + Weight::from_parts(5_132_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) @@ -233,8 +233,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `169` // Estimated: `3634` - // Minimum execution time: 30_487_000 picoseconds. - Weight::from_parts(30_935_000, 3634) + // Minimum execution time: 29_375_000 picoseconds. + Weight::from_parts(30_320_000, 3634) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -242,36 +242,36 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_584_000 picoseconds. - Weight::from_parts(4_658_000, 0) + // Minimum execution time: 4_101_000 picoseconds. + Weight::from_parts(4_228_000, 0) } pub(crate) fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_112_000 picoseconds. - Weight::from_parts(3_203_000, 0) + // Minimum execution time: 2_740_000 picoseconds. + Weight::from_parts(2_814_000, 0) } pub(crate) fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_033_000 picoseconds. - Weight::from_parts(3_095_000, 0) + // Minimum execution time: 2_716_000 picoseconds. + Weight::from_parts(2_795_000, 0) } pub(crate) fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_945_000 picoseconds. - Weight::from_parts(3_014_000, 0) + // Minimum execution time: 2_550_000 picoseconds. + Weight::from_parts(2_601_000, 0) } pub(crate) fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_117_000 picoseconds. - Weight::from_parts(3_204_000, 0) + // Minimum execution time: 2_762_000 picoseconds. + Weight::from_parts(2_849_000, 0) } /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) @@ -291,8 +291,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `169` // Estimated: `3634` - // Minimum execution time: 32_939_000 picoseconds. - Weight::from_parts(33_499_000, 3634) + // Minimum execution time: 31_709_000 picoseconds. + Weight::from_parts(32_288_000, 3634) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -300,8 +300,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_781_000 picoseconds. - Weight::from_parts(7_881_000, 0) + // Minimum execution time: 7_209_000 picoseconds. + Weight::from_parts(7_332_000, 0) } /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) @@ -321,8 +321,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `169` // Estimated: `3634` - // Minimum execution time: 26_864_000 picoseconds. - Weight::from_parts(27_419_000, 3634) + // Minimum execution time: 26_161_000 picoseconds. + Weight::from_parts(26_605_000, 3634) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -330,35 +330,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_000_000 picoseconds. - Weight::from_parts(3_061_000, 0) + // Minimum execution time: 2_539_000 picoseconds. + Weight::from_parts(2_647_000, 0) } pub(crate) fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_881_000 picoseconds. - Weight::from_parts(2_968_000, 0) + // Minimum execution time: 2_494_000 picoseconds. + Weight::from_parts(2_588_000, 0) } pub(crate) fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_902_000 picoseconds. - Weight::from_parts(2_976_000, 0) + // Minimum execution time: 2_510_000 picoseconds. + Weight::from_parts(2_590_000, 0) } pub(crate) fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_907_000 picoseconds. - Weight::from_parts(2_981_000, 0) + // Minimum execution time: 2_491_000 picoseconds. + Weight::from_parts(2_546_000, 0) } pub(crate) fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_136_000 picoseconds. - Weight::from_parts(3_184_000, 0) + // Minimum execution time: 2_696_000 picoseconds. + Weight::from_parts(2_816_000, 0) } } diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index c3c28e8c3fe7..d6a3feb3bc0f 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -268,6 +268,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; type SafeCallFilter = SafeCallFilter; + type Aliasers = Nothing; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location diff --git a/xcm/pallet-xcm-benchmarks/Cargo.toml b/xcm/pallet-xcm-benchmarks/Cargo.toml index c9c04d533cd5..34a5a8fa9c88 100644 --- a/xcm/pallet-xcm-benchmarks/Cargo.toml +++ b/xcm/pallet-xcm-benchmarks/Cargo.toml @@ -49,6 +49,7 @@ std = [ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index a6dd469a868f..6f99ac60fc7b 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -159,6 +159,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; + type Aliasers = Nothing; } impl crate::Config for Test { diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 9a4519937aea..fa062ce0f84d 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -634,6 +634,19 @@ benchmarks! { executor.bench_process(xcm)?; } + alias_origin { + let (origin, target) = T::alias_origin().map_err(|_| BenchmarkError::Skip)?; + + let mut executor = new_executor::(origin); + + let instruction = Instruction::AliasOrigin(target.clone()); + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } verify { + assert_eq!(executor.origin(), &Some(target)); + } + impl_benchmark_test_suite!( Pallet, crate::generic::mock::new_test_ext(), diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 9110d55f800a..2d1df0164ab4 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -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 { parents: 0, interior: X1(Parachain(_)) } + }; +} + +type Aliasers = AliasForeignAccountId32; 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")] diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index 17e8aa6de95f..e5fce008a0f2 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -80,6 +80,11 @@ pub mod pallet { /// If set to `Err`, benchmarks which rely on `export_message` will be skipped. fn export_message_origin_and_destination( ) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError>; + + /// A `(MultiLocation, MultiLocation)` that is one of the `Aliasers` configured by the XCM executor. + /// + /// If set to `Err`, benchmarks which rely on a universal alias will be skipped. + fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError>; } #[pallet::pallet] diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 6cfc1447e2b4..2d3cc385c230 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -310,6 +310,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; + type Aliasers = Nothing; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index 124e83d3c338..41cb0a833195 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -97,5 +97,8 @@ pub use universal_exports::{ SovereignPaidRemoteExporter, UnpaidLocalExporter, UnpaidRemoteExporter, }; +mod origin_aliases; +pub use origin_aliases::AliasForeignAccountId32; + mod pay; pub use pay::{FixedLocation, LocatableAssetId, PayAccountId32OnChainOverXcm, PayOverXcm}; diff --git a/xcm/xcm-builder/src/origin_aliases.rs b/xcm/xcm-builder/src/origin_aliases.rs new file mode 100644 index 000000000000..d9e3ee3dfc4f --- /dev/null +++ b/xcm/xcm-builder/src/origin_aliases.rs @@ -0,0 +1,37 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . + +//! Implementation for ContainsPair. + +use frame_support::traits::{Contains, ContainsPair}; +use sp_std::marker::PhantomData; +use xcm::latest::prelude::*; + +/// Alias a Foreign AccountId32 with a local AccountId32 if the Foreign AccountId32 matches the `Prefix` pattern. +/// +/// Requires that the prefixed origin AccountId32 matches the target AccountId32. +pub struct AliasForeignAccountId32(PhantomData); +impl> ContainsPair + for AliasForeignAccountId32 +{ + fn contains(origin: &MultiLocation, target: &MultiLocation) -> bool { + if let (prefix, Some(account_id @ AccountId32 { .. })) = origin.split_last_interior() { + return Prefix::contains(&prefix) && + *target == MultiLocation { parents: 0, interior: X1(account_id) } + } + false + } +} diff --git a/xcm/xcm-builder/src/tests/aliases.rs b/xcm/xcm-builder/src/tests/aliases.rs new file mode 100644 index 000000000000..f686926a2522 --- /dev/null +++ b/xcm/xcm-builder/src/tests/aliases.rs @@ -0,0 +1,85 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . + +use super::*; + +#[test] +fn alias_foreign_account_sibling_prefix() { + // Accounts Differ + assert!(!AliasForeignAccountId32::::contains( + &(Parent, Parachain(1), AccountId32 { network: None, id: [0; 32] }).into(), + &(AccountId32 { network: None, id: [1; 32] }).into() + )); + + assert!(AliasForeignAccountId32::::contains( + &(Parent, Parachain(1), AccountId32 { network: None, id: [0; 32] }).into(), + &(AccountId32 { network: None, id: [0; 32] }).into() + )); +} + +#[test] +fn alias_foreign_account_child_prefix() { + // Accounts Differ + assert!(!AliasForeignAccountId32::::contains( + &(Parachain(1), AccountId32 { network: None, id: [0; 32] }).into(), + &(AccountId32 { network: None, id: [1; 32] }).into() + )); + + assert!(AliasForeignAccountId32::::contains( + &(Parachain(1), AccountId32 { network: None, id: [0; 32] }).into(), + &(AccountId32 { network: None, id: [0; 32] }).into() + )); +} + +#[test] +fn alias_foreign_account_parent_prefix() { + // Accounts Differ + assert!(!AliasForeignAccountId32::::contains( + &(Parent, AccountId32 { network: None, id: [0; 32] }).into(), + &(AccountId32 { network: None, id: [1; 32] }).into() + )); + + assert!(AliasForeignAccountId32::::contains( + &(Parent, AccountId32 { network: None, id: [0; 32] }).into(), + &(AccountId32 { network: None, id: [0; 32] }).into() + )); +} + +#[test] +fn alias_origin_should_work() { + AllowUnpaidFrom::set(vec![ + (Parent, Parachain(1), AccountId32 { network: None, id: [0; 32] }).into(), + (Parachain(1), AccountId32 { network: None, id: [0; 32] }).into(), + ]); + + let message = Xcm(vec![AliasOrigin((AccountId32 { network: None, id: [0; 32] }).into())]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm( + (Parachain(1), AccountId32 { network: None, id: [0; 32] }), + message.clone(), + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::NoPermission)); + + let r = XcmExecutor::::execute_xcm( + (Parent, Parachain(1), AccountId32 { network: None, id: [0; 32] }), + message.clone(), + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); +} diff --git a/xcm/xcm-builder/src/tests/mock.rs b/xcm/xcm-builder/src/tests/mock.rs index b87e78df5b12..66a676369a67 100644 --- a/xcm/xcm-builder/src/tests/mock.rs +++ b/xcm/xcm-builder/src/tests/mock.rs @@ -19,8 +19,9 @@ use crate::{ test_utils::*, }; pub use crate::{ - AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowTopLevelPaidExecutionFrom, - AllowUnpaidExecutionFrom, FixedRateOfFungible, FixedWeightBounds, TakeWeightCredit, + AliasForeignAccountId32, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, + AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, FixedRateOfFungible, + FixedWeightBounds, TakeWeightCredit, }; use frame_support::traits::{ContainsPair, Everything}; pub use frame_support::{ @@ -28,9 +29,9 @@ pub use frame_support::{ DispatchError, DispatchInfo, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo, Parameter, PostDispatchInfo, }, - ensure, parameter_types, + ensure, match_types, parameter_types, sp_runtime::DispatchErrorWithPostInfo, - traits::{Contains, Get, IsInVec}, + traits::{ConstU32, Contains, Get, IsInVec}, }; pub use parity_scale_codec::{Decode, Encode}; pub use sp_io::hashing::blake2_256; @@ -646,6 +647,18 @@ impl AssetExchange for TestAssetExchange { } } +match_types! { + pub type SiblingPrefix: impl Contains = { + MultiLocation { parents: 1, interior: X1(Parachain(_)) } + }; + pub type ChildPrefix: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(_)) } + }; + pub type ParentPrefix: impl Contains = { + MultiLocation { parents: 1, interior: Here } + }; +} + pub struct TestConfig; impl Config for TestConfig { type RuntimeCall = TestCall; @@ -671,6 +684,7 @@ impl Config for TestConfig { type MessageExporter = TestMessageExporter; type CallDispatcher = TestCall; type SafeCallFilter = Everything; + type Aliasers = AliasForeignAccountId32; } pub fn fungible_multi_asset(location: MultiLocation, amount: u128) -> MultiAsset { diff --git a/xcm/xcm-builder/src/tests/mod.rs b/xcm/xcm-builder/src/tests/mod.rs index 62172005a0cf..6daf1872f055 100644 --- a/xcm/xcm-builder/src/tests/mod.rs +++ b/xcm/xcm-builder/src/tests/mod.rs @@ -26,6 +26,7 @@ use xcm_executor::{traits::prelude::*, Config, XcmExecutor}; mod mock; use mock::*; +mod aliases; mod assets; mod barriers; mod basic; diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 2cee366742ce..6c2c8f222add 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -203,6 +203,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; + type Aliasers = Nothing; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index 2672eb41502f..1fc5cef39215 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -45,6 +45,10 @@ pub trait Config { /// Combinations of (Asset, Location) pairs which we trust as teleporters. type IsTeleporter: ContainsPair; + /// A list of (Origin, Target) pairs allowing a given Origin to be substituted with its + /// corresponding Target pair. + type Aliasers: ContainsPair; + /// This chain's Universal Location. type UniversalLocation: Get; diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 16f53fd6503b..050d73837085 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -914,7 +914,15 @@ impl XcmExecutor { self.context.topic = None; Ok(()) }, - AliasOrigin(_) => Err(XcmError::NoPermission), + AliasOrigin(target) => { + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; + if Config::Aliasers::contains(origin, &target) { + self.context.origin = Some(target); + Ok(()) + } else { + Err(XcmError::NoPermission) + } + }, UnpaidExecution { check_origin, .. } => { ensure!( check_origin.is_none() || self.context.origin == check_origin, diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 39a2e27470b2..b79c6662f4c6 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -250,6 +250,7 @@ impl Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; + type Aliasers = Nothing; } #[frame_support::pallet] diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index 10ad9b68c634..6f64249b40fc 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -194,6 +194,7 @@ impl Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; + type Aliasers = Nothing; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index 4934bd6ab1c1..26438f02f45f 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -163,6 +163,7 @@ impl Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; + type Aliasers = Nothing; } #[frame_support::pallet] diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 6b0023a78965..75b42e300316 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -158,6 +158,7 @@ impl Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; + type Aliasers = Nothing; } pub type LocalOriginToLocation = SignedToAccountId32;