mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 15:11:02 +00:00
17b2e1b300
* Nits (merge before separatelly) * Small cosmetics for Rococo/Wococo bridge local run * Squashed 'bridges/' changes from 04b3dda6aa..5fc377ab34 5fc377ab34 Support for kusama-polkadot relaying (#2128) 01f4b7f1ba Fix clippy warnings (#2127) 696ff1c368 BHK/P alignments (#2115) 2a66aa3248 Small fixes (#2126) 7810f1a988 Cosmetics (#2124) daf250f69c Remove some `expect()` statements (#2123) 1c5fba8274 temporarily remove balance guard (#2121) 3d0e547361 Propagate message receival confirmation errors (#2116) 1c33143f07 Propagate message verification errors (#2114) b075b00910 Bump time from 0.3.20 to 0.3.21 51a3a51618 Bump serde from 1.0.160 to 1.0.162 da88d044a6 Bump clap from 4.2.5 to 4.2.7 cdca322cd6 Bump sysinfo from 0.28.4 to 0.29.0 git-subtree-dir: bridges git-subtree-split: 5fc377ab34f7dfd3293099c5feec49255e827812 * Fix * Allow to change storage constants (DeliveryReward, RequiredStakeForStakeAndSlash) + tests * Clippy * New SA for RO/WO * Squashed 'bridges/' changes from 5fc377ab34..0f6091d481 0f6091d481 Bump polkadot/substrate (#2134) 9233f0a337 Bump tokio from 1.28.0 to 1.28.1 a29c1caa93 Bump serde from 1.0.162 to 1.0.163 git-subtree-dir: bridges git-subtree-split: 0f6091d48184ebb4f75cb3089befa6b92cf37335
286 lines
9.8 KiB
Rust
286 lines
9.8 KiB
Rust
// Copyright 2023 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 bridge_hub_rococo_runtime::{
|
|
constants::fee::WeightToFee,
|
|
xcm_config::{RelayNetwork, XcmConfig, XcmRouter},
|
|
Balances, BridgeGrandpaRococoInstance, BridgeGrandpaWococoInstance, BridgeWococoMessages,
|
|
DeliveryRewardInBalance, ExistentialDeposit, ParachainSystem, PolkadotXcm,
|
|
RequiredStakeForStakeAndSlash, Runtime, RuntimeCall, RuntimeEvent, SessionKeys,
|
|
};
|
|
use codec::{Decode, Encode};
|
|
use xcm::latest::prelude::*;
|
|
|
|
use bridge_hub_rococo_runtime::{
|
|
bridge_hub_rococo_config, bridge_hub_wococo_config, WithBridgeHubRococoMessagesInstance,
|
|
WithBridgeHubWococoMessagesInstance,
|
|
};
|
|
|
|
use frame_support::parameter_types;
|
|
use parachains_common::{AccountId, AuraId, Balance};
|
|
|
|
const ALICE: [u8; 32] = [1u8; 32];
|
|
|
|
parameter_types! {
|
|
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
|
}
|
|
|
|
mod bridge_hub_rococo_tests {
|
|
use super::*;
|
|
|
|
bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!(
|
|
Runtime,
|
|
XcmConfig,
|
|
CheckingAccount,
|
|
WeightToFee,
|
|
ParachainSystem,
|
|
bridge_hub_test_utils::CollatorSessionKeys::new(
|
|
AccountId::from(ALICE),
|
|
AccountId::from(ALICE),
|
|
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }
|
|
),
|
|
ExistentialDeposit::get(),
|
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
|
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
|
Ok(RuntimeEvent::PolkadotXcm(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,
|
|
}
|
|
}),
|
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID
|
|
);
|
|
|
|
bridge_hub_test_utils::include_initialize_bridge_by_governance_works!(
|
|
Runtime,
|
|
BridgeGrandpaWococoInstance,
|
|
bridge_hub_test_utils::CollatorSessionKeys::new(
|
|
AccountId::from(ALICE),
|
|
AccountId::from(ALICE),
|
|
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }
|
|
),
|
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
|
Box::new(|call| RuntimeCall::BridgeWococoGrandpa(call).encode())
|
|
);
|
|
|
|
bridge_hub_test_utils::include_change_storage_constant_by_governance_works!(
|
|
change_delivery_reward_by_governance_works,
|
|
Runtime,
|
|
bridge_hub_test_utils::CollatorSessionKeys::new(
|
|
AccountId::from(ALICE),
|
|
AccountId::from(ALICE),
|
|
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }
|
|
),
|
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
|
Box::new(|call| RuntimeCall::System(call).encode()),
|
|
(DeliveryRewardInBalance, u64),
|
|
|| (DeliveryRewardInBalance::key().to_vec(), DeliveryRewardInBalance::get()),
|
|
|old_value| old_value.checked_mul(2).unwrap()
|
|
);
|
|
|
|
bridge_hub_test_utils::include_change_storage_constant_by_governance_works!(
|
|
change_required_stake_by_governance_works,
|
|
Runtime,
|
|
bridge_hub_test_utils::CollatorSessionKeys::new(
|
|
AccountId::from(ALICE),
|
|
AccountId::from(ALICE),
|
|
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }
|
|
),
|
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
|
Box::new(|call| RuntimeCall::System(call).encode()),
|
|
(RequiredStakeForStakeAndSlash, Balance),
|
|
|| (RequiredStakeForStakeAndSlash::key().to_vec(), RequiredStakeForStakeAndSlash::get()),
|
|
|old_value| old_value.checked_mul(2).unwrap()
|
|
);
|
|
|
|
bridge_hub_test_utils::include_handle_export_message_from_system_parachain_to_outbound_queue_works!(
|
|
Runtime,
|
|
XcmConfig,
|
|
WithBridgeHubWococoMessagesInstance,
|
|
bridge_hub_test_utils::CollatorSessionKeys::new(
|
|
AccountId::from(ALICE),
|
|
AccountId::from(ALICE),
|
|
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }
|
|
),
|
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
|
1000,
|
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
|
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
|
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
|
|
);
|
|
|
|
bridge_hub_test_utils::include_message_dispatch_routing_works!(
|
|
Runtime,
|
|
XcmConfig,
|
|
ParachainSystem,
|
|
WithBridgeHubWococoMessagesInstance,
|
|
RelayNetwork,
|
|
bridge_hub_rococo_config::WococoGlobalConsensusNetwork,
|
|
bridge_hub_test_utils::CollatorSessionKeys::new(
|
|
AccountId::from(ALICE),
|
|
AccountId::from(ALICE),
|
|
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }
|
|
),
|
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
|
1000,
|
|
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,
|
|
}
|
|
}),
|
|
bridge_hub_rococo_config::DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO
|
|
);
|
|
}
|
|
|
|
mod bridge_hub_wococo_tests {
|
|
use super::*;
|
|
|
|
bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!(
|
|
Runtime,
|
|
XcmConfig,
|
|
CheckingAccount,
|
|
WeightToFee,
|
|
ParachainSystem,
|
|
bridge_hub_test_utils::CollatorSessionKeys::new(
|
|
AccountId::from(ALICE),
|
|
AccountId::from(ALICE),
|
|
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }
|
|
),
|
|
ExistentialDeposit::get(),
|
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
|
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
|
Ok(RuntimeEvent::PolkadotXcm(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,
|
|
}
|
|
}),
|
|
bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID
|
|
);
|
|
|
|
bridge_hub_test_utils::include_initialize_bridge_by_governance_works!(
|
|
Runtime,
|
|
BridgeGrandpaRococoInstance,
|
|
bridge_hub_test_utils::CollatorSessionKeys::new(
|
|
AccountId::from(ALICE),
|
|
AccountId::from(ALICE),
|
|
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }
|
|
),
|
|
bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID,
|
|
Box::new(|call| RuntimeCall::BridgeRococoGrandpa(call).encode())
|
|
);
|
|
|
|
bridge_hub_test_utils::include_change_storage_constant_by_governance_works!(
|
|
change_delivery_reward_by_governance_works,
|
|
Runtime,
|
|
bridge_hub_test_utils::CollatorSessionKeys::new(
|
|
AccountId::from(ALICE),
|
|
AccountId::from(ALICE),
|
|
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }
|
|
),
|
|
bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID,
|
|
Box::new(|call| RuntimeCall::System(call).encode()),
|
|
(DeliveryRewardInBalance, u64),
|
|
|| (DeliveryRewardInBalance::key().to_vec(), DeliveryRewardInBalance::get()),
|
|
|old_value| old_value.checked_mul(2).unwrap()
|
|
);
|
|
|
|
bridge_hub_test_utils::include_change_storage_constant_by_governance_works!(
|
|
change_required_stake_by_governance_works,
|
|
Runtime,
|
|
bridge_hub_test_utils::CollatorSessionKeys::new(
|
|
AccountId::from(ALICE),
|
|
AccountId::from(ALICE),
|
|
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }
|
|
),
|
|
bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID,
|
|
Box::new(|call| RuntimeCall::System(call).encode()),
|
|
(RequiredStakeForStakeAndSlash, Balance),
|
|
|| (RequiredStakeForStakeAndSlash::key().to_vec(), RequiredStakeForStakeAndSlash::get()),
|
|
|old_value| old_value.checked_mul(2).unwrap()
|
|
);
|
|
|
|
bridge_hub_test_utils::include_handle_export_message_from_system_parachain_to_outbound_queue_works!(
|
|
Runtime,
|
|
XcmConfig,
|
|
WithBridgeHubRococoMessagesInstance,
|
|
bridge_hub_test_utils::CollatorSessionKeys::new(
|
|
AccountId::from(ALICE),
|
|
AccountId::from(ALICE),
|
|
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }
|
|
),
|
|
bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID,
|
|
1000,
|
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
|
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
|
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
|
|
);
|
|
|
|
bridge_hub_test_utils::include_message_dispatch_routing_works!(
|
|
Runtime,
|
|
XcmConfig,
|
|
ParachainSystem,
|
|
WithBridgeHubRococoMessagesInstance,
|
|
RelayNetwork,
|
|
bridge_hub_wococo_config::RococoGlobalConsensusNetwork,
|
|
bridge_hub_test_utils::CollatorSessionKeys::new(
|
|
AccountId::from(ALICE),
|
|
AccountId::from(ALICE),
|
|
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }
|
|
),
|
|
bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID,
|
|
1000,
|
|
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,
|
|
}
|
|
}),
|
|
bridge_hub_wococo_config::DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO
|
|
);
|
|
}
|