From 37fe3254e561950ce9a5a59faeddfb265430eccb Mon Sep 17 00:00:00 2001 From: Sergej Sakac Date: Sat, 8 Apr 2023 13:25:28 +0300 Subject: [PATCH 1/2] Warn if pallet does not exist in try-state --- frame/support/src/traits/try_runtime.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frame/support/src/traits/try_runtime.rs b/frame/support/src/traits/try_runtime.rs index 6103f07a73c78..1dc4a8d48210e 100644 --- a/frame/support/src/traits/try_runtime.rs +++ b/frame/support/src/traits/try_runtime.rs @@ -168,11 +168,19 @@ impl TryState::name(), Tuple::try_state) ),* )]; let mut result = Ok(()); - for (name, try_state_fn) in try_state_fns { - if pallet_names.iter().any(|n| n == name.as_bytes()) { + pallet_names.iter().for_each(|pallet_name| { + if let Some((name, try_state_fn)) = + try_state_fns.iter().find(|(name, _)| name.as_bytes() == pallet_name) + { result = result.and(try_state_fn(n.clone(), targets.clone())); + } else { + crate::log::warn!( + "Pallet {:?} not found", + sp_std::str::from_utf8(pallet_name).unwrap() + ); } - } + }); + result }, } From b2b06b2f73ad15325eb2aedff93b47c649b2de67 Mon Sep 17 00:00:00 2001 From: Sergej Sakac Date: Sat, 8 Apr 2023 13:36:07 +0300 Subject: [PATCH 2/2] unwrap_or_default --- frame/support/src/traits/try_runtime.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/src/traits/try_runtime.rs b/frame/support/src/traits/try_runtime.rs index 1dc4a8d48210e..bebc248721c99 100644 --- a/frame/support/src/traits/try_runtime.rs +++ b/frame/support/src/traits/try_runtime.rs @@ -176,7 +176,7 @@ impl TryState