Skip to content

Commit b58f0ae

Browse files
authored
Governance can halt and resume Rococo <> Wococo bridge pallets over XCM (#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`.
1 parent 11edbaf commit b58f0ae

5 files changed

Lines changed: 312 additions & 31 deletions

File tree

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ use super::{
1919
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
2020
TransactionByteFee, WeightToFee, XcmpQueue,
2121
};
22-
use crate::bridge_common_config::{
23-
BridgeGrandpaRococoBulletinInstance, BridgeGrandpaWestendInstance, DeliveryRewardInBalance,
24-
RequiredStakeForStakeAndSlash,
22+
use crate::{
23+
bridge_common_config::{
24+
BridgeGrandpaRococoBulletinInstance, BridgeGrandpaWestendInstance,
25+
BridgeParachainWestendInstance, DeliveryRewardInBalance, RequiredStakeForStakeAndSlash,
26+
},
27+
bridge_to_bulletin_config::WithRococoBulletinMessagesInstance,
28+
bridge_to_westend_config::WithBridgeHubWestendMessagesInstance,
2529
};
2630
use bp_messages::LaneId;
2731
use bp_relayers::{PayRewardFromAccount, RewardsAccountOwner, RewardsAccountParams};
@@ -190,10 +194,30 @@ impl Contains<RuntimeCall> for SafeCallFilter {
190194
Runtime,
191195
BridgeGrandpaWestendInstance,
192196
>::initialize { .. }) |
197+
RuntimeCall::BridgeWestendGrandpa(pallet_bridge_grandpa::Call::<
198+
Runtime,
199+
BridgeGrandpaWestendInstance,
200+
>::set_operating_mode { .. }) |
201+
RuntimeCall::BridgeWestendParachains(pallet_bridge_parachains::Call::<
202+
Runtime,
203+
BridgeParachainWestendInstance,
204+
>::set_operating_mode { .. }) |
205+
RuntimeCall::BridgeWestendMessages(pallet_bridge_messages::Call::<
206+
Runtime,
207+
WithBridgeHubWestendMessagesInstance,
208+
>::set_operating_mode { .. }) |
193209
RuntimeCall::BridgePolkadotBulletinGrandpa(pallet_bridge_grandpa::Call::<
194210
Runtime,
195211
BridgeGrandpaRococoBulletinInstance,
196-
>::initialize { .. })
212+
>::initialize { .. }) |
213+
RuntimeCall::BridgePolkadotBulletinGrandpa(pallet_bridge_grandpa::Call::<
214+
Runtime,
215+
BridgeGrandpaRococoBulletinInstance,
216+
>::set_operating_mode { .. }) |
217+
RuntimeCall::BridgePolkadotBulletinMessages(pallet_bridge_messages::Call::<
218+
Runtime,
219+
WithRococoBulletinMessagesInstance,
220+
>::set_operating_mode { .. })
197221
)
198222
}
199223
}

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,34 @@ mod bridge_hub_westend_tests {
152152
bridge_hub_test_utils::test_cases::initialize_bridge_by_governance_works::<
153153
Runtime,
154154
BridgeGrandpaWestendInstance,
155-
>(
156-
collator_session_keys(),
157-
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
158-
Box::new(|call| RuntimeCall::BridgeWestendGrandpa(call).encode()),
159-
)
155+
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
156+
}
157+
158+
#[test]
159+
fn change_bridge_grandpa_pallet_mode_by_governance_works() {
160+
// for Westend finality
161+
bridge_hub_test_utils::test_cases::change_bridge_grandpa_pallet_mode_by_governance_works::<
162+
Runtime,
163+
BridgeGrandpaWestendInstance,
164+
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
165+
}
166+
167+
#[test]
168+
fn change_bridge_parachains_pallet_mode_by_governance_works() {
169+
// for Westend finality
170+
bridge_hub_test_utils::test_cases::change_bridge_parachains_pallet_mode_by_governance_works::<
171+
Runtime,
172+
BridgeParachainWestendInstance,
173+
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
174+
}
175+
176+
#[test]
177+
fn change_bridge_messages_pallet_mode_by_governance_works() {
178+
// for Westend finality
179+
bridge_hub_test_utils::test_cases::change_bridge_messages_pallet_mode_by_governance_works::<
180+
Runtime,
181+
WithBridgeHubWestendMessagesInstance,
182+
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
160183
}
161184

