From a6a561d25249310832a0dd7c48190150c4f97837 Mon Sep 17 00:00:00 2001 From: Rohit Sarpotdar Date: Mon, 26 May 2025 18:03:40 +0530 Subject: [PATCH] Bridges: Fix - Improve try-state for pallet-xcm-bridge-hub (#8615) Fixing https://github.com/paritytech/polkadot-sdk/issues/8215 based on https://github.com/paritytech/polkadot-sdk/issues/8185: Improve try-state for pallet-xcm-bridge-hub It removes try_as and uses try_into implementation instead. --------- Co-authored-by: Branislav Kontur Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> (cherry picked from commit c2174ff3505eaa1ea1eb047b784a0ed7afe1cbd7) --- bridges/modules/xcm-bridge-hub/src/dispatcher.rs | 2 +- bridges/modules/xcm-bridge-hub/src/exporter.rs | 5 +++-- prdoc/pr_8615.prdoc | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 prdoc/pr_8615.prdoc diff --git a/bridges/modules/xcm-bridge-hub/src/dispatcher.rs b/bridges/modules/xcm-bridge-hub/src/dispatcher.rs index dd855c7069aad..a36b75912511f 100644 --- a/bridges/modules/xcm-bridge-hub/src/dispatcher.rs +++ b/bridges/modules/xcm-bridge-hub/src/dispatcher.rs @@ -59,7 +59,7 @@ where fn is_active(lane: Self::LaneId) -> bool { Pallet::::bridge_by_lane_id(&lane) - .and_then(|(_, bridge)| bridge.bridge_origin_relative_location.try_as().cloned().ok()) + .and_then(|(_, bridge)| (*bridge.bridge_origin_relative_location).try_into().ok()) .map(|recipient: Location| !T::LocalXcmChannelManager::is_congested(&recipient)) .unwrap_or(false) } diff --git a/bridges/modules/xcm-bridge-hub/src/exporter.rs b/bridges/modules/xcm-bridge-hub/src/exporter.rs index 93b6093b42af5..f9f4883179275 100644 --- a/bridges/modules/xcm-bridge-hub/src/exporter.rs +++ b/bridges/modules/xcm-bridge-hub/src/exporter.rs @@ -228,8 +228,9 @@ impl, I: 'static> Pallet { } // else - suspend the bridge - let bridge_origin_relative_location = match bridge.bridge_origin_relative_location.try_as() - { + let result_bridge_origin_relative_location = + (*bridge.bridge_origin_relative_location).clone().try_into(); + let bridge_origin_relative_location = match &result_bridge_origin_relative_location { Ok(bridge_origin_relative_location) => bridge_origin_relative_location, Err(_) => { log::debug!( diff --git a/prdoc/pr_8615.prdoc b/prdoc/pr_8615.prdoc new file mode 100644 index 0000000000000..1f8845b01ea66 --- /dev/null +++ b/prdoc/pr_8615.prdoc @@ -0,0 +1,8 @@ +title: 'Bridges: Fix - Improve try-state for pallet-xcm-bridge-hub' +doc: +- audience: Runtime Dev + description: |- + Improve try-state for pallet-xcm-bridge-hub, it removes try_as and uses try_into implementation instead. +crates: +- name: pallet-xcm-bridge-hub + bump: patch