mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 00:31:02 +00:00
[testnet] Add AssetHubRococo <-> AssetHubWestend asset bridging support (#1967)
## Summary Asset bridging support for AssetHub**Rococo** <-> AssetHub**Wococo** was added [here](https://github.com/paritytech/polkadot-sdk/pull/1215), so now we aim to bridge AssetHub**Rococo** and AssetHub**Westend**. (And perhaps retire AssetHubWococo and the Wococo chains). ## Solution **bridge-hub-westend-runtime** - added new runtime as a copy of `bridge-hub-rococo-runtime` - added support for bridging to `BridgeHubRococo` - added tests and benchmarks **bridge-hub-rococo-runtime** - added support for bridging to `BridgeHubWestend` - added tests and benchmarks - internal refactoring by splitting bridge configuration per network, e.g., `bridge_to_whatevernetwork_config.rs`. **asset-hub-rococo-runtime** - added support for asset bridging to `AssetHubWestend` (allows to receive only WNDs) - added new xcm router for `Westend` - added tests and benchmarks **asset-hub-westend-runtime** - added support for asset bridging to `AssetHubRococo` (allows to receive only ROCs) - added new xcm router for `Rococo` - added tests and benchmarks ## Deployment All changes will be deployed as a part of https://github.com/paritytech/polkadot-sdk/issues/1988. ## TODO - [x] benchmarks for all pallet instances - [x] integration tests - [x] local run scripts Relates to: https://github.com/paritytech/parity-bridges-common/issues/2602 Relates to: https://github.com/paritytech/polkadot-sdk/issues/1988 --------- Co-authored-by: command-bot <> Co-authored-by: Adrian Catangiu <adrian@parity.io> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
This commit is contained in:
@@ -18,7 +18,8 @@
|
||||
|
||||
use bp_polkadot_core::Signature;
|
||||
use bridge_hub_rococo_runtime::{
|
||||
bridge_common_config, bridge_hub_rococo_config, bridge_hub_wococo_config,
|
||||
bridge_common_config, bridge_to_rococo_config, bridge_to_westend_config,
|
||||
bridge_to_wococo_config,
|
||||
xcm_config::{RelayNetwork, TokenLocation, XcmConfig},
|
||||
AllPalletsWithoutSystem, BridgeRejectObsoleteHeadersAndMessages, Executive, ExistentialDeposit,
|
||||
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, SessionKeys, SignedExtra,
|
||||
@@ -57,8 +58,9 @@ fn construct_extrinsic(
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0),
|
||||
BridgeRejectObsoleteHeadersAndMessages::default(),
|
||||
(
|
||||
bridge_hub_wococo_config::BridgeRefundBridgeHubRococoMessages::default(),
|
||||
bridge_hub_rococo_config::BridgeRefundBridgeHubWococoMessages::default(),
|
||||
bridge_to_wococo_config::OnBridgeHubRococoRefundBridgeHubWococoMessages::default(),
|
||||
bridge_to_westend_config::OnBridgeHubRococoRefundBridgeHubWestendMessages::default(),
|
||||
bridge_to_rococo_config::OnBridgeHubWococoRefundBridgeHubRococoMessages::default(),
|
||||
),
|
||||
);
|
||||
let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap();
|
||||
@@ -96,12 +98,17 @@ fn collator_session_keys() -> bridge_hub_test_utils::CollatorSessionKeys<Runtime
|
||||
mod bridge_hub_rococo_tests {
|
||||
use super::*;
|
||||
use bridge_common_config::{
|
||||
BridgeGrandpaWococoInstance, BridgeParachainWococoInstance, DeliveryRewardInBalance,
|
||||
RequiredStakeForStakeAndSlash,
|
||||
BridgeGrandpaWestendInstance, BridgeGrandpaWococoInstance, BridgeParachainWestendInstance,
|
||||
BridgeParachainWococoInstance, DeliveryRewardInBalance, RequiredStakeForStakeAndSlash,
|
||||
};
|
||||
use bridge_hub_rococo_config::{
|
||||
WithBridgeHubWococoMessageBridge, WithBridgeHubWococoMessagesInstance,
|
||||
DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO,
|
||||
use bridge_to_westend_config::{
|
||||
BridgeHubWestendChainId, WestendGlobalConsensusNetwork, WithBridgeHubWestendMessageBridge,
|
||||
WithBridgeHubWestendMessagesInstance, XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND,
|
||||
};
|
||||
use bridge_to_wococo_config::{
|
||||
BridgeHubWococoChainId, WithBridgeHubWococoMessageBridge,
|
||||
WithBridgeHubWococoMessagesInstance, WococoGlobalConsensusNetwork,
|
||||
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WOCOCO,
|
||||
};
|
||||
|
||||
bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!(
|
||||
@@ -130,6 +137,7 @@ mod bridge_hub_rococo_tests {
|
||||
|
||||
#[test]
|
||||
fn initialize_bridge_by_governance_works() {
|
||||
// for Wococo finality
|
||||
bridge_hub_test_utils::test_cases::initialize_bridge_by_governance_works::<
|
||||
Runtime,
|
||||
BridgeGrandpaWococoInstance,
|
||||
@@ -137,6 +145,15 @@ mod bridge_hub_rococo_tests {
|
||||
collator_session_keys(),
|
||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||
Box::new(|call| RuntimeCall::BridgeWococoGrandpa(call).encode()),
|
||||
);
|
||||
// for Westend finality
|
||||
bridge_hub_test_utils::test_cases::initialize_bridge_by_governance_works::<
|
||||
Runtime,
|
||||
BridgeGrandpaWestendInstance,
|
||||
>(
|
||||
collator_session_keys(),
|
||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||
Box::new(|call| RuntimeCall::BridgeWestendGrandpa(call).encode()),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -177,6 +194,7 @@ mod bridge_hub_rococo_tests {
|
||||
|
||||
#[test]
|
||||
fn handle_export_message_from_system_parachain_add_to_outbound_queue_works() {
|
||||
// for Wococo
|
||||
bridge_hub_test_utils::test_cases::handle_export_message_from_system_parachain_to_outbound_queue_works::<
|
||||
Runtime,
|
||||
XcmConfig,
|
||||
@@ -187,12 +205,34 @@ mod bridge_hub_rococo_tests {
|
||||
SIBLING_PARACHAIN_ID,
|
||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
||||
Ok(RuntimeEvent::BridgeRococoToWococoMessages(event)) => Some(event),
|
||||
Ok(RuntimeEvent::BridgeWococoMessages(event)) => Some(event),
|
||||
_ => None,
|
||||
}
|
||||
}),
|
||||
|| ExportMessage { network: Wococo, destination: X1(Parachain(1234)), xcm: Xcm(vec![]) },
|
||||
bridge_hub_rococo_config::DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO,
|
||||
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WOCOCO,
|
||||
Some((TokenLocation::get(), ExistentialDeposit::get()).into()),
|
||||
// value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer`
|
||||
Some((TokenLocation::get(), bp_asset_hub_rococo::BridgeHubRococoBaseFeeInRocs::get()).into()),
|
||||
|| (),
|
||||
);
|
||||
// for Westend
|
||||
bridge_hub_test_utils::test_cases::handle_export_message_from_system_parachain_to_outbound_queue_works::<
|
||||
Runtime,
|
||||
XcmConfig,
|
||||
WithBridgeHubWestendMessagesInstance,
|
||||
>(
|
||||
collator_session_keys(),
|
||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||
SIBLING_PARACHAIN_ID,
|
||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
||||
Ok(RuntimeEvent::BridgeWestendMessages(event)) => Some(event),
|
||||
_ => None,
|
||||
}
|
||||
}),
|
||||
|| ExportMessage { network: Westend, destination: X1(Parachain(1234)), xcm: Xcm(vec![]) },
|
||||
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND,
|
||||
Some((TokenLocation::get(), ExistentialDeposit::get()).into()),
|
||||
// value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer`
|
||||
Some((TokenLocation::get(), bp_asset_hub_rococo::BridgeHubRococoBaseFeeInRocs::get()).into()),
|
||||
@@ -202,6 +242,7 @@ mod bridge_hub_rococo_tests {
|
||||
|
||||
#[test]
|
||||
fn message_dispatch_routing_works() {
|
||||
// from Wococo
|
||||
bridge_hub_test_utils::test_cases::message_dispatch_routing_works::<
|
||||
Runtime,
|
||||
AllPalletsWithoutSystem,
|
||||
@@ -209,7 +250,7 @@ mod bridge_hub_rococo_tests {
|
||||
ParachainSystem,
|
||||
WithBridgeHubWococoMessagesInstance,
|
||||
RelayNetwork,
|
||||
bridge_hub_rococo_config::WococoGlobalConsensusNetwork,
|
||||
WococoGlobalConsensusNetwork,
|
||||
>(
|
||||
collator_session_keys(),
|
||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||
@@ -226,13 +267,42 @@ mod bridge_hub_rococo_tests {
|
||||
_ => None,
|
||||
}
|
||||
}),
|
||||
bridge_hub_rococo_config::DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO,
|
||||
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WOCOCO,
|
||||
|| (),
|
||||
);
|
||||
// from Westend
|
||||
bridge_hub_test_utils::test_cases::message_dispatch_routing_works::<
|
||||
Runtime,
|
||||
AllPalletsWithoutSystem,
|
||||
XcmConfig,
|
||||
ParachainSystem,
|
||||
WithBridgeHubWococoMessagesInstance,
|
||||
RelayNetwork,
|
||||
WestendGlobalConsensusNetwork,
|
||||
>(
|
||||
collator_session_keys(),
|
||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||
SIBLING_PARACHAIN_ID,
|
||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
||||
Ok(RuntimeEvent::ParachainSystem(event)) => Some(event),
|
||||
_ => None,
|
||||
}
|
||||
}),
|
||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
||||
Ok(RuntimeEvent::XcmpQueue(event)) => Some(event),
|
||||
_ => None,
|
||||
}
|
||||
}),
|
||||
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND,
|
||||
|| (),
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn relayed_incoming_message_works() {
|
||||
// from Wococo
|
||||
bridge_hub_test_utils::test_cases::relayed_incoming_message_works::<
|
||||
Runtime,
|
||||
AllPalletsWithoutSystem,
|
||||
@@ -248,13 +318,33 @@ mod bridge_hub_rococo_tests {
|
||||
bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID,
|
||||
SIBLING_PARACHAIN_ID,
|
||||
Rococo,
|
||||
DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO,
|
||||
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WOCOCO,
|
||||
|| (),
|
||||
);
|
||||
// from Westend
|
||||
bridge_hub_test_utils::test_cases::relayed_incoming_message_works::<
|
||||
Runtime,
|
||||
AllPalletsWithoutSystem,
|
||||
XcmConfig,
|
||||
ParachainSystem,
|
||||
BridgeGrandpaWestendInstance,
|
||||
BridgeParachainWestendInstance,
|
||||
WithBridgeHubWestendMessagesInstance,
|
||||
WithBridgeHubWestendMessageBridge,
|
||||
>(
|
||||
collator_session_keys(),
|
||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
|
||||
SIBLING_PARACHAIN_ID,
|
||||
Rococo,
|
||||
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND,
|
||||
|| (),
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn complex_relay_extrinsic_works() {
|
||||
// for Wococo
|
||||
bridge_hub_test_utils::test_cases::complex_relay_extrinsic_works::<
|
||||
Runtime,
|
||||
AllPalletsWithoutSystem,
|
||||
@@ -269,9 +359,32 @@ mod bridge_hub_rococo_tests {
|
||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||
bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID,
|
||||
SIBLING_PARACHAIN_ID,
|
||||
bridge_hub_rococo_config::BridgeHubWococoChainId::get(),
|
||||
BridgeHubWococoChainId::get(),
|
||||
Rococo,
|
||||
DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO,
|
||||
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WOCOCO,
|
||||
ExistentialDeposit::get(),
|
||||
executive_init_block,
|
||||
construct_and_apply_extrinsic,
|
||||
|| (),
|
||||
);
|
||||
// for Westend
|
||||
bridge_hub_test_utils::test_cases::complex_relay_extrinsic_works::<
|
||||
Runtime,
|
||||
AllPalletsWithoutSystem,
|
||||
XcmConfig,
|
||||
ParachainSystem,
|
||||
BridgeGrandpaWestendInstance,
|
||||
BridgeParachainWestendInstance,
|
||||
WithBridgeHubWestendMessagesInstance,
|
||||
WithBridgeHubWestendMessageBridge,
|
||||
>(
|
||||
collator_session_keys(),
|
||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
|
||||
SIBLING_PARACHAIN_ID,
|
||||
BridgeHubWestendChainId::get(),
|
||||
Rococo,
|
||||
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND,
|
||||
ExistentialDeposit::get(),
|
||||
executive_init_block,
|
||||
construct_and_apply_extrinsic,
|
||||
@@ -305,9 +418,9 @@ mod bridge_hub_wococo_tests {
|
||||
RequiredStakeForStakeAndSlash,
|
||||
};
|
||||
use bridge_hub_rococo_runtime::{xcm_config, AllPalletsWithoutSystem, RuntimeFlavor};
|
||||
use bridge_hub_wococo_config::{
|
||||
WithBridgeHubRococoMessageBridge, WithBridgeHubRococoMessagesInstance,
|
||||
DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO,
|
||||
use bridge_to_rococo_config::{
|
||||
BridgeHubRococoChainId, RococoGlobalConsensusNetwork, WithBridgeHubRococoMessageBridge,
|
||||
WithBridgeHubRococoMessagesInstance, XCM_LANE_FOR_ASSET_HUB_WOCOCO_TO_ASSET_HUB_ROCOCO,
|
||||
};
|
||||
use frame_support::assert_ok;
|
||||
|
||||
@@ -419,12 +532,12 @@ mod bridge_hub_wococo_tests {
|
||||
SIBLING_PARACHAIN_ID,
|
||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
||||
Ok(RuntimeEvent::BridgeWococoToRococoMessages(event)) => Some(event),
|
||||
Ok(RuntimeEvent::BridgeRococoMessages(event)) => Some(event),
|
||||
_ => None,
|
||||
}
|
||||
}),
|
||||
|| ExportMessage { network: Rococo, destination: X1(Parachain(4321)), xcm: Xcm(vec![]) },
|
||||
bridge_hub_wococo_config::DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO,
|
||||
XCM_LANE_FOR_ASSET_HUB_WOCOCO_TO_ASSET_HUB_ROCOCO,
|
||||
Some((TokenLocation::get(), ExistentialDeposit::get()).into()),
|
||||
// value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer`
|
||||
Some((TokenLocation::get(), bp_asset_hub_wococo::BridgeHubWococoBaseFeeInWocs::get()).into()),
|
||||
@@ -441,7 +554,7 @@ mod bridge_hub_wococo_tests {
|
||||
ParachainSystem,
|
||||
WithBridgeHubRococoMessagesInstance,
|
||||
RelayNetwork,
|
||||
bridge_hub_wococo_config::RococoGlobalConsensusNetwork,
|
||||
RococoGlobalConsensusNetwork,
|
||||
>(
|
||||
collator_session_keys(),
|
||||
bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID,
|
||||
@@ -458,7 +571,7 @@ mod bridge_hub_wococo_tests {
|
||||
_ => None,
|
||||
}
|
||||
}),
|
||||
bridge_hub_wococo_config::DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO,
|
||||
XCM_LANE_FOR_ASSET_HUB_WOCOCO_TO_ASSET_HUB_ROCOCO,
|
||||
set_wococo_flavor,
|
||||
)
|
||||
}
|
||||
@@ -480,7 +593,7 @@ mod bridge_hub_wococo_tests {
|
||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||
SIBLING_PARACHAIN_ID,
|
||||
Wococo,
|
||||
DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO,
|
||||
XCM_LANE_FOR_ASSET_HUB_WOCOCO_TO_ASSET_HUB_ROCOCO,
|
||||
set_wococo_flavor,
|
||||
)
|
||||
}
|
||||
@@ -501,9 +614,9 @@ mod bridge_hub_wococo_tests {
|
||||
bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID,
|
||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||
SIBLING_PARACHAIN_ID,
|
||||
bridge_hub_wococo_config::BridgeHubRococoChainId::get(),
|
||||
BridgeHubRococoChainId::get(),
|
||||
Wococo,
|
||||
DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO,
|
||||
XCM_LANE_FOR_ASSET_HUB_WOCOCO_TO_ASSET_HUB_ROCOCO,
|
||||
ExistentialDeposit::get(),
|
||||
executive_init_block,
|
||||
construct_and_apply_extrinsic,
|
||||
|
||||
Reference in New Issue
Block a user