From 67adfea6f6cf0a7cb1b4a955c17c2280c097a445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sun, 4 Apr 2021 13:42:11 +0200 Subject: [PATCH] Use `log::error!` for bad mandatory (#8521) To make the life of people easier ;) --- frame/election-provider-multi-phase/src/unsigned.rs | 2 +- frame/system/src/extensions/check_weight.rs | 6 ++---- primitives/runtime/src/lib.rs | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index 280907ac5439a..b54a7d75a0a20 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -650,7 +650,7 @@ mod tests { #[test] #[should_panic(expected = "Invalid unsigned submission must produce invalid block and \ deprive validator from their authoring reward.: \ - DispatchError::Module { index: 2, error: 1, message: \ + Module { index: 2, error: 1, message: \ Some(\"PreDispatchWrongWinnerCount\") }")] fn unfeasible_solution_panics() { ExtBuilder::default().build_and_execute(|| { diff --git a/frame/system/src/extensions/check_weight.rs b/frame/system/src/extensions/check_weight.rs index fc9898b778b8d..a4ebeaea30c23 100644 --- a/frame/system/src/extensions/check_weight.rs +++ b/frame/system/src/extensions/check_weight.rs @@ -18,7 +18,7 @@ use crate::{limits::BlockWeights, Config, Pallet}; use codec::{Encode, Decode}; use sp_runtime::{ - traits::{SignedExtension, DispatchInfoOf, Dispatchable, PostDispatchInfoOf, Printable}, + traits::{SignedExtension, DispatchInfoOf, Dispatchable, PostDispatchInfoOf}, transaction_validity::{ ValidTransaction, TransactionValidityError, InvalidTransaction, TransactionValidity, TransactionPriority, @@ -248,9 +248,7 @@ impl SignedExtension for CheckWeight where // to them actually being useful. Block producers are thus not allowed to include mandatory // extrinsics that result in error. if let (DispatchClass::Mandatory, Err(e)) = (info.class, result) { - "Bad mandatory".print(); - e.print(); - + log::error!(target: "runtime::system", "Bad mandatory: {:?}", e); Err(InvalidTransaction::BadMandatory)? } diff --git a/primitives/runtime/src/lib.rs b/primitives/runtime/src/lib.rs index 090c9781eb13d..59d78bb89642c 100644 --- a/primitives/runtime/src/lib.rs +++ b/primitives/runtime/src/lib.rs @@ -450,7 +450,7 @@ pub type DispatchResult = sp_std::result::Result<(), DispatchError>; pub type DispatchResultWithInfo = sp_std::result::Result>; /// Reason why a dispatch call failed. -#[derive(Eq, Clone, Copy, Encode, Decode, RuntimeDebug)] +#[derive(Eq, Clone, Copy, Encode, Decode, Debug)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum DispatchError { /// Some error occurred. @@ -535,7 +535,7 @@ impl From for DispatchError { } /// Description of what went wrong when trying to complete an operation on a token. -#[derive(Eq, PartialEq, Clone, Copy, Encode, Decode, RuntimeDebug)] +#[derive(Eq, PartialEq, Clone, Copy, Encode, Decode, Debug)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum TokenError { /// Funds are unavailable.