Align BridgeHub runtimes with other SP runtimes + reused test for teleport native tokens + some nits (#2449)

* Align BridgeHub runtimes with other SP runtimes

* Reused `teleports_for_native_asset_works` test to all bridge-hub runtime

* Fix import vs doc

* Removed unnecessery deps

* DealWithFees + ToAuthor->ToStakingPot for BH according to the other runtimes

* Update parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Update parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Update parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Align all desc

* Extract runtime_para_id for test

* Fix test

---------

Co-authored-by: parity-processbot <>
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
This commit is contained in:
Branislav Kontur
2023-04-24 15:43:16 +02:00
committed by GitHub
parent 457d1724df
commit 4e3f0857ab
28 changed files with 312 additions and 87 deletions
@@ -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;
@@ -356,7 +356,7 @@ pub type Barrier = DenyThenTry<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent and its plurality (i.e. governance bodies) gets free execution.
// Parent and its pluralities (i.e. governance bodies) get free execution.
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
@@ -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!(
@@ -259,7 +259,7 @@ pub type Barrier = DenyThenTry<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// 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<ParentOrSiblings>,
@@ -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!(
@@ -78,6 +78,7 @@ pub fn teleports_for_native_asset_works<
unwrap_xcmp_queue_event: Box<
dyn Fn(Vec<u8>) -> Option<cumulus_pallet_xcmp_queue::Event<Runtime>>,
>,
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<Runtime>,
>,
{
let runtime_para_id = 1000;
ExtBuilder::<Runtime>::default()
.with_collators(collator_session_keys.collators())
.with_session_keys(collator_session_keys.session_keys())
@@ -273,14 +273,15 @@ 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() {
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,
@@ -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
)
}
}
@@ -598,7 +600,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 +717,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 +971,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 +1299,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,
@@ -354,7 +354,7 @@ pub type Barrier = DenyThenTry<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent or its plurality (i.e. governance bodies) gets free execution.
// Parent and its pluralities (i.e. governance bodies) get free execution.
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
@@ -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!(