From 97ae18aa696585b70d5c5967ea0ca3ae7c1fd57c Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Thu, 13 Apr 2023 12:57:44 +0200 Subject: [PATCH 01/11] Align BridgeHub runtimes with other SP runtimes --- Cargo.lock | 3 --- docs/release.md | 2 +- .../bridge-hubs/bridge-hub-kusama/Cargo.toml | 2 -- .../bridge-hubs/bridge-hub-kusama/src/lib.rs | 5 ----- .../bridge-hub-kusama/src/xcm_config.rs | 13 ++++++------- .../bridge-hubs/bridge-hub-polkadot/Cargo.toml | 2 -- .../bridge-hubs/bridge-hub-polkadot/src/lib.rs | 5 ----- .../bridge-hub-polkadot/src/xcm_config.rs | 16 +++++++++------- .../bridge-hubs/bridge-hub-rococo/Cargo.toml | 2 -- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 5 ----- .../bridge-hub-rococo/src/xcm_config.rs | 12 ++++++------ 11 files changed, 22 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 85596ef1e8e..81173ff99b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -726,7 +726,6 @@ dependencies = [ "pallet-collator-selection", "pallet-multisig", "pallet-session", - "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", @@ -788,7 +787,6 @@ dependencies = [ "pallet-collator-selection", "pallet-multisig", "pallet-session", - "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", @@ -851,7 +849,6 @@ dependencies = [ "pallet-collator-selection", "pallet-multisig", "pallet-session", - "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", diff --git a/docs/release.md b/docs/release.md index 2b7c79c50be..9c0a6acc0e9 100644 --- a/docs/release.md +++ b/docs/release.md @@ -123,7 +123,7 @@ for `release-parachains-v0.9.270` 5. Clone `it/release--fast-sudo` from Polkadot In case the branch does not exists (it is a manual process): cherry pick paritytech/polkadot@791c8b8 and run `find . -type f -name "*.toml" -print0 | xargs -0 sed -i '' -e 's/polkadot-vX.X.X/polkadot-v/g'` -6. `cargo build --release features --fast-runtime` +6. `cargo build --release --features fast-runtime` 7. Copy `./target/polkadot` into `./bin` (in Cumulus) 8. Run the tests: - Statemint: `yarn zombienet-test -c ./examples/statemint/config.toml -t ./examples/statemint` diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml index 00a9da0103c..c2a273f437d 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml @@ -29,7 +29,6 @@ pallet-authorship = { git = "https://github.com/paritytech/substrate", default-f pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } @@ -100,7 +99,6 @@ std = [ "pallet-collator-selection/std", "pallet-multisig/std", "pallet-session/std", - "pallet-sudo/std", "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index 4ebf760e849..e7f7da5ae99 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -143,11 +143,6 @@ pub fn native_version() -> NativeVersion { parameter_types! { pub const Version: RuntimeVersion = VERSION; - - // This part is copied from Substrate's `bin/node/runtime/src/lib.rs`. - // The `RuntimeBlockLength` and `RuntimeBlockWeights` exist here because the - // `DeletionWeightLimit` and `DeletionQueueDepth` depend on those to parameterize - // the lazy contract deletion. pub RuntimeBlockLength: BlockLength = BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder() diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index cfe8662cb7c..e07ae2c2b40 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -96,17 +96,16 @@ pub type XcmOriginToTransactDispatchOrigin = ( // transaction from the Root origin. ParentAsSuperuser, // Native signed account converter; this just converts an `AccountId32` origin into a normal - // `Origin::Signed` origin of the same 32-byte value. + // `RuntimeOrigin::Signed` origin of the same 32-byte value. SignedAccountId32AsNative, // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. XcmPassthrough, ); match_types! { - // TODO: map gov2 origins here - after merge https://github.com/paritytech/cumulus/pull/1895 - pub type ParentOrParentsExecutivePlurality: impl Contains = { + pub type ParentOrParentsPlurality: impl Contains = { MultiLocation { parents: 1, interior: Here } | - MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) } + MultiLocation { parents: 1, interior: X1(Plurality { .. }) } }; pub type ParentOrSiblings: impl Contains = { MultiLocation { parents: 1, interior: Here } | @@ -165,10 +164,10 @@ pub type Barrier = DenyThenTry< AllowKnownQueryResponses, WithComputedOrigin< ( - // Allow anything to pay for execution. + // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - // Parent and its exec plurality get free execution. - AllowExplicitUnpaidExecutionFrom, + // Parent and its plurality (i.e. governance bodies) gets free execution. + AllowExplicitUnpaidExecutionFrom, // Subscriptions for version tracking are OK. AllowSubscriptionsFrom, ), diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml index 86bb0780027..7fb066e7abb 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml @@ -29,7 +29,6 @@ pallet-authorship = { git = "https://github.com/paritytech/substrate", default-f pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } @@ -100,7 +99,6 @@ std = [ "pallet-collator-selection/std", "pallet-multisig/std", "pallet-session/std", - "pallet-sudo/std", "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 109cd2434b3..89f41e6f5d4 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -143,11 +143,6 @@ pub fn native_version() -> NativeVersion { parameter_types! { pub const Version: RuntimeVersion = VERSION; - - // This part is copied from Substrate's `bin/node/runtime/src/lib.rs`. - // The `RuntimeBlockLength` and `RuntimeBlockWeights` exist here because the - // `DeletionWeightLimit` and `DeletionQueueDepth` depend on those to parameterize - // the lazy contract deletion. pub RuntimeBlockLength: BlockLength = BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder() diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index 189e7c74f81..aca42c84a53 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -96,22 +96,24 @@ pub type XcmOriginToTransactDispatchOrigin = ( // transaction from the Root origin. ParentAsSuperuser, // Native signed account converter; this just converts an `AccountId32` origin into a normal - // `Origin::Signed` origin of the same 32-byte value. + // `RuntimeOrigin::Signed` origin of the same 32-byte value. SignedAccountId32AsNative, // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. XcmPassthrough, ); match_types! { - // TODO: map gov2 origins here - after merge https://github.com/paritytech/cumulus/pull/1895 - pub type ParentOrParentsExecutivePlurality: impl Contains = { + pub type ParentOrParentsPlurality: impl Contains = { MultiLocation { parents: 1, interior: Here } | - MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) } + MultiLocation { parents: 1, interior: X1(Plurality { .. }) } }; pub type ParentOrSiblings: impl Contains = { MultiLocation { parents: 1, interior: Here } | MultiLocation { parents: 1, interior: X1(_) } }; + pub type FellowsPlurality: impl Contains = { + MultiLocation { parents: 1, interior: X2(Parachain(1001), Plurality { id: BodyId::Technical, ..}) } + }; } /// A call filter for the XCM Transact instruction. This is a temporary measure until we properly /// account for proof size weights. @@ -165,10 +167,10 @@ pub type Barrier = DenyThenTry< AllowKnownQueryResponses, WithComputedOrigin< ( - // Allow anything to pay for execution. + // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - // Parent and its exec plurality get free execution. - AllowExplicitUnpaidExecutionFrom, + // Parent, its plurality (i.e. governance bodies) and Fellows plurality gets free execution. + AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>, // Subscriptions for version tracking are OK. AllowSubscriptionsFrom, ), diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index 2efdcfd8263..fd33bd0e5b2 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -29,7 +29,6 @@ pallet-authorship = { git = "https://github.com/paritytech/substrate", default-f pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } @@ -99,7 +98,6 @@ std = [ "pallet-collator-selection/std", "pallet-multisig/std", "pallet-session/std", - "pallet-sudo/std", "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 04eddf59e3a..ab584247515 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -209,11 +209,6 @@ pub fn native_version() -> NativeVersion { parameter_types! { pub const Version: RuntimeVersion = VERSION; - - // This part is copied from Substrate's `bin/node/runtime/src/lib.rs`. - // The `RuntimeBlockLength` and `RuntimeBlockWeights` exist here because the - // `DeletionWeightLimit` and `DeletionQueueDepth` depend on those to parameterize - // the lazy contract deletion. pub RuntimeBlockLength: BlockLength = BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder() diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 17ac293c62b..5250890e5b0 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -94,16 +94,16 @@ pub type XcmOriginToTransactDispatchOrigin = ( // transaction from the Root origin. ParentAsSuperuser, // Native signed account converter; this just converts an `AccountId32` origin into a normal - // `Origin::Signed` origin of the same 32-byte value. + // `RuntimeOrigin::Signed` origin of the same 32-byte value. SignedAccountId32AsNative, // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. XcmPassthrough, ); match_types! { - pub type ParentOrParentsExecutivePlurality: impl Contains = { + pub type ParentOrParentsPlurality: impl Contains = { MultiLocation { parents: 1, interior: Here } | - MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) } + MultiLocation { parents: 1, interior: X1(Plurality { .. }) } }; pub type ParentOrSiblings: impl Contains = { MultiLocation { parents: 1, interior: Here } | @@ -163,10 +163,10 @@ pub type Barrier = DenyThenTry< AllowKnownQueryResponses, WithComputedOrigin< ( - // Allow anything to pay for execution. + // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - // Parent and its exec plurality get free execution. - AllowExplicitUnpaidExecutionFrom, + // Parent and its plurality (i.e. governance bodies) gets free execution. + AllowExplicitUnpaidExecutionFrom, // Subscriptions for version tracking are OK. AllowSubscriptionsFrom, ), From b807bc613dfce1df6abd362ec25cb0c8849f71a4 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Thu, 13 Apr 2023 15:13:08 +0200 Subject: [PATCH 02/11] Reused `teleports_for_native_asset_works` test to all bridge-hub runtime --- Cargo.lock | 25 +++++++++ .../assets/test-utils/src/test_cases.rs | 10 ++-- .../bridge-hubs/bridge-hub-kusama/Cargo.toml | 3 + .../bridge-hub-kusama/tests/tests.rs | 55 +++++++++++++++++++ .../bridge-hub-polkadot/Cargo.toml | 3 + .../bridge-hub-polkadot/tests/tests.rs | 55 +++++++++++++++++++ .../bridge-hubs/bridge-hub-rococo/Cargo.toml | 3 + .../bridge-hub-rococo/tests/tests.rs | 55 +++++++++++++++++++ .../bridge-hubs/test-utils/Cargo.toml | 50 +++++++++++++++++ .../bridge-hubs/test-utils/src/lib.rs | 18 ++++++ .../bridge-hubs/test-utils/src/test_cases.rs | 20 +++++++ 11 files changed, 292 insertions(+), 5 deletions(-) create mode 100644 parachains/runtimes/bridge-hubs/bridge-hub-kusama/tests/tests.rs create mode 100644 parachains/runtimes/bridge-hubs/bridge-hub-polkadot/tests/tests.rs create mode 100644 parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs create mode 100644 parachains/runtimes/bridge-hubs/test-utils/Cargo.toml create mode 100644 parachains/runtimes/bridge-hubs/test-utils/src/lib.rs create mode 100644 parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs diff --git a/Cargo.lock b/Cargo.lock index 81173ff99b4..fb35457680d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -701,6 +701,7 @@ dependencies = [ name = "bridge-hub-kusama-runtime" version = "0.1.0" dependencies = [ + "bridge-hub-test-utils", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", @@ -763,6 +764,7 @@ dependencies = [ name = "bridge-hub-polkadot-runtime" version = "0.1.0" dependencies = [ + "bridge-hub-test-utils", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", @@ -825,6 +827,7 @@ dependencies = [ name = "bridge-hub-rococo-runtime" version = "0.1.0" dependencies = [ + "bridge-hub-test-utils", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", @@ -883,6 +886,28 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "bridge-hub-test-utils" +version = "0.1.0" +dependencies = [ + "asset-test-utils", + "cumulus-pallet-parachain-system", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-test-relay-sproof-builder", + "frame-support", + "frame-system", + "pallet-xcm", + "pallet-xcm-benchmarks", + "parachain-info", + "parachains-common", + "polkadot-parachain", + "sp-runtime", + "xcm", + "xcm-builder", + "xcm-executor", +] + [[package]] name = "bs58" version = "0.4.0" diff --git a/parachains/runtimes/assets/test-utils/src/test_cases.rs b/parachains/runtimes/assets/test-utils/src/test_cases.rs index 079e6bd60ae..88e36144694 100644 --- a/parachains/runtimes/assets/test-utils/src/test_cases.rs +++ b/parachains/runtimes/assets/test-utils/src/test_cases.rs @@ -280,7 +280,7 @@ macro_rules! include_teleports_for_native_asset_works( const BOB: [u8; 32] = [2u8; 32]; let target_account = parachains_common::AccountId::from(BOB); - asset_test_utils::test_cases::teleports_for_native_asset_works::< + $crate::test_cases::teleports_for_native_asset_works::< $runtime, $xcm_config, $checking_account, @@ -598,7 +598,7 @@ macro_rules! include_teleports_for_foreign_assets_works( const SOME_ASSET_OWNER: [u8; 32] = [5u8; 32]; let asset_owner = parachains_common::AccountId::from(SOME_ASSET_OWNER); - asset_test_utils::test_cases::teleports_for_foreign_assets_works::< + $crate::test_cases::teleports_for_foreign_assets_works::< $runtime, $xcm_config, $checking_account, @@ -715,7 +715,7 @@ macro_rules! include_asset_transactor_transfer_with_local_consensus_currency_wor const BOB: [u8; 32] = [2u8; 32]; let target_account = parachains_common::AccountId::from(BOB); - asset_test_utils::test_cases::asset_transactor_transfer_with_local_consensus_currency_works::< + $crate::test_cases::asset_transactor_transfer_with_local_consensus_currency_works::< $runtime, $xcm_config >( @@ -969,7 +969,7 @@ macro_rules! include_asset_transactor_transfer_with_pallet_assets_instance_works const CHARLIE: [u8; 32] = [3u8; 32]; let charlie_account = parachains_common::AccountId::from(CHARLIE); - asset_test_utils::test_cases::asset_transactor_transfer_with_pallet_assets_instance_works::< + $crate::test_cases::asset_transactor_transfer_with_pallet_assets_instance_works::< $runtime, $xcm_config, $assets_pallet_instance, @@ -1297,7 +1297,7 @@ macro_rules! include_create_and_manage_foreign_assets_for_local_consensus_parach const BOB: [u8; 32] = [2u8; 32]; let bob_account = parachains_common::AccountId::from(BOB); - asset_test_utils::test_cases::create_and_manage_foreign_assets_for_local_consensus_parachain_assets_works::< + $crate::test_cases::create_and_manage_foreign_assets_for_local_consensus_parachain_assets_works::< $runtime, $xcm_config, $weight_to_fee, diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml index c2a273f437d..e37527b8d6c 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml @@ -71,6 +71,9 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } parachains-common = { path = "../../../../parachains/common", default-features = false } +[dev-dependencies] +bridge-hub-test-utils = { path = "../test-utils"} + [features] default = [ "std", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/tests/tests.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/tests/tests.rs new file mode 100644 index 00000000000..492078a54aa --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/tests/tests.rs @@ -0,0 +1,55 @@ +// Copyright 2023 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +pub use bridge_hub_kusama_runtime::{ + constants::fee::WeightToFee, xcm_config::XcmConfig, Balances, ExistentialDeposit, + ParachainSystem, PolkadotXcm, Runtime, RuntimeEvent, SessionKeys, +}; +use codec::Decode; +use frame_support::parameter_types; +use parachains_common::{AccountId, AuraId}; + +const ALICE: [u8; 32] = [1u8; 32]; + +parameter_types! { + pub CheckingAccount: AccountId = PolkadotXcm::check_account(); +} + +bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!( + Runtime, + XcmConfig, + CheckingAccount, + WeightToFee, + ParachainSystem, + bridge_hub_test_utils::CollatorSessionKeys::new( + AccountId::from(ALICE), + AccountId::from(ALICE), + SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } + ), + ExistentialDeposit::get(), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::PolkadotXcm(event)) => Some(event), + _ => None, + } + }), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), + _ => None, + } + }) +); diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml index 7fb066e7abb..520907e9d7c 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml @@ -71,6 +71,9 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } parachains-common = { path = "../../../../parachains/common", default-features = false } +[dev-dependencies] +bridge-hub-test-utils = { path = "../test-utils"} + [features] default = [ "std", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/tests/tests.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/tests/tests.rs new file mode 100644 index 00000000000..2ec12fff4ba --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/tests/tests.rs @@ -0,0 +1,55 @@ +// Copyright 2023 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +pub use bridge_hub_polkadot_runtime::{ + constants::fee::WeightToFee, xcm_config::XcmConfig, Balances, ExistentialDeposit, + ParachainSystem, PolkadotXcm, Runtime, RuntimeEvent, SessionKeys, +}; +use codec::Decode; +use frame_support::parameter_types; +use parachains_common::{AccountId, AuraId}; + +const ALICE: [u8; 32] = [1u8; 32]; + +parameter_types! { + pub CheckingAccount: AccountId = PolkadotXcm::check_account(); +} + +bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!( + Runtime, + XcmConfig, + CheckingAccount, + WeightToFee, + ParachainSystem, + bridge_hub_test_utils::CollatorSessionKeys::new( + AccountId::from(ALICE), + AccountId::from(ALICE), + SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } + ), + ExistentialDeposit::get(), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::PolkadotXcm(event)) => Some(event), + _ => None, + } + }), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), + _ => None, + } + }) +); diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index fd33bd0e5b2..cfd1894491b 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -71,6 +71,9 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } parachains-common = { path = "../../../../parachains/common", default-features = false } +[dev-dependencies] +bridge-hub-test-utils = { path = "../test-utils"} + [features] default = [ "std", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs new file mode 100644 index 00000000000..426f9867154 --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs @@ -0,0 +1,55 @@ +// Copyright 2023 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +pub use bridge_hub_rococo_runtime::{ + constants::fee::WeightToFee, xcm_config::XcmConfig, Balances, ExistentialDeposit, + ParachainSystem, PolkadotXcm, Runtime, RuntimeEvent, SessionKeys, +}; +use codec::Decode; +use frame_support::parameter_types; +use parachains_common::{AccountId, AuraId}; + +const ALICE: [u8; 32] = [1u8; 32]; + +parameter_types! { + pub CheckingAccount: AccountId = PolkadotXcm::check_account(); +} + +bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!( + Runtime, + XcmConfig, + CheckingAccount, + WeightToFee, + ParachainSystem, + bridge_hub_test_utils::CollatorSessionKeys::new( + AccountId::from(ALICE), + AccountId::from(ALICE), + SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } + ), + ExistentialDeposit::get(), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::PolkadotXcm(event)) => Some(event), + _ => None, + } + }), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), + _ => None, + } + }) +); diff --git a/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml b/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml new file mode 100644 index 00000000000..8a5fab28bfe --- /dev/null +++ b/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml @@ -0,0 +1,50 @@ +[package] +name = "bridge-hub-test-utils" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +description = "Utils for BridgeHub testing" + +[dependencies] + +# Substrate +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } + +# Cumulus +parachains-common = { path = "../../../common", default-features = false } +cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false } +cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false } +cumulus-primitives-parachain-inherent = { path = "../../../../primitives/parachain-inherent", default-features = false } +cumulus-test-relay-sproof-builder = { path = "../../../../test/relay-sproof-builder", default-features = false } +parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } +asset-test-utils = { path = "../../assets/test-utils"} + +# Polkadot +polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +pallet-xcm-benchmarks = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false, optional = true } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } + +[features] +default = [ "std" ] +std = [ + "frame-support/std", + "frame-system/std", + "parachains-common/std", + "parachain-info/std", + "cumulus-primitives-core/std", + "cumulus-pallet-parachain-system/std", + "cumulus-primitives-parachain-inherent/std", + "cumulus-test-relay-sproof-builder/std", + "polkadot-parachain/std", + "pallet-xcm/std", + "sp-runtime/std", + "xcm/std", + "xcm-builder/std", + "xcm-executor/std", + "asset-test-utils/std", +] diff --git a/parachains/runtimes/bridge-hubs/test-utils/src/lib.rs b/parachains/runtimes/bridge-hubs/test-utils/src/lib.rs new file mode 100644 index 00000000000..882910b5fc0 --- /dev/null +++ b/parachains/runtimes/bridge-hubs/test-utils/src/lib.rs @@ -0,0 +1,18 @@ +// Copyright 2023 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +pub mod test_cases; +pub use test_cases::CollatorSessionKeys; diff --git a/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs b/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs new file mode 100644 index 00000000000..cdbeb65fab1 --- /dev/null +++ b/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs @@ -0,0 +1,20 @@ +// Copyright 2023 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +//! Module contains predefined test-case scenarios for `Runtime` with bridging capabilities. + +// Re-export test_cases from assets +pub use asset_test_utils::{include_teleports_for_native_asset_works, CollatorSessionKeys}; From 85e6c722c8e8f1ae47766d7b9ca27ad07568d39e Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Thu, 13 Apr 2023 15:16:18 +0200 Subject: [PATCH 03/11] Fix import vs doc --- .../parachain-system/src/validate_block/implementation.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pallets/parachain-system/src/validate_block/implementation.rs b/pallets/parachain-system/src/validate_block/implementation.rs index 3a5f90e0495..f953dfc77c5 100644 --- a/pallets/parachain-system/src/validate_block/implementation.rs +++ b/pallets/parachain-system/src/validate_block/implementation.rs @@ -22,9 +22,7 @@ use cumulus_primitives_core::{ }; use cumulus_primitives_parachain_inherent::ParachainInherentData; -use polkadot_parachain::primitives::{ - HeadData, RelayChainBlockNumber, ValidationParams, ValidationResult, -}; +use polkadot_parachain::primitives::{HeadData, RelayChainBlockNumber, ValidationResult}; use codec::Encode; @@ -238,7 +236,7 @@ where .expect("Could not find `set_validation_data` inherent") } -/// Validate the given [`PersistedValidationData`] against the [`ValidationParams`]. +/// Validate the given [`PersistedValidationData`] against the [`MemoryOptimizedValidationParams`]. fn validate_validation_data( validation_data: &PersistedValidationData, relay_parent_number: RelayChainBlockNumber, From ccf7da4b716f64a83cb84b93ae9d39a4763fbcab Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Fri, 14 Apr 2023 12:59:55 +0200 Subject: [PATCH 04/11] Removed unnecessery deps --- Cargo.lock | 15 --------- .../bridge-hubs/test-utils/Cargo.toml | 33 ------------------- 2 files changed, 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb35457680d..9240a291465 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -891,21 +891,6 @@ name = "bridge-hub-test-utils" version = "0.1.0" dependencies = [ "asset-test-utils", - "cumulus-pallet-parachain-system", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-test-relay-sproof-builder", - "frame-support", - "frame-system", - "pallet-xcm", - "pallet-xcm-benchmarks", - "parachain-info", - "parachains-common", - "polkadot-parachain", - "sp-runtime", - "xcm", - "xcm-builder", - "xcm-executor", ] [[package]] diff --git a/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml b/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml index 8a5fab28bfe..ccee28f82cf 100644 --- a/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml @@ -7,44 +7,11 @@ description = "Utils for BridgeHub testing" [dependencies] -# Substrate -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } - # Cumulus -parachains-common = { path = "../../../common", default-features = false } -cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false } -cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false } -cumulus-primitives-parachain-inherent = { path = "../../../../primitives/parachain-inherent", default-features = false } -cumulus-test-relay-sproof-builder = { path = "../../../../test/relay-sproof-builder", default-features = false } -parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } asset-test-utils = { path = "../../assets/test-utils"} -# Polkadot -polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } -pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } -pallet-xcm-benchmarks = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false, optional = true } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } -xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } -xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } - [features] default = [ "std" ] std = [ - "frame-support/std", - "frame-system/std", - "parachains-common/std", - "parachain-info/std", - "cumulus-primitives-core/std", - "cumulus-pallet-parachain-system/std", - "cumulus-primitives-parachain-inherent/std", - "cumulus-test-relay-sproof-builder/std", - "polkadot-parachain/std", - "pallet-xcm/std", - "sp-runtime/std", - "xcm/std", - "xcm-builder/std", - "xcm-executor/std", "asset-test-utils/std", ] From b24f9bc891419e222c9b7440ad7801743a458906 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Fri, 14 Apr 2023 13:32:01 +0200 Subject: [PATCH 05/11] DealWithFees + ToAuthor->ToStakingPot for BH according to the other runtimes --- parachains/runtimes/assets/statemine/src/lib.rs | 6 +++--- .../runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs | 7 ++++--- .../bridge-hubs/bridge-hub-kusama/src/xcm_config.rs | 8 ++++---- .../runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs | 5 +++-- .../bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs | 8 ++++---- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 5 +++-- .../bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 8 ++++---- 7 files changed, 25 insertions(+), 22 deletions(-) diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/statemine/src/lib.rs index 62425aa7496..62f85c59a61 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/statemine/src/lib.rs @@ -28,6 +28,9 @@ pub mod constants; mod weights; pub mod xcm_config; +use assets_common::{ + foreign_creators::ForeignCreators, matching::FromSiblingParachain, MultiLocationForAssetId, +}; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; @@ -74,9 +77,6 @@ use xcm_config::{ pub use sp_runtime::BuildStorage; // Polkadot imports -use assets_common::{ - foreign_creators::ForeignCreators, matching::FromSiblingParachain, MultiLocationForAssetId, -}; use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; use xcm::latest::BodyId; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index e7f7da5ae99..952c3147306 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -64,15 +64,15 @@ use xcm_config::{ #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -// Polkadot imports use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use parachains_common::{ - opaque, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature, + impls::DealWithFees, opaque, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; + // XCM Imports use xcm::latest::prelude::BodyId; use xcm_executor::XcmExecutor; @@ -259,7 +259,8 @@ parameter_types! { impl pallet_transaction_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; + type OnChargeTransaction = + pallet_transaction_payment::CurrencyAdapter>; type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = WeightToFee; type LengthToFee = ConstantMultiplier; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index e07ae2c2b40..9b08a5c5331 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -24,11 +24,11 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::xcm_config::{ - ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry, +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, }; use polkadot_parachain::primitives::Sibling; -use polkadot_runtime_common::impls::ToAuthor; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -196,7 +196,7 @@ impl xcm_executor::Config for XcmConfig { MaxInstructions, >; type Trader = - UsingComponents>; + UsingComponents>; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; type AssetClaims = PolkadotXcm; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 89f41e6f5d4..dfc08b4c184 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -70,7 +70,7 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use parachains_common::{ - opaque, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature, + impls::DealWithFees, opaque, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; // XCM Imports @@ -259,7 +259,8 @@ parameter_types! { impl pallet_transaction_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; + type OnChargeTransaction = + pallet_transaction_payment::CurrencyAdapter>; type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = WeightToFee; type LengthToFee = ConstantMultiplier; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index aca42c84a53..f74da930515 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -24,11 +24,11 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::xcm_config::{ - ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry, +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, }; use polkadot_parachain::primitives::Sibling; -use polkadot_runtime_common::impls::ToAuthor; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -199,7 +199,7 @@ impl xcm_executor::Config for XcmConfig { MaxInstructions, >; type Trader = - UsingComponents>; + UsingComponents>; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; type AssetClaims = PolkadotXcm; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index ab584247515..2e985546e02 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -73,7 +73,7 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; // XCM Imports use parachains_common::{ - opaque, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature, + impls::DealWithFees, opaque, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; use xcm_executor::XcmExecutor; @@ -326,7 +326,8 @@ parameter_types! { impl pallet_transaction_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; + type OnChargeTransaction = + pallet_transaction_payment::CurrencyAdapter>; type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = WeightToFee; type LengthToFee = ConstantMultiplier; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 5250890e5b0..99067fa97db 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -24,11 +24,11 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::xcm_config::{ - ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry, +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, }; use polkadot_parachain::primitives::Sibling; -use polkadot_runtime_common::impls::ToAuthor; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -195,7 +195,7 @@ impl xcm_executor::Config for XcmConfig { MaxInstructions, >; type Trader = - UsingComponents>; + UsingComponents>; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; type AssetClaims = PolkadotXcm; From 0fc01369ded11c07078bedcf5018460a70885dd1 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Wed, 19 Apr 2023 10:38:03 +0200 Subject: [PATCH 06/11] Update parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- .../runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 99067fa97db..c629c18e0ca 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -165,7 +165,7 @@ pub type Barrier = DenyThenTry< ( // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - // Parent and its plurality (i.e. governance bodies) gets free execution. + // Parent and its pluralities (i.e. governance bodies) get free execution. AllowExplicitUnpaidExecutionFrom, // Subscriptions for version tracking are OK. AllowSubscriptionsFrom, From 5c125db446ffa015cdb79586c0c7c91e901ce8a9 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Wed, 19 Apr 2023 10:38:35 +0200 Subject: [PATCH 07/11] Update parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- .../runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index f74da930515..d063fda2c13 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -169,7 +169,7 @@ pub type Barrier = DenyThenTry< ( // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - // Parent, its plurality (i.e. governance bodies) and Fellows plurality gets free execution. + // Parent, its pluralities (i.e. governance bodies), and the Fellows plurality get free execution. AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>, // Subscriptions for version tracking are OK. AllowSubscriptionsFrom, From b01d022788ed3bcc7d5663bea5a2d265a7e9b82a Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Wed, 19 Apr 2023 10:42:09 +0200 Subject: [PATCH 08/11] Update parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- .../runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 9b08a5c5331..7b395a4d4e3 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -166,7 +166,7 @@ pub type Barrier = DenyThenTry< ( // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - // Parent and its plurality (i.e. governance bodies) gets free execution. + // Parent and its pluralities (i.e. governance bodies) get free execution. AllowExplicitUnpaidExecutionFrom, // Subscriptions for version tracking are OK. AllowSubscriptionsFrom, From 78ab2cde59f569c7cc091cce25553ff780b74adc Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Wed, 19 Apr 2023 10:43:11 +0200 Subject: [PATCH 09/11] Align all desc --- parachains/runtimes/assets/statemine/src/xcm_config.rs | 2 +- parachains/runtimes/assets/statemint/src/xcm_config.rs | 2 +- parachains/runtimes/assets/westmint/src/xcm_config.rs | 2 +- .../runtimes/collectives/collectives-polkadot/src/xcm_config.rs | 2 +- .../runtimes/contracts/contracts-rococo/src/xcm_config.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/parachains/runtimes/assets/statemine/src/xcm_config.rs b/parachains/runtimes/assets/statemine/src/xcm_config.rs index 5d4c45fd4f3..45f95ee07d4 100644 --- a/parachains/runtimes/assets/statemine/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemine/src/xcm_config.rs @@ -356,7 +356,7 @@ pub type Barrier = DenyThenTry< ( // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - // Parent and its plurality (i.e. governance bodies) gets free execution. + // Parent and its pluralities (i.e. governance bodies) get free execution. AllowExplicitUnpaidExecutionFrom, // Subscriptions for version tracking are OK. AllowSubscriptionsFrom, diff --git a/parachains/runtimes/assets/statemint/src/xcm_config.rs b/parachains/runtimes/assets/statemint/src/xcm_config.rs index 90b0ee85fef..9d31bc0da60 100644 --- a/parachains/runtimes/assets/statemint/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemint/src/xcm_config.rs @@ -259,7 +259,7 @@ pub type Barrier = DenyThenTry< ( // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - // Parent, its plurality (i.e. governance bodies) and Fellows plurality gets free execution. + // Parent, its pluralities (i.e. governance bodies), and the Fellows plurality get free execution. AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>, // Subscriptions for version tracking are OK. AllowSubscriptionsFrom, diff --git a/parachains/runtimes/assets/westmint/src/xcm_config.rs b/parachains/runtimes/assets/westmint/src/xcm_config.rs index 1f57b34fcae..d9987a627ae 100644 --- a/parachains/runtimes/assets/westmint/src/xcm_config.rs +++ b/parachains/runtimes/assets/westmint/src/xcm_config.rs @@ -354,7 +354,7 @@ pub type Barrier = DenyThenTry< ( // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - // Parent or its plurality (i.e. governance bodies) gets free execution. + // Parent and its pluralities (i.e. governance bodies) get free execution. AllowExplicitUnpaidExecutionFrom, // Subscriptions for version tracking are OK. AllowSubscriptionsFrom, diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index 9c1fda61bd8..b2b93d88ffe 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -204,7 +204,7 @@ pub type Barrier = DenyThenTry< ( // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - // Parent and its plurality (i.e. governance bodies) gets free execution. + // Parent and its pluralities (i.e. governance bodies) get free execution. AllowExplicitUnpaidExecutionFrom, // Subscriptions for version tracking are OK. AllowSubscriptionsFrom, diff --git a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index d8ed043fb54..1b42819b423 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -129,7 +129,7 @@ pub type Barrier = DenyThenTry< ( // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - // Parent and its plurality (i.e. governance bodies) gets free execution. + // Parent and its pluralities (i.e. governance bodies) get free execution. AllowExplicitUnpaidExecutionFrom, // Subscriptions for version tracking are OK. AllowSubscriptionsFrom, From 0829744686dee64e3cd2ef4d9d46f36e032984b8 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Wed, 19 Apr 2023 10:52:04 +0200 Subject: [PATCH 10/11] Extract runtime_para_id for test --- parachains/runtimes/assets/statemine/tests/tests.rs | 3 ++- parachains/runtimes/assets/statemint/tests/tests.rs | 3 ++- parachains/runtimes/assets/test-utils/src/test_cases.rs | 8 +++++--- parachains/runtimes/assets/westmint/tests/tests.rs | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/parachains/runtimes/assets/statemine/tests/tests.rs b/parachains/runtimes/assets/statemine/tests/tests.rs index acfb2417e4b..b9001a35a99 100644 --- a/parachains/runtimes/assets/statemine/tests/tests.rs +++ b/parachains/runtimes/assets/statemine/tests/tests.rs @@ -492,7 +492,8 @@ asset_test_utils::include_teleports_for_native_asset_works!( Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), _ => None, } - }) + }), + 1000 ); asset_test_utils::include_teleports_for_foreign_assets_works!( diff --git a/parachains/runtimes/assets/statemint/tests/tests.rs b/parachains/runtimes/assets/statemint/tests/tests.rs index 75f6aaf6d57..7bbed6bb54a 100644 --- a/parachains/runtimes/assets/statemint/tests/tests.rs +++ b/parachains/runtimes/assets/statemint/tests/tests.rs @@ -470,7 +470,8 @@ asset_test_utils::include_teleports_for_native_asset_works!( Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), _ => None, } - }) + }), + 1000 ); asset_test_utils::include_asset_transactor_transfer_with_local_consensus_currency_works!( diff --git a/parachains/runtimes/assets/test-utils/src/test_cases.rs b/parachains/runtimes/assets/test-utils/src/test_cases.rs index 88e36144694..3fd27940aea 100644 --- a/parachains/runtimes/assets/test-utils/src/test_cases.rs +++ b/parachains/runtimes/assets/test-utils/src/test_cases.rs @@ -78,6 +78,7 @@ pub fn teleports_for_native_asset_works< unwrap_xcmp_queue_event: Box< dyn Fn(Vec) -> Option>, >, + runtime_para_id: u32, ) where Runtime: frame_system::Config + pallet_balances::Config @@ -102,7 +103,6 @@ pub fn teleports_for_native_asset_works< Call = cumulus_pallet_parachain_system::Call, >, { - let runtime_para_id = 1000; ExtBuilder::::default() .with_collators(collator_session_keys.collators()) .with_session_keys(collator_session_keys.session_keys()) @@ -273,7 +273,8 @@ macro_rules! include_teleports_for_native_asset_works( $collator_session_key:expr, $existential_deposit:expr, $unwrap_pallet_xcm_event:expr, - $unwrap_xcmp_queue_event:expr + $unwrap_xcmp_queue_event:expr, + $runtime_para_id:expr ) => { #[test] fn teleports_for_native_asset_works() { @@ -291,7 +292,8 @@ macro_rules! include_teleports_for_native_asset_works( $existential_deposit, target_account, $unwrap_pallet_xcm_event, - $unwrap_xcmp_queue_event + $unwrap_xcmp_queue_event, + $runtime_para_id ) } } diff --git a/parachains/runtimes/assets/westmint/tests/tests.rs b/parachains/runtimes/assets/westmint/tests/tests.rs index c0c20c6b61a..3ef09d14e52 100644 --- a/parachains/runtimes/assets/westmint/tests/tests.rs +++ b/parachains/runtimes/assets/westmint/tests/tests.rs @@ -497,7 +497,8 @@ asset_test_utils::include_teleports_for_native_asset_works!( Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), _ => None, } - }) + }), + 1000 ); asset_test_utils::include_teleports_for_foreign_assets_works!( From 27d3951d544992518c1e0cf6e83f2408ae0c15a5 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Wed, 19 Apr 2023 11:08:20 +0200 Subject: [PATCH 11/11] Fix test --- .../runtimes/bridge-hubs/bridge-hub-kusama/tests/tests.rs | 3 ++- .../runtimes/bridge-hubs/bridge-hub-polkadot/tests/tests.rs | 3 ++- .../runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/tests/tests.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/tests/tests.rs index 492078a54aa..9998e3d804d 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/tests/tests.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/tests/tests.rs @@ -51,5 +51,6 @@ bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!( Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), _ => None, } - }) + }), + 1002 ); diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/tests/tests.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/tests/tests.rs index 2ec12fff4ba..9a3ccd59cd6 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/tests/tests.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/tests/tests.rs @@ -51,5 +51,6 @@ bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!( Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), _ => None, } - }) + }), + 1002 ); diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs index 426f9867154..bf899b567d8 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs @@ -51,5 +51,6 @@ bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!( Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), _ => None, } - }) + }), + 1013 );