Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add event with XCM executor outcome, which includes weight fee #1286

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions pallets/xcmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Some XCM was executed ok.
Success(Option<T::Hash>),
Success { message_id: Option<T::Hash>, weight: Weight },
/// Some XCM failed.
Fail(Option<T::Hash>, XcmError),
Fail { message_id: Option<T::Hash>, error: XcmError, weight: Weight },
/// Bad XCM version used.
BadVersion(Option<T::Hash>),
/// Bad XCM format used.
Expand Down Expand Up @@ -599,12 +599,16 @@ impl<T: Config> Pallet<T> {
let (result, event) = match Xcm::<T::Call>::try_from(xcm) {
Ok(xcm) => {
let location = (1, Parachain(sender.into()));

match T::XcmExecutor::execute_xcm(location, xcm, max_weight) {
Outcome::Error(e) => (Err(e), Event::Fail(Some(hash), e)),
Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))),
Outcome::Error(e) =>
(Err(e), Event::Fail { message_id: Some(hash), error: e, weight: 0 }),
Outcome::Complete(w) =>
(Ok(w), Event::Success { message_id: Some(hash), weight: w }),
// As far as the caller is concerned, this was dispatched without error, so
// we just report the weight used.
Outcome::Incomplete(w, e) => (Ok(w), Event::Fail(Some(hash), e)),
Outcome::Incomplete(w, e) =>
(Ok(w), Event::Fail { message_id: Some(hash), error: e, weight: w }),
}
},
Err(()) => (Err(XcmError::UnhandledXcmVersion), Event::BadVersion(Some(hash))),
Expand Down