From 0d197e655f1536a69c6ec46fe04b404366cbda32 Mon Sep 17 00:00:00 2001 From: Nikolaos Dymitriadis Date: Thu, 30 Jan 2025 11:49:42 +0100 Subject: [PATCH] better err Signed-off-by: Nikolaos Dymitriadis --- .../session-validator-management/src/lib.rs | 9 ++++++++- .../session-validator-management/src/lib.rs | 14 ++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/toolkit/pallets/session-validator-management/src/lib.rs b/toolkit/pallets/session-validator-management/src/lib.rs index 37a1b1740..b5ff42f26 100644 --- a/toolkit/pallets/session-validator-management/src/lib.rs +++ b/toolkit/pallets/session-validator-management/src/lib.rs @@ -213,7 +213,14 @@ pub mod pallet { }); if *validators_param != validators { - return Err(InherentError::InvalidValidators); + if *call_selection_inputs_hash == computed_selection_inputs_hash { + return Err(InherentError::InvalidValidators(computed_selection_inputs_hash)); + } else { + return Err(InherentError::InvalidValidatorsHashMismatch( + computed_selection_inputs_hash, + call_selection_inputs_hash.clone(), + )); + } } if *call_selection_inputs_hash != computed_selection_inputs_hash { diff --git a/toolkit/primitives/session-validator-management/src/lib.rs b/toolkit/primitives/session-validator-management/src/lib.rs index 6f12c558e..c01cc2570 100644 --- a/toolkit/primitives/session-validator-management/src/lib.rs +++ b/toolkit/primitives/session-validator-management/src/lib.rs @@ -14,19 +14,21 @@ pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"/ariadne"; pub enum InherentError { #[cfg_attr( feature = "std", - error("The validators in the block do not match the calculated validators") + error("The validators in the block do not match the calculated validators. Input data hash ({}) is valid.", .0.to_hex_string()) )] - InvalidValidators, + InvalidValidators(SizedByteString<32>), #[cfg_attr( feature = "std", - error("Candidates inherent required: committee needs to be stored one epoch in advance") + error("The validators and input data hash in the block do not match the calculated values. Expected hash: {}, got: {}", + .0.to_hex_string(), + .1.to_hex_string()) )] - CommitteeNeedsToBeStoredOneEpochInAdvance, + InvalidValidatorsHashMismatch(SizedByteString<32>, SizedByteString<32>), #[cfg_attr( feature = "std", - error("Inherent called with data hash {0:?} but {1:?} expected from inherent data") + error("Candidates inherent required: committee needs to be stored one epoch in advance") )] - DataHashMismatch(SizedByteString<32>, SizedByteString<32>), + CommitteeNeedsToBeStoredOneEpochInAdvance, } impl IsFatalError for InherentError {