mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +00:00
BridgeHubRococo/Wococo nits + updated subtree (#2572)
* 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
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
- [Bridge-hub Parachains](#bridge-hub-parachains)
|
||||
* [How to test locally Rococo <-> Wococo](#how-to-test-locally-rococo-----wococo)
|
||||
+ [Prepare/Build/Deploy](#prepare-build-deploy)
|
||||
* [Requirements for local run/testing](#requirements-for-local-run-testing)
|
||||
* [How to test locally Rococo <-> Wococo bridge](#how-to-test-locally-rococo-----wococo-bridge)
|
||||
+ [Run chains (Rococo + BridgeHub, Wococo + BridgeHub) with zombienet](#run-chains--rococo---bridgehub--wococo---bridgehub--with-zombienet)
|
||||
+ [Run relayers (Rococo, Wococo)](#run-relayers--rococo--wococo-)
|
||||
+ [Run relayer (BridgeHubRococo, BridgeHubWococo)](#run-relayer--bridgehubrococo--bridgehubwococo-)
|
||||
- [Run with script (alternative 1)](#run-with-script--alternative-1-)
|
||||
- [Run with binary (alternative 2)](#run-with-binary--alternative-2-)
|
||||
+ [Send messages](#send-messages)
|
||||
@@ -29,9 +29,8 @@ The current trustless bridges planned for the BridgeHub(s) are:
|
||||
|
||||

|
||||
|
||||
## How to test locally Rococo <-> Wococo
|
||||
## Requirements for local run/testing
|
||||
|
||||
### Prepare/Build/Deploy
|
||||
```
|
||||
# Prepare empty directory for testing
|
||||
mkdir -p ~/local_bridge_testing/bin
|
||||
@@ -44,7 +43,13 @@ Copy the apropriate binary (zombienet-linux) from the latest release to ~/local_
|
||||
# 2. Build polkadot binary
|
||||
git clone https://github.com/paritytech/polkadot.git
|
||||
cd polkadot
|
||||
cargo build --release
|
||||
|
||||
# if you want to test Kusama/Polkadot bridge, we need "sudo pallet + fast-runtime",
|
||||
# so please, find the latest polkadot's repository branch `it/release-vX.Y.Z-fast-sudo`
|
||||
# e.g:
|
||||
# git checkout -b it/release-v0.9.42-fast-sudo --track origin/it/release-v0.9.42-fast-sudo
|
||||
|
||||
cargo build --release --features fast-runtime
|
||||
cp target/release/polkadot ~/local_bridge_testing/bin/polkadot
|
||||
|
||||
# 3. Build cumulus polkadot-parachain binary
|
||||
@@ -69,6 +74,8 @@ cargo build --release --locked -p polkadot-parachain-bin
|
||||
cp target/release/polkadot-parachain ~/local_bridge_testing/bin/polkadot-parachain-mint
|
||||
```
|
||||
|
||||
## How to test locally Rococo <-> Wococo bridge
|
||||
|
||||
### Run chains (Rococo + BridgeHub, Wococo + BridgeHub) with zombienet
|
||||
|
||||
```
|
||||
@@ -87,7 +94,7 @@ POLKADOT_PARACHAIN_BINARY_PATH_FOR_WOCKMINT=~/local_bridge_testing/bin/polkadot-
|
||||
~/local_bridge_testing/bin/zombienet-linux --provider native spawn ./zombienet/bridge-hubs/bridge_hub_wococo_local_network.toml
|
||||
```
|
||||
|
||||
### Run relayers (Rococo, Wococo)
|
||||
### Run relayer (BridgeHubRococo, BridgeHubWococo)
|
||||
|
||||
**Accounts of BridgeHub parachains:**
|
||||
- `Bob` is pallet owner of all bridge pallets
|
||||
|
||||
+1
-5
@@ -134,7 +134,7 @@ impl ThisChainWithMessages for BridgeHubRococo {
|
||||
/// Signed extension that refunds relayers that are delivering messages from the Wococo parachain.
|
||||
pub type BridgeRefundBridgeHubWococoMessages = RefundBridgedParachainMessages<
|
||||
Runtime,
|
||||
RefundableParachain<BridgeParachainWococoInstance, BridgeHubWococoParachainId>,
|
||||
RefundableParachain<BridgeParachainWococoInstance, bp_bridge_hub_wococo::BridgeHubWococo>,
|
||||
RefundableMessagesLane<WithBridgeHubWococoMessagesInstance, BridgeHubWococoMessagesLane>,
|
||||
ActualFeeRefund<Runtime>,
|
||||
PriorityBoostPerMessage,
|
||||
@@ -144,10 +144,6 @@ bp_runtime::generate_static_str_provider!(BridgeRefundBridgeHubWococoMessages);
|
||||
|
||||
parameter_types! {
|
||||
pub const BridgeHubWococoMessagesLane: bp_messages::LaneId = DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO;
|
||||
pub const BridgeHubWococoParachainId: u32 = {
|
||||
use bp_runtime::Parachain;
|
||||
BridgeHubWococo::PARACHAIN_ID
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
+1
-5
@@ -134,7 +134,7 @@ impl ThisChainWithMessages for BridgeHubWococo {
|
||||
/// Signed extension that refunds relayers that are delivering messages from the Rococo parachain.
|
||||
pub type BridgeRefundBridgeHubRococoMessages = RefundBridgedParachainMessages<
|
||||
Runtime,
|
||||
RefundableParachain<BridgeParachainRococoInstance, BridgeHubRococoParachainId>,
|
||||
RefundableParachain<BridgeParachainRococoInstance, bp_bridge_hub_rococo::BridgeHubRococo>,
|
||||
RefundableMessagesLane<WithBridgeHubRococoMessagesInstance, BridgeHubRococoMessagesLane>,
|
||||
ActualFeeRefund<Runtime>,
|
||||
PriorityBoostPerMessage,
|
||||
@@ -144,10 +144,6 @@ bp_runtime::generate_static_str_provider!(BridgeRefundBridgeHubRococoMessages);
|
||||
|
||||
parameter_types! {
|
||||
pub const BridgeHubRococoMessagesLane: bp_messages::LaneId = DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO;
|
||||
pub const BridgeHubRococoParachainId: u32 = {
|
||||
use bp_runtime::Parachain;
|
||||
BridgeHubRococo::PARACHAIN_ID
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -92,8 +92,6 @@ use parachains_common::{
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
pub const LOG_TARGET: &str = "runtime::bridge-hub";
|
||||
|
||||
/// The address format for describing accounts.
|
||||
pub type Address = MultiAddress<AccountId, ()>;
|
||||
|
||||
|
||||
@@ -80,12 +80,12 @@ impl pallet_bridge_messages::WeightInfoExt for pallet_bridge_messages_bridge_mes
|
||||
|
||||
impl pallet_bridge_parachains::WeightInfoExt for pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance::WeightInfo<crate::Runtime> {
|
||||
fn expected_extra_storage_proof_size() -> u32 {
|
||||
bp_bridge_hub_wococo::EXTRA_STORAGE_PROOF_SIZE
|
||||
bp_bridge_hub_rococo::EXTRA_STORAGE_PROOF_SIZE
|
||||
}
|
||||
}
|
||||
|
||||
impl pallet_bridge_parachains::WeightInfoExt for pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance::WeightInfo<crate::Runtime> {
|
||||
fn expected_extra_storage_proof_size() -> u32 {
|
||||
bp_bridge_hub_rococo::EXTRA_STORAGE_PROOF_SIZE
|
||||
bp_bridge_hub_wococo::EXTRA_STORAGE_PROOF_SIZE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
|
||||
use super::{
|
||||
AccountId, AllPalletsWithSystem, Balances, BridgeGrandpaRococoInstance,
|
||||
BridgeGrandpaWococoInstance, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall,
|
||||
RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
BridgeGrandpaWococoInstance, DeliveryRewardInBalance, ParachainInfo, ParachainSystem,
|
||||
PolkadotXcm, RequiredStakeForStakeAndSlash, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
|
||||
WeightToFee, XcmpQueue,
|
||||
};
|
||||
use crate::{
|
||||
bridge_hub_rococo_config::ToBridgeHubWococoHaulBlobExporter,
|
||||
@@ -152,6 +153,17 @@ impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
}
|
||||
}
|
||||
|
||||
// Allow to change dedicated storage items (called by governance-like)
|
||||
match call {
|
||||
RuntimeCall::System(frame_system::Call::set_storage { items })
|
||||
if items.iter().any(|(k, _)| {
|
||||
k.eq(&DeliveryRewardInBalance::key()) |
|
||||
k.eq(&RequiredStakeForStakeAndSlash::key())
|
||||
}) =>
|
||||
return true,
|
||||
_ => (),
|
||||
};
|
||||
|
||||
matches!(
|
||||
call,
|
||||
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
|
||||
@@ -232,12 +244,12 @@ impl xcm_executor::Config for XcmConfig {
|
||||
UsingComponents<WeightToFee, RelayLocation, AccountId, Balances, ToStakingPot<Runtime>>;
|
||||
type ResponseHandler = PolkadotXcm;
|
||||
type AssetTrap = PolkadotXcm;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type AssetClaims = PolkadotXcm;
|
||||
type SubscriptionService = PolkadotXcm;
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type FeeManager = ();
|
||||
type MessageExporter = BridgeHubRococoOrBridgeHubWococoSwitchExporter;
|
||||
type UniversalAliases = Nothing;
|
||||
|
||||
@@ -18,8 +18,8 @@ pub use bridge_hub_rococo_runtime::{
|
||||
constants::fee::WeightToFee,
|
||||
xcm_config::{RelayNetwork, XcmConfig, XcmRouter},
|
||||
Balances, BridgeGrandpaRococoInstance, BridgeGrandpaWococoInstance, BridgeWococoMessages,
|
||||
ExistentialDeposit, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent,
|
||||
SessionKeys,
|
||||
DeliveryRewardInBalance, ExistentialDeposit, ParachainSystem, PolkadotXcm,
|
||||
RequiredStakeForStakeAndSlash, Runtime, RuntimeCall, RuntimeEvent, SessionKeys,
|
||||
};
|
||||
use codec::{Decode, Encode};
|
||||
use xcm::latest::prelude::*;
|
||||
@@ -30,7 +30,7 @@ use bridge_hub_rococo_runtime::{
|
||||
};
|
||||
|
||||
use frame_support::parameter_types;
|
||||
use parachains_common::{AccountId, AuraId};
|
||||
use parachains_common::{AccountId, AuraId, Balance};
|
||||
|
||||
const ALICE: [u8; 32] = [1u8; 32];
|
||||
|
||||
@@ -80,6 +80,36 @@ mod bridge_hub_rococo_tests {
|
||||
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,
|
||||
@@ -173,6 +203,36 @@ mod bridge_hub_wococo_tests {
|
||||
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,
|
||||
|
||||
@@ -84,8 +84,7 @@ pub fn initialize_bridge_by_governance_works<Runtime, GrandpaPalletInstance>(
|
||||
let require_weight_at_most =
|
||||
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(7, 7);
|
||||
|
||||
// execute XCM with Transacts to initialize bridge as governance does
|
||||
// prepare data for xcm::Transact(create)
|
||||
// execute XCM with Transacts to `initialize bridge` as governance does
|
||||
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
|
||||
initialize_call,
|
||||
require_weight_at_most
|
||||
@@ -123,6 +122,105 @@ macro_rules! include_initialize_bridge_by_governance_works(
|
||||
}
|
||||
);
|
||||
|
||||
/// Test-case makes sure that `Runtime` can change storage constant via governance-like call
|
||||
pub fn change_storage_constant_by_governance_works<Runtime, StorageConstant, StorageConstantType>(
|
||||
collator_session_key: CollatorSessionKeys<Runtime>,
|
||||
runtime_para_id: u32,
|
||||
runtime_call_encode: Box<dyn Fn(frame_system::Call<Runtime>) -> Vec<u8>>,
|
||||
storage_constant_key_value: fn() -> (Vec<u8>, StorageConstantType),
|
||||
new_storage_constant_value: fn(&StorageConstantType) -> StorageConstantType,
|
||||
) where
|
||||
Runtime: frame_system::Config
|
||||
+ pallet_balances::Config
|
||||
+ pallet_session::Config
|
||||
+ pallet_xcm::Config
|
||||
+ parachain_info::Config
|
||||
+ pallet_collator_selection::Config
|
||||
+ cumulus_pallet_dmp_queue::Config
|
||||
+ cumulus_pallet_parachain_system::Config,
|
||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
||||
StorageConstant: Get<StorageConstantType>,
|
||||
StorageConstantType: Encode + PartialEq + std::fmt::Debug,
|
||||
{
|
||||
ExtBuilder::<Runtime>::default()
|
||||
.with_collators(collator_session_key.collators())
|
||||
.with_session_keys(collator_session_key.session_keys())
|
||||
.with_para_id(runtime_para_id.into())
|
||||
.with_tracing()
|
||||
.build()
|
||||
.execute_with(|| {
|
||||
let (storage_constant_key, storage_constant_init_value): (
|
||||
Vec<u8>,
|
||||
StorageConstantType,
|
||||
) = storage_constant_key_value();
|
||||
|
||||
// check delivery reward constant before (not stored yet, just as default value is used)
|
||||
assert_eq!(StorageConstant::get(), storage_constant_init_value);
|
||||
assert_eq!(sp_io::storage::get(&storage_constant_key), None);
|
||||
|
||||
let new_storage_constant_value =
|
||||
new_storage_constant_value(&storage_constant_init_value);
|
||||
assert_ne!(new_storage_constant_value, storage_constant_init_value);
|
||||
|
||||
// encode `set_storage` call
|
||||
let set_storage_call =
|
||||
runtime_call_encode(frame_system::Call::<Runtime>::set_storage {
|
||||
items: vec![(
|
||||
storage_constant_key.clone(),
|
||||
new_storage_constant_value.encode(),
|
||||
)],
|
||||
});
|
||||
|
||||
// estimate - storing just 1 value
|
||||
use frame_system::WeightInfo;
|
||||
let require_weight_at_most =
|
||||
<Runtime as frame_system::Config>::SystemWeightInfo::set_storage(1);
|
||||
|
||||
// execute XCM with Transact to `set_storage` as governance does
|
||||
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
|
||||
set_storage_call,
|
||||
require_weight_at_most
|
||||
)
|
||||
.ensure_complete());
|
||||
|
||||
// check delivery reward constant after (stored)
|
||||
assert_eq!(StorageConstant::get(), new_storage_constant_value);
|
||||
assert_eq!(
|
||||
sp_io::storage::get(&storage_constant_key),
|
||||
Some(new_storage_constant_value.encode().into())
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! include_change_storage_constant_by_governance_works(
|
||||
(
|
||||
$test_name:tt,
|
||||
$runtime:path,
|
||||
$collator_session_key:expr,
|
||||
$runtime_para_id:expr,
|
||||
$runtime_call_encode:expr,
|
||||
($storage_constant:path, $storage_constant_type:path),
|
||||
$storage_constant_key_value:expr,
|
||||
$new_storage_constant_value:expr
|
||||
) => {
|
||||
#[test]
|
||||
fn $test_name() {
|
||||
$crate::test_cases::change_storage_constant_by_governance_works::<
|
||||
$runtime,
|
||||
$storage_constant,
|
||||
$storage_constant_type,
|
||||
>(
|
||||
$collator_session_key,
|
||||
$runtime_para_id,
|
||||
$runtime_call_encode,
|
||||
$storage_constant_key_value,
|
||||
$new_storage_constant_value,
|
||||
)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/// Test-case makes sure that `Runtime` can handle xcm `ExportMessage`:
|
||||
/// Checks if received XCM messages is correctly added to the message outbound queue for delivery.
|
||||
/// For SystemParachains we expect unpaid execution.
|
||||
|
||||
Reference in New Issue
Block a user