From 7e7ec0c3bc22425f9ed4bef3204f4aecce5eb9b8 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Tue, 22 Nov 2022 13:23:48 +0100 Subject: [PATCH] More accurate dispatch_result: true/false (#1659) --- bridges/bin/runtime-common/src/messages.rs | 40 ++++++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/bridges/bin/runtime-common/src/messages.rs b/bridges/bin/runtime-common/src/messages.rs index 3bbf6df4f559a..3127e3c7665e2 100644 --- a/bridges/bin/runtime-common/src/messages.rs +++ b/bridges/bin/runtime-common/src/messages.rs @@ -511,14 +511,40 @@ pub mod target { }; let xcm_outcome = do_dispatch(); - log::trace!( - target: "runtime::bridge-dispatch", - "Incoming message {:?} dispatched with result: {:?}", - message_id, - xcm_outcome, - ); + let dispatch_result = match xcm_outcome { + Ok(outcome) => { + log::trace!( + target: "runtime::bridge-dispatch", + "Incoming message {:?} dispatched with result: {:?}", + message_id, + outcome, + ); + match outcome.ensure_execution() { + Ok(_weight) => true, + Err(e) => { + log::error!( + target: "runtime::bridge-dispatch", + "Incoming message {:?} was not dispatched, error: {:?}", + message_id, + e, + ); + false + }, + } + }, + Err(e) => { + log::error!( + target: "runtime::bridge-dispatch", + "Incoming message {:?} was not dispatched, codec error: {:?}", + message_id, + e, + ); + false + }, + }; + MessageDispatchResult { - dispatch_result: true, + dispatch_result, unspent_weight: Weight::zero(), dispatch_fee_paid_during_dispatch: false, }