Skip to content

Commit

Permalink
better err
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolaos Dymitriadis <[email protected]>
  • Loading branch information
AmbientTea committed Feb 3, 2025
1 parent 63c920f commit 0d197e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 8 additions & 1 deletion toolkit/pallets/session-validator-management/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 8 additions & 6 deletions toolkit/primitives/session-validator-management/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0d197e6

Please sign in to comment.