162185
#[test]
@@ -365,11 +388,25 @@ mod bridge_hub_bulletin_tests {
365388
bridge_hub_test_utils::test_cases::initialize_bridge_by_governance_works::<
366389
Runtime,
367390
BridgeGrandpaRococoBulletinInstance,
368-
>(
369-
collator_session_keys(),
370-
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
371-
Box::new(|call| RuntimeCall::BridgePolkadotBulletinGrandpa(call).encode()),
372-
)
391+
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
392+
}
393+
394+
#[test]
395+
fn change_bridge_grandpa_pallet_mode_by_governance_works() {
396+
// for Bulletin finality
397+
bridge_hub_test_utils::test_cases::change_bridge_grandpa_pallet_mode_by_governance_works::<
398+
Runtime,
399+
BridgeGrandpaRococoBulletinInstance,
400+
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
401+
}
402+
403+
#[test]
404+
fn change_bridge_messages_pallet_mode_by_governance_works() {
405+
// for Bulletin finality
406+
bridge_hub_test_utils::test_cases::change_bridge_messages_pallet_mode_by_governance_works::<
407+
Runtime,
408+
WithRococoBulletinMessagesInstance,
409+
>(collator_session_keys(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)
373410
}
374411

375412
#[test]

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,19 @@ impl Contains<RuntimeCall> for SafeCallFilter {
176176
RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::<
177177
Runtime,
178178
crate::bridge_to_rococo_config::BridgeGrandpaRococoInstance,
179-
>::initialize { .. })
179+
>::initialize { .. }) |
180+
RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::<
181+
Runtime,
182+
crate::bridge_to_rococo_config::BridgeGrandpaRococoInstance,
183+
>::set_operating_mode { .. }) |
184+
RuntimeCall::BridgeRococoParachains(pallet_bridge_parachains::Call::<
185+
Runtime,
186+
crate::bridge_to_rococo_config::BridgeParachainRococoInstance,
187+
>::set_operating_mode { .. }) |
188+
RuntimeCall::BridgeRococoMessages(pallet_bridge_messages::Call::<
189+
Runtime,
190+
crate::bridge_to_rococo_config::WithBridgeHubRococoMessagesInstance,
191+
>::set_operating_mode { .. })
180192
)
181193
}
182194
}

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/tests/tests.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,31 @@ fn initialize_bridge_by_governance_works() {
123123
bridge_hub_test_utils::test_cases::initialize_bridge_by_governance_works::<
124124
Runtime,
125125
BridgeGrandpaRococoInstance,
126-
>(
127-
collator_session_keys(),
128-
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
129-
Box::new(|call| RuntimeCall::BridgeRococoGrandpa(call).encode()),
130-
)
126+
>(collator_session_keys(), bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID)
127+
}
128+
129+
#[test]
130+
fn change_bridge_grandpa_pallet_mode_by_governance_works() {
131+
bridge_hub_test_utils::test_cases::change_bridge_grandpa_pallet_mode_by_governance_works::<
132+
Runtime,
133+
BridgeGrandpaRococoInstance,
134+
>(collator_session_keys(), bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID)
135+
}
136+
137+
#[test]
138+
fn change_bridge_parachains_pallet_mode_by_governance_works() {
139+
bridge_hub_test_utils::test_cases::change_bridge_parachains_pallet_mode_by_governance_works::<
140+
Runtime,
141+
BridgeParachainRococoInstance,
142+
>(collator_session_keys(), bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID)
143+
}
144+
145+
#[test]
146+
fn change_bridge_messages_pallet_mode_by_governance_works() {
147+
bridge_hub_test_utils::test_cases::change_bridge_messages_pallet_mode_by_governance_works::<
148+
Runtime,
149+
WithBridgeHubRococoMessagesInstance,
150+
>(collator_session_keys(), bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID)
131151
}
132152

133153
#[test]

0 commit comments

Comments
 (0)