From ad92061a1a14af0a260b34e14f97f0df4d415304 Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 15 Jul 2024 12:04:56 +0200 Subject: [PATCH 1/5] kusama: General Admin to Location mapping --- relay/kusama/src/xcm_config.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/relay/kusama/src/xcm_config.rs b/relay/kusama/src/xcm_config.rs index e404ddf1c8..2ea2a41688 100644 --- a/relay/kusama/src/xcm_config.rs +++ b/relay/kusama/src/xcm_config.rs @@ -17,9 +17,9 @@ //! XCM configurations for the Kusama runtime. use super::{ - parachains_origin, AccountId, AllPalletsWithSystem, Balances, Dmp, Fellows, ParaId, Runtime, - RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, TransactionByteFee, Treasury, - WeightToFee, XcmPallet, + parachains_origin, AccountId, AllPalletsWithSystem, Balances, Dmp, Fellows, GeneralAdmin, + ParaId, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, TransactionByteFee, + Treasury, WeightToFee, XcmPallet, }; use frame_support::{ parameter_types, @@ -234,6 +234,8 @@ parameter_types! { pub const StakingAdminBodyId: BodyId = BodyId::Defense; // Fellows pluralistic body. pub const FellowsBodyId: BodyId = BodyId::Technical; + // `GeneralAdmin` pluralistic body. + pub const GeneralAdminBodyId: BodyId = BodyId::Administration; } /// Type to convert an `Origin` type value into a `Location` value which represents an interior @@ -250,9 +252,15 @@ pub type StakingAdminToPlurality = /// Type to convert the Fellows origin to a Plurality `Location` value. pub type FellowsToPlurality = OriginToPluralityVoice; +/// Type to convert the `GeneralAdmin` origin to a Plurality `Location` value. +pub type GeneralAdminToPlurality = + OriginToPluralityVoice; + /// Type to convert a pallet `Origin` type value into a `Location` value which represents an /// interior location of this chain for a destination chain. pub type LocalPalletOrSignedOriginToLocation = ( + // GeneralAdmin origin to be used in XCM as a corresponding Plurality `Location` value. + GeneralAdminToPlurality, // StakingAdmin origin to be used in XCM as a corresponding Plurality `Location` value. StakingAdminToPlurality, // Fellows origin to be used in XCM as a corresponding Plurality `Location` value. From dc0391f56af0727dcc0a15bc725e0326837e9fea Mon Sep 17 00:00:00 2001 From: muharem Date: Tue, 16 Jul 2024 11:35:16 +0200 Subject: [PATCH 2/5] tests --- .../tests/people/people-kusama/Cargo.toml | 1 + .../people-kusama/src/tests/governance.rs | 124 ++++++++++++++++++ .../people/people-kusama/src/tests/mod.rs | 1 + .../people-kusama/src/tests/teleport.rs | 12 +- .../tests/people/people-polkadot/Cargo.toml | 1 + .../people-polkadot/src/tests/governance.rs | 124 ++++++++++++++++++ .../people/people-polkadot/src/tests/mod.rs | 1 + .../people-polkadot/src/tests/teleport.rs | 12 +- 8 files changed, 270 insertions(+), 6 deletions(-) create mode 100644 integration-tests/emulated/tests/people/people-kusama/src/tests/governance.rs create mode 100644 integration-tests/emulated/tests/people/people-polkadot/src/tests/governance.rs diff --git a/integration-tests/emulated/tests/people/people-kusama/Cargo.toml b/integration-tests/emulated/tests/people/people-kusama/Cargo.toml index d14a9f43a9..58b1a66d8b 100644 --- a/integration-tests/emulated/tests/people/people-kusama/Cargo.toml +++ b/integration-tests/emulated/tests/people/people-kusama/Cargo.toml @@ -20,6 +20,7 @@ pallet-identity = { workspace = true, default-features = true } # Polkadot polkadot-runtime-common = { workspace = true, default-features = true } xcm = { workspace = true, default-features = true } +pallet-xcm = { workspace = true, default-features = true } xcm-executor = { workspace = true } # Cumulus diff --git a/integration-tests/emulated/tests/people/people-kusama/src/tests/governance.rs b/integration-tests/emulated/tests/people/people-kusama/src/tests/governance.rs new file mode 100644 index 0000000000..71dd23774c --- /dev/null +++ b/integration-tests/emulated/tests/people/people-kusama/src/tests/governance.rs @@ -0,0 +1,124 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::*; +use frame_support::sp_runtime::traits::Dispatchable; +use kusama_runtime::governance::pallet_custom_origins::Origin::GeneralAdmin as GeneralAdminOrigin; + +#[test] +fn general_admin_add_registrar() { + let registrar: AccountId = [1; 32].into(); + Kusama::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type RuntimeOrigin = ::RuntimeOrigin; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_registrar_call = + PeopleCall::Identity(pallet_identity::Call::::add_registrar { + account: registrar.into(), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::V4(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::V4(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind: OriginKind::Xcm, + require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), + call: add_registrar_call.encode().into(), + } + ]))), + }); + + let general_admin: RuntimeOrigin = GeneralAdminOrigin.into(); + + assert_ok!(xcm_message.dispatch(general_admin)); + + assert_expected_events!( + Kusama, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeopleKusama::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleKusama, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); +} + +#[test] +fn relay_root_add_registrar() { + let registrar: AccountId = [1; 32].into(); + Kusama::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type RuntimeOrigin = ::RuntimeOrigin; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_registrar_call = + PeopleCall::Identity(pallet_identity::Call::::add_registrar { + account: registrar.into(), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::V4(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::V4(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind: OriginKind::Superuser, + require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), + call: add_registrar_call.encode().into(), + } + ]))), + }); + + let root: RuntimeOrigin = RuntimeOrigin::root(); + + assert_ok!(xcm_message.dispatch(root)); + + assert_expected_events!( + Kusama, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeopleKusama::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleKusama, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); +} diff --git a/integration-tests/emulated/tests/people/people-kusama/src/tests/mod.rs b/integration-tests/emulated/tests/people/people-kusama/src/tests/mod.rs index 516ec37cc1..40ee1de643 100644 --- a/integration-tests/emulated/tests/people/people-kusama/src/tests/mod.rs +++ b/integration-tests/emulated/tests/people/people-kusama/src/tests/mod.rs @@ -13,4 +13,5 @@ // See the License for the specific language governing permissions and // limitations under the License. +mod governance; mod teleport; diff --git a/integration-tests/emulated/tests/people/people-kusama/src/tests/teleport.rs b/integration-tests/emulated/tests/people/people-kusama/src/tests/teleport.rs index 33647a3c43..ae6d190703 100644 --- a/integration-tests/emulated/tests/people/people-kusama/src/tests/teleport.rs +++ b/integration-tests/emulated/tests/people/people-kusama/src/tests/teleport.rs @@ -157,7 +157,9 @@ fn limited_teleport_native_assets_from_relay_to_system_para_works() { let delivery_fees = Kusama::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) + >( + test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest + ) }); let sender_balance_after = test.sender.balance; @@ -206,7 +208,9 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { let delivery_fees = PeopleKusama::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) + >( + test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest + ) }); // Sender's balance is reduced @@ -250,7 +254,9 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() { let delivery_fees = PeopleKusama::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) + >( + test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest + ) }); // Sender's balance is reduced diff --git a/integration-tests/emulated/tests/people/people-polkadot/Cargo.toml b/integration-tests/emulated/tests/people/people-polkadot/Cargo.toml index ed9fef5f81..5276c94e56 100644 --- a/integration-tests/emulated/tests/people/people-polkadot/Cargo.toml +++ b/integration-tests/emulated/tests/people/people-polkadot/Cargo.toml @@ -20,6 +20,7 @@ pallet-identity = { workspace = true, default-features = true } # Polkadot polkadot-runtime-common = { workspace = true, default-features = true } xcm = { workspace = true, default-features = true } +pallet-xcm = { workspace = true, default-features = true } xcm-executor = { workspace = true } # Cumulus diff --git a/integration-tests/emulated/tests/people/people-polkadot/src/tests/governance.rs b/integration-tests/emulated/tests/people/people-polkadot/src/tests/governance.rs new file mode 100644 index 0000000000..8857487c28 --- /dev/null +++ b/integration-tests/emulated/tests/people/people-polkadot/src/tests/governance.rs @@ -0,0 +1,124 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::*; +use frame_support::sp_runtime::traits::Dispatchable; +use polkadot_runtime::governance::pallet_custom_origins::Origin::GeneralAdmin as GeneralAdminOrigin; + +#[test] +fn general_admin_add_registrar() { + let registrar: AccountId = [1; 32].into(); + Polkadot::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type RuntimeOrigin = ::RuntimeOrigin; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_registrar_call = + PeopleCall::Identity(pallet_identity::Call::::add_registrar { + account: registrar.into(), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::V4(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::V4(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind: OriginKind::Xcm, + require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), + call: add_registrar_call.encode().into(), + } + ]))), + }); + + let general_admin: RuntimeOrigin = GeneralAdminOrigin.into(); + + assert_ok!(xcm_message.dispatch(general_admin)); + + assert_expected_events!( + Polkadot, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeoplePolkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeoplePolkadot, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); +} + +#[test] +fn relay_root_add_registrar() { + let registrar: AccountId = [1; 32].into(); + Polkadot::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type RuntimeOrigin = ::RuntimeOrigin; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_registrar_call = + PeopleCall::Identity(pallet_identity::Call::::add_registrar { + account: registrar.into(), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::V4(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::V4(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind: OriginKind::Superuser, + require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), + call: add_registrar_call.encode().into(), + } + ]))), + }); + + let root: RuntimeOrigin = RuntimeOrigin::root(); + + assert_ok!(xcm_message.dispatch(root)); + + assert_expected_events!( + Polkadot, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeoplePolkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeoplePolkadot, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); +} diff --git a/integration-tests/emulated/tests/people/people-polkadot/src/tests/mod.rs b/integration-tests/emulated/tests/people/people-polkadot/src/tests/mod.rs index 80c00021ca..6d61e2fea9 100644 --- a/integration-tests/emulated/tests/people/people-polkadot/src/tests/mod.rs +++ b/integration-tests/emulated/tests/people/people-polkadot/src/tests/mod.rs @@ -13,5 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. +mod governance; mod reap_identity; mod teleport; diff --git a/integration-tests/emulated/tests/people/people-polkadot/src/tests/teleport.rs b/integration-tests/emulated/tests/people/people-polkadot/src/tests/teleport.rs index 3907a941a5..493b81733e 100644 --- a/integration-tests/emulated/tests/people/people-polkadot/src/tests/teleport.rs +++ b/integration-tests/emulated/tests/people/people-polkadot/src/tests/teleport.rs @@ -157,7 +157,9 @@ fn limited_teleport_native_assets_from_relay_to_system_para_works() { let delivery_fees = Polkadot::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) + >( + test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest + ) }); let sender_balance_after = test.sender.balance; @@ -206,7 +208,9 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { let delivery_fees = PeoplePolkadot::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) + >( + test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest + ) }); // Sender's balance is reduced @@ -250,7 +254,9 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() { let delivery_fees = PeoplePolkadot::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) + >( + test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest + ) }); // Sender's balance is reduced From c544bc2e35726cb3201b1176127626d5f7b77e01 Mon Sep 17 00:00:00 2001 From: muharem Date: Tue, 16 Jul 2024 11:39:44 +0200 Subject: [PATCH 3/5] changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5af3b2d71c..636a737925 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ Changelog for the runtimes governed by the Polkadot Fellowship. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [Unreleased] + +### Added + +- Kusama: Relay General Admin Origin mapping to xcm Location ([polkadot-fellows/runtimes#383](https://github.com/polkadot-fellows/runtimes/pull/383)) + ## [1.2.8] 03.07.2024 ### Added From c5dc12239ec56121f9b0e866b95de56c6aafd64b Mon Sep 17 00:00:00 2001 From: muharem Date: Tue, 16 Jul 2024 17:07:09 +0200 Subject: [PATCH 4/5] tests fix --- .../people-kusama/src/tests/governance.rs | 144 ++++++------------ .../people-kusama/src/tests/teleport.rs | 12 +- .../people-polkadot/src/tests/governance.rs | 144 ++++++------------ .../people-polkadot/src/tests/teleport.rs | 12 +- 4 files changed, 100 insertions(+), 212 deletions(-) diff --git a/integration-tests/emulated/tests/people/people-kusama/src/tests/governance.rs b/integration-tests/emulated/tests/people/people-kusama/src/tests/governance.rs index 71dd23774c..50b4bd5626 100644 --- a/integration-tests/emulated/tests/people/people-kusama/src/tests/governance.rs +++ b/integration-tests/emulated/tests/people/people-kusama/src/tests/governance.rs @@ -18,107 +18,57 @@ use frame_support::sp_runtime::traits::Dispatchable; use kusama_runtime::governance::pallet_custom_origins::Origin::GeneralAdmin as GeneralAdminOrigin; #[test] -fn general_admin_add_registrar() { - let registrar: AccountId = [1; 32].into(); - Kusama::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type RuntimeOrigin = ::RuntimeOrigin; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; - - let add_registrar_call = - PeopleCall::Identity(pallet_identity::Call::::add_registrar { - account: registrar.into(), +fn relay_commands_add_registrar() { + let origins = vec![ + (OriginKind::Xcm, GeneralAdminOrigin.into()), + (OriginKind::Superuser, ::RuntimeOrigin::root()), + ]; + for (origin_kind, origin) in origins { + let registrar: AccountId = [1; 32].into(); + Kusama::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_registrar_call = + PeopleCall::Identity(pallet_identity::Call::::add_registrar { + account: registrar.into(), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::V4(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::V4(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), + call: add_registrar_call.encode().into(), + } + ]))), }); - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::V4(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::V4(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind: OriginKind::Xcm, - require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), - call: add_registrar_call.encode().into(), - } - ]))), - }); - - let general_admin: RuntimeOrigin = GeneralAdminOrigin.into(); - - assert_ok!(xcm_message.dispatch(general_admin)); - - assert_expected_events!( - Kusama, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - PeopleKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeopleKusama, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); -} - -#[test] -fn relay_root_add_registrar() { - let registrar: AccountId = [1; 32].into(); - Kusama::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type RuntimeOrigin = ::RuntimeOrigin; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; - - let add_registrar_call = - PeopleCall::Identity(pallet_identity::Call::::add_registrar { - account: registrar.into(), - }); + assert_ok!(xcm_message.dispatch(origin)); - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::V4(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::V4(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind: OriginKind::Superuser, - require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), - call: add_registrar_call.encode().into(), - } - ]))), + assert_expected_events!( + Kusama, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); }); - let root: RuntimeOrigin = RuntimeOrigin::root(); + PeopleKusama::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; - assert_ok!(xcm_message.dispatch(root)); - - assert_expected_events!( - Kusama, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - PeopleKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeopleKusama, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); + assert_expected_events!( + PeopleKusama, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); + } } diff --git a/integration-tests/emulated/tests/people/people-kusama/src/tests/teleport.rs b/integration-tests/emulated/tests/people/people-kusama/src/tests/teleport.rs index ae6d190703..33647a3c43 100644 --- a/integration-tests/emulated/tests/people/people-kusama/src/tests/teleport.rs +++ b/integration-tests/emulated/tests/people/people-kusama/src/tests/teleport.rs @@ -157,9 +157,7 @@ fn limited_teleport_native_assets_from_relay_to_system_para_works() { let delivery_fees = Kusama::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >( - test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest - ) + >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) }); let sender_balance_after = test.sender.balance; @@ -208,9 +206,7 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { let delivery_fees = PeopleKusama::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >( - test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest - ) + >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) }); // Sender's balance is reduced @@ -254,9 +250,7 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() { let delivery_fees = PeopleKusama::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >( - test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest - ) + >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) }); // Sender's balance is reduced diff --git a/integration-tests/emulated/tests/people/people-polkadot/src/tests/governance.rs b/integration-tests/emulated/tests/people/people-polkadot/src/tests/governance.rs index 8857487c28..8adba4ddd8 100644 --- a/integration-tests/emulated/tests/people/people-polkadot/src/tests/governance.rs +++ b/integration-tests/emulated/tests/people/people-polkadot/src/tests/governance.rs @@ -18,107 +18,57 @@ use frame_support::sp_runtime::traits::Dispatchable; use polkadot_runtime::governance::pallet_custom_origins::Origin::GeneralAdmin as GeneralAdminOrigin; #[test] -fn general_admin_add_registrar() { - let registrar: AccountId = [1; 32].into(); - Polkadot::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type RuntimeOrigin = ::RuntimeOrigin; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; - - let add_registrar_call = - PeopleCall::Identity(pallet_identity::Call::::add_registrar { - account: registrar.into(), +fn relay_commands_add_registrar() { + let origins = vec![ + (OriginKind::Xcm, GeneralAdminOrigin.into()), + (OriginKind::Superuser, ::RuntimeOrigin::root()), + ]; + for (origin_kind, origin) in origins { + let registrar: AccountId = [1; 32].into(); + Polkadot::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_registrar_call = + PeopleCall::Identity(pallet_identity::Call::::add_registrar { + account: registrar.into(), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::V4(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::V4(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), + call: add_registrar_call.encode().into(), + } + ]))), }); - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::V4(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::V4(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind: OriginKind::Xcm, - require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), - call: add_registrar_call.encode().into(), - } - ]))), - }); - - let general_admin: RuntimeOrigin = GeneralAdminOrigin.into(); - - assert_ok!(xcm_message.dispatch(general_admin)); - - assert_expected_events!( - Polkadot, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - PeoplePolkadot::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeoplePolkadot, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); -} - -#[test] -fn relay_root_add_registrar() { - let registrar: AccountId = [1; 32].into(); - Polkadot::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type RuntimeOrigin = ::RuntimeOrigin; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; - - let add_registrar_call = - PeopleCall::Identity(pallet_identity::Call::::add_registrar { - account: registrar.into(), - }); + assert_ok!(xcm_message.dispatch(origin)); - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::V4(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::V4(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind: OriginKind::Superuser, - require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), - call: add_registrar_call.encode().into(), - } - ]))), + assert_expected_events!( + Polkadot, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); }); - let root: RuntimeOrigin = RuntimeOrigin::root(); + PeoplePolkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; - assert_ok!(xcm_message.dispatch(root)); - - assert_expected_events!( - Polkadot, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - PeoplePolkadot::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeoplePolkadot, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); + assert_expected_events!( + PeoplePolkadot, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); + } } diff --git a/integration-tests/emulated/tests/people/people-polkadot/src/tests/teleport.rs b/integration-tests/emulated/tests/people/people-polkadot/src/tests/teleport.rs index 493b81733e..3907a941a5 100644 --- a/integration-tests/emulated/tests/people/people-polkadot/src/tests/teleport.rs +++ b/integration-tests/emulated/tests/people/people-polkadot/src/tests/teleport.rs @@ -157,9 +157,7 @@ fn limited_teleport_native_assets_from_relay_to_system_para_works() { let delivery_fees = Polkadot::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >( - test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest - ) + >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) }); let sender_balance_after = test.sender.balance; @@ -208,9 +206,7 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { let delivery_fees = PeoplePolkadot::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >( - test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest - ) + >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) }); // Sender's balance is reduced @@ -254,9 +250,7 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() { let delivery_fees = PeoplePolkadot::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >( - test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest - ) + >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) }); // Sender's balance is reduced From 8b4d0a7767419b3a0db03ab7e8d1711fe749379e Mon Sep 17 00:00:00 2001 From: muharem Date: Tue, 16 Jul 2024 17:14:20 +0200 Subject: [PATCH 5/5] cargo.lock update --- Cargo.lock | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index be996e7cf0..8e57740176 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9287,6 +9287,7 @@ dependencies = [ "pallet-balances", "pallet-identity", "pallet-message-queue", + "pallet-xcm", "parachains-common", "parity-scale-codec", "people-kusama-runtime", @@ -9389,6 +9390,7 @@ dependencies = [ "pallet-balances", "pallet-identity", "pallet-message-queue", + "pallet-xcm", "parachains-common", "parity-scale-codec", "people-polkadot-runtime",