Skip to content

Commit 061eee1

Browse files
authored
Bridges subtree sync (#3022)
* Squashed 'bridges/' changes from edf33a2..277f0d5 277f0d5 Dynamic fees for bridges-v1 (#2294) b1c51f7 Finality loop refactoring (#2357) 620db2b Add equivocation detector crate and implement clients (#2348) (#2353) 3fe4b13 Add basic equivocation detection pipeline schema (#2338) (#2341) git-subtree-dir: bridges git-subtree-split: 277f0d5 * [dynfees] Rococo/Wococo does not need congestion and dynamic fees (for now) * Fix * ".git/.scripts/commands/fmt/fmt.sh" * Forgotten bridges/Cargo.lock --------- Co-authored-by: command-bot <>
1 parent 840ca86 commit 061eee1

File tree

40 files changed

+2178
-251
lines changed

40 files changed

+2178
-251
lines changed

cumulus/Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cumulus/bridges/bin/runtime-common/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ bp-parachains = { path = "../../primitives/parachains", default-features = false
2121
bp-polkadot-core = { path = "../../primitives/polkadot-core", default-features = false }
2222
bp-relayers = { path = "../../primitives/relayers", default-features = false }
2323
bp-runtime = { path = "../../primitives/runtime", default-features = false }
24+
bp-xcm-bridge-hub-router = { path = "../../primitives/xcm-bridge-hub-router", default-features = false }
2425
pallet-bridge-grandpa = { path = "../../modules/grandpa", default-features = false }
2526
pallet-bridge-messages = { path = "../../modules/messages", default-features = false }
2627
pallet-bridge-parachains = { path = "../../modules/parachains", default-features = false }
@@ -55,6 +56,7 @@ std = [
5556
"bp-parachains/std",
5657
"bp-polkadot-core/std",
5758
"bp-runtime/std",
59+
"bp-xcm-bridge-hub-router/std",
5860
"codec/std",
5961
"frame-support/std",
6062
"frame-system/std",

cumulus/bridges/bin/runtime-common/src/messages_call_ext.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use crate::messages::{
1818
source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof,
1919
};
20-
use bp_messages::{InboundLaneData, LaneId, MessageNonce};
20+
use bp_messages::{target_chain::MessageDispatch, InboundLaneData, LaneId, MessageNonce};
2121
use frame_support::{
2222
dispatch::CallableCallFor,
2323
traits::{Get, IsSubType},
@@ -77,7 +77,12 @@ impl ReceiveMessagesProofInfo {
7777
///
7878
/// - or there are no bundled messages, but the inbound lane is blocked by too many unconfirmed
7979
/// messages and/or unrewarded relayers.
80-
fn is_obsolete(&self) -> bool {
80+
fn is_obsolete(&self, is_dispatcher_active: bool) -> bool {
81+
// if dispatcher is inactive, we don't accept any delivery transactions
82+
if !is_dispatcher_active {
83+
return true
84+
}
85+
8186
// transactions with zero bundled nonces are not allowed, unless they're message
8287
// delivery transactions, which brings reward confirmations required to unblock
8388
// the lane
@@ -275,7 +280,9 @@ impl<
275280

276281
fn check_obsolete_call(&self) -> TransactionValidity {
277282
match self.call_info() {
278-
Some(CallInfo::ReceiveMessagesProof(proof_info)) if proof_info.is_obsolete() => {
283+
Some(CallInfo::ReceiveMessagesProof(proof_info))
284+
if proof_info.is_obsolete(T::MessageDispatch::is_active()) =>
285+
{
279286
log::trace!(
280287
target: pallet_bridge_messages::LOG_TARGET,
281288
"Rejecting obsolete messages delivery transaction: {:?}",
@@ -327,8 +334,8 @@ mod tests {
327334
},
328335
messages_call_ext::MessagesCallSubType,
329336
mock::{
330-
MaxUnconfirmedMessagesAtInboundLane, MaxUnrewardedRelayerEntriesAtInboundLane,
331-
TestRuntime, ThisChainRuntimeCall,
337+
DummyMessageDispatch, MaxUnconfirmedMessagesAtInboundLane,
338+
MaxUnrewardedRelayerEntriesAtInboundLane, TestRuntime, ThisChainRuntimeCall,
332339
},
333340
};
334341
use bp_messages::{DeliveredMessages, UnrewardedRelayer, UnrewardedRelayersState};
@@ -435,6 +442,18 @@ mod tests {
435442
});
436443
}
437444

445+
#[test]
446+
fn extension_reject_call_when_dispatcher_is_inactive() {
447+
sp_io::TestExternalities::new(Default::default()).execute_with(|| {
448+
// when current best delivered is message#10 and we're trying to deliver message 11..=15
449+
// => tx is accepted, but we have inactive dispatcher, so...
450+
deliver_message_10();
451+
452+
DummyMessageDispatch::deactivate();
453+
assert!(!validate_message_delivery(11, 15));
454+
});
455+
}
456+
438457
#[test]
439458
fn extension_rejects_empty_delivery_with_rewards_confirmations_if_there_are_free_relayer_and_message_slots(
440459
) {

0 commit comments

Comments
 (0)