From 3800b01fe13c01660564090ffd7a29c5863c1497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Tue, 18 Jan 2022 18:39:23 +0200 Subject: [PATCH] Fix `pallet_xcm::execute` (#4490) * Make `pallet_xcm::execute` supply the proper weight credit * Use weight correction Co-authored-by: Shawn Tabrizi --- polkadot/xcm/pallet-xcm/src/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index c6985057c1..ca0d5c7392 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -572,15 +572,21 @@ pub mod pallet { origin: OriginFor, message: Box::Call>>, max_weight: Weight, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?; let message = (*message).try_into().map_err(|()| Error::::BadVersion)?; let value = (origin_location, message); ensure!(T::XcmExecuteFilter::contains(&value), Error::::Filtered); let (origin_location, message) = value; - let outcome = T::XcmExecutor::execute_xcm(origin_location, message, max_weight); + let outcome = T::XcmExecutor::execute_xcm_in_credit( + origin_location, + message, + max_weight, + max_weight, + ); + let result = Ok(Some(outcome.weight_used().saturating_add(100_000_000)).into()); Self::deposit_event(Event::Attempted(outcome)); - Ok(()) + result } /// Extoll that a particular destination can be communicated with through a particular