Skip to content

Commit

Permalink
Bridges subtree sync (#3022)
Browse files Browse the repository at this point in the history
* 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 <>
  • Loading branch information
bkontur authored Aug 17, 2023
1 parent 840ca86 commit 061eee1
Show file tree
Hide file tree
Showing 40 changed files with 2,178 additions and 251 deletions.
11 changes: 11 additions & 0 deletions cumulus/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cumulus/bridges/bin/runtime-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bp-parachains = { path = "../../primitives/parachains", default-features = false
bp-polkadot-core = { path = "../../primitives/polkadot-core", default-features = false }
bp-relayers = { path = "../../primitives/relayers", default-features = false }
bp-runtime = { path = "../../primitives/runtime", default-features = false }
bp-xcm-bridge-hub-router = { path = "../../primitives/xcm-bridge-hub-router", default-features = false }
pallet-bridge-grandpa = { path = "../../modules/grandpa", default-features = false }
pallet-bridge-messages = { path = "../../modules/messages", default-features = false }
pallet-bridge-parachains = { path = "../../modules/parachains", default-features = false }
Expand Down Expand Up @@ -55,6 +56,7 @@ std = [
"bp-parachains/std",
"bp-polkadot-core/std",
"bp-runtime/std",
"bp-xcm-bridge-hub-router/std",
"codec/std",
"frame-support/std",
"frame-system/std",
Expand Down
29 changes: 24 additions & 5 deletions cumulus/bridges/bin/runtime-common/src/messages_call_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use crate::messages::{
source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof,
};
use bp_messages::{InboundLaneData, LaneId, MessageNonce};
use bp_messages::{target_chain::MessageDispatch, InboundLaneData, LaneId, MessageNonce};
use frame_support::{
dispatch::CallableCallFor,
traits::{Get, IsSubType},
Expand Down Expand Up @@ -77,7 +77,12 @@ impl ReceiveMessagesProofInfo {
///
/// - or there are no bundled messages, but the inbound lane is blocked by too many unconfirmed
/// messages and/or unrewarded relayers.
fn is_obsolete(&self) -> bool {
fn is_obsolete(&self, is_dispatcher_active: bool) -> bool {
// if dispatcher is inactive, we don't accept any delivery transactions
if !is_dispatcher_active {
return true
}

// transactions with zero bundled nonces are not allowed, unless they're message
// delivery transactions, which brings reward confirmations required to unblock
// the lane
Expand Down Expand Up @@ -275,7 +280,9 @@ impl<

fn check_obsolete_call(&self) -> TransactionValidity {
match self.call_info() {
Some(CallInfo::ReceiveMessagesProof(proof_info)) if proof_info.is_obsolete() => {
Some(CallInfo::ReceiveMessagesProof(proof_info))
if proof_info.is_obsolete(T::MessageDispatch::is_active()) =>
{
log::trace!(
target: pallet_bridge_messages::LOG_TARGET,
"Rejecting obsolete messages delivery transaction: {:?}",
Expand Down Expand Up @@ -327,8 +334,8 @@ mod tests {
},
messages_call_ext::MessagesCallSubType,
mock::{
MaxUnconfirmedMessagesAtInboundLane, MaxUnrewardedRelayerEntriesAtInboundLane,
TestRuntime, ThisChainRuntimeCall,
DummyMessageDispatch, MaxUnconfirmedMessagesAtInboundLane,
MaxUnrewardedRelayerEntriesAtInboundLane, TestRuntime, ThisChainRuntimeCall,
},
};
use bp_messages::{DeliveredMessages, UnrewardedRelayer, UnrewardedRelayersState};
Expand Down Expand Up @@ -435,6 +442,18 @@ mod tests {
});
}

#[test]
fn extension_reject_call_when_dispatcher_is_inactive() {
sp_io::TestExternalities::new(Default::default()).execute_with(|| {
// when current best delivered is message#10 and we're trying to deliver message 11..=15
// => tx is accepted, but we have inactive dispatcher, so...
deliver_message_10();

DummyMessageDispatch::deactivate();
assert!(!validate_message_delivery(11, 15));
});
}

#[test]
fn extension_rejects_empty_delivery_with_rewards_confirmations_if_there_are_free_relayer_and_message_slots(
) {
Expand Down
Loading

0 comments on commit 061eee1

Please sign in to comment.