Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Update aggregate message origin (#38)
Browse files Browse the repository at this point in the history
* update aggregate message origin

* fix imports

* fmt

* revert non-rococo changes

* adds log

* Fix compile error & breaking tests (#39)

* westend needs the same config

* revert log

* add test back in

* revert fmt

* Fix breaking test

---------

Co-authored-by: claravanstaden <Cats 4 life!>
Co-authored-by: Ron <[email protected]>
  • Loading branch information
claravanstaden and yrong authored Nov 28, 2023
1 parent 771e43c commit 91d6e27
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 46 deletions.
8 changes: 7 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ parachains-common = { path = "../../../../../../../parachains/common" }
cumulus-primitives-core = { path = "../../../../../../../primitives/core", default-features = false }
emulated-integration-tests-common = { path = "../../../../common", default-features = false }
bridge-hub-rococo-runtime = { path = "../../../../../../runtimes/bridge-hubs/bridge-hub-rococo" }
bridge-hub-common = { path = "../../../../../../runtimes/bridge-hubs/common", default-features = false }

# Snowbridge
snowbridge-core = { path = "../../../../../../../../../parachain/primitives/core", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ decl_test_parachains! {
XcmpMessageHandler: bridge_hub_rococo_runtime::XcmpQueue,
LocationToAccountId: bridge_hub_rococo_runtime::xcm_config::LocationToAccountId,
ParachainInfo: bridge_hub_rococo_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
MessageOrigin: bridge_hub_common::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ parachains-common = { path = "../../../../../../../parachains/common" }
cumulus-primitives-core = { path = "../../../../../../../primitives/core", default-features = false }
emulated-integration-tests-common = { path = "../../../../common", default-features = false }
bridge-hub-westend-runtime = { path = "../../../../../../runtimes/bridge-hubs/bridge-hub-westend" }
bridge-hub-common = { path = "../../../../../../runtimes/bridge-hubs/common", default-features = false }
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ decl_test_parachains! {
XcmpMessageHandler: bridge_hub_westend_runtime::XcmpQueue,
LocationToAccountId: bridge_hub_westend_runtime::xcm_config::LocationToAccountId,
ParachainInfo: bridge_hub_westend_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
MessageOrigin: bridge_hub_common::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: bridge_hub_westend_runtime::PolkadotXcm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ rococo-westend-system-emulated-network = { path = "../../../networks/rococo-west
bridge-hub-rococo-emulated-chain = { path = "../../../chains/parachains/bridges/bridge-hub-rococo"}
asset-hub-rococo-emulated-chain = { path = "../../../chains/parachains/assets/asset-hub-rococo"}
penpal-emulated-chain = { path = "../../../chains/parachains/testing/penpal" }
penpal-runtime = { path = "../../../../../runtimes/testing/penpal" }
rococo-system-emulated-network ={ path = "../../../networks/rococo-system" }

# Snowbridge
snowbridge-core = { path = "../../../../../../../../parachain/primitives/core", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ pub use emulated_integration_tests_common::{
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
};
pub use parachains_common::{AccountId, Balance};
pub use rococo_system_emulated_network::{
penpal_emulated_chain::PenpalAParaPallet as PenpalAPallet,
BridgeHubRococoParaReceiver as BridgeHubRococoReceiver, PenpalAPara as PenpalA,
PenpalAParaReceiver as PenpalAReceiver, PenpalAParaSender as PenpalASender,
};
pub use rococo_westend_system_emulated_network::{
asset_hub_rococo_emulated_chain::{
genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococoParaPallet as AssetHubRococoPallet,
Expand All @@ -51,16 +56,13 @@ pub use rococo_westend_system_emulated_network::{
bridge_hub_rococo_emulated_chain::{
genesis::ED as BRIDGE_HUB_ROCOCO_ED, BridgeHubRococoParaPallet as BridgeHubRococoPallet,
},
penpal_emulated_chain::PenpalAParaPallet as PenpalAPallet,
rococo_emulated_chain::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet},
AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver,
AssetHubRococoParaSender as AssetHubRococoSender, AssetHubWestendPara as AssetHubWestend,
AssetHubWestendParaReceiver as AssetHubWestendReceiver, BridgeHubRococoPara as BridgeHubRococo,
BridgeHubRococoParaReceiver as BridgeHubRococoReceiver,
BridgeHubRococoParaSender as BridgeHubRococoSender, BridgeHubWestendPara as BridgeHubWestend,
PenpalAPara as PenpalA, PenpalAParaReceiver as PenpalAReceiver,
PenpalAParaSender as PenpalASender, RococoRelay as Rococo,
RococoRelayReceiver as RococoReceiver, RococoRelaySender as RococoSender,
RococoRelay as Rococo, RococoRelayReceiver as RococoReceiver,
RococoRelaySender as RococoSender,
};

pub const ASSET_ID: u32 = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,36 @@ fn send_token_to_penpal() {
});
BridgeHubRococo::fund_accounts(vec![(asset_hub_sovereign.clone(), INITIAL_FUND)]);

// Fund ethereum sovereign in asset hub
AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]);

PenpalA::fund_accounts(vec![
(PenpalAReceiver::get(), INITIAL_FUND),
(PenpalASender::get(), INITIAL_FUND),
]);

let weth_asset_id: MultiLocation =
let weth_asset_location: MultiLocation =
(Parent, Parent, Ethereum { chain_id: 15 }, AccountKey20 { network: None, key: WETH })
.into();
let weth_asset_id = weth_asset_location.into();

let origin_location =
MultiLocation { parents: 2, interior: weth_asset_location.interior.split_last().0 };

// Fund ethereum sovereign in asset hub
let ethereum_sovereign: AccountId =
hex!("da4d66c3651dc151264eee5460493210338e41a7bbfca91a520e438daf180bf5").into();
AssetHubRococo::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);
// Create asset on assethub.
AssetHubRococo::execute_with(|| {
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::ForeignAssets::create(
pallet_xcm::Origin::Xcm(origin_location).into(),
weth_asset_id,
asset_hub_sovereign.clone().into(),
1000,
));

assert!(<AssetHubRococo as AssetHubRococoPallet>::ForeignAssets::asset_exists(
weth_asset_id
));
});

// Create asset on penpal.
PenpalA::execute_with(|| {
Expand All @@ -259,7 +278,7 @@ fn send_token_to_penpal() {
1000,
));

//assert!(<PenpalA as PenpalAPallet>::Assets::asset_exists(weth_asset_id));
assert!(<PenpalA as PenpalAPallet>::ForeignAssets::asset_exists(weth_asset_id));
});

let message_id_: H256 = [1; 32].into();
Expand All @@ -268,12 +287,6 @@ fn send_token_to_penpal() {
type RuntimeEvent = <BridgeHubRococo as Chain>::RuntimeEvent;
type EthereumInboundQueue =
<BridgeHubRococo as BridgeHubRococoPallet>::EthereumInboundQueue;
let message = VersionedMessage::V1(MessageV1 {
chain_id: CHAIN_ID,
command: Command::RegisterToken { token: WETH.into() },
});
let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap();
let message = VersionedMessage::V1(MessageV1 {
chain_id: CHAIN_ID,
command: Command::SendToken {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use sp_std::prelude::*;
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;

use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use cumulus_primitives_core::ParaId;
use frame_support::{
construct_runtime,
dispatch::DispatchClass,
Expand All @@ -65,8 +65,11 @@ use frame_system::{
EnsureRoot,
};

use bridge_hub_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
AggregateMessageOrigin,
};
use pallet_xcm::EnsureXcm;
use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling};
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use xcm::VersionedMultiLocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pallet-bridge-messages = { path = "../../../../../bridges/modules/messages", def
pallet-bridge-parachains = { path = "../../../../../bridges/modules/parachains", default-features = false }
pallet-bridge-relayers = { path = "../../../../../bridges/modules/relayers", default-features = false }
bridge-runtime-common = { path = "../../../../../bridges/bin/runtime-common", default-features = false }
bridge-hub-common = { path = "../../bridge-hubs/common", default-features = false }

[dev-dependencies]
static_assertions = "1.1"
Expand Down Expand Up @@ -173,6 +174,7 @@ std = [
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
"bridge-hub-common/std",
]

runtime-benchmarks = [
Expand Down Expand Up @@ -205,6 +207,7 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"bridge-hub-common/runtime-benchmarks",
]

try-runtime = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ mod weights;
pub mod xcm_config;

use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling};
use cumulus_primitives_core::ParaId;
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
Expand All @@ -49,6 +48,10 @@ use sp_std::prelude::*;
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;

use bridge_hub_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
AggregateMessageOrigin,
};
use frame_support::{
construct_runtime,
dispatch::DispatchClass,
Expand Down
7 changes: 5 additions & 2 deletions cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sp-runtime = { path = "../../../../../substrate/primitives/runtime", default-fea
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
xcm = { package = "staging-xcm", path = "../../../../../polkadot/xcm", default-features = false}
pallet-message-queue = { path = "../../../../../substrate/frame/message-queue", default-features = false}
snowbridge-core = { path = "../../../../../../parachain/primitives/core", default-features = false }

[features]
default = [ "std" ]
Expand All @@ -26,12 +27,14 @@ std = [
"sp-runtime/std",
"cumulus-primitives-core/std",
"xcm/std",
"pallet-message-queue/std"
"pallet-message-queue/std",
"snowbridge-core/std"
]

runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks"
"pallet-message-queue/runtime-benchmarks",
"snowbridge-core/runtime-benchmarks"
]
2 changes: 1 addition & 1 deletion cumulus/parachains/runtimes/bridge-hubs/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

pub mod message_queue;

pub use message_queue::BridgeHubMessageRouter;
pub use message_queue::{AggregateMessageOrigin, BridgeHubMessageRouter};
Loading

0 comments on commit 91d6e27

Please sign in to comment.