From 3eaf47bbaa1d1b4e1efbc8589757fadc2238a004 Mon Sep 17 00:00:00 2001
From: Doordashcon <90750465+Doordashcon@users.noreply.github.com>
Date: Tue, 12 Apr 2022 21:39:17 +0100
Subject: [PATCH] Log XCMP Queue Errors (#1147)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* test invalid xcmp data

* proper messaging

* cargo fmt

* Use `error` instead of `info`

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
---
 cumulus/pallets/xcmp-queue/src/lib.rs   |  6 +++++-
 cumulus/pallets/xcmp-queue/src/tests.rs | 12 ++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/cumulus/pallets/xcmp-queue/src/lib.rs b/cumulus/pallets/xcmp-queue/src/lib.rs
index e0c5b6e41ea..1b416a7c69e 100644
--- a/cumulus/pallets/xcmp-queue/src/lib.rs
+++ b/cumulus/pallets/xcmp-queue/src/lib.rs
@@ -655,7 +655,11 @@ impl<T: Config> Pallet<T> {
 								remaining_fragments = last_remaining_fragments;
 								break
 							},
-							Err(_) => {
+							Err(error) => {
+								log::error!(
+									"Failed to process XCMP-XCM message, caused by {:?}",
+									error
+								);
 								// Message looks invalid; don't attempt to retry
 							},
 						}
diff --git a/cumulus/pallets/xcmp-queue/src/tests.rs b/cumulus/pallets/xcmp-queue/src/tests.rs
index b6d8ef40b04..62e674004ec 100644
--- a/cumulus/pallets/xcmp-queue/src/tests.rs
+++ b/cumulus/pallets/xcmp-queue/src/tests.rs
@@ -65,6 +65,18 @@ fn handle_blob_message() {
 	});
 }
 
+#[test]
+#[should_panic = "Invalid incoming XCMP message data"]
+#[cfg(debug_assertions)]
+fn handle_invalid_data() {
+	new_test_ext().execute_with(|| {
+		let data = Xcm::<Test>(vec![]).encode();
+		InboundXcmpMessages::<Test>::insert(ParaId::from(1000), 1, data);
+		let format = XcmpMessageFormat::ConcatenatedVersionedXcm;
+		XcmpQueue::process_xcmp_message(1000.into(), (1, format), 10_000_000_000, 10_000_000_000);
+	});
+}
+
 #[test]
 fn service_overweight_unknown() {
 	new_test_ext().execute_with(|| {
-- 
GitLab