This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 379
Add Bridges to xcm-emulator
#2812
Merged
paritytech-processbot
merged 33 commits into
master
from
nacho/xcm-emulator-bridges-support-rococo
Jul 5, 2023
Merged
Changes from 25 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
832ea95
rename bridge hub + BridgeMessages type
NachoPal 2e1e065
bridge base
NachoPal 5d8dda1
bridge string approach
NachoPal ee1a0d2
add decl_test_bridges macro
NachoPal 0714c47
outbound lanes on the way
NachoPal 7e22c13
get & dispatch mock bridge done
NachoPal ab15f33
fix bridge errors + log::debug for messages
NachoPal 1c71eb4
clean up
NachoPal ea9606f
update source OutboundLaneData
NachoPal a478ae6
rococo & wococo added
NachoPal d53b674
sender_receiver_accounts_parameter_types macro
NachoPal 281f5a5
sender_receiver_accounts_parameter_types macro 2
NachoPal 1463d22
fixed multi parachain + example on the way
NachoPal d39deeb
working but router error
NachoPal 6e91b96
bridge working
NachoPal 97bb46a
refactor NetworkComponent
NachoPal e9d3a07
make it generic
NachoPal b0cbf79
working as generic
NachoPal 4ea717b
clean up
NachoPal 7ca9ecb
last bit
NachoPal 8e645b7
merge master
NachoPal 420c779
".git/.scripts/commands/fmt/fmt.sh"
f9675bc
fix bridge hub handler name
NachoPal 0dbb673
fix conflict
NachoPal d0d6eb2
".git/.scripts/commands/fmt/fmt.sh"
5830ec2
add AssetConversion back for AssetHubWestend
NachoPal 52281b5
Update xcm/xcm-emulator/src/lib.rs
NachoPal 4cd02c5
add LaneId wrapper
NachoPal 92e8f20
update substrate
NachoPal 82c20a9
fix wrapper conversion
NachoPal 17c0612
remove duplicate in workspace
NachoPal e9ff40d
Revert "update substrate"
NachoPal 1f9bc13
".git/.scripts/commands/fmt/fmt.sh"
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
parachains/integration-tests/emulated/bridges/bridge-hub-rococo/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[package] | ||
name = "bridge-hub-rococo-integration-tests" | ||
version = "1.0.0" | ||
authors = ["Parity Technologies <[email protected]>"] | ||
edition = "2021" | ||
description = "Bridge Hub Rococo runtime integration tests with xcm-emulator" | ||
|
||
[dependencies] | ||
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } | ||
|
||
# Substrate | ||
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } | ||
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } | ||
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } | ||
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } | ||
sp-weights = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } | ||
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } | ||
pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } | ||
|
||
# Polkadot | ||
polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } | ||
polkadot-parachain = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } | ||
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" } | ||
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } | ||
xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } | ||
xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } | ||
pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } | ||
|
||
# Cumulus | ||
parachains-common = { path = "../../../../common" } | ||
cumulus-pallet-xcmp-queue = { default-features = false, path = "../../../../../pallets/xcmp-queue" } | ||
bridge-hub-rococo-runtime = { path = "../../../../runtimes/bridge-hubs/bridge-hub-rococo" } | ||
pallet-bridge-messages = { default-features = false, path = "../../../../../bridges/modules/messages" } | ||
bp-messages = { default-features = false, path = "../../../../../bridges/primitives/messages" } | ||
|
||
# Local | ||
xcm-emulator = { default-features = false, path = "../../../../../xcm/xcm-emulator" } | ||
integration-tests-common = { default-features = false, path = "../../common" } |
48 changes: 48 additions & 0 deletions
48
parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 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 <http://www.gnu.org/licenses/>. | ||
|
||
pub use bp_messages::LaneId; | ||
pub use codec::Encode; | ||
pub use frame_support::{assert_ok, pallet_prelude::Weight}; | ||
pub use integration_tests_common::{ | ||
constants::{ | ||
accounts::{ALICE, BOB}, | ||
rococo::{ED as ROCOCO_ED, ED as WOCOCO_ED}, | ||
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, | ||
}, | ||
AccountId, AssetHubWococo, BridgeHubPolkadot, BridgeHubPolkadotPallet, | ||
BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, BridgeHubRococo, BridgeHubRococoPallet, | ||
BridgeHubRococoReceiver, BridgeHubRococoSender, BridgeHubWococo, Collectives, | ||
CollectivesPallet, CollectivesReceiver, CollectivesSender, Kusama, KusamaPallet, | ||
PenpalPolkadot, PenpalPolkadotReceiver, PenpalPolkadotSender, Polkadot, PolkadotMockNet, | ||
PolkadotPallet, PolkadotReceiver, PolkadotSender, Rococo, RococoMockNet, RococoPallet, | ||
RococoReceiver, RococoSender, | ||
}; | ||
// pub use polkadot_core_primitives::InboundDownwardMessage; | ||
pub use xcm::{ | ||
prelude::*, | ||
v3::{ | ||
Error, | ||
NetworkId::{Rococo as RococoId, Wococo as WococoId}, | ||
}, | ||
}; | ||
pub use xcm_emulator::{ | ||
assert_expected_events, bx, cumulus_pallet_dmp_queue, helpers::weight_within_threshold, | ||
Parachain as Para, RelayChain as Relay, TestExt, | ||
}; | ||
|
||
#[cfg(test)] | ||
mod tests; |
99 changes: 99 additions & 0 deletions
99
parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/example.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Copyright 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 <http://www.gnu.org/licenses/>. | ||
|
||
use crate::*; | ||
|
||
#[test] | ||
fn example() { | ||
// Init tests variables | ||
// XcmPallet send arguments | ||
let sudo_origin = <Rococo as Relay>::RuntimeOrigin::root(); | ||
let destination = Rococo::child_location_of(BridgeHubRococo::para_id()).into(); | ||
let weight_limit = WeightLimit::Unlimited; | ||
let check_origin = None; | ||
|
||
let remote_xcm = Xcm(vec![ClearOrigin]); | ||
|
||
let xcm = VersionedXcm::from(Xcm(vec![ | ||
UnpaidExecution { weight_limit, check_origin }, | ||
ExportMessage { | ||
network: WococoId, | ||
destination: X1(Parachain(AssetHubWococo::para_id().into())), | ||
xcm: remote_xcm, | ||
}, | ||
])); | ||
|
||
//Rococo Global Consensus | ||
// Send XCM message from Relay Chain to Brid Hub source Parachain | ||
Rococo::execute_with(|| { | ||
assert_ok!(<Rococo as RococoPallet>::XcmPallet::send( | ||
sudo_origin, | ||
bx!(destination), | ||
bx!(xcm), | ||
)); | ||
|
||
type RuntimeEvent = <Rococo as Relay>::RuntimeEvent; | ||
|
||
assert_expected_events!( | ||
Rococo, | ||
vec![ | ||
RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, | ||
] | ||
); | ||
}); | ||
// Receive XCM message in Bridge Hub source Parachain | ||
BridgeHubRococo::execute_with(|| { | ||
type RuntimeEvent = <BridgeHubRococo as Para>::RuntimeEvent; | ||
|
||
assert_expected_events!( | ||
BridgeHubRococo, | ||
vec![ | ||
RuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { | ||
outcome: Outcome::Complete(_), | ||
.. | ||
}) => {}, | ||
RuntimeEvent::BridgeWococoMessages(pallet_bridge_messages::Event::MessageAccepted { | ||
lane_id: LaneId([0, 0, 0, 1]), | ||
nonce: 1, | ||
}) => {}, | ||
] | ||
); | ||
}); | ||
|
||
// Wococo GLobal Consensus | ||
// Receive XCM message in Bridge Hub target Parachain | ||
BridgeHubWococo::execute_with(|| { | ||
type RuntimeEvent = <BridgeHubWococo as Para>::RuntimeEvent; | ||
|
||
assert_expected_events!( | ||
BridgeHubWococo, | ||
vec![ | ||
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, | ||
] | ||
); | ||
}); | ||
// Receive embeded XCM message within `ExportMessage` in Parachain destination | ||
AssetHubWococo::execute_with(|| { | ||
type RuntimeEvent = <AssetHubWococo as Para>::RuntimeEvent; | ||
|
||
assert_expected_events!( | ||
AssetHubWococo, | ||
vec![ | ||
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail { .. }) => {}, | ||
] | ||
); | ||
}); | ||
} |
17 changes: 17 additions & 0 deletions
17
parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 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 <http://www.gnu.org/licenses/>. | ||
|
||
mod example; |
2 changes: 1 addition & 1 deletion
2
parachains/integration-tests/emulated/collectives/collectives-polkadot/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "collectives-polkadot-it" | ||
name = "collectives-polkadot-integration-tests" | ||
version = "0.1.0" | ||
authors = ["Parity Technologies <[email protected]>"] | ||
edition = "2021" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NachoPal @svyatonik
I am not sure about this, can we move this out of
bridges
substree?Because then we need to backport it back to bridges repo and also in new version LaneId has a different type: https://github.com/paritytech/parity-bridges-common/pull/2221/files#diff-836b204328629e6af4b33c2a34ae41191cab06cf89c066e31bdb7085314fcda1L185-R203
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed there's probably a better way to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is implementing
From
forLaneId
or the fact thatLaneId
is going to change? I do not think it is harmful to implement an extraFrom
for a new type.I could try to locally (as part of the
BridgeHubMessageHandler
impl) wrapLaneId
in a new type and implement theFrom
trait for it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkontur @gilescope Check it out