mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
Add Bridges to xcm-emulator (#2812)
* rename bridge hub + BridgeMessages type * bridge base * bridge string approach * add decl_test_bridges macro * outbound lanes on the way * get & dispatch mock bridge done * fix bridge errors + log::debug for messages * clean up * update source OutboundLaneData * rococo & wococo added * sender_receiver_accounts_parameter_types macro * sender_receiver_accounts_parameter_types macro 2 * fixed multi parachain + example on the way * working but router error * bridge working * refactor NetworkComponent * make it generic * working as generic * clean up * last bit * ".git/.scripts/commands/fmt/fmt.sh" * fix bridge hub handler name * ".git/.scripts/commands/fmt/fmt.sh" * add AssetConversion back for AssetHubWestend * Update xcm/xcm-emulator/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * add LaneId wrapper * update substrate * fix wrapper conversion * remove duplicate in workspace * Revert "update substrate" This reverts commit 92e8f201ae433aed3f70b998ebd4c23d9168d0ee. * ".git/.scripts/commands/fmt/fmt.sh" --------- Co-authored-by: command-bot <> Co-authored-by: Squirrel <gilescope@gmail.com>
This commit is contained in:
@@ -25,12 +25,12 @@ pub use integration_tests_common::{
|
||||
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
|
||||
},
|
||||
AccountId, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender,
|
||||
BHKusama, BHKusamaPallet, BHKusamaReceiver, BHKusamaSender, BHPolkadot, BHPolkadotPallet,
|
||||
BHPolkadotReceiver, BHPolkadotSender, Collectives, CollectivesPallet, CollectivesReceiver,
|
||||
CollectivesSender, Kusama, KusamaMockNet, KusamaPallet, KusamaReceiver, KusamaSender,
|
||||
PenpalKusama, PenpalKusamaReceiver, PenpalKusamaSender, PenpalPolkadot, PenpalPolkadotReceiver,
|
||||
PenpalPolkadotSender, Polkadot, PolkadotMockNet, PolkadotPallet, PolkadotReceiver,
|
||||
PolkadotSender,
|
||||
BridgeHubKusama, BridgeHubKusamaPallet, BridgeHubKusamaReceiver, BridgeHubKusamaSender,
|
||||
BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender,
|
||||
Collectives, CollectivesPallet, CollectivesReceiver, CollectivesSender, Kusama, KusamaMockNet,
|
||||
KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusama, PenpalKusamaReceiver,
|
||||
PenpalKusamaSender, PenpalPolkadot, PenpalPolkadotReceiver, PenpalPolkadotSender, Polkadot,
|
||||
PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender,
|
||||
};
|
||||
pub use polkadot_core_primitives::InboundDownwardMessage;
|
||||
pub use xcm::{
|
||||
|
||||
@@ -26,12 +26,12 @@ pub use integration_tests_common::{
|
||||
},
|
||||
AccountId, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender,
|
||||
AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender,
|
||||
BHKusama, BHKusamaPallet, BHKusamaReceiver, BHKusamaSender, BHPolkadot, BHPolkadotPallet,
|
||||
BHPolkadotReceiver, BHPolkadotSender, Collectives, CollectivesPallet, CollectivesReceiver,
|
||||
CollectivesSender, Kusama, KusamaMockNet, KusamaPallet, KusamaReceiver, KusamaSender,
|
||||
PenpalKusama, PenpalKusamaReceiver, PenpalKusamaSender, PenpalPolkadot, PenpalPolkadotReceiver,
|
||||
PenpalPolkadotSender, Polkadot, PolkadotMockNet, PolkadotPallet, PolkadotReceiver,
|
||||
PolkadotSender,
|
||||
BridgeHubKusama, BridgeHubKusamaPallet, BridgeHubKusamaReceiver, BridgeHubKusamaSender,
|
||||
BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender,
|
||||
Collectives, CollectivesPallet, CollectivesReceiver, CollectivesSender, Kusama, KusamaMockNet,
|
||||
KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusama, PenpalKusamaReceiver,
|
||||
PenpalKusamaSender, PenpalPolkadot, PenpalPolkadotReceiver, PenpalPolkadotSender, Polkadot,
|
||||
PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender,
|
||||
};
|
||||
pub use polkadot_core_primitives::InboundDownwardMessage;
|
||||
pub use xcm::{
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
[package]
|
||||
name = "bridge-hub-rococo-integration-tests"
|
||||
version = "1.0.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
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" }
|
||||
@@ -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
@@ -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 Bridge 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
@@ -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;
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "collectives-polkadot-it"
|
||||
name = "collectives-polkadot-integration-tests"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2021"
|
||||
|
||||
@@ -21,6 +21,7 @@ pallet-balances = { default-features = false, git = "https://github.com/parityte
|
||||
pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-staking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-im-online = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
beefy-primitives = { package = "sp-consensus-beefy", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
# Polkadot
|
||||
polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
@@ -32,7 +33,9 @@ polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "m
|
||||
polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
kusama-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
westend-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
rococo-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
rococo-runtime-constants = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
westend-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
westend-runtime-constants = { 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" }
|
||||
@@ -49,7 +52,12 @@ asset-hub-westend-runtime = { path = "../../../runtimes/assets/asset-hub-westend
|
||||
collectives-polkadot-runtime = { path = "../../../runtimes/collectives/collectives-polkadot" }
|
||||
bridge-hub-kusama-runtime = { path = "../../../runtimes/bridge-hubs/bridge-hub-kusama" }
|
||||
bridge-hub-polkadot-runtime = { path = "../../../runtimes/bridge-hubs/bridge-hub-polkadot" }
|
||||
bridge-hub-rococo-runtime = { path = "../../../runtimes/bridge-hubs/bridge-hub-rococo" }
|
||||
xcm-emulator = { default-features = false, path = "../../../../xcm/xcm-emulator" }
|
||||
bp-messages = { path = "../../../../bridges/primitives/messages"}
|
||||
bp-runtime = { path = "../../../../bridges/primitives/runtime"}
|
||||
pallet-bridge-messages = { path = "../../../../bridges/modules/messages" }
|
||||
bridge-runtime-common = { path = "../../../../bridges/bin/runtime-common"}
|
||||
|
||||
[features]
|
||||
runtime-benchmarks = [
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use beefy_primitives::crypto::AuthorityId as BeefyId;
|
||||
use grandpa::AuthorityId as GrandpaId;
|
||||
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
pub use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber};
|
||||
use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber};
|
||||
use polkadot_primitives::{AssignmentId, ValidatorId};
|
||||
pub use polkadot_runtime_parachains::configuration::HostConfiguration;
|
||||
use polkadot_runtime_parachains::configuration::HostConfiguration;
|
||||
use polkadot_service::chain_spec::get_authority_keys_from_seed_no_beefy;
|
||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||
use sp_consensus_babe::AuthorityId as BabeId;
|
||||
@@ -11,7 +12,7 @@ use sp_runtime::{
|
||||
traits::{IdentifyAccount, Verify},
|
||||
BuildStorage, MultiSignature, Perbill,
|
||||
};
|
||||
pub use xcm;
|
||||
use xcm;
|
||||
|
||||
pub const XCM_V2: u32 = 3;
|
||||
pub const XCM_V3: u32 = 2;
|
||||
@@ -49,6 +50,7 @@ pub mod accounts {
|
||||
pub const DAVE_STASH: &str = "Dave//stash";
|
||||
pub const EVE_STASH: &str = "Eve//stash";
|
||||
pub const FERDIE_STASH: &str = "Ferdie//stash";
|
||||
pub const FERDIE_BEEFY: &str = "Ferdie//stash";
|
||||
|
||||
pub fn init_balances() -> Vec<AccountId> {
|
||||
vec![
|
||||
@@ -209,6 +211,7 @@ pub mod polkadot {
|
||||
}
|
||||
}
|
||||
|
||||
// Westend
|
||||
pub mod westend {
|
||||
use super::*;
|
||||
use westend_runtime_constants::currency::UNITS as WND;
|
||||
@@ -401,6 +404,93 @@ pub mod kusama {
|
||||
}
|
||||
}
|
||||
|
||||
// Rococo
|
||||
pub mod rococo {
|
||||
use super::*;
|
||||
pub const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT;
|
||||
use rococo_runtime_constants::currency::UNITS as ROC;
|
||||
const ENDOWMENT: u128 = 1_000_000 * ROC;
|
||||
|
||||
pub fn get_host_config() -> HostConfiguration<BlockNumber> {
|
||||
HostConfiguration {
|
||||
max_upward_queue_size: 51200,
|
||||
max_upward_message_size: 51200,
|
||||
max_upward_message_num_per_candidate: 10,
|
||||
max_downward_message_size: 51200,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn session_keys(
|
||||
babe: BabeId,
|
||||
grandpa: GrandpaId,
|
||||
im_online: ImOnlineId,
|
||||
para_validator: ValidatorId,
|
||||
para_assignment: AssignmentId,
|
||||
authority_discovery: AuthorityDiscoveryId,
|
||||
beefy: BeefyId,
|
||||
) -> rococo_runtime::SessionKeys {
|
||||
rococo_runtime::SessionKeys {
|
||||
babe,
|
||||
grandpa,
|
||||
im_online,
|
||||
para_validator,
|
||||
para_assignment,
|
||||
authority_discovery,
|
||||
beefy,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn genesis() -> Storage {
|
||||
let genesis_config = rococo_runtime::RuntimeGenesisConfig {
|
||||
system: rococo_runtime::SystemConfig {
|
||||
code: rococo_runtime::WASM_BINARY.unwrap().to_vec(),
|
||||
},
|
||||
balances: rococo_runtime::BalancesConfig {
|
||||
balances: accounts::init_balances()
|
||||
.iter()
|
||||
.map(|k| (k.clone(), ENDOWMENT))
|
||||
.collect(),
|
||||
},
|
||||
// indices: rococo_runtime::IndicesConfig { indices: vec![] },
|
||||
session: rococo_runtime::SessionConfig {
|
||||
keys: validators::initial_authorities()
|
||||
.iter()
|
||||
.map(|x| {
|
||||
(
|
||||
x.0.clone(),
|
||||
x.0.clone(),
|
||||
session_keys(
|
||||
x.2.clone(),
|
||||
x.3.clone(),
|
||||
x.4.clone(),
|
||||
x.5.clone(),
|
||||
x.6.clone(),
|
||||
x.7.clone(),
|
||||
get_from_seed::<BeefyId>("Alice"),
|
||||
),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
},
|
||||
babe: rococo_runtime::BabeConfig {
|
||||
authorities: Default::default(),
|
||||
epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG),
|
||||
},
|
||||
sudo: rococo_runtime::SudoConfig {
|
||||
key: Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
|
||||
},
|
||||
configuration: rococo_runtime::ConfigurationConfig { config: get_host_config() },
|
||||
registrar: rococo_runtime::RegistrarConfig {
|
||||
next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID,
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
genesis_config.build_storage().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
// Asset Hub Polkadot
|
||||
pub mod asset_hub_polkadot {
|
||||
use super::*;
|
||||
@@ -445,12 +535,10 @@ pub mod asset_hub_polkadot {
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
aura: Default::default(),
|
||||
aura_ext: Default::default(),
|
||||
parachain_system: Default::default(),
|
||||
polkadot_xcm: asset_hub_polkadot_runtime::PolkadotXcmConfig {
|
||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
genesis_config.build_storage().unwrap()
|
||||
@@ -501,12 +589,10 @@ pub mod asset_hub_westend {
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
aura: Default::default(),
|
||||
aura_ext: Default::default(),
|
||||
parachain_system: Default::default(),
|
||||
polkadot_xcm: asset_hub_westend_runtime::PolkadotXcmConfig {
|
||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
genesis_config.build_storage().unwrap()
|
||||
@@ -557,12 +643,10 @@ pub mod asset_hub_kusama {
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
aura: Default::default(),
|
||||
aura_ext: Default::default(),
|
||||
parachain_system: Default::default(),
|
||||
polkadot_xcm: asset_hub_kusama_runtime::PolkadotXcmConfig {
|
||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
genesis_config.build_storage().unwrap()
|
||||
@@ -611,15 +695,13 @@ pub mod penpal {
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
aura: Default::default(),
|
||||
aura_ext: Default::default(),
|
||||
parachain_system: Default::default(),
|
||||
polkadot_xcm: penpal_runtime::PolkadotXcmConfig {
|
||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||
},
|
||||
sudo: penpal_runtime::SudoConfig {
|
||||
key: Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
genesis_config.build_storage().unwrap()
|
||||
@@ -670,22 +752,17 @@ pub mod collectives {
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
|
||||
// of this.
|
||||
aura: Default::default(),
|
||||
aura_ext: Default::default(),
|
||||
parachain_system: Default::default(),
|
||||
polkadot_xcm: collectives_polkadot_runtime::PolkadotXcmConfig {
|
||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||
},
|
||||
alliance: Default::default(),
|
||||
alliance_motion: Default::default(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
genesis_config.build_storage().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
// Bridge Hub Kusama
|
||||
pub mod bridge_hub_kusama {
|
||||
use super::*;
|
||||
pub const PARA_ID: u32 = 1002;
|
||||
@@ -729,18 +806,17 @@ pub mod bridge_hub_kusama {
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
aura: Default::default(),
|
||||
aura_ext: Default::default(),
|
||||
parachain_system: Default::default(),
|
||||
polkadot_xcm: bridge_hub_kusama_runtime::PolkadotXcmConfig {
|
||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
genesis_config.build_storage().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
// Bridge Hub Polkadot
|
||||
pub mod bridge_hub_polkadot {
|
||||
use super::*;
|
||||
pub const PARA_ID: u32 = 1002;
|
||||
@@ -784,12 +860,80 @@ pub mod bridge_hub_polkadot {
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
aura: Default::default(),
|
||||
aura_ext: Default::default(),
|
||||
parachain_system: Default::default(),
|
||||
polkadot_xcm: bridge_hub_polkadot_runtime::PolkadotXcmConfig {
|
||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
genesis_config.build_storage().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
// Bridge Hub Rococo & Bridge Hub Wococo
|
||||
pub mod bridge_hub_rococo {
|
||||
use super::*;
|
||||
pub const PARA_ID: u32 = 1013;
|
||||
pub const ED: Balance = bridge_hub_rococo_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
||||
|
||||
pub fn genesis() -> Storage {
|
||||
let genesis_config = bridge_hub_rococo_runtime::RuntimeGenesisConfig {
|
||||
system: bridge_hub_rococo_runtime::SystemConfig {
|
||||
code: bridge_hub_rococo_runtime::WASM_BINARY
|
||||
.expect("WASM binary was not build, please build it!")
|
||||
.to_vec(),
|
||||
},
|
||||
balances: bridge_hub_rococo_runtime::BalancesConfig {
|
||||
balances: accounts::init_balances()
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|k| (k, ED * 4096))
|
||||
.collect(),
|
||||
},
|
||||
parachain_info: bridge_hub_rococo_runtime::ParachainInfoConfig {
|
||||
parachain_id: PARA_ID.into(),
|
||||
},
|
||||
collator_selection: bridge_hub_rococo_runtime::CollatorSelectionConfig {
|
||||
invulnerables: collators::invulnerables()
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|(acc, _)| acc)
|
||||
.collect(),
|
||||
candidacy_bond: ED * 16,
|
||||
..Default::default()
|
||||
},
|
||||
session: bridge_hub_rococo_runtime::SessionConfig {
|
||||
keys: collators::invulnerables()
|
||||
.into_iter()
|
||||
.map(|(acc, aura)| {
|
||||
(
|
||||
acc.clone(), // account id
|
||||
acc, // validator id
|
||||
bridge_hub_rococo_runtime::SessionKeys { aura }, // session keys
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
polkadot_xcm: bridge_hub_rococo_runtime::PolkadotXcmConfig {
|
||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||
},
|
||||
bridge_wococo_grandpa: bridge_hub_rococo_runtime::BridgeWococoGrandpaConfig {
|
||||
owner: Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
|
||||
..Default::default()
|
||||
},
|
||||
bridge_rococo_grandpa: bridge_hub_rococo_runtime::BridgeRococoGrandpaConfig {
|
||||
owner: Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
|
||||
..Default::default()
|
||||
},
|
||||
bridge_rococo_messages: bridge_hub_rococo_runtime::BridgeRococoMessagesConfig {
|
||||
owner: Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
|
||||
..Default::default()
|
||||
},
|
||||
bridge_wococo_messages: bridge_hub_rococo_runtime::BridgeWococoMessagesConfig {
|
||||
owner: Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
genesis_config.build_storage().unwrap()
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
use super::{BridgeHubRococo, BridgeHubWococo};
|
||||
use bp_messages::{
|
||||
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
|
||||
LaneId, MessageKey, OutboundLaneData,
|
||||
};
|
||||
use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult;
|
||||
use codec::Decode;
|
||||
pub use cumulus_primitives_core::{DmpMessageHandler, XcmpMessageHandler};
|
||||
use pallet_bridge_messages::{Config, Instance1, Instance2, OutboundLanes, Pallet};
|
||||
use sp_core::Get;
|
||||
use xcm_emulator::{BridgeMessage, BridgeMessageDispatchError, BridgeMessageHandler, Parachain};
|
||||
|
||||
pub struct BridgeHubMessageHandler<S, T, I> {
|
||||
_marker: std::marker::PhantomData<(S, T, I)>,
|
||||
}
|
||||
|
||||
struct LaneIdWrapper(LaneId);
|
||||
|
||||
impl From<LaneIdWrapper> for u32 {
|
||||
fn from(lane_id: LaneIdWrapper) -> u32 {
|
||||
u32::from_be_bytes(lane_id.0 .0)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u32> for LaneIdWrapper {
|
||||
fn from(id: u32) -> LaneIdWrapper {
|
||||
LaneIdWrapper(LaneId(id.to_be_bytes()))
|
||||
}
|
||||
}
|
||||
|
||||
type BridgeHubRococoRuntime = <BridgeHubRococo as Parachain>::Runtime;
|
||||
type BridgeHubWococoRuntime = <BridgeHubWococo as Parachain>::Runtime;
|
||||
|
||||
// TODO: uncomment when https://github.com/paritytech/cumulus/pull/2528 is merged
|
||||
// type BridgeHubPolkadotRuntime = <BridgeHubPolkadot as Parachain>::Runtime;
|
||||
// type BridgeHubKusamaRuntime = <BridgeHubKusama as Parachain>::Runtime;
|
||||
|
||||
pub type RococoWococoMessageHandler =
|
||||
BridgeHubMessageHandler<BridgeHubRococoRuntime, BridgeHubWococoRuntime, Instance2>;
|
||||
pub type WococoRococoMessageHandler =
|
||||
BridgeHubMessageHandler<BridgeHubWococoRuntime, BridgeHubRococoRuntime, Instance2>;
|
||||
|
||||
// TODO: uncomment when https://github.com/paritytech/cumulus/pull/2528 is merged
|
||||
// pub type PolkadotKusamaMessageHandler
|
||||
// = BridgeHubMessageHandler<BridgeHubPolkadotRuntime, BridgeHubKusamaRuntime, Instance1>;
|
||||
// pub type KusamaPolkadotMessageHandler
|
||||
// = BridgeHubMessageHandler<BridgeHubKusamaRuntime, BridgeHubPolkadoRuntime, Instance1>;
|
||||
|
||||
impl<S, T, I> BridgeMessageHandler for BridgeHubMessageHandler<S, T, I>
|
||||
where
|
||||
S: Config<Instance1>,
|
||||
T: Config<I>,
|
||||
I: 'static,
|
||||
<T as Config<I>>::InboundPayload: From<Vec<u8>>,
|
||||
<T as Config<I>>::MessageDispatch:
|
||||
MessageDispatch<DispatchLevelResult = XcmBlobMessageDispatchResult>,
|
||||
{
|
||||
fn get_source_outbound_messages() -> Vec<BridgeMessage> {
|
||||
// get the source active outbound lanes
|
||||
let active_lanes = S::ActiveOutboundLanes::get();
|
||||
|
||||
let mut messages: Vec<BridgeMessage> = Default::default();
|
||||
|
||||
// collect messages from `OutboundMessages` for each active outbound lane in the source
|
||||
for lane in active_lanes {
|
||||
let latest_generated_nonce =
|
||||
OutboundLanes::<S, Instance1>::get(lane).latest_generated_nonce;
|
||||
let latest_received_nonce =
|
||||
OutboundLanes::<S, Instance1>::get(lane).latest_received_nonce;
|
||||
|
||||
(latest_received_nonce + 1..=latest_generated_nonce).for_each(|nonce| {
|
||||
let encoded_payload: Vec<u8> =
|
||||
Pallet::<S, Instance1>::outbound_message_data(*lane, nonce)
|
||||
.expect("Bridge message does not exist")
|
||||
.into();
|
||||
let payload = Vec::<u8>::decode(&mut &encoded_payload[..])
|
||||
.expect("Decodign XCM message failed");
|
||||
let id: u32 = LaneIdWrapper(*lane).into();
|
||||
let message = BridgeMessage { id, nonce, payload };
|
||||
|
||||
messages.push(message);
|
||||
});
|
||||
}
|
||||
messages
|
||||
}
|
||||
|
||||
fn dispatch_target_inbound_message(
|
||||
message: BridgeMessage,
|
||||
) -> Result<(), BridgeMessageDispatchError> {
|
||||
type TargetMessageDispatch<T, I> = <T as Config<I>>::MessageDispatch;
|
||||
type InboundPayload<T, I> = <T as Config<I>>::InboundPayload;
|
||||
|
||||
let lane_id = LaneIdWrapper::from(message.id).0;
|
||||
let nonce = message.nonce;
|
||||
let payload = Ok(From::from(message.payload));
|
||||
|
||||
// Directly dispatch outbound messages assuming everything is correct
|
||||
// and bypassing the `Relayers` and `InboundLane` logic
|
||||
let dispatch_result = TargetMessageDispatch::<T, I>::dispatch(DispatchMessage {
|
||||
key: MessageKey { lane_id, nonce },
|
||||
data: DispatchMessageData::<InboundPayload<T, I>> { payload },
|
||||
});
|
||||
|
||||
let result = match dispatch_result.dispatch_level_result {
|
||||
XcmBlobMessageDispatchResult::Dispatched => Ok(()),
|
||||
XcmBlobMessageDispatchResult::InvalidPayload => Err(BridgeMessageDispatchError(
|
||||
Box::new(XcmBlobMessageDispatchResult::InvalidPayload),
|
||||
)),
|
||||
XcmBlobMessageDispatchResult::NotDispatched(e) => Err(BridgeMessageDispatchError(
|
||||
Box::new(XcmBlobMessageDispatchResult::NotDispatched(e)),
|
||||
)),
|
||||
};
|
||||
result
|
||||
}
|
||||
|
||||
fn notify_source_message_delivery(lane_id: u32) {
|
||||
let data = OutboundLanes::<S, Instance1>::get(LaneIdWrapper::from(lane_id).0);
|
||||
let new_data = OutboundLaneData {
|
||||
oldest_unpruned_nonce: data.oldest_unpruned_nonce + 1,
|
||||
latest_received_nonce: data.latest_received_nonce + 1,
|
||||
..data
|
||||
};
|
||||
|
||||
OutboundLanes::<S, Instance1>::insert(LaneIdWrapper::from(lane_id).0, new_data);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,25 @@
|
||||
pub mod constants;
|
||||
pub mod impls;
|
||||
|
||||
pub use constants::{
|
||||
accounts::{ALICE, BOB},
|
||||
asset_hub_kusama, asset_hub_polkadot, asset_hub_westend, bridge_hub_kusama,
|
||||
bridge_hub_polkadot, collectives, kusama, penpal, polkadot, westend,
|
||||
bridge_hub_polkadot, bridge_hub_rococo, collectives, kusama, penpal, polkadot, rococo, westend,
|
||||
};
|
||||
pub use impls::{RococoWococoMessageHandler, WococoRococoMessageHandler};
|
||||
|
||||
use frame_support::{parameter_types, sp_io, sp_tracing};
|
||||
pub use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber};
|
||||
pub use sp_core::{sr25519, storage::Storage, Get};
|
||||
use xcm::prelude::*;
|
||||
use xcm_emulator::{
|
||||
decl_test_networks, decl_test_parachains, decl_test_relay_chains, Parachain, RelayChain,
|
||||
TestExt,
|
||||
decl_test_bridges, decl_test_networks, decl_test_parachains, decl_test_relay_chains,
|
||||
decl_test_sender_receiver_accounts_parameter_types, BridgeMessageHandler, Parachain,
|
||||
RelayChain, TestExt,
|
||||
};
|
||||
use xcm_executor::traits::ConvertLocation;
|
||||
|
||||
decl_test_relay_chains! {
|
||||
#[api_version(5)]
|
||||
pub struct Westend {
|
||||
genesis = westend::genesis(),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: westend_runtime::Runtime,
|
||||
RuntimeOrigin: westend_runtime::RuntimeOrigin,
|
||||
RuntimeCall: westend_runtime::RuntimeCall,
|
||||
RuntimeEvent: westend_runtime::RuntimeEvent,
|
||||
MessageQueue: westend_runtime::MessageQueue,
|
||||
XcmConfig: westend_runtime::xcm_config::XcmConfig,
|
||||
SovereignAccountOf: westend_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf,
|
||||
System: westend_runtime::System,
|
||||
Balances: westend_runtime::Balances,
|
||||
},
|
||||
pallets_extra = {
|
||||
XcmPallet: westend_runtime::XcmPallet,
|
||||
Sudo: westend_runtime::Sudo,
|
||||
}
|
||||
},
|
||||
#[api_version(5)]
|
||||
pub struct Polkadot {
|
||||
genesis = polkadot::genesis(),
|
||||
@@ -73,35 +57,71 @@ decl_test_relay_chains! {
|
||||
pallets_extra = {
|
||||
XcmPallet: kusama_runtime::XcmPallet,
|
||||
}
|
||||
},
|
||||
#[api_version(5)]
|
||||
pub struct Westend {
|
||||
genesis = westend::genesis(),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: westend_runtime::Runtime,
|
||||
RuntimeOrigin: westend_runtime::RuntimeOrigin,
|
||||
RuntimeCall: westend_runtime::RuntimeCall,
|
||||
RuntimeEvent: westend_runtime::RuntimeEvent,
|
||||
MessageQueue: westend_runtime::MessageQueue,
|
||||
XcmConfig: westend_runtime::xcm_config::XcmConfig,
|
||||
SovereignAccountOf: westend_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf,
|
||||
System: westend_runtime::System,
|
||||
Balances: westend_runtime::Balances,
|
||||
},
|
||||
pallets_extra = {
|
||||
XcmPallet: westend_runtime::XcmPallet,
|
||||
Sudo: westend_runtime::Sudo,
|
||||
}
|
||||
},
|
||||
#[api_version(5)]
|
||||
pub struct Rococo {
|
||||
genesis = rococo::genesis(),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: rococo_runtime::Runtime,
|
||||
RuntimeOrigin: rococo_runtime::RuntimeOrigin,
|
||||
RuntimeCall: rococo_runtime::RuntimeCall,
|
||||
RuntimeEvent: rococo_runtime::RuntimeEvent,
|
||||
MessageQueue: rococo_runtime::MessageQueue,
|
||||
XcmConfig: rococo_runtime::xcm_config::XcmConfig,
|
||||
SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf,
|
||||
System: rococo_runtime::System,
|
||||
Balances: rococo_runtime::Balances,
|
||||
},
|
||||
pallets_extra = {
|
||||
XcmPallet: rococo_runtime::XcmPallet,
|
||||
Sudo: rococo_runtime::Sudo,
|
||||
}
|
||||
},
|
||||
#[api_version(5)]
|
||||
pub struct Wococo {
|
||||
genesis = rococo::genesis(),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: rococo_runtime::Runtime,
|
||||
RuntimeOrigin: rococo_runtime::RuntimeOrigin,
|
||||
RuntimeCall: rococo_runtime::RuntimeCall,
|
||||
RuntimeEvent: rococo_runtime::RuntimeEvent,
|
||||
MessageQueue: rococo_runtime::MessageQueue,
|
||||
XcmConfig: rococo_runtime::xcm_config::XcmConfig,
|
||||
SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf,
|
||||
System: rococo_runtime::System,
|
||||
Balances: rococo_runtime::Balances,
|
||||
},
|
||||
pallets_extra = {
|
||||
XcmPallet: rococo_runtime::XcmPallet,
|
||||
Sudo: rococo_runtime::Sudo,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
decl_test_parachains! {
|
||||
// Westend
|
||||
pub struct AssetHubWestend {
|
||||
genesis = asset_hub_westend::genesis(),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: asset_hub_westend_runtime::Runtime,
|
||||
RuntimeOrigin: asset_hub_westend_runtime::RuntimeOrigin,
|
||||
RuntimeCall: asset_hub_westend_runtime::RuntimeCall,
|
||||
RuntimeEvent: asset_hub_westend_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: asset_hub_westend_runtime::XcmpQueue,
|
||||
DmpMessageHandler: asset_hub_westend_runtime::DmpQueue,
|
||||
LocationToAccountId: asset_hub_westend_runtime::xcm_config::LocationToAccountId,
|
||||
System: asset_hub_westend_runtime::System,
|
||||
Balances: asset_hub_westend_runtime::Balances,
|
||||
ParachainSystem: asset_hub_westend_runtime::ParachainSystem,
|
||||
ParachainInfo: asset_hub_westend_runtime::ParachainInfo,
|
||||
},
|
||||
pallets_extra = {
|
||||
PolkadotXcm: asset_hub_westend_runtime::PolkadotXcm,
|
||||
Assets: asset_hub_westend_runtime::Assets,
|
||||
ForeignAssets: asset_hub_westend_runtime::ForeignAssets,
|
||||
AssetConversion: asset_hub_westend_runtime::AssetConversion,
|
||||
}
|
||||
},
|
||||
// Polkadot
|
||||
// Polkadot Parachains
|
||||
pub struct AssetHubPolkadot {
|
||||
genesis = asset_hub_polkadot::genesis(),
|
||||
on_init = (),
|
||||
@@ -123,6 +143,46 @@ decl_test_parachains! {
|
||||
Assets: asset_hub_polkadot_runtime::Assets,
|
||||
}
|
||||
},
|
||||
pub struct Collectives {
|
||||
genesis = collectives::genesis(),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: collectives_polkadot_runtime::Runtime,
|
||||
RuntimeOrigin: collectives_polkadot_runtime::RuntimeOrigin,
|
||||
RuntimeCall: collectives_polkadot_runtime::RuntimeCall,
|
||||
RuntimeEvent: collectives_polkadot_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: collectives_polkadot_runtime::XcmpQueue,
|
||||
DmpMessageHandler: collectives_polkadot_runtime::DmpQueue,
|
||||
LocationToAccountId: collectives_polkadot_runtime::xcm_config::LocationToAccountId,
|
||||
System: collectives_polkadot_runtime::System,
|
||||
Balances: collectives_polkadot_runtime::Balances,
|
||||
ParachainSystem: collectives_polkadot_runtime::ParachainSystem,
|
||||
ParachainInfo: collectives_polkadot_runtime::ParachainInfo,
|
||||
},
|
||||
pallets_extra = {
|
||||
PolkadotXcm: collectives_polkadot_runtime::PolkadotXcm,
|
||||
}
|
||||
},
|
||||
pub struct BridgeHubPolkadot {
|
||||
genesis = bridge_hub_polkadot::genesis(),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: bridge_hub_polkadot_runtime::Runtime,
|
||||
RuntimeOrigin: bridge_hub_polkadot_runtime::RuntimeOrigin,
|
||||
RuntimeCall: bridge_hub_polkadot_runtime::RuntimeCall,
|
||||
RuntimeEvent: bridge_hub_polkadot_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: bridge_hub_polkadot_runtime::XcmpQueue,
|
||||
DmpMessageHandler: bridge_hub_polkadot_runtime::DmpQueue,
|
||||
LocationToAccountId: bridge_hub_polkadot_runtime::xcm_config::LocationToAccountId,
|
||||
System: bridge_hub_polkadot_runtime::System,
|
||||
Balances: bridge_hub_polkadot_runtime::Balances,
|
||||
ParachainSystem: bridge_hub_polkadot_runtime::ParachainSystem,
|
||||
ParachainInfo: bridge_hub_polkadot_runtime::ParachainInfo,
|
||||
},
|
||||
pallets_extra = {
|
||||
PolkadotXcm: bridge_hub_polkadot_runtime::PolkadotXcm,
|
||||
}
|
||||
},
|
||||
pub struct PenpalPolkadot {
|
||||
genesis = penpal::genesis(penpal::PARA_ID),
|
||||
on_init = (),
|
||||
@@ -144,29 +204,7 @@ decl_test_parachains! {
|
||||
Assets: penpal_runtime::Assets,
|
||||
}
|
||||
},
|
||||
pub struct PenpalWestend {
|
||||
genesis = penpal::genesis(penpal::PARA_ID),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: penpal_runtime::Runtime,
|
||||
RuntimeOrigin: penpal_runtime::RuntimeOrigin,
|
||||
RuntimeCall: penpal_runtime::RuntimeCall,
|
||||
RuntimeEvent: penpal_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: penpal_runtime::XcmpQueue,
|
||||
DmpMessageHandler: penpal_runtime::DmpQueue,
|
||||
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
|
||||
System: penpal_runtime::System,
|
||||
Balances: penpal_runtime::Balances,
|
||||
ParachainSystem: penpal_runtime::ParachainSystem,
|
||||
ParachainInfo: penpal_runtime::ParachainInfo,
|
||||
},
|
||||
pallets_extra = {
|
||||
PolkadotXcm: penpal_runtime::PolkadotXcm,
|
||||
Assets: penpal_runtime::Assets,
|
||||
}
|
||||
},
|
||||
|
||||
// Kusama
|
||||
// Kusama Parachains
|
||||
pub struct AssetHubKusama {
|
||||
genesis = asset_hub_kusama::genesis(),
|
||||
on_init = (),
|
||||
@@ -189,6 +227,26 @@ decl_test_parachains! {
|
||||
ForeignAssets: asset_hub_kusama_runtime::Assets,
|
||||
}
|
||||
},
|
||||
pub struct BridgeHubKusama {
|
||||
genesis = bridge_hub_kusama::genesis(),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: bridge_hub_kusama_runtime::Runtime,
|
||||
RuntimeOrigin: bridge_hub_kusama_runtime::RuntimeOrigin,
|
||||
RuntimeCall: bridge_hub_kusama_runtime::RuntimeCall,
|
||||
RuntimeEvent: bridge_hub_kusama_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: bridge_hub_kusama_runtime::XcmpQueue,
|
||||
DmpMessageHandler: bridge_hub_kusama_runtime::DmpQueue,
|
||||
LocationToAccountId: bridge_hub_kusama_runtime::xcm_config::LocationToAccountId,
|
||||
System: bridge_hub_kusama_runtime::System,
|
||||
Balances: bridge_hub_kusama_runtime::Balances,
|
||||
ParachainSystem: bridge_hub_kusama_runtime::ParachainSystem,
|
||||
ParachainInfo: bridge_hub_kusama_runtime::ParachainInfo,
|
||||
},
|
||||
pallets_extra = {
|
||||
PolkadotXcm: bridge_hub_kusama_runtime::PolkadotXcm,
|
||||
}
|
||||
},
|
||||
pub struct PenpalKusama {
|
||||
genesis = penpal::genesis(penpal::PARA_ID),
|
||||
on_init = (),
|
||||
@@ -210,64 +268,133 @@ decl_test_parachains! {
|
||||
Assets: penpal_runtime::Assets,
|
||||
}
|
||||
},
|
||||
pub struct Collectives {
|
||||
genesis = collectives::genesis(),
|
||||
// Westend Parachains
|
||||
pub struct AssetHubWestend {
|
||||
genesis = asset_hub_westend::genesis(),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: collectives_polkadot_runtime::Runtime,
|
||||
RuntimeOrigin: collectives_polkadot_runtime::RuntimeOrigin,
|
||||
RuntimeCall: collectives_polkadot_runtime::RuntimeCall,
|
||||
RuntimeEvent: collectives_polkadot_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: collectives_polkadot_runtime::XcmpQueue,
|
||||
DmpMessageHandler: collectives_polkadot_runtime::DmpQueue,
|
||||
LocationToAccountId: collectives_polkadot_runtime::xcm_config::LocationToAccountId,
|
||||
System: collectives_polkadot_runtime::System,
|
||||
Balances: collectives_polkadot_runtime::Balances,
|
||||
ParachainSystem: collectives_polkadot_runtime::ParachainSystem,
|
||||
ParachainInfo: collectives_polkadot_runtime::ParachainInfo,
|
||||
Runtime: asset_hub_westend_runtime::Runtime,
|
||||
RuntimeOrigin: asset_hub_westend_runtime::RuntimeOrigin,
|
||||
RuntimeCall: asset_hub_westend_runtime::RuntimeCall,
|
||||
RuntimeEvent: asset_hub_westend_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: asset_hub_westend_runtime::XcmpQueue,
|
||||
DmpMessageHandler: asset_hub_westend_runtime::DmpQueue,
|
||||
LocationToAccountId: asset_hub_westend_runtime::xcm_config::LocationToAccountId,
|
||||
System: asset_hub_westend_runtime::System,
|
||||
Balances: asset_hub_westend_runtime::Balances,
|
||||
ParachainSystem: asset_hub_westend_runtime::ParachainSystem,
|
||||
ParachainInfo: asset_hub_westend_runtime::ParachainInfo,
|
||||
},
|
||||
pallets_extra = {
|
||||
PolkadotXcm: collectives_polkadot_runtime::PolkadotXcm,
|
||||
PolkadotXcm: asset_hub_westend_runtime::PolkadotXcm,
|
||||
Assets: asset_hub_westend_runtime::Assets,
|
||||
ForeignAssets: asset_hub_westend_runtime::ForeignAssets,
|
||||
AssetConversion: asset_hub_westend_runtime::AssetConversion,
|
||||
}
|
||||
},
|
||||
pub struct BHKusama {
|
||||
genesis = bridge_hub_kusama::genesis(),
|
||||
pub struct PenpalWestend {
|
||||
genesis = penpal::genesis(penpal::PARA_ID),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: bridge_hub_kusama_runtime::Runtime,
|
||||
RuntimeOrigin: bridge_hub_kusama_runtime::RuntimeOrigin,
|
||||
RuntimeCall: bridge_hub_kusama_runtime::RuntimeCall,
|
||||
RuntimeEvent: bridge_hub_kusama_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: bridge_hub_kusama_runtime::XcmpQueue,
|
||||
DmpMessageHandler: bridge_hub_kusama_runtime::DmpQueue,
|
||||
LocationToAccountId: bridge_hub_kusama_runtime::xcm_config::LocationToAccountId,
|
||||
System: bridge_hub_kusama_runtime::System,
|
||||
Balances: bridge_hub_kusama_runtime::Balances,
|
||||
ParachainSystem: bridge_hub_kusama_runtime::ParachainSystem,
|
||||
ParachainInfo:bridge_hub_kusama_runtime::ParachainInfo,
|
||||
Runtime: penpal_runtime::Runtime,
|
||||
RuntimeOrigin: penpal_runtime::RuntimeOrigin,
|
||||
RuntimeCall: penpal_runtime::RuntimeCall,
|
||||
RuntimeEvent: penpal_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: penpal_runtime::XcmpQueue,
|
||||
DmpMessageHandler: penpal_runtime::DmpQueue,
|
||||
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
|
||||
System: penpal_runtime::System,
|
||||
Balances: penpal_runtime::Balances,
|
||||
ParachainSystem: penpal_runtime::ParachainSystem,
|
||||
ParachainInfo: penpal_runtime::ParachainInfo,
|
||||
},
|
||||
pallets_extra = {
|
||||
PolkadotXcm: bridge_hub_kusama_runtime::PolkadotXcm,
|
||||
PolkadotXcm: penpal_runtime::PolkadotXcm,
|
||||
Assets: penpal_runtime::Assets,
|
||||
}
|
||||
},
|
||||
pub struct BHPolkadot {
|
||||
genesis = bridge_hub_polkadot::genesis(),
|
||||
// Rococo Parachains
|
||||
pub struct BridgeHubRococo {
|
||||
genesis = bridge_hub_rococo::genesis(),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: bridge_hub_polkadot_runtime::Runtime,
|
||||
RuntimeOrigin: bridge_hub_polkadot_runtime::RuntimeOrigin,
|
||||
RuntimeCall: bridge_hub_polkadot_runtime::RuntimeCall,
|
||||
RuntimeEvent: bridge_hub_polkadot_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: bridge_hub_polkadot_runtime::XcmpQueue,
|
||||
DmpMessageHandler: bridge_hub_polkadot_runtime::DmpQueue,
|
||||
LocationToAccountId: bridge_hub_polkadot_runtime::xcm_config::LocationToAccountId,
|
||||
System: bridge_hub_polkadot_runtime::System,
|
||||
Balances: bridge_hub_polkadot_runtime::Balances,
|
||||
ParachainSystem: bridge_hub_polkadot_runtime::ParachainSystem,
|
||||
ParachainInfo:bridge_hub_polkadot_runtime::ParachainInfo,
|
||||
Runtime: bridge_hub_rococo_runtime::Runtime,
|
||||
RuntimeOrigin: bridge_hub_rococo_runtime::RuntimeOrigin,
|
||||
RuntimeCall: bridge_hub_rococo_runtime::RuntimeCall,
|
||||
RuntimeEvent: bridge_hub_rococo_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: bridge_hub_rococo_runtime::XcmpQueue,
|
||||
DmpMessageHandler: bridge_hub_rococo_runtime::DmpQueue,
|
||||
LocationToAccountId: bridge_hub_rococo_runtime::xcm_config::LocationToAccountId,
|
||||
System: bridge_hub_rococo_runtime::System,
|
||||
Balances: bridge_hub_rococo_runtime::Balances,
|
||||
ParachainSystem: bridge_hub_rococo_runtime::ParachainSystem,
|
||||
ParachainInfo: bridge_hub_rococo_runtime::ParachainInfo,
|
||||
},
|
||||
pallets_extra = {
|
||||
PolkadotXcm: bridge_hub_polkadot_runtime::PolkadotXcm,
|
||||
PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm,
|
||||
}
|
||||
},
|
||||
pub struct AssetHubRococo {
|
||||
genesis = asset_hub_polkadot::genesis(),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: asset_hub_polkadot_runtime::Runtime,
|
||||
RuntimeOrigin: asset_hub_polkadot_runtime::RuntimeOrigin,
|
||||
RuntimeCall: asset_hub_polkadot_runtime::RuntimeCall,
|
||||
RuntimeEvent: asset_hub_polkadot_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue,
|
||||
DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue,
|
||||
LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId,
|
||||
System: asset_hub_polkadot_runtime::System,
|
||||
Balances: asset_hub_polkadot_runtime::Balances,
|
||||
ParachainSystem: asset_hub_polkadot_runtime::ParachainSystem,
|
||||
ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo,
|
||||
},
|
||||
pallets_extra = {
|
||||
PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm,
|
||||
Assets: asset_hub_polkadot_runtime::Assets,
|
||||
}
|
||||
},
|
||||
// Wococo Parachains
|
||||
pub struct BridgeHubWococo {
|
||||
genesis = bridge_hub_rococo::genesis(),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: bridge_hub_rococo_runtime::Runtime,
|
||||
RuntimeOrigin: bridge_hub_rococo_runtime::RuntimeOrigin,
|
||||
RuntimeCall: bridge_hub_rococo_runtime::RuntimeCall,
|
||||
RuntimeEvent: bridge_hub_rococo_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: bridge_hub_rococo_runtime::XcmpQueue,
|
||||
DmpMessageHandler: bridge_hub_rococo_runtime::DmpQueue,
|
||||
LocationToAccountId: bridge_hub_rococo_runtime::xcm_config::LocationToAccountId,
|
||||
System: bridge_hub_rococo_runtime::System,
|
||||
Balances: bridge_hub_rococo_runtime::Balances,
|
||||
ParachainSystem: bridge_hub_rococo_runtime::ParachainSystem,
|
||||
ParachainInfo: bridge_hub_rococo_runtime::ParachainInfo,
|
||||
},
|
||||
pallets_extra = {
|
||||
PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm,
|
||||
}
|
||||
},
|
||||
pub struct AssetHubWococo {
|
||||
genesis = asset_hub_polkadot::genesis(),
|
||||
on_init = (),
|
||||
runtime = {
|
||||
Runtime: asset_hub_polkadot_runtime::Runtime,
|
||||
RuntimeOrigin: asset_hub_polkadot_runtime::RuntimeOrigin,
|
||||
RuntimeCall: asset_hub_polkadot_runtime::RuntimeCall,
|
||||
RuntimeEvent: asset_hub_polkadot_runtime::RuntimeEvent,
|
||||
XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue,
|
||||
DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue,
|
||||
LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId,
|
||||
System: asset_hub_polkadot_runtime::System,
|
||||
Balances: asset_hub_polkadot_runtime::Balances,
|
||||
ParachainSystem: asset_hub_polkadot_runtime::ParachainSystem,
|
||||
ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo,
|
||||
},
|
||||
pallets_extra = {
|
||||
PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm,
|
||||
Assets: asset_hub_polkadot_runtime::Assets,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -279,16 +406,22 @@ decl_test_networks! {
|
||||
AssetHubPolkadot,
|
||||
PenpalPolkadot,
|
||||
Collectives,
|
||||
BHPolkadot,
|
||||
BridgeHubPolkadot,
|
||||
],
|
||||
// TODO: uncomment when https://github.com/paritytech/cumulus/pull/2528 is merged
|
||||
// bridge = PolkadotKusamaMockBridge
|
||||
bridge = ()
|
||||
},
|
||||
pub struct KusamaMockNet {
|
||||
relay_chain = Kusama,
|
||||
parachains = vec![
|
||||
AssetHubKusama,
|
||||
PenpalKusama,
|
||||
BHKusama,
|
||||
BridgeHubKusama,
|
||||
],
|
||||
// TODO: uncomment when https://github.com/paritytech/cumulus/pull/2528 is merged
|
||||
// bridge = KusamaPolkadotMockBridge
|
||||
bridge = ()
|
||||
},
|
||||
pub struct WestendMockNet {
|
||||
relay_chain = Westend,
|
||||
@@ -296,44 +429,72 @@ decl_test_networks! {
|
||||
AssetHubWestend,
|
||||
PenpalWestend,
|
||||
],
|
||||
bridge = ()
|
||||
},
|
||||
pub struct RococoMockNet {
|
||||
relay_chain = Rococo,
|
||||
parachains = vec![
|
||||
AssetHubRococo,
|
||||
BridgeHubRococo,
|
||||
],
|
||||
bridge = RococoWococoMockBridge
|
||||
},
|
||||
pub struct WococoMockNet {
|
||||
relay_chain = Wococo,
|
||||
parachains = vec![
|
||||
AssetHubWococo,
|
||||
BridgeHubWococo,
|
||||
],
|
||||
bridge = WococoRococoMockBridge
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// Polkadot
|
||||
pub PolkadotSender: AccountId = Polkadot::account_id_of(ALICE);
|
||||
pub PolkadotReceiver: AccountId = Polkadot::account_id_of(BOB);
|
||||
// Kusama
|
||||
pub KusamaSender: AccountId = Kusama::account_id_of(ALICE);
|
||||
pub KusamaReceiver: AccountId = Kusama::account_id_of(BOB);
|
||||
// Westend
|
||||
pub WestendSender: AccountId = Westend::account_id_of(ALICE);
|
||||
pub WestendReceiver: AccountId = Westend::account_id_of(BOB);
|
||||
// Asset Hub Westend
|
||||
pub AssetHubWestendSender: AccountId = AssetHubWestend::account_id_of(ALICE);
|
||||
pub AssetHubWestendReceiver: AccountId = AssetHubWestend::account_id_of(BOB);
|
||||
// Asset Hub Polkadot
|
||||
pub AssetHubPolkadotSender: AccountId = AssetHubPolkadot::account_id_of(ALICE);
|
||||
pub AssetHubPolkadotReceiver: AccountId = AssetHubPolkadot::account_id_of(BOB);
|
||||
// Asset Hub Kusama
|
||||
pub AssetHubKusamaSender: AccountId = AssetHubKusama::account_id_of(ALICE);
|
||||
pub AssetHubKusamaReceiver: AccountId = AssetHubKusama::account_id_of(BOB);
|
||||
// Penpal Polkadot
|
||||
pub PenpalPolkadotSender: AccountId = PenpalPolkadot::account_id_of(ALICE);
|
||||
pub PenpalPolkadotReceiver: AccountId = PenpalPolkadot::account_id_of(BOB);
|
||||
// Penpal Kusama
|
||||
pub PenpalKusamaSender: AccountId = PenpalKusama::account_id_of(ALICE);
|
||||
pub PenpalKusamaReceiver: AccountId = PenpalKusama::account_id_of(BOB);
|
||||
// Penpal Westend
|
||||
pub PenpalWestendSender: AccountId = PenpalWestend::account_id_of(ALICE);
|
||||
pub PenpalWestendReceiver: AccountId = PenpalWestend::account_id_of(BOB);
|
||||
// Collectives
|
||||
pub CollectivesSender: AccountId = Collectives::account_id_of(ALICE);
|
||||
pub CollectivesReceiver: AccountId = Collectives::account_id_of(BOB);
|
||||
// Bridge Hub Polkadot
|
||||
pub BHPolkadotSender: AccountId = BHPolkadot::account_id_of(ALICE);
|
||||
pub BHPolkadotReceiver: AccountId = BHPolkadot::account_id_of(BOB);
|
||||
// Bridge Hub Kusama
|
||||
pub BHKusamaSender: AccountId = BHKusama::account_id_of(ALICE);
|
||||
pub BHKusamaReceiver: AccountId = BHKusama::account_id_of(BOB);
|
||||
decl_test_bridges! {
|
||||
pub struct RococoWococoMockBridge {
|
||||
source = BridgeHubRococo,
|
||||
target = BridgeHubWococo,
|
||||
handler = RococoWococoMessageHandler
|
||||
},
|
||||
pub struct WococoRococoMockBridge {
|
||||
source = BridgeHubWococo,
|
||||
target = BridgeHubRococo,
|
||||
handler = WococoRococoMessageHandler
|
||||
}
|
||||
// TODO: uncomment when https://github.com/paritytech/cumulus/pull/2528 is merged
|
||||
// pub struct PolkadotKusamaMockBridge {
|
||||
// source = BridgeHubPolkadot,
|
||||
// target = BridgeHubKusama,
|
||||
// handler = PolkadotKusamaMessageHandler
|
||||
// },
|
||||
// pub struct KusamaPolkadotMockBridge {
|
||||
// source = BridgeHubKusama,
|
||||
// target = BridgeHubPolkadot,
|
||||
// handler = KusamaPolkadotMessageHandler
|
||||
// }
|
||||
}
|
||||
|
||||
decl_test_sender_receiver_accounts_parameter_types! {
|
||||
// Relays
|
||||
Polkadot { sender: ALICE, receiver: BOB },
|
||||
Kusama { sender: ALICE, receiver: BOB },
|
||||
Westend { sender: ALICE, receiver: BOB },
|
||||
Rococo { sender: ALICE, receiver: BOB },
|
||||
Wococo { sender: ALICE, receiver: BOB },
|
||||
// Asset Hubs
|
||||
AssetHubPolkadot { sender: ALICE, receiver: BOB },
|
||||
AssetHubKusama { sender: ALICE, receiver: BOB },
|
||||
AssetHubWestend { sender: ALICE, receiver: BOB },
|
||||
AssetHubRococo { sender: ALICE, receiver: BOB },
|
||||
AssetHubWococo { sender: ALICE, receiver: BOB },
|
||||
// Collectives
|
||||
Collectives { sender: ALICE, receiver: BOB },
|
||||
// Bridged Hubs
|
||||
BridgeHubPolkadot { sender: ALICE, receiver: BOB },
|
||||
BridgeHubKusama { sender: ALICE, receiver: BOB },
|
||||
BridgeHubRococo { sender: ALICE, receiver: BOB },
|
||||
BridgeHubWococo { sender: ALICE, receiver: BOB },
|
||||
// Penpals
|
||||
PenpalPolkadot { sender: ALICE, receiver: BOB },
|
||||
PenpalKusama { sender: ALICE, receiver: BOB },
|
||||
PenpalWestend { sender: ALICE, receiver: BOB }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user