Skip to content

Commit

Permalink
Governance can halt and resume Rococo <> Wococo bridge pallets over X…
Browse files Browse the repository at this point in the history
…CM (#2712)

This PR adds possibility for relay chain governance to halt and resume
bridge pallets using XCM calls. Following calls are enabled over XCM for
the `root` origin: `pallet_bridge_grandpa::set_operating_mode`,
`pallet_bridge_parachains::set_operating_mode` and
`pallet_bridge_messages::set_operating_mode`.
  • Loading branch information
svyatonik authored Dec 15, 2023
1 parent 11edbaf commit b58f0ae
Show file tree
Hide file tree
Showing 5 changed files with 312 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ use super::{
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
TransactionByteFee, WeightToFee, XcmpQueue,
};
use crate::bridge_common_config::{
BridgeGrandpaRococoBulletinInstance, BridgeGrandpaWestendInstance, DeliveryRewardInBalance,
RequiredStakeForStakeAndSlash,
use crate::{
bridge_common_config::{
BridgeGrandpaRococoBulletinInstance, BridgeGrandpaWestendInstance,
BridgeParachainWestendInstance, DeliveryRewardInBalance, RequiredStakeForStakeAndSlash,
},
bridge_to_bulletin_config::WithRococoBulletinMessagesInstance,
bridge_to_westend_config::WithBridgeHubWestendMessagesInstance,
};
use bp_messages::LaneId;
use bp_relayers::{PayRewardFromAccount, RewardsAccountOwner, RewardsAccountParams};
Expand Down Expand Up @@ -190,10 +194,30 @@ impl Contains<RuntimeCall> for SafeCallFilter {
Runtime,
BridgeGrandpaWestendInstance,
>::initialize { .. }) |
RuntimeCall::BridgeWestendGrandpa(pallet_bridge_grandpa::Call::<
Runtime,
BridgeGrandpaWestendInstance,
>::set_operating_mode { .. }) |
RuntimeCall::BridgeWestendParachains(pallet_bridge_parachains::Call::<
Runtime,
BridgeParachainWestendInstance,
>::set_operating_mode { .. }) |
RuntimeCall::BridgeWestendMessages(pallet_bridge_messages::Call::<
Runtime,
WithBridgeHubWestendMessagesInstance,
>::set_operating_mode { .. }) |
RuntimeCall::BridgePolkadotBulletinGrandpa(pallet_bridge_grandpa::Call::<
Runtime,
BridgeGrandpaRococoBulletinInstance,
>::initialize { .. })
>::initialize { .. }) |
RuntimeCall::BridgePolkadotBulletinGrandpa(pallet_bridge_grandpa::Call::<
Runtime,
BridgeGrandpaRococoBulletinInstance,
>::set_operating_mode { .. }) |
RuntimeCall::BridgePolkadotBulletinMessages(pallet_bridge_messages::Call::<
Runtime,
WithRococoBulletinMessagesInstance,
>::set_operating_mode { .. })
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,34 @@ mod bridge_hub_westend_tests {
bridge_hub_test_utils::test_cases::initialize_bridge_by_governance_works::<
Runtime,
BridgeGrandpaWestendInstance,
>(
collator_session_keys(),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
Box::new(|call| RuntimeCall::BridgeWestendGrandpa(call).encode()),
)
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
}

#[test]
fn change_bridge_grandpa_pallet_mode_by_governance_works() {
// for Westend finality
bridge_hub_test_utils::test_cases::change_bridge_grandpa_pallet_mode_by_governance_works::<
Runtime,
BridgeGrandpaWestendInstance,
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
}

#[test]
fn change_bridge_parachains_pallet_mode_by_governance_works() {
// for Westend finality
bridge_hub_test_utils::test_cases::change_bridge_parachains_pallet_mode_by_governance_works::<
Runtime,
BridgeParachainWestendInstance,
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
}

#[test]
fn change_bridge_messages_pallet_mode_by_governance_works() {
// for Westend finality
bridge_hub_test_utils::test_cases::change_bridge_messages_pallet_mode_by_governance_works::<
Runtime,
WithBridgeHubWestendMessagesInstance,
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
}

#[test]
Expand Down Expand Up @@ -365,11 +388,25 @@ mod bridge_hub_bulletin_tests {
bridge_hub_test_utils::test_cases::initialize_bridge_by_governance_works::<
Runtime,
BridgeGrandpaRococoBulletinInstance,
>(
collator_session_keys(),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
Box::new(|call| RuntimeCall::BridgePolkadotBulletinGrandpa(call).encode()),
)
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
}

#[test]
fn change_bridge_grandpa_pallet_mode_by_governance_works() {
// for Bulletin finality
bridge_hub_test_utils::test_cases::change_bridge_grandpa_pallet_mode_by_governance_works::<
Runtime,
BridgeGrandpaRococoBulletinInstance,
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
}

#[test]
fn change_bridge_messages_pallet_mode_by_governance_works() {
// for Bulletin finality
bridge_hub_test_utils::test_cases::change_bridge_messages_pallet_mode_by_governance_works::<
Runtime,
WithRococoBulletinMessagesInstance,
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,19 @@ impl Contains<RuntimeCall> for SafeCallFilter {
RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::<
Runtime,
crate::bridge_to_rococo_config::BridgeGrandpaRococoInstance,
>::initialize { .. })
>::initialize { .. }) |
RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::<
Runtime,
crate::bridge_to_rococo_config::BridgeGrandpaRococoInstance,
>::set_operating_mode { .. }) |
RuntimeCall::BridgeRococoParachains(pallet_bridge_parachains::Call::<
Runtime,
crate::bridge_to_rococo_config::BridgeParachainRococoInstance,
>::set_operating_mode { .. }) |
RuntimeCall::BridgeRococoMessages(pallet_bridge_messages::Call::<
Runtime,
crate::bridge_to_rococo_config::WithBridgeHubRococoMessagesInstance,
>::set_operating_mode { .. })
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,31 @@ fn initialize_bridge_by_governance_works() {
bridge_hub_test_utils::test_cases::initialize_bridge_by_governance_works::<
Runtime,
BridgeGrandpaRococoInstance,
>(
collator_session_keys(),
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
Box::new(|call| RuntimeCall::BridgeRococoGrandpa(call).encode()),
)
>(collator_session_keys(), bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID)
}

#[test]
fn change_bridge_grandpa_pallet_mode_by_governance_works() {
bridge_hub_test_utils::test_cases::change_bridge_grandpa_pallet_mode_by_governance_works::<
Runtime,
BridgeGrandpaRococoInstance,
>(collator_session_keys(), bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID)
}

#[test]
fn change_bridge_parachains_pallet_mode_by_governance_works() {
bridge_hub_test_utils::test_cases::change_bridge_parachains_pallet_mode_by_governance_works::<
Runtime,
BridgeParachainRococoInstance,
>(collator_session_keys(), bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID)
}

#[test]
fn change_bridge_messages_pallet_mode_by_governance_works() {
bridge_hub_test_utils::test_cases::change_bridge_messages_pallet_mode_by_governance_works::<
Runtime,
WithBridgeHubRococoMessagesInstance,
>(collator_session_keys(), bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID)
}

#[test]
Expand Down
Loading

0 comments on commit b58f0ae

Please sign in to comment.