Skip to content

Commit

Permalink
Merge branch 'stable2407' into backport-5599-to-stable2407
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoaguirre authored Oct 25, 2024
2 parents 8af22fe + fc62793 commit f2fbf09
Show file tree
Hide file tree
Showing 15 changed files with 468 additions and 81 deletions.
5 changes: 5 additions & 0 deletions Cargo.lock

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

35 changes: 7 additions & 28 deletions bridges/modules/xcm-bridge-hub-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub mod pallet {
/// Origin of the sibling bridge hub that is allowed to report bridge status.
type BridgeHubOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// Actual message sender (`HRMP` or `DMP`) to the sibling bridge hub location.
type ToBridgeHubSender: SendXcm + InspectMessageQueues;
type ToBridgeHubSender: SendXcm;
/// Underlying channel with the sibling bridge hub. It must match the channel, used
/// by the `Self::ToBridgeHubSender`.
type WithBridgeHubChannel: XcmChannelStatusProvider;
Expand Down Expand Up @@ -398,12 +398,12 @@ impl<T: Config<I>, I: 'static> SendXcm for Pallet<T, I> {
}

impl<T: Config<I>, I: 'static> InspectMessageQueues for Pallet<T, I> {
fn clear_messages() {
ViaBridgeHubExporter::<T, I>::clear_messages()
}
fn clear_messages() {}

/// This router needs to implement `InspectMessageQueues` but doesn't have to
/// return any messages, since it just reuses the `XcmpQueue` router.
fn get_messages() -> Vec<(VersionedLocation, Vec<VersionedXcm<()>>)> {
ViaBridgeHubExporter::<T, I>::get_messages()
Vec::new()
}
}

Expand Down Expand Up @@ -648,34 +648,13 @@ mod tests {
}

#[test]
fn get_messages_works() {
fn get_messages_does_not_return_anything() {
run_test(|| {
assert_ok!(send_xcm::<XcmBridgeHubRouter>(
(Parent, Parent, GlobalConsensus(BridgedNetworkId::get()), Parachain(1000)).into(),
vec![ClearOrigin].into()
));
assert_eq!(
XcmBridgeHubRouter::get_messages(),
vec![(
VersionedLocation::V4((Parent, Parachain(1002)).into()),
vec![VersionedXcm::V4(
Xcm::builder()
.withdraw_asset((Parent, 1_002_000))
.buy_execution((Parent, 1_002_000), Unlimited)
.set_appendix(
Xcm::builder_unsafe()
.deposit_asset(AllCounted(1), (Parent, Parachain(1000)))
.build()
)
.export_message(
Kusama,
Parachain(1000),
Xcm::builder_unsafe().clear_origin().build()
)
.build()
)],
),],
);
assert_eq!(XcmBridgeHubRouter::get_messages(), vec![]);
});
}
}
6 changes: 5 additions & 1 deletion cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,11 @@ impl<T: Config> InspectMessageQueues for Pallet<T> {
.map(|encoded_message| VersionedXcm::<()>::decode(&mut &encoded_message[..]).unwrap())
.collect();

vec![(VersionedLocation::V4(Parent.into()), messages)]
if messages.is_empty() {
vec![]
} else {
vec![(VersionedLocation::from(Location::parent()), messages)]
}
}
}

Expand Down
Loading

0 comments on commit f2fbf09

Please sign in to comment.