From 474fdafb8cdabcbe3b870037cc70af5b0f9370a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= <git@kchr.de> Date: Thu, 23 Jan 2025 13:56:23 +0100 Subject: [PATCH] Revert "[stable2409] Backport #6604 (#6952)" (#7310) This reverts commit 2afc17f448a656201548d369507fc26d4ec70413. --- Cargo.lock | 3 - bridges/bin/runtime-common/Cargo.toml | 1 - .../modules/xcm-bridge-hub-router/Cargo.toml | 1 - bridges/modules/xcm-bridge-hub/Cargo.toml | 1 - .../pallets/inbound-queue/Cargo.toml | 1 - bridges/snowbridge/pallets/system/Cargo.toml | 1 - bridges/snowbridge/primitives/core/Cargo.toml | 1 - .../snowbridge/primitives/router/Cargo.toml | 1 - .../runtime/runtime-common/Cargo.toml | 1 - .../snowbridge/runtime/test-common/Cargo.toml | 1 - cumulus/pallets/dmp-queue/Cargo.toml | 1 - cumulus/pallets/parachain-system/Cargo.toml | 4 +- cumulus/pallets/parachain-system/src/lib.rs | 2 +- cumulus/pallets/xcmp-queue/Cargo.toml | 1 - cumulus/parachains/common/Cargo.toml | 1 - .../emulated/common/src/impls.rs | 2 - .../emulated/common/src/macros.rs | 3 - .../src/tests/hybrid_transfers.rs | 4 - .../src/tests/reserve_transfer.rs | 13 - .../asset-hub-rococo/src/tests/treasury.rs | 4 - .../src/tests/hybrid_transfers.rs | 4 - .../src/tests/reserve_transfer.rs | 13 - .../asset-hub-westend/src/tests/treasury.rs | 3 - .../bridge-hub-rococo/src/tests/send_xcm.rs | 4 - .../bridge-hub-westend/src/tests/send_xcm.rs | 4 - .../src/tests/fellowship_treasury.rs | 3 - .../src/tests/coretime_interface.rs | 240 -------- .../src/tests/coretime_interface.rs | 228 -------- .../people-westend/src/tests/governance.rs | 550 ------------------ .../assets/asset-hub-rococo/Cargo.toml | 1 - .../assets/asset-hub-westend/Cargo.toml | 1 - .../runtimes/assets/common/Cargo.toml | 1 - .../bridge-hubs/bridge-hub-rococo/Cargo.toml | 1 - .../bridge-hubs/bridge-hub-westend/Cargo.toml | 1 - .../runtimes/bridge-hubs/common/Cargo.toml | 1 - .../collectives-westend/Cargo.toml | 1 - .../contracts/contracts-rococo/Cargo.toml | 1 - .../coretime/coretime-rococo/Cargo.toml | 1 - .../coretime/coretime-westend/Cargo.toml | 1 - .../glutton/glutton-westend/Cargo.toml | 1 - .../runtimes/people/people-rococo/Cargo.toml | 1 - .../runtimes/people/people-westend/Cargo.toml | 1 - .../runtimes/testing/penpal/Cargo.toml | 1 - .../testing/rococo-parachain/Cargo.toml | 1 - cumulus/polkadot-parachain/Cargo.toml | 1 - cumulus/primitives/core/Cargo.toml | 1 - cumulus/primitives/utility/Cargo.toml | 1 - polkadot/node/service/Cargo.toml | 1 - polkadot/parachain/src/primitives.rs | 5 - polkadot/runtime/common/Cargo.toml | 1 - .../runtime/common/src/identity_migrator.rs | 16 - .../runtime/common/src/paras_sudo_wrapper.rs | 3 - polkadot/runtime/common/src/xcm_sender.rs | 29 +- polkadot/runtime/parachains/Cargo.toml | 1 - .../parachains/src/coretime/benchmarking.rs | 2 - polkadot/runtime/parachains/src/dmp.rs | 37 +- polkadot/runtime/parachains/src/dmp/tests.rs | 44 -- polkadot/runtime/parachains/src/lib.rs | 16 - polkadot/runtime/rococo/Cargo.toml | 1 - polkadot/runtime/rococo/src/impls.rs | 5 - polkadot/runtime/rococo/src/lib.rs | 6 +- polkadot/runtime/test-runtime/Cargo.toml | 1 - polkadot/runtime/westend/Cargo.toml | 1 - polkadot/runtime/westend/src/impls.rs | 5 - polkadot/runtime/westend/src/lib.rs | 6 +- polkadot/xcm/Cargo.toml | 1 - polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml | 1 - .../src/fungible/benchmarking.rs | 24 +- .../src/generic/benchmarking.rs | 4 - polkadot/xcm/pallet-xcm/Cargo.toml | 1 - polkadot/xcm/pallet-xcm/src/benchmarking.rs | 32 +- polkadot/xcm/src/v4/traits.rs | 11 - polkadot/xcm/src/v5/traits.rs | 537 ----------------- polkadot/xcm/xcm-builder/Cargo.toml | 1 - polkadot/xcm/xcm-builder/src/pay.rs | 11 +- polkadot/xcm/xcm-builder/src/routing.rs | 15 - polkadot/xcm/xcm-builder/src/tests/pay/pay.rs | 2 +- .../xcm/xcm-builder/src/universal_exports.rs | 16 - polkadot/xcm/xcm-executor/Cargo.toml | 1 - .../xcm-executor/integration-tests/Cargo.toml | 5 +- .../xcm-executor/integration-tests/src/lib.rs | 25 +- polkadot/xcm/xcm-runtime-apis/Cargo.toml | 1 - polkadot/xcm/xcm-simulator/example/Cargo.toml | 1 - polkadot/xcm/xcm-simulator/fuzzer/Cargo.toml | 1 - substrate/frame/contracts/Cargo.toml | 1 - .../frame/contracts/mock-network/Cargo.toml | 1 - substrate/frame/revive/Cargo.toml | 1 - .../frame/revive/mock-network/Cargo.toml | 1 - umbrella/Cargo.toml | 1 - 89 files changed, 47 insertions(+), 1942 deletions(-) delete mode 100644 cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-rococo/src/tests/coretime_interface.rs delete mode 100644 cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-westend/src/tests/coretime_interface.rs delete mode 100644 cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs delete mode 100644 polkadot/xcm/src/v5/traits.rs diff --git a/Cargo.lock b/Cargo.lock index de4be1f1403..814e7acc677 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24092,13 +24092,10 @@ name = "xcm-executor-integration-tests" version = "1.0.0" dependencies = [ "frame-support", - "frame-system", "futures", - "pallet-sudo", "pallet-transaction-payment", "pallet-xcm", "parity-scale-codec", - "polkadot-runtime-parachains", "polkadot-test-client", "polkadot-test-runtime", "polkadot-test-service", diff --git a/bridges/bin/runtime-common/Cargo.toml b/bridges/bin/runtime-common/Cargo.toml index 28f862206b2..54fdf17eccc 100644 --- a/bridges/bin/runtime-common/Cargo.toml +++ b/bridges/bin/runtime-common/Cargo.toml @@ -83,7 +83,6 @@ runtime-benchmarks = [ "pallet-utility/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "sp-trie", - "xcm/runtime-benchmarks", ] integrity-test = ["static_assertions"] test-helpers = ["bp-runtime/test-helpers", "sp-trie"] diff --git a/bridges/modules/xcm-bridge-hub-router/Cargo.toml b/bridges/modules/xcm-bridge-hub-router/Cargo.toml index 2a8ebc0b0c8..d75df7d8867 100644 --- a/bridges/modules/xcm-bridge-hub-router/Cargo.toml +++ b/bridges/modules/xcm-bridge-hub-router/Cargo.toml @@ -50,7 +50,6 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", diff --git a/bridges/modules/xcm-bridge-hub/Cargo.toml b/bridges/modules/xcm-bridge-hub/Cargo.toml index 90ba32c38d1..21f538f4499 100644 --- a/bridges/modules/xcm-bridge-hub/Cargo.toml +++ b/bridges/modules/xcm-bridge-hub/Cargo.toml @@ -62,7 +62,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", diff --git a/bridges/snowbridge/pallets/inbound-queue/Cargo.toml b/bridges/snowbridge/pallets/inbound-queue/Cargo.toml index a9ab0dd5c6f..145318913dc 100644 --- a/bridges/snowbridge/pallets/inbound-queue/Cargo.toml +++ b/bridges/snowbridge/pallets/inbound-queue/Cargo.toml @@ -79,7 +79,6 @@ runtime-benchmarks = [ "snowbridge-router-primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", diff --git a/bridges/snowbridge/pallets/system/Cargo.toml b/bridges/snowbridge/pallets/system/Cargo.toml index 531e8cc2fb5..d43bf039183 100644 --- a/bridges/snowbridge/pallets/system/Cargo.toml +++ b/bridges/snowbridge/pallets/system/Cargo.toml @@ -64,7 +64,6 @@ runtime-benchmarks = [ "snowbridge-core/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", diff --git a/bridges/snowbridge/primitives/core/Cargo.toml b/bridges/snowbridge/primitives/core/Cargo.toml index 1bddd27d365..851d5a2b3f6 100644 --- a/bridges/snowbridge/primitives/core/Cargo.toml +++ b/bridges/snowbridge/primitives/core/Cargo.toml @@ -60,5 +60,4 @@ runtime-benchmarks = [ "polkadot-parachain-primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/bridges/snowbridge/primitives/router/Cargo.toml b/bridges/snowbridge/primitives/router/Cargo.toml index 461b960f002..ddf133cd59c 100644 --- a/bridges/snowbridge/primitives/router/Cargo.toml +++ b/bridges/snowbridge/primitives/router/Cargo.toml @@ -48,5 +48,4 @@ runtime-benchmarks = [ "snowbridge-core/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/bridges/snowbridge/runtime/runtime-common/Cargo.toml b/bridges/snowbridge/runtime/runtime-common/Cargo.toml index 3efebeb35f2..18d2c97a7f1 100644 --- a/bridges/snowbridge/runtime/runtime-common/Cargo.toml +++ b/bridges/snowbridge/runtime/runtime-common/Cargo.toml @@ -42,5 +42,4 @@ runtime-benchmarks = [ "snowbridge-core/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/bridges/snowbridge/runtime/test-common/Cargo.toml b/bridges/snowbridge/runtime/test-common/Cargo.toml index 01baa2cbcc7..00462895eb4 100644 --- a/bridges/snowbridge/runtime/test-common/Cargo.toml +++ b/bridges/snowbridge/runtime/test-common/Cargo.toml @@ -83,6 +83,5 @@ runtime-benchmarks = [ "snowbridge-pallet-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] fast-runtime = [] diff --git a/cumulus/pallets/dmp-queue/Cargo.toml b/cumulus/pallets/dmp-queue/Cargo.toml index f4de8e4f011..9e73c54cf99 100644 --- a/cumulus/pallets/dmp-queue/Cargo.toml +++ b/cumulus/pallets/dmp-queue/Cargo.toml @@ -51,7 +51,6 @@ runtime-benchmarks = [ "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ diff --git a/cumulus/pallets/parachain-system/Cargo.toml b/cumulus/pallets/parachain-system/Cargo.toml index 80e6f2b8119..c91f6791730 100644 --- a/cumulus/pallets/parachain-system/Cargo.toml +++ b/cumulus/pallets/parachain-system/Cargo.toml @@ -77,6 +77,7 @@ std = [ "log/std", "pallet-message-queue/std", "polkadot-parachain-primitives/std", + "polkadot-runtime-common/std", "polkadot-runtime-parachains/std", "scale-info/std", "sp-core/std", @@ -99,16 +100,17 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "pallet-message-queue/runtime-benchmarks", "polkadot-parachain-primitives/runtime-benchmarks", + "polkadot-runtime-common/runtime-benchmarks", "polkadot-runtime-parachains/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", "pallet-message-queue/try-runtime", + "polkadot-runtime-common?/try-runtime", "polkadot-runtime-parachains/try-runtime", "sp-runtime/try-runtime", ] diff --git a/cumulus/pallets/parachain-system/src/lib.rs b/cumulus/pallets/parachain-system/src/lib.rs index 18e72acf67b..4163e440360 100644 --- a/cumulus/pallets/parachain-system/src/lib.rs +++ b/cumulus/pallets/parachain-system/src/lib.rs @@ -1561,7 +1561,7 @@ impl<T: Config> InspectMessageQueues for Pallet<T> { } #[cfg(feature = "runtime-benchmarks")] -impl<T: Config> polkadot_runtime_parachains::EnsureForParachain for Pallet<T> { +impl<T: Config> polkadot_runtime_common::xcm_sender::EnsureForParachain for Pallet<T> { fn ensure(para_id: ParaId) { if let ChannelStatus::Closed = Self::get_channel_status(para_id) { Self::open_outbound_hrmp_channel_for_benchmarks_or_tests(para_id) diff --git a/cumulus/pallets/xcmp-queue/Cargo.toml b/cumulus/pallets/xcmp-queue/Cargo.toml index 29dd4e030dd..0adc4ccc39b 100644 --- a/cumulus/pallets/xcmp-queue/Cargo.toml +++ b/cumulus/pallets/xcmp-queue/Cargo.toml @@ -73,7 +73,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", diff --git a/cumulus/parachains/common/Cargo.toml b/cumulus/parachains/common/Cargo.toml index a8ce9df4061..62aea848d35 100644 --- a/cumulus/parachains/common/Cargo.toml +++ b/cumulus/parachains/common/Cargo.toml @@ -85,5 +85,4 @@ runtime-benchmarks = [ "polkadot-primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/cumulus/parachains/integration-tests/emulated/common/src/impls.rs b/cumulus/parachains/integration-tests/emulated/common/src/impls.rs index 9dad323aa19..c0d42cf2758 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/impls.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/impls.rs @@ -370,8 +370,6 @@ macro_rules! impl_send_transact_helpers_for_relay_chain { let destination: $crate::impls::Location = <Self as RelayChain>::child_location_of(recipient); let xcm = $crate::impls::xcm_transact_unpaid_execution(call, $crate::impls::OriginKind::Superuser); - $crate::impls::dmp::Pallet::<<Self as $crate::impls::Chain>::Runtime>::make_parachain_reachable(recipient); - // Send XCM `Transact` $crate::impls::assert_ok!(<Self as [<$chain RelayPallet>]>::XcmPallet::send( root_origin, diff --git a/cumulus/parachains/integration-tests/emulated/common/src/macros.rs b/cumulus/parachains/integration-tests/emulated/common/src/macros.rs index 8634b82e131..3ff5ed388a3 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/macros.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/macros.rs @@ -23,7 +23,6 @@ pub use pallet_message_queue; pub use pallet_xcm; // Polkadot -pub use polkadot_runtime_parachains::dmp::Pallet as Dmp; pub use xcm::{ prelude::{ AccountId32, All, Asset, AssetId, BuyExecution, DepositAsset, ExpectTransactStatus, @@ -157,8 +156,6 @@ macro_rules! test_relay_is_trusted_teleporter { // Send XCM message from Relay <$sender_relay>::execute_with(|| { - $crate::macros::Dmp::<<$sender_relay as $crate::macros::Chain>::Runtime>::make_parachain_reachable(<$receiver_para>::para_id()); - assert_ok!(<$sender_relay as [<$sender_relay Pallet>]>::XcmPallet::limited_teleport_assets( origin.clone(), bx!(para_destination.clone().into()), diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/hybrid_transfers.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/hybrid_transfers.rs index d175847206d..7bb25d7cec6 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/hybrid_transfers.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/hybrid_transfers.rs @@ -13,8 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use rococo_system_emulated_network::rococo_emulated_chain::rococo_runtime::Dmp; - use super::reserve_transfer::*; use crate::{ imports::*, @@ -779,8 +777,6 @@ fn transfer_native_asset_from_relay_to_para_through_asset_hub() { xcm: xcm_on_final_dest, }]); - Dmp::make_parachain_reachable(AssetHubRococo::para_id()); - // First leg is a teleport, from there a local-reserve-transfer to final dest <Rococo as RococoPallet>::XcmPallet::transfer_assets_using_type_and_then( t.signed_origin, diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/reserve_transfer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/reserve_transfer.rs index 6039c9baa5c..8aad4b392b2 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/reserve_transfer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/reserve_transfer.rs @@ -14,7 +14,6 @@ // limitations under the License. use crate::imports::*; -use rococo_system_emulated_network::rococo_emulated_chain::rococo_runtime::Dmp; fn relay_to_para_sender_assertions(t: RelayToParaTest) { type RuntimeEvent = <Rococo as Chain>::RuntimeEvent; @@ -487,11 +486,6 @@ pub fn para_to_para_through_hop_receiver_assertions<Hop: Clone>(t: Test<PenpalA, } fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { - let Junction::Parachain(para_id) = *t.args.dest.chain_location().last().unwrap() else { - unimplemented!("Destination is not a parachain?") - }; - - Dmp::make_parachain_reachable(para_id); <Rococo as RococoPallet>::XcmPallet::limited_reserve_transfer_assets( t.signed_origin, bx!(t.args.dest.into()), @@ -551,13 +545,6 @@ fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> Dispa fn para_to_para_through_relay_limited_reserve_transfer_assets( t: ParaToParaThroughRelayTest, ) -> DispatchResult { - let Junction::Parachain(para_id) = *t.args.dest.chain_location().last().unwrap() else { - unimplemented!("Destination is not a parachain?") - }; - - Rococo::ext_wrapper(|| { - Dmp::make_parachain_reachable(para_id); - }); <PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets( t.signed_origin, bx!(t.args.dest.into()), diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/treasury.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/treasury.rs index 2ad9510eb14..3320392b495 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/treasury.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/treasury.rs @@ -29,7 +29,6 @@ use frame_support::{ use parachains_common::AccountId; use polkadot_runtime_common::impls::VersionedLocatableAsset; use rococo_runtime_constants::currency::GRAND; -use rococo_system_emulated_network::rococo_emulated_chain::rococo_runtime::Dmp; use xcm_executor::traits::ConvertLocation; // Fund Treasury account on Asset Hub from Treasury account on Relay Chain with ROCs. @@ -65,7 +64,6 @@ fn spend_roc_on_asset_hub() { treasury_balance * 2, )); - Dmp::make_parachain_reachable(1000); let native_asset = Location::here(); let asset_hub_location: Location = [Parachain(1000)].into(); let treasury_location: Location = (Parent, PalletInstance(18)).into(); @@ -204,8 +202,6 @@ fn create_and_claim_treasury_spend_in_usdt() { // create a conversion rate from `asset_kind` to the native currency. assert_ok!(AssetRate::create(root.clone(), Box::new(asset_kind.clone()), 2.into())); - Dmp::make_parachain_reachable(1000); - // create and approve a treasury spend. assert_ok!(Treasury::spend( root, diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs index 055fd101b1a..4d6cdd9a94d 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs @@ -13,8 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use westend_system_emulated_network::westend_emulated_chain::westend_runtime::Dmp; - use super::reserve_transfer::*; use crate::{ imports::*, @@ -780,8 +778,6 @@ fn transfer_native_asset_from_relay_to_para_through_asset_hub() { xcm: xcm_on_final_dest, }]); - Dmp::make_parachain_reachable(AssetHubWestend::para_id()); - // First leg is a teleport, from there a local-reserve-transfer to final dest <Westend as WestendPallet>::XcmPallet::transfer_assets_using_type_and_then( t.signed_origin, diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs index 0e4f68e6105..0100e8e34ef 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs @@ -14,7 +14,6 @@ // limitations under the License. use crate::imports::*; -use westend_system_emulated_network::westend_emulated_chain::westend_runtime::Dmp; fn relay_to_para_sender_assertions(t: RelayToParaTest) { type RuntimeEvent = <Westend as Chain>::RuntimeEvent; @@ -487,11 +486,6 @@ pub fn para_to_para_through_hop_receiver_assertions<Hop: Clone>(t: Test<PenpalA, } fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { - let Junction::Parachain(para_id) = *t.args.dest.chain_location().last().unwrap() else { - unimplemented!("Destination is not a parachain?") - }; - - Dmp::make_parachain_reachable(para_id); <Westend as WestendPallet>::XcmPallet::limited_reserve_transfer_assets( t.signed_origin, bx!(t.args.dest.into()), @@ -538,13 +532,6 @@ fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> Dispa fn para_to_para_through_relay_limited_reserve_transfer_assets( t: ParaToParaThroughRelayTest, ) -> DispatchResult { - let Junction::Parachain(para_id) = *t.args.dest.chain_location().last().unwrap() else { - unimplemented!("Destination is not a parachain?") - }; - - Westend::ext_wrapper(|| { - Dmp::make_parachain_reachable(para_id); - }); <PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets( t.signed_origin, bx!(t.args.dest.into()), diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs index 6541f9b4416..b7096718438 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs @@ -20,7 +20,6 @@ use emulated_integration_tests_common::{ }; use frame_support::traits::fungibles::{Inspect, Mutate}; use polkadot_runtime_common::impls::VersionedLocatableAsset; -use westend_system_emulated_network::westend_emulated_chain::westend_runtime::Dmp; use xcm_executor::traits::ConvertLocation; #[test] @@ -60,8 +59,6 @@ fn create_and_claim_treasury_spend() { // create a conversion rate from `asset_kind` to the native currency. assert_ok!(AssetRate::create(root.clone(), Box::new(asset_kind.clone()), 2.into())); - Dmp::make_parachain_reachable(1000); - // create and approve a treasury spend. assert_ok!(Treasury::spend( root, diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/send_xcm.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/send_xcm.rs index 395769eaaea..12f05742a08 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/send_xcm.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/send_xcm.rs @@ -13,8 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use rococo_system_emulated_network::rococo_emulated_chain::rococo_runtime::Dmp; - use crate::tests::*; #[test] @@ -40,8 +38,6 @@ fn send_xcm_from_rococo_relay_to_westend_asset_hub_should_fail_on_not_applicable // Rococo Global Consensus // Send XCM message from Relay Chain to Bridge Hub source Parachain Rococo::execute_with(|| { - Dmp::make_parachain_reachable(BridgeHubRococo::para_id()); - assert_ok!(<Rococo as RococoPallet>::XcmPallet::send( sudo_origin, bx!(destination), diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/send_xcm.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/send_xcm.rs index 51dbc678105..ae05e4223b0 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/send_xcm.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/send_xcm.rs @@ -13,8 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use rococo_westend_system_emulated_network::westend_emulated_chain::westend_runtime::Dmp; - use crate::tests::*; #[test] @@ -40,8 +38,6 @@ fn send_xcm_from_westend_relay_to_rococo_asset_hub_should_fail_on_not_applicable // Westend Global Consensus // Send XCM message from Relay Chain to Bridge Hub source Parachain Westend::execute_with(|| { - Dmp::make_parachain_reachable(BridgeHubWestend::para_id()); - assert_ok!(<Westend as WestendPallet>::XcmPallet::send( sudo_origin, bx!(destination), diff --git a/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/src/tests/fellowship_treasury.rs b/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/src/tests/fellowship_treasury.rs index 102cecdcf09..943f8965540 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/src/tests/fellowship_treasury.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/src/tests/fellowship_treasury.rs @@ -20,7 +20,6 @@ use frame_support::{ }; use polkadot_runtime_common::impls::VersionedLocatableAsset; use westend_runtime_constants::currency::UNITS; -use westend_system_emulated_network::westend_emulated_chain::westend_runtime::Dmp; use xcm_executor::traits::ConvertLocation; // Fund Fellowship Treasury from Westend Treasury and spend from Fellowship Treasury. @@ -58,8 +57,6 @@ fn fellowship_treasury_spend() { treasury_balance * 2, )); - Dmp::make_parachain_reachable(1000); - let native_asset = Location::here(); let asset_hub_location: Location = [Parachain(1000)].into(); let treasury_location: Location = (Parent, PalletInstance(37)).into(); diff --git a/cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-rococo/src/tests/coretime_interface.rs b/cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-rococo/src/tests/coretime_interface.rs deleted file mode 100644 index 554025e1ecf..00000000000 --- a/cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-rococo/src/tests/coretime_interface.rs +++ /dev/null @@ -1,240 +0,0 @@ -// 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::imports::*; -use frame_support::traits::OnInitialize; -use pallet_broker::{ConfigRecord, Configuration, CoreAssignment, CoreMask, ScheduleItem}; -use rococo_runtime_constants::system_parachain::coretime::TIMESLICE_PERIOD; -use rococo_system_emulated_network::rococo_emulated_chain::rococo_runtime::Dmp; -use sp_runtime::Perbill; - -#[test] -fn transact_hardcoded_weights_are_sane() { - // There are three transacts with hardcoded weights sent from the Coretime Chain to the Relay - // Chain across the CoretimeInterface which are triggered at various points in the sales cycle. - // - Request core count - triggered directly by `start_sales` or `request_core_count` - // extrinsics. - // - Request revenue info - triggered when each timeslice is committed. - // - Assign core - triggered when an entry is encountered in the workplan for the next - // timeslice. - - // RuntimeEvent aliases to avoid warning from usage of qualified paths in assertions due to - // <https://github.com/rust-lang/rust/issues/86935> - type CoretimeEvent = <CoretimeRococo as Chain>::RuntimeEvent; - type RelayEvent = <Rococo as Chain>::RuntimeEvent; - - Rococo::execute_with(|| { - Dmp::make_parachain_reachable(CoretimeRococo::para_id()); - }); - - // Reserve a workload, configure broker and start sales. - CoretimeRococo::execute_with(|| { - // Hooks don't run in emulated tests - workaround as we need `on_initialize` to tick things - // along and have no concept of time passing otherwise. - <CoretimeRococo as CoretimeRococoPallet>::Broker::on_initialize( - <CoretimeRococo as Chain>::System::block_number(), - ); - - let coretime_root_origin = <CoretimeRococo as Chain>::RuntimeOrigin::root(); - - // Create and populate schedule with the worst case assignment on this core. - let mut schedule = Vec::new(); - for i in 0..80 { - schedule.push(ScheduleItem { - mask: CoreMask::void().set(i), - assignment: CoreAssignment::Task(2000 + i), - }) - } - - assert_ok!(<CoretimeRococo as CoretimeRococoPallet>::Broker::reserve( - coretime_root_origin.clone(), - schedule.try_into().expect("Vector is within bounds."), - )); - - // Configure broker and start sales. - let config = ConfigRecord { - advance_notice: 1, - interlude_length: 1, - leadin_length: 2, - region_length: 1, - ideal_bulk_proportion: Perbill::from_percent(40), - limit_cores_offered: None, - renewal_bump: Perbill::from_percent(2), - contribution_timeout: 1, - }; - assert_ok!(<CoretimeRococo as CoretimeRococoPallet>::Broker::configure( - coretime_root_origin.clone(), - config - )); - assert_ok!(<CoretimeRococo as CoretimeRococoPallet>::Broker::start_sales( - coretime_root_origin, - 100, - 0 - )); - assert_eq!( - pallet_broker::Status::<<CoretimeRococo as Chain>::Runtime>::get() - .unwrap() - .core_count, - 1 - ); - - assert_expected_events!( - CoretimeRococo, - vec![ - CoretimeEvent::Broker( - pallet_broker::Event::ReservationMade { .. } - ) => {}, - CoretimeEvent::Broker( - pallet_broker::Event::CoreCountRequested { core_count: 1 } - ) => {}, - CoretimeEvent::ParachainSystem( - cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. } - ) => {}, - ] - ); - }); - - // Check that the request_core_count message was processed successfully. This will fail if the - // weights are misconfigured. - Rococo::execute_with(|| { - Rococo::assert_ump_queue_processed(true, Some(CoretimeRococo::para_id()), None); - - assert_expected_events!( - Rococo, - vec![ - RelayEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - ] - ); - }); - - // Keep track of the relay chain block number so we can fast forward while still checking the - // right block. - let mut block_number_cursor = Rococo::ext_wrapper(<Rococo as Chain>::System::block_number); - - let config = CoretimeRococo::ext_wrapper(|| { - Configuration::<<CoretimeRococo as Chain>::Runtime>::get() - .expect("Pallet was configured earlier.") - }); - - // Now run up to the block before the sale is rotated. - while block_number_cursor < TIMESLICE_PERIOD - config.advance_notice - 1 { - CoretimeRococo::execute_with(|| { - // Hooks don't run in emulated tests - workaround. - <CoretimeRococo as CoretimeRococoPallet>::Broker::on_initialize( - <CoretimeRococo as Chain>::System::block_number(), - ); - }); - - Rococo::ext_wrapper(|| { - block_number_cursor = <Rococo as Chain>::System::block_number(); - }); - } - - // In this block we trigger assign core. - CoretimeRococo::execute_with(|| { - // Hooks don't run in emulated tests - workaround. - <CoretimeRococo as CoretimeRococoPallet>::Broker::on_initialize( - <CoretimeRococo as Chain>::System::block_number(), - ); - - assert_expected_events!( - CoretimeRococo, - vec![ - CoretimeEvent::Broker( - pallet_broker::Event::SaleInitialized { .. } - ) => {}, - CoretimeEvent::Broker( - pallet_broker::Event::CoreAssigned { .. } - ) => {}, - CoretimeEvent::ParachainSystem( - cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. } - ) => {}, - ] - ); - }); - - // Check that the assign_core message was processed successfully. - // This will fail if the weights are misconfigured. - Rococo::execute_with(|| { - Rococo::assert_ump_queue_processed(true, Some(CoretimeRococo::para_id()), None); - - assert_expected_events!( - Rococo, - vec![ - RelayEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - RelayEvent::Coretime( - polkadot_runtime_parachains::coretime::Event::CoreAssigned { .. } - ) => {}, - ] - ); - }); - - // In this block we trigger request revenue. - CoretimeRococo::execute_with(|| { - // Hooks don't run in emulated tests - workaround. - <CoretimeRococo as CoretimeRococoPallet>::Broker::on_initialize( - <CoretimeRococo as Chain>::System::block_number(), - ); - - assert_expected_events!( - CoretimeRococo, - vec![ - CoretimeEvent::ParachainSystem( - cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. } - ) => {}, - ] - ); - }); - - // Check that the request_revenue_info_at message was processed successfully. - // This will fail if the weights are misconfigured. - Rococo::execute_with(|| { - Rococo::assert_ump_queue_processed(true, Some(CoretimeRococo::para_id()), None); - - assert_expected_events!( - Rococo, - vec![ - RelayEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - ] - ); - }); - - // Here we receive and process the notify_revenue XCM with zero revenue. - CoretimeRococo::execute_with(|| { - // Hooks don't run in emulated tests - workaround. - <CoretimeRococo as CoretimeRococoPallet>::Broker::on_initialize( - <CoretimeRococo as Chain>::System::block_number(), - ); - - assert_expected_events!( - CoretimeRococo, - vec![ - CoretimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - // Zero revenue in first timeslice so history is immediately dropped. - CoretimeEvent::Broker( - pallet_broker::Event::HistoryDropped { when: 0, revenue: 0 } - ) => {}, - ] - ); - }); -} diff --git a/cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-westend/src/tests/coretime_interface.rs b/cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-westend/src/tests/coretime_interface.rs deleted file mode 100644 index 900994b1afc..00000000000 --- a/cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-westend/src/tests/coretime_interface.rs +++ /dev/null @@ -1,228 +0,0 @@ -// 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::imports::*; -use frame_support::traits::OnInitialize; -use pallet_broker::{ConfigRecord, Configuration, CoreAssignment, CoreMask, ScheduleItem}; -use sp_runtime::Perbill; -use westend_runtime_constants::system_parachain::coretime::TIMESLICE_PERIOD; -use westend_system_emulated_network::westend_emulated_chain::westend_runtime::Dmp; - -#[test] -fn transact_hardcoded_weights_are_sane() { - // There are three transacts with hardcoded weights sent from the Coretime Chain to the Relay - // Chain across the CoretimeInterface which are triggered at various points in the sales cycle. - // - Request core count - triggered directly by `start_sales` or `request_core_count` - // extrinsics. - // - Request revenue info - triggered when each timeslice is committed. - // - Assign core - triggered when an entry is encountered in the workplan for the next - // timeslice. - - // RuntimeEvent aliases to avoid warning from usage of qualified paths in assertions due to - // <https://github.com/rust-lang/rust/issues/86935> - type CoretimeEvent = <CoretimeWestend as Chain>::RuntimeEvent; - type RelayEvent = <Westend as Chain>::RuntimeEvent; - - Westend::execute_with(|| { - Dmp::make_parachain_reachable(CoretimeWestend::para_id()); - }); - - // Reserve a workload, configure broker and start sales. - CoretimeWestend::execute_with(|| { - // Hooks don't run in emulated tests - workaround as we need `on_initialize` to tick things - // along and have no concept of time passing otherwise. - <CoretimeWestend as CoretimeWestendPallet>::Broker::on_initialize( - <CoretimeWestend as Chain>::System::block_number(), - ); - - let coretime_root_origin = <CoretimeWestend as Chain>::RuntimeOrigin::root(); - - // Create and populate schedule with the worst case assignment on this core. - let mut schedule = Vec::new(); - for i in 0..80 { - schedule.push(ScheduleItem { - mask: CoreMask::void().set(i), - assignment: CoreAssignment::Task(2000 + i), - }) - } - - assert_ok!(<CoretimeWestend as CoretimeWestendPallet>::Broker::reserve( - coretime_root_origin.clone(), - schedule.try_into().expect("Vector is within bounds."), - )); - - // Configure broker and start sales. - let config = ConfigRecord { - advance_notice: 1, - interlude_length: 1, - leadin_length: 2, - region_length: 1, - ideal_bulk_proportion: Perbill::from_percent(40), - limit_cores_offered: None, - renewal_bump: Perbill::from_percent(2), - contribution_timeout: 1, - }; - assert_ok!(<CoretimeWestend as CoretimeWestendPallet>::Broker::configure( - coretime_root_origin.clone(), - config - )); - assert_ok!(<CoretimeWestend as CoretimeWestendPallet>::Broker::start_sales( - coretime_root_origin, - 100, - 0 - )); - assert_eq!( - pallet_broker::Status::<<CoretimeWestend as Chain>::Runtime>::get() - .unwrap() - .core_count, - 1 - ); - - assert_expected_events!( - CoretimeWestend, - vec![ - CoretimeEvent::Broker( - pallet_broker::Event::ReservationMade { .. } - ) => {}, - CoretimeEvent::Broker( - pallet_broker::Event::CoreCountRequested { core_count: 1 } - ) => {}, - CoretimeEvent::ParachainSystem( - cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. } - ) => {}, - ] - ); - }); - - // Check that the request_core_count message was processed successfully. This will fail if the - // weights are misconfigured. - Westend::execute_with(|| { - Westend::assert_ump_queue_processed(true, Some(CoretimeWestend::para_id()), None); - - assert_expected_events!( - Westend, - vec![ - RelayEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - ] - ); - }); - - // Keep track of the relay chain block number so we can fast forward while still checking the - // right block. - let mut block_number_cursor = Westend::ext_wrapper(<Westend as Chain>::System::block_number); - - let config = CoretimeWestend::ext_wrapper(|| { - Configuration::<<CoretimeWestend as Chain>::Runtime>::get() - .expect("Pallet was configured earlier.") - }); - - // Now run up to the block before the sale is rotated. - while block_number_cursor < TIMESLICE_PERIOD - config.advance_notice - 1 { - CoretimeWestend::execute_with(|| { - // Hooks don't run in emulated tests - workaround. - <CoretimeWestend as CoretimeWestendPallet>::Broker::on_initialize( - <CoretimeWestend as Chain>::System::block_number(), - ); - }); - - Westend::ext_wrapper(|| { - block_number_cursor = <Westend as Chain>::System::block_number(); - }); - } - - // In this block we trigger assign core. - CoretimeWestend::execute_with(|| { - // Hooks don't run in emulated tests - workaround. - <CoretimeWestend as CoretimeWestendPallet>::Broker::on_initialize( - <CoretimeWestend as Chain>::System::block_number(), - ); - - assert_expected_events!( - CoretimeWestend, - vec![ - CoretimeEvent::Broker( - pallet_broker::Event::SaleInitialized { .. } - ) => {}, - CoretimeEvent::Broker( - pallet_broker::Event::CoreAssigned { .. } - ) => {}, - CoretimeEvent::ParachainSystem( - cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. } - ) => {}, - ] - ); - }); - - // In this block we trigger request revenue. - CoretimeWestend::execute_with(|| { - // Hooks don't run in emulated tests - workaround. - <CoretimeWestend as CoretimeWestendPallet>::Broker::on_initialize( - <CoretimeWestend as Chain>::System::block_number(), - ); - - assert_expected_events!( - CoretimeWestend, - vec![ - CoretimeEvent::ParachainSystem( - cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. } - ) => {}, - ] - ); - }); - - // Check that the assign_core and request_revenue_info_at messages were processed successfully. - // This will fail if the weights are misconfigured. - Westend::execute_with(|| { - Westend::assert_ump_queue_processed(true, Some(CoretimeWestend::para_id()), None); - - assert_expected_events!( - Westend, - vec![ - RelayEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - RelayEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - RelayEvent::Coretime( - polkadot_runtime_parachains::coretime::Event::CoreAssigned { .. } - ) => {}, - ] - ); - }); - - // Here we receive and process the notify_revenue XCM with zero revenue. - CoretimeWestend::execute_with(|| { - // Hooks don't run in emulated tests - workaround. - <CoretimeWestend as CoretimeWestendPallet>::Broker::on_initialize( - <CoretimeWestend as Chain>::System::block_number(), - ); - - assert_expected_events!( - CoretimeWestend, - vec![ - CoretimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - // Zero revenue in first timeslice so history is immediately dropped. - CoretimeEvent::Broker( - pallet_broker::Event::HistoryDropped { when: 0, revenue: 0 } - ) => {}, - ] - ); - }); -} diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs deleted file mode 100644 index ea438f80552..00000000000 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs +++ /dev/null @@ -1,550 +0,0 @@ -// 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::imports::*; -use frame_support::traits::ProcessMessageError; - -use codec::Encode; -use frame_support::sp_runtime::traits::Dispatchable; -use parachains_common::AccountId; -use people_westend_runtime::people::IdentityInfo; -use westend_runtime::{ - governance::pallet_custom_origins::Origin::GeneralAdmin as GeneralAdminOrigin, Dmp, -}; -use westend_system_emulated_network::people_westend_emulated_chain::people_westend_runtime; - -use pallet_identity::Data; - -use emulated_integration_tests_common::accounts::{ALICE, BOB}; - -#[test] -fn relay_commands_add_registrar() { - let (origin_kind, origin) = (OriginKind::Superuser, <Westend as Chain>::RuntimeOrigin::root()); - - let registrar: AccountId = [1; 32].into(); - Westend::execute_with(|| { - type Runtime = <Westend as Chain>::Runtime; - type RuntimeCall = <Westend as Chain>::RuntimeCall; - type RuntimeEvent = <Westend as Chain>::RuntimeEvent; - type PeopleCall = <PeopleWestend as Chain>::RuntimeCall; - type PeopleRuntime = <PeopleWestend as Chain>::Runtime; - - Dmp::make_parachain_reachable(1004); - - let add_registrar_call = - PeopleCall::Identity(pallet_identity::Call::<PeopleRuntime>::add_registrar { - account: registrar.into(), - }); - - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::<Runtime>::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: add_registrar_call.encode().into(), - fallback_max_weight: None - } - ]))), - }); - - assert_ok!(xcm_message.dispatch(origin)); - - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - PeopleWestend::execute_with(|| { - type RuntimeEvent = <PeopleWestend as Chain>::RuntimeEvent; - - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); -} - -#[test] -fn relay_commands_add_registrar_wrong_origin() { - let people_westend_alice = PeopleWestend::account_id_of(ALICE); - - let origins = vec![ - ( - OriginKind::SovereignAccount, - <Westend as Chain>::RuntimeOrigin::signed(people_westend_alice), - ), - (OriginKind::Xcm, GeneralAdminOrigin.into()), - ]; - - let mut signed_origin = true; - - for (origin_kind, origin) in origins { - let registrar: AccountId = [1; 32].into(); - Westend::execute_with(|| { - type Runtime = <Westend as Chain>::Runtime; - type RuntimeCall = <Westend as Chain>::RuntimeCall; - type RuntimeEvent = <Westend as Chain>::RuntimeEvent; - type PeopleCall = <PeopleWestend as Chain>::RuntimeCall; - type PeopleRuntime = <PeopleWestend as Chain>::Runtime; - - Dmp::make_parachain_reachable(1004); - - let add_registrar_call = - PeopleCall::Identity(pallet_identity::Call::<PeopleRuntime>::add_registrar { - account: registrar.into(), - }); - - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::<Runtime>::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: add_registrar_call.encode().into(), - fallback_max_weight: None - } - ]))), - }); - - assert_ok!(xcm_message.dispatch(origin)); - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - PeopleWestend::execute_with(|| { - type RuntimeEvent = <PeopleWestend as Chain>::RuntimeEvent; - - if signed_origin { - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, - ] - ); - } else { - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - } - }); - - signed_origin = false; - } -} - -#[test] -fn relay_commands_kill_identity() { - // To kill an identity, first one must be set - PeopleWestend::execute_with(|| { - type PeopleRuntime = <PeopleWestend as Chain>::Runtime; - type PeopleRuntimeEvent = <PeopleWestend as Chain>::RuntimeEvent; - - let people_westend_alice = - <PeopleWestend as Chain>::RuntimeOrigin::signed(PeopleWestend::account_id_of(ALICE)); - - let identity_info = IdentityInfo { - email: Data::Raw(b"test@test.io".to_vec().try_into().unwrap()), - ..Default::default() - }; - let identity: Box<<PeopleRuntime as pallet_identity::Config>::IdentityInformation> = - Box::new(identity_info); - - assert_ok!(<PeopleWestend as PeopleWestendPallet>::Identity::set_identity( - people_westend_alice, - identity - )); - - assert_expected_events!( - PeopleWestend, - vec![ - PeopleRuntimeEvent::Identity(pallet_identity::Event::IdentitySet { .. }) => {}, - ] - ); - }); - - let (origin_kind, origin) = (OriginKind::Superuser, <Westend as Chain>::RuntimeOrigin::root()); - - Westend::execute_with(|| { - type Runtime = <Westend as Chain>::Runtime; - type RuntimeCall = <Westend as Chain>::RuntimeCall; - type PeopleCall = <PeopleWestend as Chain>::RuntimeCall; - type RuntimeEvent = <Westend as Chain>::RuntimeEvent; - type PeopleRuntime = <PeopleWestend as Chain>::Runtime; - - Dmp::make_parachain_reachable(1004); - - let kill_identity_call = - PeopleCall::Identity(pallet_identity::Call::<PeopleRuntime>::kill_identity { - target: people_westend_runtime::MultiAddress::Id(PeopleWestend::account_id_of( - ALICE, - )), - }); - - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::<Runtime>::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: kill_identity_call.encode().into(), - fallback_max_weight: None - } - ]))), - }); - - assert_ok!(xcm_message.dispatch(origin)); - - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - PeopleWestend::execute_with(|| { - type RuntimeEvent = <PeopleWestend as Chain>::RuntimeEvent; - - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::IdentityKilled { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); -} - -#[test] -fn relay_commands_kill_identity_wrong_origin() { - let people_westend_alice = PeopleWestend::account_id_of(BOB); - - let origins = vec![ - ( - OriginKind::SovereignAccount, - <Westend as Chain>::RuntimeOrigin::signed(people_westend_alice), - ), - (OriginKind::Xcm, GeneralAdminOrigin.into()), - ]; - - for (origin_kind, origin) in origins { - Westend::execute_with(|| { - type Runtime = <Westend as Chain>::Runtime; - type RuntimeCall = <Westend as Chain>::RuntimeCall; - type PeopleCall = <PeopleWestend as Chain>::RuntimeCall; - type RuntimeEvent = <Westend as Chain>::RuntimeEvent; - type PeopleRuntime = <PeopleWestend as Chain>::Runtime; - - Dmp::make_parachain_reachable(1004); - - let kill_identity_call = - PeopleCall::Identity(pallet_identity::Call::<PeopleRuntime>::kill_identity { - target: people_westend_runtime::MultiAddress::Id(PeopleWestend::account_id_of( - ALICE, - )), - }); - - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::<Runtime>::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: kill_identity_call.encode().into(), - fallback_max_weight: None - } - ]))), - }); - - assert_ok!(xcm_message.dispatch(origin)); - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - PeopleWestend::execute_with(|| { - assert_expected_events!(PeopleWestend, vec![]); - }); - } -} - -#[test] -fn relay_commands_add_remove_username_authority() { - let people_westend_alice = PeopleWestend::account_id_of(ALICE); - let people_westend_bob = PeopleWestend::account_id_of(BOB); - - let (origin_kind, origin, usr) = - (OriginKind::Superuser, <Westend as Chain>::RuntimeOrigin::root(), "rootusername"); - - // First, add a username authority. - Westend::execute_with(|| { - type Runtime = <Westend as Chain>::Runtime; - type RuntimeCall = <Westend as Chain>::RuntimeCall; - type RuntimeEvent = <Westend as Chain>::RuntimeEvent; - type PeopleCall = <PeopleWestend as Chain>::RuntimeCall; - type PeopleRuntime = <PeopleWestend as Chain>::Runtime; - - Dmp::make_parachain_reachable(1004); - - let add_username_authority = - PeopleCall::Identity(pallet_identity::Call::<PeopleRuntime>::add_username_authority { - authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), - suffix: b"suffix1".into(), - allocation: 10, - }); - - let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::<Runtime>::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: add_username_authority.encode().into(), - fallback_max_weight: None - } - ]))), - }); - - assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); - - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - // Check events system-parachain-side - PeopleWestend::execute_with(|| { - type RuntimeEvent = <PeopleWestend as Chain>::RuntimeEvent; - - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::AuthorityAdded { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); - - // Now, use the previously added username authority to concede a username to an account. - PeopleWestend::execute_with(|| { - type PeopleRuntimeEvent = <PeopleWestend as Chain>::RuntimeEvent; - let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); - - assert_ok!(<PeopleWestend as PeopleWestendPallet>::Identity::set_username_for( - <PeopleWestend as Chain>::RuntimeOrigin::signed(people_westend_alice.clone()), - people_westend_runtime::MultiAddress::Id(people_westend_bob.clone()), - full_username, - None, - true - )); - - assert_expected_events!( - PeopleWestend, - vec![ - PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameQueued { .. }) => {}, - ] - ); - }); - - // Accept the given username - PeopleWestend::execute_with(|| { - type PeopleRuntimeEvent = <PeopleWestend as Chain>::RuntimeEvent; - let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); - - assert_ok!(<PeopleWestend as PeopleWestendPallet>::Identity::accept_username( - <PeopleWestend as Chain>::RuntimeOrigin::signed(people_westend_bob.clone()), - full_username.try_into().unwrap(), - )); - - assert_expected_events!( - PeopleWestend, - vec![ - PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameSet { .. }) => {}, - ] - ); - }); - - // Now, remove the username authority with another priviledged XCM call. - Westend::execute_with(|| { - type Runtime = <Westend as Chain>::Runtime; - type RuntimeCall = <Westend as Chain>::RuntimeCall; - type RuntimeEvent = <Westend as Chain>::RuntimeEvent; - type PeopleCall = <PeopleWestend as Chain>::RuntimeCall; - type PeopleRuntime = <PeopleWestend as Chain>::Runtime; - - Dmp::make_parachain_reachable(1004); - - let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< - PeopleRuntime, - >::remove_username_authority { - authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), - suffix: b"suffix1".into(), - }); - - let remove_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::<Runtime>::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: remove_username_authority.encode().into(), - fallback_max_weight: None - } - ]))), - }); - - assert_ok!(remove_authority_xcm_msg.dispatch(origin)); - - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - // Final event check. - PeopleWestend::execute_with(|| { - type RuntimeEvent = <PeopleWestend as Chain>::RuntimeEvent; - - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::AuthorityRemoved { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); -} - -#[test] -fn relay_commands_add_remove_username_authority_wrong_origin() { - let people_westend_alice = PeopleWestend::account_id_of(ALICE); - - let origins = vec![ - ( - OriginKind::SovereignAccount, - <Westend as Chain>::RuntimeOrigin::signed(people_westend_alice.clone()), - ), - (OriginKind::Xcm, GeneralAdminOrigin.into()), - ]; - - for (origin_kind, origin) in origins { - Westend::execute_with(|| { - type Runtime = <Westend as Chain>::Runtime; - type RuntimeCall = <Westend as Chain>::RuntimeCall; - type RuntimeEvent = <Westend as Chain>::RuntimeEvent; - type PeopleCall = <PeopleWestend as Chain>::RuntimeCall; - type PeopleRuntime = <PeopleWestend as Chain>::Runtime; - - Dmp::make_parachain_reachable(1004); - - let add_username_authority = PeopleCall::Identity(pallet_identity::Call::< - PeopleRuntime, - >::add_username_authority { - authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), - suffix: b"suffix1".into(), - allocation: 10, - }); - - let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::<Runtime>::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: add_username_authority.encode().into(), - fallback_max_weight: None - } - ]))), - }); - - assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - // Check events system-parachain-side - PeopleWestend::execute_with(|| { - assert_expected_events!(PeopleWestend, vec![]); - }); - - Westend::execute_with(|| { - type Runtime = <Westend as Chain>::Runtime; - type RuntimeCall = <Westend as Chain>::RuntimeCall; - type RuntimeEvent = <Westend as Chain>::RuntimeEvent; - type PeopleCall = <PeopleWestend as Chain>::RuntimeCall; - type PeopleRuntime = <PeopleWestend as Chain>::Runtime; - - let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< - PeopleRuntime, - >::remove_username_authority { - authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), - suffix: b"suffix1".into(), - }); - - Dmp::make_parachain_reachable(1004); - - let remove_authority_xcm_msg = - RuntimeCall::XcmPallet(pallet_xcm::Call::<Runtime>::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind: OriginKind::SovereignAccount, - call: remove_username_authority.encode().into(), - fallback_max_weight: None, - } - ]))), - }); - - assert_ok!(remove_authority_xcm_msg.dispatch(origin)); - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - PeopleWestend::execute_with(|| { - assert_expected_events!(PeopleWestend, vec![]); - }); - } -} diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml b/cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml index 041b43c685d..3cd01de3fb3 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml @@ -133,7 +133,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "cumulus-pallet-aura-ext/try-runtime", diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/Cargo.toml b/cumulus/parachains/runtimes/assets/asset-hub-westend/Cargo.toml index b808f3d7712..877ba11a849 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/Cargo.toml @@ -135,7 +135,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "cumulus-pallet-aura-ext/try-runtime", diff --git a/cumulus/parachains/runtimes/assets/common/Cargo.toml b/cumulus/parachains/runtimes/assets/common/Cargo.toml index ace30911770..7e8647be9b6 100644 --- a/cumulus/parachains/runtimes/assets/common/Cargo.toml +++ b/cumulus/parachains/runtimes/assets/common/Cargo.toml @@ -59,5 +59,4 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index e1141b3caa9..54745db210e 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -254,7 +254,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml index 6d90411e060..45f4f1b2c37 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml @@ -246,7 +246,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml index 2f19289b8b4..31b692c47c4 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml @@ -39,5 +39,4 @@ runtime-benchmarks = [ "pallet-message-queue/runtime-benchmarks", "snowbridge-core/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/Cargo.toml b/cumulus/parachains/runtimes/collectives/collectives-westend/Cargo.toml index 00daf0dd26b..c5658031c5b 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/Cargo.toml @@ -127,7 +127,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "cumulus-pallet-aura-ext/try-runtime", diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/Cargo.toml b/cumulus/parachains/runtimes/contracts/contracts-rococo/Cargo.toml index 8f2792a7e58..bea87ad0061 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/Cargo.toml +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/Cargo.toml @@ -163,7 +163,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/Cargo.toml b/cumulus/parachains/runtimes/coretime/coretime-rococo/Cargo.toml index e3e16fe551a..4bfc7e9a00c 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/Cargo.toml +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/Cargo.toml @@ -170,7 +170,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/Cargo.toml b/cumulus/parachains/runtimes/coretime/coretime-westend/Cargo.toml index d7f5ff24dd3..843afd90f20 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/Cargo.toml @@ -167,7 +167,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ diff --git a/cumulus/parachains/runtimes/glutton/glutton-westend/Cargo.toml b/cumulus/parachains/runtimes/glutton/glutton-westend/Cargo.toml index 9760c01a26e..e5da8acd7e7 100644 --- a/cumulus/parachains/runtimes/glutton/glutton-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/glutton/glutton-westend/Cargo.toml @@ -70,7 +70,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] std = [ "codec/std", diff --git a/cumulus/parachains/runtimes/people/people-rococo/Cargo.toml b/cumulus/parachains/runtimes/people/people-rococo/Cargo.toml index 6a9d82c7e61..8e74c68315c 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/Cargo.toml +++ b/cumulus/parachains/runtimes/people/people-rococo/Cargo.toml @@ -164,7 +164,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ diff --git a/cumulus/parachains/runtimes/people/people-westend/Cargo.toml b/cumulus/parachains/runtimes/people/people-westend/Cargo.toml index 15c9edccd74..4c4da0dbb8f 100644 --- a/cumulus/parachains/runtimes/people/people-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/people/people-westend/Cargo.toml @@ -164,7 +164,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ diff --git a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml index c57c9e5176b..79cfc5fa645 100644 --- a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml +++ b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml @@ -165,7 +165,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ diff --git a/cumulus/parachains/runtimes/testing/rococo-parachain/Cargo.toml b/cumulus/parachains/runtimes/testing/rococo-parachain/Cargo.toml index 1e0735c3dc6..5a95e3ac29d 100644 --- a/cumulus/parachains/runtimes/testing/rococo-parachain/Cargo.toml +++ b/cumulus/parachains/runtimes/testing/rococo-parachain/Cargo.toml @@ -127,7 +127,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] # A feature that should be enabled when the runtime should be built for on-chain diff --git a/cumulus/polkadot-parachain/Cargo.toml b/cumulus/polkadot-parachain/Cargo.toml index 8bb56ee9da1..8c0f723d3f5 100644 --- a/cumulus/polkadot-parachain/Cargo.toml +++ b/cumulus/polkadot-parachain/Cargo.toml @@ -85,7 +85,6 @@ runtime-benchmarks = [ "people-rococo-runtime/runtime-benchmarks", "people-westend-runtime/runtime-benchmarks", "rococo-parachain-runtime/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "polkadot-parachain-lib/try-runtime", diff --git a/cumulus/primitives/core/Cargo.toml b/cumulus/primitives/core/Cargo.toml index 2ea56424ca2..4afc7c33acb 100644 --- a/cumulus/primitives/core/Cargo.toml +++ b/cumulus/primitives/core/Cargo.toml @@ -37,5 +37,4 @@ runtime-benchmarks = [ "polkadot-parachain-primitives/runtime-benchmarks", "polkadot-primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/cumulus/primitives/utility/Cargo.toml b/cumulus/primitives/utility/Cargo.toml index b2a67ba9e48..dfc148ec3c7 100644 --- a/cumulus/primitives/utility/Cargo.toml +++ b/cumulus/primitives/utility/Cargo.toml @@ -44,5 +44,4 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/polkadot/node/service/Cargo.toml b/polkadot/node/service/Cargo.toml index 0b48d9eb5c3..914de1161f8 100644 --- a/polkadot/node/service/Cargo.toml +++ b/polkadot/node/service/Cargo.toml @@ -251,7 +251,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "westend-runtime?/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-system/try-runtime", diff --git a/polkadot/parachain/src/primitives.rs b/polkadot/parachain/src/primitives.rs index 1f2f9e2e9cd..c5757928c3f 100644 --- a/polkadot/parachain/src/primitives.rs +++ b/polkadot/parachain/src/primitives.rs @@ -57,8 +57,6 @@ impl HeadData { } } -impl codec::EncodeLike<HeadData> for alloc::vec::Vec<u8> {} - /// Parachain validation code. #[derive( PartialEq, @@ -156,9 +154,6 @@ pub struct BlockData(#[cfg_attr(feature = "std", serde(with = "bytes"))] pub Vec #[cfg_attr(feature = "std", derive(derive_more::Display))] pub struct Id(u32); -impl codec::EncodeLike<u32> for Id {} -impl codec::EncodeLike<Id> for u32 {} - impl TypeId for Id { const TYPE_ID: [u8; 4] = *b"para"; } diff --git a/polkadot/runtime/common/Cargo.toml b/polkadot/runtime/common/Cargo.toml index e9cfed82314..66afbb79384 100644 --- a/polkadot/runtime/common/Cargo.toml +++ b/polkadot/runtime/common/Cargo.toml @@ -133,7 +133,6 @@ runtime-benchmarks = [ "sp-staking/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-election-provider-support/try-runtime", diff --git a/polkadot/runtime/common/src/identity_migrator.rs b/polkadot/runtime/common/src/identity_migrator.rs index e3835b69252..126c886280e 100644 --- a/polkadot/runtime/common/src/identity_migrator.rs +++ b/polkadot/runtime/common/src/identity_migrator.rs @@ -160,22 +160,12 @@ pub trait OnReapIdentity<AccountId> { /// - `bytes`: The byte size of `IdentityInfo`. /// - `subs`: The number of sub-accounts they had. fn on_reap_identity(who: &AccountId, bytes: u32, subs: u32) -> DispatchResult; - - /// Ensure that identity reaping will be succesful in benchmarking. - /// - /// Should setup the state in a way that the same call ot `[Self::on_reap_identity]` will be - /// successful. - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_identity_reaping(who: &AccountId, bytes: u32, subs: u32); } impl<AccountId> OnReapIdentity<AccountId> for () { fn on_reap_identity(_who: &AccountId, _bytes: u32, _subs: u32) -> DispatchResult { Ok(()) } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_identity_reaping(_: &AccountId, _: u32, _: u32) {} } #[cfg(feature = "runtime-benchmarks")] @@ -229,12 +219,6 @@ mod benchmarks { } Identity::<T>::set_subs(target_origin.clone(), subs.clone())?; - T::ReapIdentityHandler::ensure_successful_identity_reaping( - &target, - info.encoded_size() as u32, - subs.len() as u32, - ); - // add registrars and provide judgements let registrar_origin = T::RegistrarOrigin::try_successful_origin() .expect("RegistrarOrigin has no successful origin required for the benchmark"); diff --git a/polkadot/runtime/common/src/paras_sudo_wrapper.rs b/polkadot/runtime/common/src/paras_sudo_wrapper.rs index 4309931fe81..af93c70b478 100644 --- a/polkadot/runtime/common/src/paras_sudo_wrapper.rs +++ b/polkadot/runtime/common/src/paras_sudo_wrapper.rs @@ -48,8 +48,6 @@ pub mod pallet { /// A DMP message couldn't be sent because it exceeds the maximum size allowed for a /// downward message. ExceedsMaxMessageSize, - /// A DMP message couldn't be sent because the destination is unreachable. - Unroutable, /// Could not schedule para cleanup. CouldntCleanup, /// Not a parathread (on-demand parachain). @@ -154,7 +152,6 @@ pub mod pallet { { dmp::QueueDownwardMessageError::ExceedsMaxMessageSize => Error::<T>::ExceedsMaxMessageSize.into(), - dmp::QueueDownwardMessageError::Unroutable => Error::<T>::Unroutable.into(), }) } diff --git a/polkadot/runtime/common/src/xcm_sender.rs b/polkadot/runtime/common/src/xcm_sender.rs index bdd407fd11c..37fe7f0b59e 100644 --- a/polkadot/runtime/common/src/xcm_sender.rs +++ b/polkadot/runtime/common/src/xcm_sender.rs @@ -138,13 +138,6 @@ where .map(|()| hash) .map_err(|_| SendError::Transport(&"Error placing into DMP queue")) } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_delivery(location: Option<Location>) { - if let Some((0, [Parachain(id)])) = location.as_ref().map(|l| l.unpack()) { - dmp::Pallet::<T>::make_parachain_reachable(*id); - } - } } impl<T: dmp::Config, W, P> InspectMessageQueues for ChildParachainRouter<T, W, P> { @@ -197,7 +190,7 @@ impl< ExistentialDeposit: Get<Option<Asset>>, PriceForDelivery: PriceForMessageDelivery<Id = ParaId>, Parachain: Get<ParaId>, - ToParachainHelper: polkadot_runtime_parachains::EnsureForParachain, + ToParachainHelper: EnsureForParachain, > xcm_builder::EnsureDelivery for ToParachainDeliveryHelper< XcmConfig, @@ -226,9 +219,6 @@ impl< return (None, None) } - // allow more initialization for target parachain - ToParachainHelper::ensure(Parachain::get()); - let mut fees_mode = None; if !XcmConfig::FeeManager::is_waived(Some(origin_ref), fee_reason) { // if not waived, we need to set up accounts for paying and receiving fees @@ -248,6 +238,9 @@ impl< XcmConfig::AssetTransactor::deposit_asset(&fee, &origin_ref, None).unwrap(); } + // allow more initialization for target parachain + ToParachainHelper::ensure(Parachain::get()); + // expected worst case - direct withdraw fees_mode = Some(FeesMode { jit_withdraw: true }); } @@ -255,6 +248,18 @@ impl< } } +/// Ensure more initialization for `ParaId`. (e.g. open HRMP channels, ...) +#[cfg(feature = "runtime-benchmarks")] +pub trait EnsureForParachain { + fn ensure(para_id: ParaId); +} +#[cfg(feature = "runtime-benchmarks")] +impl EnsureForParachain for () { + fn ensure(_: ParaId) { + // doing nothing + } +} + #[cfg(test)] mod tests { use super::*; @@ -344,8 +349,6 @@ mod tests { c.max_downward_message_size = u32::MAX; }); - dmp::Pallet::<crate::integration_tests::Test>::make_parachain_reachable(5555); - // Check that the good message is validated: assert_ok!(<Router as SendXcm>::validate( &mut Some(dest.into()), diff --git a/polkadot/runtime/parachains/Cargo.toml b/polkadot/runtime/parachains/Cargo.toml index 8873cb60806..0419ebb28d3 100644 --- a/polkadot/runtime/parachains/Cargo.toml +++ b/polkadot/runtime/parachains/Cargo.toml @@ -133,7 +133,6 @@ runtime-benchmarks = [ "sp-std", "static_assertions", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", diff --git a/polkadot/runtime/parachains/src/coretime/benchmarking.rs b/polkadot/runtime/parachains/src/coretime/benchmarking.rs index 49e3d8a88c0..6d593f1954f 100644 --- a/polkadot/runtime/parachains/src/coretime/benchmarking.rs +++ b/polkadot/runtime/parachains/src/coretime/benchmarking.rs @@ -43,8 +43,6 @@ mod benchmarks { .unwrap(); on_demand::Revenue::<T>::put(rev); - crate::paras::Heads::<T>::insert(ParaId::from(T::BrokerId::get()), vec![1, 2, 3]); - <T as on_demand::Config>::Currency::make_free_balance_be( &<on_demand::Pallet<T>>::account_id(), minimum_balance * (mhr * (mhr + 1)).into(), diff --git a/polkadot/runtime/parachains/src/dmp.rs b/polkadot/runtime/parachains/src/dmp.rs index 3c9cf800418..03580e11b8e 100644 --- a/polkadot/runtime/parachains/src/dmp.rs +++ b/polkadot/runtime/parachains/src/dmp.rs @@ -44,7 +44,7 @@ use crate::{ configuration::{self, HostConfiguration}, - initializer, paras, FeeTracker, + initializer, FeeTracker, }; use alloc::vec::Vec; use core::fmt; @@ -72,15 +72,12 @@ const MESSAGE_SIZE_FEE_BASE: FixedU128 = FixedU128::from_rational(1, 1000); // 0 pub enum QueueDownwardMessageError { /// The message being sent exceeds the configured max message size. ExceedsMaxMessageSize, - /// The destination is unknown. - Unroutable, } impl From<QueueDownwardMessageError> for SendError { fn from(err: QueueDownwardMessageError) -> Self { match err { QueueDownwardMessageError::ExceedsMaxMessageSize => SendError::ExceedsMaxMessageSize, - QueueDownwardMessageError::Unroutable => SendError::Unroutable, } } } @@ -119,7 +116,7 @@ pub mod pallet { pub struct Pallet<T>(_); #[pallet::config] - pub trait Config: frame_system::Config + configuration::Config + paras::Config {} + pub trait Config: frame_system::Config + configuration::Config {} /// The downward messages addressed for a certain para. #[pallet::storage] @@ -203,11 +200,6 @@ impl<T: Config> Pallet<T> { return Err(QueueDownwardMessageError::ExceedsMaxMessageSize) } - // If the head exists, we assume the parachain is legit and exists. - if !paras::Heads::<T>::contains_key(para) { - return Err(QueueDownwardMessageError::Unroutable) - } - Ok(()) } @@ -225,7 +217,14 @@ impl<T: Config> Pallet<T> { msg: DownwardMessage, ) -> Result<(), QueueDownwardMessageError> { let serialized_len = msg.len() as u32; - Self::can_queue_downward_message(config, ¶, &msg)?; + if serialized_len > config.max_downward_message_size { + return Err(QueueDownwardMessageError::ExceedsMaxMessageSize) + } + + // Hard limit on Queue size + if Self::dmq_length(para) > Self::dmq_max_length(config.max_downward_message_size) { + return Err(QueueDownwardMessageError::ExceedsMaxMessageSize) + } let inbound = InboundDownwardMessage { msg, sent_at: frame_system::Pallet::<T>::block_number() }; @@ -337,15 +336,6 @@ impl<T: Config> Pallet<T> { ) -> Vec<InboundDownwardMessage<BlockNumberFor<T>>> { DownwardMessageQueues::<T>::get(&recipient) } - - /// Make the parachain reachable for downward messages. - /// - /// Only useable in benchmarks or tests. - #[cfg(any(feature = "runtime-benchmarks", feature = "std"))] - pub fn make_parachain_reachable(para: impl Into<ParaId>) { - let para = para.into(); - crate::paras::Heads::<T>::insert(para, para.encode()); - } } impl<T: Config> FeeTracker for Pallet<T> { @@ -369,10 +359,3 @@ impl<T: Config> FeeTracker for Pallet<T> { }) } } - -#[cfg(feature = "runtime-benchmarks")] -impl<T: Config> crate::EnsureForParachain for Pallet<T> { - fn ensure(para: ParaId) { - Self::make_parachain_reachable(para); - } -} diff --git a/polkadot/runtime/parachains/src/dmp/tests.rs b/polkadot/runtime/parachains/src/dmp/tests.rs index 617c9488bd2..de151595812 100644 --- a/polkadot/runtime/parachains/src/dmp/tests.rs +++ b/polkadot/runtime/parachains/src/dmp/tests.rs @@ -61,12 +61,6 @@ fn queue_downward_message( Dmp::queue_downward_message(&configuration::ActiveConfig::<Test>::get(), para_id, msg) } -fn register_paras(paras: &[ParaId]) { - paras.iter().for_each(|p| { - Dmp::make_parachain_reachable(*p); - }); -} - #[test] fn clean_dmp_works() { let a = ParaId::from(1312); @@ -74,8 +68,6 @@ fn clean_dmp_works() { let c = ParaId::from(123); new_test_ext(default_genesis_config()).execute_with(|| { - register_paras(&[a, b, c]); - // enqueue downward messages to A, B and C. queue_downward_message(a, vec![1, 2, 3]).unwrap(); queue_downward_message(b, vec![4, 5, 6]).unwrap(); @@ -97,8 +89,6 @@ fn dmq_length_and_head_updated_properly() { let b = ParaId::from(228); new_test_ext(default_genesis_config()).execute_with(|| { - register_paras(&[a, b]); - assert_eq!(Dmp::dmq_length(a), 0); assert_eq!(Dmp::dmq_length(b), 0); @@ -111,30 +101,11 @@ fn dmq_length_and_head_updated_properly() { }); } -#[test] -fn dmq_fail_if_para_does_not_exist() { - let a = ParaId::from(1312); - - new_test_ext(default_genesis_config()).execute_with(|| { - assert_eq!(Dmp::dmq_length(a), 0); - - assert!(matches!( - queue_downward_message(a, vec![1, 2, 3]), - Err(QueueDownwardMessageError::Unroutable) - )); - - assert_eq!(Dmp::dmq_length(a), 0); - assert!(Dmp::dmq_mqc_head(a).is_zero()); - }); -} - #[test] fn dmp_mqc_head_fixture() { let a = ParaId::from(2000); new_test_ext(default_genesis_config()).execute_with(|| { - register_paras(&[a]); - run_to_block(2, None); assert!(Dmp::dmq_mqc_head(a).is_zero()); queue_downward_message(a, vec![1, 2, 3]).unwrap(); @@ -154,8 +125,6 @@ fn check_processed_downward_messages() { let a = ParaId::from(1312); new_test_ext(default_genesis_config()).execute_with(|| { - register_paras(&[a]); - let block_number = System::block_number(); // processed_downward_messages=0 is allowed when the DMQ is empty. @@ -181,8 +150,6 @@ fn check_processed_downward_messages_advancement_rule() { let a = ParaId::from(1312); new_test_ext(default_genesis_config()).execute_with(|| { - register_paras(&[a]); - let block_number = System::block_number(); run_to_block(block_number + 1, None); @@ -203,8 +170,6 @@ fn dmq_pruning() { let a = ParaId::from(1312); new_test_ext(default_genesis_config()).execute_with(|| { - register_paras(&[a]); - assert_eq!(Dmp::dmq_length(a), 0); queue_downward_message(a, vec![1, 2, 3]).unwrap(); @@ -229,8 +194,6 @@ fn queue_downward_message_critical() { genesis.configuration.config.max_downward_message_size = 7; new_test_ext(genesis).execute_with(|| { - register_paras(&[a]); - let smol = [0; 3].to_vec(); let big = [0; 8].to_vec(); @@ -252,8 +215,6 @@ fn verify_dmq_mqc_head_is_externally_accessible() { let a = ParaId::from(2020); new_test_ext(default_genesis_config()).execute_with(|| { - register_paras(&[a]); - let head = sp_io::storage::get(&well_known_keys::dmq_mqc_head(a)); assert_eq!(head, None); @@ -274,12 +235,9 @@ fn verify_dmq_mqc_head_is_externally_accessible() { #[test] fn verify_fee_increase_and_decrease() { let a = ParaId::from(123); - let mut genesis = default_genesis_config(); genesis.configuration.config.max_downward_message_size = 16777216; new_test_ext(genesis).execute_with(|| { - register_paras(&[a]); - let initial = InitialFactor::get(); assert_eq!(DeliveryFeeFactor::<Test>::get(a), initial); @@ -329,8 +287,6 @@ fn verify_fee_factor_reaches_high_value() { let mut genesis = default_genesis_config(); genesis.configuration.config.max_downward_message_size = 51200; new_test_ext(genesis).execute_with(|| { - register_paras(&[a]); - let max_messages = Dmp::dmq_max_length(ActiveConfig::<Test>::get().max_downward_message_size); let mut total_fee_factor = FixedU128::from_float(1.0); diff --git a/polkadot/runtime/parachains/src/lib.rs b/polkadot/runtime/parachains/src/lib.rs index e86ca359929..f1162e1cc21 100644 --- a/polkadot/runtime/parachains/src/lib.rs +++ b/polkadot/runtime/parachains/src/lib.rs @@ -115,19 +115,3 @@ pub fn schedule_code_upgrade<T: paras::Config>( pub fn set_current_head<T: paras::Config>(id: ParaId, new_head: HeadData) { paras::Pallet::<T>::set_current_head(id, new_head) } - -/// Ensure more initialization for `ParaId` when benchmarking. (e.g. open HRMP channels, ...) -#[cfg(feature = "runtime-benchmarks")] -pub trait EnsureForParachain { - fn ensure(para_id: ParaId); -} - -#[cfg(feature = "runtime-benchmarks")] -#[impl_trait_for_tuples::impl_for_tuples(30)] -impl EnsureForParachain for Tuple { - fn ensure(para: ParaId) { - for_tuples!( #( - Tuple::ensure(para); - )* ); - } -} diff --git a/polkadot/runtime/rococo/Cargo.toml b/polkadot/runtime/rococo/Cargo.toml index 1da3536aebf..687ccbd2f85 100644 --- a/polkadot/runtime/rococo/Cargo.toml +++ b/polkadot/runtime/rococo/Cargo.toml @@ -264,7 +264,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-executive/try-runtime", diff --git a/polkadot/runtime/rococo/src/impls.rs b/polkadot/runtime/rococo/src/impls.rs index cac9ee792cd..f01440ea02b 100644 --- a/polkadot/runtime/rococo/src/impls.rs +++ b/polkadot/runtime/rococo/src/impls.rs @@ -176,9 +176,4 @@ where )?; Ok(()) } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_identity_reaping(_: &AccountId, _: u32, _: u32) { - crate::Dmp::make_parachain_reachable(1004); - } } diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index f7ce6de8fff..bfc1e25339b 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -2395,14 +2395,14 @@ sp_api::impl_runtime_apis! { ExistentialDepositAsset, xcm_config::PriceForChildParachainDelivery, AssetHubParaId, - Dmp, + (), >, polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper< XcmConfig, ExistentialDepositAsset, xcm_config::PriceForChildParachainDelivery, RandomParaId, - Dmp, + (), > ); @@ -2461,7 +2461,7 @@ sp_api::impl_runtime_apis! { ExistentialDepositAsset, xcm_config::PriceForChildParachainDelivery, AssetHubParaId, - Dmp, + (), >; fn valid_destination() -> Result<Location, BenchmarkError> { Ok(AssetHub::get()) diff --git a/polkadot/runtime/test-runtime/Cargo.toml b/polkadot/runtime/test-runtime/Cargo.toml index 717ddb8a744..237643ec029 100644 --- a/polkadot/runtime/test-runtime/Cargo.toml +++ b/polkadot/runtime/test-runtime/Cargo.toml @@ -152,5 +152,4 @@ runtime-benchmarks = [ "sp-staking/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/polkadot/runtime/westend/Cargo.toml b/polkadot/runtime/westend/Cargo.toml index b9e8bb1cd48..cb2803ef2f3 100644 --- a/polkadot/runtime/westend/Cargo.toml +++ b/polkadot/runtime/westend/Cargo.toml @@ -285,7 +285,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-election-provider-support/try-runtime", diff --git a/polkadot/runtime/westend/src/impls.rs b/polkadot/runtime/westend/src/impls.rs index 6f1c5e0e3b3..ac3f9e679f8 100644 --- a/polkadot/runtime/westend/src/impls.rs +++ b/polkadot/runtime/westend/src/impls.rs @@ -176,9 +176,4 @@ where )?; Ok(()) } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_identity_reaping(_: &AccountId, _: u32, _: u32) { - crate::Dmp::make_parachain_reachable(1004); - } } diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 760e878d647..cb546a910f7 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -2566,14 +2566,14 @@ sp_api::impl_runtime_apis! { ExistentialDepositAsset, xcm_config::PriceForChildParachainDelivery, AssetHubParaId, - Dmp, + (), >, polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper< xcm_config::XcmConfig, ExistentialDepositAsset, xcm_config::PriceForChildParachainDelivery, RandomParaId, - Dmp, + (), > ); @@ -2639,7 +2639,7 @@ sp_api::impl_runtime_apis! { ExistentialDepositAsset, xcm_config::PriceForChildParachainDelivery, AssetHubParaId, - Dmp, + (), >; fn valid_destination() -> Result<Location, BenchmarkError> { Ok(AssetHub::get()) diff --git a/polkadot/xcm/Cargo.toml b/polkadot/xcm/Cargo.toml index b0b0545715f..ebc024b05e4 100644 --- a/polkadot/xcm/Cargo.toml +++ b/polkadot/xcm/Cargo.toml @@ -48,4 +48,3 @@ json-schema = [ "dep:schemars", "sp-weights/json-schema", ] -runtime-benchmarks = ["sp-runtime/runtime-benchmarks"] diff --git a/polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml b/polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml index 6ae183be893..636f483293a 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml +++ b/polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml @@ -57,5 +57,4 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index 4faf3ed935d..6ce49074a6e 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -231,13 +231,6 @@ benchmarks_instance_pallet! { let dest_account = T::AccountIdConverter::convert_location(&dest_location).unwrap(); assert!(T::TransactAsset::balance(&dest_account).is_zero()); - // Ensure that origin can send to destination (e.g. setup delivery fees, ensure router setup, ...) - let (_, _) = T::DeliveryHelper::ensure_successful_delivery( - &Default::default(), - &dest_location, - FeeReason::ChargeFees, - ); - let mut executor = new_executor::<T>(Default::default()); executor.set_holding(holding.into()); let instruction = Instruction::<XcmCallOf<T>>::DepositAsset { @@ -264,13 +257,6 @@ benchmarks_instance_pallet! { let dest_account = T::AccountIdConverter::convert_location(&dest_location).unwrap(); assert!(T::TransactAsset::balance(&dest_account).is_zero()); - // Ensure that origin can send to destination (e.g. setup delivery fees, ensure router setup, ...) - let (_, _) = T::DeliveryHelper::ensure_successful_delivery( - &Default::default(), - &dest_location, - FeeReason::ChargeFees, - ); - let mut executor = new_executor::<T>(Default::default()); executor.set_holding(holding.into()); let instruction = Instruction::<XcmCallOf<T>>::DepositReserveAsset { @@ -295,20 +281,12 @@ benchmarks_instance_pallet! { // Checked account starts at zero assert!(T::CheckedAccount::get().map_or(true, |(c, _)| T::TransactAsset::balance(&c).is_zero())); - let dest_location = T::valid_destination()?; - - // Ensure that origin can send to destination (e.g. setup delivery fees, ensure router setup, ...) - let (_, _) = T::DeliveryHelper::ensure_successful_delivery( - &Default::default(), - &dest_location, - FeeReason::ChargeFees, - ); let mut executor = new_executor::<T>(Default::default()); executor.set_holding(holding.into()); let instruction = Instruction::<XcmCallOf<T>>::InitiateTeleport { assets: asset.into(), - dest: dest_location, + dest: T::valid_destination()?, xcm: Xcm::new(), }; let xcm = Xcm(vec![instruction]); diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index c382f59733a..40a7da58a68 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -293,7 +293,6 @@ benchmarks! { let mut executor = new_executor::<T>(origin.clone()); let instruction = Instruction::SubscribeVersion { query_id, max_response_weight }; let xcm = Xcm(vec![instruction]); - T::DeliveryHelper::ensure_successful_delivery(&origin, &origin, FeeReason::QueryPallet); } : { executor.bench_process(xcm)?; } verify { @@ -304,9 +303,6 @@ benchmarks! { use xcm_executor::traits::VersionChangeNotifier; // First we need to subscribe to notifications. let (origin, _) = T::transact_origin_and_runtime_call()?; - - T::DeliveryHelper::ensure_successful_delivery(&origin, &origin, FeeReason::QueryPallet); - let query_id = Default::default(); let max_response_weight = Default::default(); <T::XcmConfig as xcm_executor::Config>::SubscriptionService::start( diff --git a/polkadot/xcm/pallet-xcm/Cargo.toml b/polkadot/xcm/pallet-xcm/Cargo.toml index 6716dc8e97f..a1da980e63b 100644 --- a/polkadot/xcm/pallet-xcm/Cargo.toml +++ b/polkadot/xcm/pallet-xcm/Cargo.toml @@ -63,7 +63,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-runtime-apis/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", diff --git a/polkadot/xcm/pallet-xcm/src/benchmarking.rs b/polkadot/xcm/pallet-xcm/src/benchmarking.rs index f5c78a93509..d09c81bf434 100644 --- a/polkadot/xcm/pallet-xcm/src/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm/src/benchmarking.rs @@ -96,13 +96,6 @@ benchmarks! { )? .into(); let versioned_msg = VersionedXcm::from(msg); - - // Ensure that origin can send to destination (e.g. setup delivery fees, ensure router setup, ...) - T::DeliveryHelper::ensure_successful_delivery( - &Default::default(), - &versioned_dest.clone().try_into().unwrap(), - FeeReason::ChargeFees, - ); }: _<RuntimeOrigin<T>>(send_origin, Box::new(versioned_dest), Box::new(versioned_msg)) teleport_assets { @@ -171,7 +164,7 @@ benchmarks! { } // Ensure that origin can send to destination (e.g. setup delivery fees, ensure router setup, ...) - T::DeliveryHelper::ensure_successful_delivery( + let (_, _) = T::DeliveryHelper::ensure_successful_delivery( &origin_location, &destination, FeeReason::ChargeFees, @@ -234,13 +227,6 @@ benchmarks! { let versioned_beneficiary: VersionedLocation = AccountId32 { network: None, id: recipient.into() }.into(); let versioned_assets: VersionedAssets = assets.into(); - - // Ensure that origin can send to destination (e.g. setup delivery fees, ensure router setup, ...) - T::DeliveryHelper::ensure_successful_delivery( - &Default::default(), - &versioned_dest.clone().try_into().unwrap(), - FeeReason::ChargeFees, - ); }: _<RuntimeOrigin<T>>(send_origin.into(), Box::new(versioned_dest), Box::new(versioned_beneficiary), Box::new(versioned_assets), 0, WeightLimit::Unlimited) verify { // run provided verification function @@ -273,14 +259,6 @@ benchmarks! { BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)), )? .into(); - - // Ensure that origin can send to destination (e.g. setup delivery fees, ensure router setup, ...) - T::DeliveryHelper::ensure_successful_delivery( - &Default::default(), - &versioned_loc.clone().try_into().unwrap(), - FeeReason::ChargeFees, - ); - }: _(RawOrigin::Root, Box::new(versioned_loc)) force_unsubscribe_version_notify { @@ -288,14 +266,6 @@ benchmarks! { BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)), )?; let versioned_loc: VersionedLocation = loc.clone().into(); - - // Ensure that origin can send to destination (e.g. setup delivery fees, ensure router setup, ...) - T::DeliveryHelper::ensure_successful_delivery( - &Default::default(), - &versioned_loc.clone().try_into().unwrap(), - FeeReason::ChargeFees, - ); - let _ = crate::Pallet::<T>::request_version_notify(loc); }: _(RawOrigin::Root, Box::new(versioned_loc)) diff --git a/polkadot/xcm/src/v4/traits.rs b/polkadot/xcm/src/v4/traits.rs index 448d869c19a..c4eec522ed0 100644 --- a/polkadot/xcm/src/v4/traits.rs +++ b/polkadot/xcm/src/v4/traits.rs @@ -246,10 +246,6 @@ pub trait SendXcm { /// Actually carry out the delivery operation for a previously validated message sending. fn deliver(ticket: Self::Ticket) -> result::Result<XcmHash, SendError>; - - /// Ensure `[Self::delivery]` is successful for the given `location` when called in benchmarks. - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_delivery(_location: Option<Location>) {} } #[impl_trait_for_tuples::impl_for_tuples(30)] @@ -290,13 +286,6 @@ impl SendXcm for Tuple { )* ); Err(SendError::Unroutable) } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_delivery(location: Option<Location>) { - for_tuples!( #( - return Tuple::ensure_successful_delivery(location.clone()); - )* ); - } } /// Convenience function for using a `SendXcm` implementation. Just interprets the `dest` and wraps diff --git a/polkadot/xcm/src/v5/traits.rs b/polkadot/xcm/src/v5/traits.rs deleted file mode 100644 index 79d32856142..00000000000 --- a/polkadot/xcm/src/v5/traits.rs +++ /dev/null @@ -1,537 +0,0 @@ -// 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 <http://www.gnu.org/licenses/>. - -//! Cross-Consensus Message format data structures. - -pub use crate::v3::{Error as OldError, SendError, XcmHash}; -use codec::{Decode, Encode}; -use core::result; -use scale_info::TypeInfo; - -pub use sp_weights::Weight; - -use super::*; - -/// Error codes used in XCM. The first errors codes have explicit indices and are part of the XCM -/// format. Those trailing are merely part of the XCM implementation; there is no expectation that -/// they will retain the same index over time. -#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] -#[scale_info(replace_segment("staging_xcm", "xcm"))] -#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))] -pub enum Error { - // Errors that happen due to instructions being executed. These alone are defined in the - // XCM specification. - /// An arithmetic overflow happened. - #[codec(index = 0)] - Overflow, - /// The instruction is intentionally unsupported. - #[codec(index = 1)] - Unimplemented, - /// Origin Register does not contain a value value for a reserve transfer notification. - #[codec(index = 2)] - UntrustedReserveLocation, - /// Origin Register does not contain a value value for a teleport notification. - #[codec(index = 3)] - UntrustedTeleportLocation, - /// `MultiLocation` value too large to descend further. - #[codec(index = 4)] - LocationFull, - /// `MultiLocation` value ascend more parents than known ancestors of local location. - #[codec(index = 5)] - LocationNotInvertible, - /// The Origin Register does not contain a valid value for instruction. - #[codec(index = 6)] - BadOrigin, - /// The location parameter is not a valid value for the instruction. - #[codec(index = 7)] - InvalidLocation, - /// The given asset is not handled. - #[codec(index = 8)] - AssetNotFound, - /// An asset transaction (like withdraw or deposit) failed (typically due to type conversions). - #[codec(index = 9)] - FailedToTransactAsset(#[codec(skip)] &'static str), - /// An asset cannot be withdrawn, potentially due to lack of ownership, availability or rights. - #[codec(index = 10)] - NotWithdrawable, - /// An asset cannot be deposited under the ownership of a particular location. - #[codec(index = 11)] - LocationCannotHold, - /// Attempt to send a message greater than the maximum supported by the transport protocol. - #[codec(index = 12)] - ExceedsMaxMessageSize, - /// The given message cannot be translated into a format supported by the destination. - #[codec(index = 13)] - DestinationUnsupported, - /// Destination is routable, but there is some issue with the transport mechanism. - #[codec(index = 14)] - Transport(#[codec(skip)] &'static str), - /// Destination is known to be unroutable. - #[codec(index = 15)] - Unroutable, - /// Used by `ClaimAsset` when the given claim could not be recognized/found. - #[codec(index = 16)] - UnknownClaim, - /// Used by `Transact` when the functor cannot be decoded. - #[codec(index = 17)] - FailedToDecode, - /// Used by `Transact` to indicate that the given weight limit could be breached by the - /// functor. - #[codec(index = 18)] - MaxWeightInvalid, - /// Used by `BuyExecution` when the Holding Register does not contain payable fees. - #[codec(index = 19)] - NotHoldingFees, - /// Used by `BuyExecution` when the fees declared to purchase weight are insufficient. - #[codec(index = 20)] - TooExpensive, - /// Used by the `Trap` instruction to force an error intentionally. Its code is included. - #[codec(index = 21)] - Trap(u64), - /// Used by `ExpectAsset`, `ExpectError` and `ExpectOrigin` when the expectation was not true. - #[codec(index = 22)] - ExpectationFalse, - /// The provided pallet index was not found. - #[codec(index = 23)] - PalletNotFound, - /// The given pallet's name is different to that expected. - #[codec(index = 24)] - NameMismatch, - /// The given pallet's version has an incompatible version to that expected. - #[codec(index = 25)] - VersionIncompatible, - /// The given operation would lead to an overflow of the Holding Register. - #[codec(index = 26)] - HoldingWouldOverflow, - /// The message was unable to be exported. - #[codec(index = 27)] - ExportError, - /// `MultiLocation` value failed to be reanchored. - #[codec(index = 28)] - ReanchorFailed, - /// No deal is possible under the given constraints. - #[codec(index = 29)] - NoDeal, - /// Fees were required which the origin could not pay. - #[codec(index = 30)] - FeesNotMet, - /// Some other error with locking. - #[codec(index = 31)] - LockError, - /// The state was not in a condition where the operation was valid to make. - #[codec(index = 32)] - NoPermission, - /// The universal location of the local consensus is improper. - #[codec(index = 33)] - Unanchored, - /// An asset cannot be deposited, probably because (too much of) it already exists. - #[codec(index = 34)] - NotDepositable, - /// Too many assets matched the given asset filter. - #[codec(index = 35)] - TooManyAssets, - - // Errors that happen prior to instructions being executed. These fall outside of the XCM - // spec. - /// XCM version not able to be handled. - UnhandledXcmVersion, - /// Execution of the XCM would potentially result in a greater weight used than weight limit. - WeightLimitReached(Weight), - /// The XCM did not pass the barrier condition for execution. - /// - /// The barrier condition differs on different chains and in different circumstances, but - /// generally it means that the conditions surrounding the message were not such that the chain - /// considers the message worth spending time executing. Since most chains lift the barrier to - /// execution on appropriate payment, presentation of an NFT voucher, or based on the message - /// origin, it means that none of those were the case. - Barrier, - /// The weight of an XCM message is not computable ahead of execution. - WeightNotComputable, - /// Recursion stack limit reached - // TODO(https://github.com/paritytech/polkadot-sdk/issues/6199): This should have a fixed index since - // we use it in `FrameTransactionalProcessor` // which is used in instructions. - // Or we should create a different error for that. - ExceedsStackLimit, -} - -impl TryFrom<OldError> for Error { - type Error = (); - fn try_from(old_error: OldError) -> result::Result<Error, ()> { - use OldError::*; - Ok(match old_error { - Overflow => Self::Overflow, - Unimplemented => Self::Unimplemented, - UntrustedReserveLocation => Self::UntrustedReserveLocation, - UntrustedTeleportLocation => Self::UntrustedTeleportLocation, - LocationFull => Self::LocationFull, - LocationNotInvertible => Self::LocationNotInvertible, - BadOrigin => Self::BadOrigin, - InvalidLocation => Self::InvalidLocation, - AssetNotFound => Self::AssetNotFound, - FailedToTransactAsset(s) => Self::FailedToTransactAsset(s), - NotWithdrawable => Self::NotWithdrawable, - LocationCannotHold => Self::LocationCannotHold, - ExceedsMaxMessageSize => Self::ExceedsMaxMessageSize, - DestinationUnsupported => Self::DestinationUnsupported, - Transport(s) => Self::Transport(s), - Unroutable => Self::Unroutable, - UnknownClaim => Self::UnknownClaim, - FailedToDecode => Self::FailedToDecode, - MaxWeightInvalid => Self::MaxWeightInvalid, - NotHoldingFees => Self::NotHoldingFees, - TooExpensive => Self::TooExpensive, - Trap(i) => Self::Trap(i), - ExpectationFalse => Self::ExpectationFalse, - PalletNotFound => Self::PalletNotFound, - NameMismatch => Self::NameMismatch, - VersionIncompatible => Self::VersionIncompatible, - HoldingWouldOverflow => Self::HoldingWouldOverflow, - ExportError => Self::ExportError, - ReanchorFailed => Self::ReanchorFailed, - NoDeal => Self::NoDeal, - FeesNotMet => Self::FeesNotMet, - LockError => Self::LockError, - NoPermission => Self::NoPermission, - Unanchored => Self::Unanchored, - NotDepositable => Self::NotDepositable, - UnhandledXcmVersion => Self::UnhandledXcmVersion, - WeightLimitReached(weight) => Self::WeightLimitReached(weight), - Barrier => Self::Barrier, - WeightNotComputable => Self::WeightNotComputable, - ExceedsStackLimit => Self::ExceedsStackLimit, - }) - } -} - -impl MaxEncodedLen for Error { - fn max_encoded_len() -> usize { - // TODO: max_encoded_len doesn't quite work here as it tries to take notice of the fields - // marked `codec(skip)`. We can hard-code it with the right answer for now. - 1 - } -} - -impl From<SendError> for Error { - fn from(e: SendError) -> Self { - match e { - SendError::NotApplicable | SendError::Unroutable | SendError::MissingArgument => - Error::Unroutable, - SendError::Transport(s) => Error::Transport(s), - SendError::DestinationUnsupported => Error::DestinationUnsupported, - SendError::ExceedsMaxMessageSize => Error::ExceedsMaxMessageSize, - SendError::Fees => Error::FeesNotMet, - } - } -} - -pub type Result = result::Result<(), Error>; - -/// Outcome of an XCM execution. -#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] -pub enum Outcome { - /// Execution completed successfully; given weight was used. - Complete { used: Weight }, - /// Execution started, but did not complete successfully due to the given error; given weight - /// was used. - Incomplete { used: Weight, error: Error }, - /// Execution did not start due to the given error. - Error { error: Error }, -} - -impl Outcome { - pub fn ensure_complete(self) -> Result { - match self { - Outcome::Complete { .. } => Ok(()), - Outcome::Incomplete { error, .. } => Err(error), - Outcome::Error { error, .. } => Err(error), - } - } - pub fn ensure_execution(self) -> result::Result<Weight, Error> { - match self { - Outcome::Complete { used, .. } => Ok(used), - Outcome::Incomplete { used, .. } => Ok(used), - Outcome::Error { error, .. } => Err(error), - } - } - /// How much weight was used by the XCM execution attempt. - pub fn weight_used(&self) -> Weight { - match self { - Outcome::Complete { used, .. } => *used, - Outcome::Incomplete { used, .. } => *used, - Outcome::Error { .. } => Weight::zero(), - } - } -} - -impl From<Error> for Outcome { - fn from(error: Error) -> Self { - Self::Error { error } - } -} - -pub trait PreparedMessage { - fn weight_of(&self) -> Weight; -} - -/// Type of XCM message executor. -pub trait ExecuteXcm<Call> { - type Prepared: PreparedMessage; - fn prepare(message: Xcm<Call>) -> result::Result<Self::Prepared, Xcm<Call>>; - fn execute( - origin: impl Into<Location>, - pre: Self::Prepared, - id: &mut XcmHash, - weight_credit: Weight, - ) -> Outcome; - fn prepare_and_execute( - origin: impl Into<Location>, - message: Xcm<Call>, - id: &mut XcmHash, - weight_limit: Weight, - weight_credit: Weight, - ) -> Outcome { - let pre = match Self::prepare(message) { - Ok(x) => x, - Err(_) => return Outcome::Error { error: Error::WeightNotComputable }, - }; - let xcm_weight = pre.weight_of(); - if xcm_weight.any_gt(weight_limit) { - return Outcome::Error { error: Error::WeightLimitReached(xcm_weight) } - } - Self::execute(origin, pre, id, weight_credit) - } - - /// Deduct some `fees` to the sovereign account of the given `location` and place them as per - /// the convention for fees. - fn charge_fees(location: impl Into<Location>, fees: Assets) -> Result; -} - -pub enum Weightless {} -impl PreparedMessage for Weightless { - fn weight_of(&self) -> Weight { - unreachable!() - } -} - -impl<C> ExecuteXcm<C> for () { - type Prepared = Weightless; - fn prepare(message: Xcm<C>) -> result::Result<Self::Prepared, Xcm<C>> { - Err(message) - } - fn execute(_: impl Into<Location>, _: Self::Prepared, _: &mut XcmHash, _: Weight) -> Outcome { - unreachable!() - } - fn charge_fees(_location: impl Into<Location>, _fees: Assets) -> Result { - Err(Error::Unimplemented) - } -} - -pub trait Reanchorable: Sized { - /// Type to return in case of an error. - type Error: Debug; - - /// Mutate `self` so that it represents the same location from the point of view of `target`. - /// The context of `self` is provided as `context`. - /// - /// Does not modify `self` in case of overflow. - fn reanchor( - &mut self, - target: &Location, - context: &InteriorLocation, - ) -> core::result::Result<(), ()>; - - /// Consume `self` and return a new value representing the same location from the point of view - /// of `target`. The context of `self` is provided as `context`. - /// - /// Returns the original `self` in case of overflow. - fn reanchored( - self, - target: &Location, - context: &InteriorLocation, - ) -> core::result::Result<Self, Self::Error>; -} - -/// Result value when attempting to send an XCM message. -pub type SendResult<T> = result::Result<(T, Assets), SendError>; - -/// Utility for sending an XCM message to a given location. -/// -/// These can be amalgamated in tuples to form sophisticated routing systems. In tuple format, each -/// router might return `NotApplicable` to pass the execution to the next sender item. Note that -/// each `NotApplicable` might alter the destination and the XCM message for to the next router. -/// -/// # Example -/// ```rust -/// # use codec::Encode; -/// # use staging_xcm::v5::{prelude::*, Weight}; -/// # use staging_xcm::VersionedXcm; -/// # use std::convert::Infallible; -/// -/// /// A sender that only passes the message through and does nothing. -/// struct Sender1; -/// impl SendXcm for Sender1 { -/// type Ticket = Infallible; -/// fn validate(_: &mut Option<Location>, _: &mut Option<Xcm<()>>) -> SendResult<Infallible> { -/// Err(SendError::NotApplicable) -/// } -/// fn deliver(_: Infallible) -> Result<XcmHash, SendError> { -/// unreachable!() -/// } -/// } -/// -/// /// A sender that accepts a message that has two junctions, otherwise stops the routing. -/// struct Sender2; -/// impl SendXcm for Sender2 { -/// type Ticket = (); -/// fn validate(destination: &mut Option<Location>, message: &mut Option<Xcm<()>>) -> SendResult<()> { -/// match destination.as_ref().ok_or(SendError::MissingArgument)?.unpack() { -/// (0, [j1, j2]) => Ok(((), Assets::new())), -/// _ => Err(SendError::Unroutable), -/// } -/// } -/// fn deliver(_: ()) -> Result<XcmHash, SendError> { -/// Ok([0; 32]) -/// } -/// } -/// -/// /// A sender that accepts a message from a parent, passing through otherwise. -/// struct Sender3; -/// impl SendXcm for Sender3 { -/// type Ticket = (); -/// fn validate(destination: &mut Option<Location>, message: &mut Option<Xcm<()>>) -> SendResult<()> { -/// match destination.as_ref().ok_or(SendError::MissingArgument)?.unpack() { -/// (1, []) => Ok(((), Assets::new())), -/// _ => Err(SendError::NotApplicable), -/// } -/// } -/// fn deliver(_: ()) -> Result<XcmHash, SendError> { -/// Ok([0; 32]) -/// } -/// } -/// -/// // A call to send via XCM. We don't really care about this. -/// # fn main() { -/// let call: Vec<u8> = ().encode(); -/// let message = Xcm(vec![Instruction::Transact { -/// origin_kind: OriginKind::Superuser, -/// call: call.into(), -/// fallback_max_weight: None, -/// }]); -/// let message_hash = message.using_encoded(sp_io::hashing::blake2_256); -/// -/// // Sender2 will block this. -/// assert!(send_xcm::<(Sender1, Sender2, Sender3)>(Parent.into(), message.clone()).is_err()); -/// -/// // Sender3 will catch this. -/// assert!(send_xcm::<(Sender1, Sender3)>(Parent.into(), message.clone()).is_ok()); -/// # } -/// ``` -pub trait SendXcm { - /// Intermediate value which connects the two phases of the send operation. - type Ticket; - - /// Check whether the given `_message` is deliverable to the given `_destination` and if so - /// determine the cost which will be paid by this chain to do so, returning a `Validated` token - /// which can be used to enact delivery. - /// - /// The `destination` and `message` must be `Some` (or else an error will be returned) and they - /// may only be consumed if the `Err` is not `NotApplicable`. - /// - /// If it is not a destination which can be reached with this type but possibly could by others, - /// then this *MUST* return `NotApplicable`. Any other error will cause the tuple - /// implementation to exit early without trying other type fields. - fn validate( - destination: &mut Option<Location>, - message: &mut Option<Xcm<()>>, - ) -> SendResult<Self::Ticket>; - - /// Actually carry out the delivery operation for a previously validated message sending. - fn deliver(ticket: Self::Ticket) -> result::Result<XcmHash, SendError>; - - /// Ensure `[Self::delivery]` is successful for the given `location` when called in benchmarks. - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_delivery(_location: Option<Location>) {} -} - -#[impl_trait_for_tuples::impl_for_tuples(30)] -impl SendXcm for Tuple { - for_tuples! { type Ticket = (#( Option<Tuple::Ticket> ),* ); } - - fn validate( - destination: &mut Option<Location>, - message: &mut Option<Xcm<()>>, - ) -> SendResult<Self::Ticket> { - let mut maybe_cost: Option<Assets> = None; - let one_ticket: Self::Ticket = (for_tuples! { #( - if maybe_cost.is_some() { - None - } else { - match Tuple::validate(destination, message) { - Err(SendError::NotApplicable) => None, - Err(e) => { return Err(e) }, - Ok((v, c)) => { - maybe_cost = Some(c); - Some(v) - }, - } - } - ),* }); - if let Some(cost) = maybe_cost { - Ok((one_ticket, cost)) - } else { - Err(SendError::NotApplicable) - } - } - - fn deliver(one_ticket: Self::Ticket) -> result::Result<XcmHash, SendError> { - for_tuples!( #( - if let Some(validated) = one_ticket.Tuple { - return Tuple::deliver(validated); - } - )* ); - Err(SendError::Unroutable) - } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_delivery(location: Option<Location>) { - for_tuples!( #( - return Tuple::ensure_successful_delivery(location.clone()); - )* ); - } -} - -/// Convenience function for using a `SendXcm` implementation. Just interprets the `dest` and wraps -/// both in `Some` before passing them as mutable references into `T::send_xcm`. -pub fn validate_send<T: SendXcm>(dest: Location, msg: Xcm<()>) -> SendResult<T::Ticket> { - T::validate(&mut Some(dest), &mut Some(msg)) -} - -/// Convenience function for using a `SendXcm` implementation. Just interprets the `dest` and wraps -/// both in `Some` before passing them as mutable references into `T::send_xcm`. -/// -/// Returns either `Ok` with the price of the delivery, or `Err` with the reason why the message -/// could not be sent. -/// -/// Generally you'll want to validate and get the price first to ensure that the sender can pay it -/// before actually doing the delivery. -pub fn send_xcm<T: SendXcm>( - dest: Location, - msg: Xcm<()>, -) -> result::Result<(XcmHash, Assets), SendError> { - let (ticket, price) = T::validate(&mut Some(dest), &mut Some(msg))?; - let hash = T::deliver(ticket)?; - Ok((hash, price)) -} diff --git a/polkadot/xcm/xcm-builder/Cargo.toml b/polkadot/xcm/xcm-builder/Cargo.toml index 1a324da86db..4181a889db7 100644 --- a/polkadot/xcm/xcm-builder/Cargo.toml +++ b/polkadot/xcm/xcm-builder/Cargo.toml @@ -47,7 +47,6 @@ runtime-benchmarks = [ "polkadot-parachain-primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] std = [ "codec/std", diff --git a/polkadot/xcm/xcm-builder/src/pay.rs b/polkadot/xcm/xcm-builder/src/pay.rs index 0093051290b..978c6870cda 100644 --- a/polkadot/xcm/xcm-builder/src/pay.rs +++ b/polkadot/xcm/xcm-builder/src/pay.rs @@ -70,8 +70,8 @@ impl< Router: SendXcm, Querier: QueryHandler, Timeout: Get<Querier::BlockNumber>, - Beneficiary: Clone + core::fmt::Debug, - AssetKind: core::fmt::Debug, + Beneficiary: Clone, + AssetKind, AssetKindToLocatableAsset: TryConvert<AssetKind, LocatableAssetId>, BeneficiaryRefToLocation: for<'a> TryConvert<&'a Beneficiary, Location>, > Pay @@ -144,9 +144,10 @@ impl< } #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful(_: &Self::Beneficiary, asset_kind: Self::AssetKind, _: Self::Balance) { - let locatable = AssetKindToLocatableAsset::try_convert(asset_kind).unwrap(); - Router::ensure_successful_delivery(Some(locatable.location)); + fn ensure_successful(_: &Self::Beneficiary, _: Self::AssetKind, _: Self::Balance) { + // We cannot generally guarantee this will go through successfully since we don't have any + // control over the XCM transport layers. We just assume that the benchmark environment + // will be sending it somewhere sensible. } #[cfg(feature = "runtime-benchmarks")] diff --git a/polkadot/xcm/xcm-builder/src/routing.rs b/polkadot/xcm/xcm-builder/src/routing.rs index fd7546b02aa..d82cc0641ec 100644 --- a/polkadot/xcm/xcm-builder/src/routing.rs +++ b/polkadot/xcm/xcm-builder/src/routing.rs @@ -60,11 +60,6 @@ impl<Inner: SendXcm> SendXcm for WithUniqueTopic<Inner> { Inner::deliver(ticket)?; Ok(unique_id) } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_delivery(location: Option<Location>) { - Inner::ensure_successful_delivery(location); - } } impl<Inner: InspectMessageQueues> InspectMessageQueues for WithUniqueTopic<Inner> { fn clear_messages() { @@ -119,11 +114,6 @@ impl<Inner: SendXcm, TopicSource: SourceTopic> SendXcm for WithTopicSource<Inner Inner::deliver(ticket)?; Ok(unique_id) } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_delivery(location: Option<Location>) { - Inner::ensure_successful_delivery(location); - } } /// Trait for a type which ensures all requirements for successful delivery with XCM transport @@ -221,9 +211,4 @@ impl<Inner: SendXcm> SendXcm for EnsureDecodableXcm<Inner> { fn deliver(ticket: Self::Ticket) -> Result<XcmHash, SendError> { Inner::deliver(ticket) } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_delivery(location: Option<Location>) { - Inner::ensure_successful_delivery(location); - } } diff --git a/polkadot/xcm/xcm-builder/src/tests/pay/pay.rs b/polkadot/xcm/xcm-builder/src/tests/pay/pay.rs index b4718edc6c9..062faee2abd 100644 --- a/polkadot/xcm/xcm-builder/src/tests/pay/pay.rs +++ b/polkadot/xcm/xcm-builder/src/tests/pay/pay.rs @@ -22,7 +22,7 @@ use frame_support::{assert_ok, traits::tokens::Pay}; /// Type representing both a location and an asset that is held at that location. /// The id of the held asset is relative to the location where it is being held. -#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug)] +#[derive(Encode, Decode, Clone, PartialEq, Eq)] pub struct AssetKind { destination: Location, asset_id: AssetId, diff --git a/polkadot/xcm/xcm-builder/src/universal_exports.rs b/polkadot/xcm/xcm-builder/src/universal_exports.rs index 6b3c3adf737..aae8438c78d 100644 --- a/polkadot/xcm/xcm-builder/src/universal_exports.rs +++ b/polkadot/xcm/xcm-builder/src/universal_exports.rs @@ -95,9 +95,6 @@ impl<Exporter: ExportXcm, UniversalLocation: Get<InteriorLocation>> SendXcm fn deliver(ticket: Exporter::Ticket) -> Result<XcmHash, SendError> { Exporter::deliver(ticket) } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_delivery(_: Option<Location>) {} } pub trait ExporterFor { @@ -264,11 +261,6 @@ impl<Bridges: ExporterFor, Router: SendXcm, UniversalLocation: Get<InteriorLocat fn deliver(validation: Self::Ticket) -> Result<XcmHash, SendError> { Router::deliver(validation) } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_delivery(location: Option<Location>) { - Router::ensure_successful_delivery(location); - } } /// Implementation of `SendXcm` which wraps the message inside an `ExportMessage` instruction @@ -369,11 +361,6 @@ impl<Bridges: ExporterFor, Router: SendXcm, UniversalLocation: Get<InteriorLocat fn deliver(ticket: Router::Ticket) -> Result<XcmHash, SendError> { Router::deliver(ticket) } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_delivery(location: Option<Location>) { - Router::ensure_successful_delivery(location); - } } impl<Bridges, Router, UniversalLocation> InspectMessageQueues @@ -626,9 +613,6 @@ mod tests { fn deliver(_ticket: Self::Ticket) -> Result<XcmHash, SendError> { Ok([0; 32]) } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful_delivery(_: Option<Location>) {} } impl<Filter: Contains<(NetworkId, InteriorLocation)>> ExportXcm for OkFor<Filter> { type Ticket = (); diff --git a/polkadot/xcm/xcm-executor/Cargo.toml b/polkadot/xcm/xcm-executor/Cargo.toml index 46ee38d60c3..f352f201963 100644 --- a/polkadot/xcm/xcm-executor/Cargo.toml +++ b/polkadot/xcm/xcm-executor/Cargo.toml @@ -30,7 +30,6 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "xcm/runtime-benchmarks", ] std = [ "codec/std", diff --git a/polkadot/xcm/xcm-executor/integration-tests/Cargo.toml b/polkadot/xcm/xcm-executor/integration-tests/Cargo.toml index a27b62be533..0045295deb0 100644 --- a/polkadot/xcm/xcm-executor/integration-tests/Cargo.toml +++ b/polkadot/xcm/xcm-executor/integration-tests/Cargo.toml @@ -13,17 +13,14 @@ workspace = true [dependencies] codec = { workspace = true, default-features = true } frame-support.workspace = true -frame-system.workspace = true futures = { workspace = true } pallet-transaction-payment.workspace = true pallet-transaction-payment.default-features = true -pallet-sudo.workspace = true pallet-xcm.workspace = true pallet-xcm.default-features = true polkadot-test-client.workspace = true polkadot-test-runtime.workspace = true polkadot-test-service.workspace = true -polkadot-runtime-parachains.workspace = true sp-consensus.workspace = true sp-consensus.default-features = true sp-keyring.workspace = true @@ -41,4 +38,4 @@ sp-core.default-features = true [features] default = ["std"] -std = ["sp-runtime/std", "xcm/std"] +std = ["frame-support/std", "sp-runtime/std", "xcm/std"] diff --git a/polkadot/xcm/xcm-executor/integration-tests/src/lib.rs b/polkadot/xcm/xcm-executor/integration-tests/src/lib.rs index 5098a6e6042..6f44cc0a75d 100644 --- a/polkadot/xcm/xcm-executor/integration-tests/src/lib.rs +++ b/polkadot/xcm/xcm-executor/integration-tests/src/lib.rs @@ -376,26 +376,6 @@ fn deposit_reserve_asset_works_for_any_xcm_sender() { let mut block_builder = client.init_polkadot_block_builder(); - // Make the para available, so that `DMP` doesn't reject the XCM because the para is unknown. - let make_para_available = - construct_extrinsic( - &client, - polkadot_test_runtime::RuntimeCall::Sudo(pallet_sudo::Call::sudo { - call: Box::new(polkadot_test_runtime::RuntimeCall::System( - frame_system::Call::set_storage { - items: vec![( - polkadot_runtime_parachains::paras::Heads::< - polkadot_test_runtime::Runtime, - >::hashed_key_for(2000u32), - vec![1, 2, 3], - )], - }, - )), - }), - sp_keyring::Sr25519Keyring::Alice, - 0, - ); - // Simulate execution of an incoming XCM message at the reserve chain let execute = construct_extrinsic( &client, @@ -404,12 +384,9 @@ fn deposit_reserve_asset_works_for_any_xcm_sender() { max_weight: Weight::from_parts(1_000_000_000, 1024 * 1024), }), sp_keyring::Sr25519Keyring::Alice, - 1, + 0, ); - block_builder - .push_polkadot_extrinsic(make_para_available) - .expect("pushes extrinsic"); block_builder.push_polkadot_extrinsic(execute).expect("pushes extrinsic"); let block = block_builder.build().expect("Finalizes the block").block; diff --git a/polkadot/xcm/xcm-runtime-apis/Cargo.toml b/polkadot/xcm/xcm-runtime-apis/Cargo.toml index d7cf0975b51..946e707078b 100644 --- a/polkadot/xcm/xcm-runtime-apis/Cargo.toml +++ b/polkadot/xcm/xcm-runtime-apis/Cargo.toml @@ -46,5 +46,4 @@ std = [ runtime-benchmarks = [ "frame-support/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/polkadot/xcm/xcm-simulator/example/Cargo.toml b/polkadot/xcm/xcm-simulator/example/Cargo.toml index 49607f40b9b..acfb12df0cd 100644 --- a/polkadot/xcm/xcm-simulator/example/Cargo.toml +++ b/polkadot/xcm/xcm-simulator/example/Cargo.toml @@ -64,5 +64,4 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/polkadot/xcm/xcm-simulator/fuzzer/Cargo.toml b/polkadot/xcm/xcm-simulator/fuzzer/Cargo.toml index 2e3e9af5e99..2168af5dbf2 100644 --- a/polkadot/xcm/xcm-simulator/fuzzer/Cargo.toml +++ b/polkadot/xcm/xcm-simulator/fuzzer/Cargo.toml @@ -75,7 +75,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] [[bin]] diff --git a/substrate/frame/contracts/Cargo.toml b/substrate/frame/contracts/Cargo.toml index 910947d64d6..7e225648d2f 100644 --- a/substrate/frame/contracts/Cargo.toml +++ b/substrate/frame/contracts/Cargo.toml @@ -110,7 +110,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "wasm-instrument", "xcm-builder/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/contracts/mock-network/Cargo.toml b/substrate/frame/contracts/mock-network/Cargo.toml index 5cd0bdfc465..8560c190e74 100644 --- a/substrate/frame/contracts/mock-network/Cargo.toml +++ b/substrate/frame/contracts/mock-network/Cargo.toml @@ -102,5 +102,4 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/substrate/frame/revive/Cargo.toml b/substrate/frame/revive/Cargo.toml index 8a8fbd8e011..30c795349bc 100644 --- a/substrate/frame/revive/Cargo.toml +++ b/substrate/frame/revive/Cargo.toml @@ -103,7 +103,6 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", - "xcm/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/revive/mock-network/Cargo.toml b/substrate/frame/revive/mock-network/Cargo.toml index dc0d7a2cac8..1105f4f0b40 100644 --- a/substrate/frame/revive/mock-network/Cargo.toml +++ b/substrate/frame/revive/mock-network/Cargo.toml @@ -98,5 +98,4 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", ] diff --git a/umbrella/Cargo.toml b/umbrella/Cargo.toml index ab7059f96a1..06a32118a6a 100644 --- a/umbrella/Cargo.toml +++ b/umbrella/Cargo.toml @@ -359,7 +359,6 @@ runtime-benchmarks = [ "staging-node-inspect?/runtime-benchmarks", "staging-xcm-builder?/runtime-benchmarks", "staging-xcm-executor?/runtime-benchmarks", - "staging-xcm?/runtime-benchmarks", "xcm-runtime-apis?/runtime-benchmarks", ] try-runtime = [ -- GitLab