check if validator disabled during the validate_unsigned and small typo fixes

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky 2025-11-08 13:48:14 +03:00
parent cc141105bb
commit 7a710ec9cb
Signed by: st1nky
GPG Key ID: 016064BD97603B40
3 changed files with 14 additions and 6 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ghost-slow-clap" name = "ghost-slow-clap"
version = "0.3.48" version = "0.3.49"
description = "Applause protocol for the EVM bridge" description = "Applause protocol for the EVM bridge"
license.workspace = true license.workspace = true
authors.workspace = true authors.workspace = true

View File

@ -399,6 +399,14 @@ pub mod pallet {
None => return InvalidTransaction::BadSigner.into(), None => return InvalidTransaction::BadSigner.into(),
}; };
if ClapsInSession::<T>::get(&session_index)
.get(&clap.authority_index)
.map(|info| info.disabled)
.unwrap_or_default()
{
return InvalidTransaction::BadSigner.into();
}
let signature_valid = let signature_valid =
clap.using_encoded(|encoded_clap| authority.verify(&encoded_clap, signature)); clap.using_encoded(|encoded_clap| authority.verify(&encoded_clap, signature));
@ -507,14 +515,14 @@ impl<T: Config> Pallet<T> {
Error::<T>::CurrentValidatorIsDisabled Error::<T>::CurrentValidatorIsDisabled
); );
let disabled_authorites = claps_in_session let disabled_authorities = claps_in_session
.values() .values()
.filter(|info| info.disabled) .filter(|info| info.disabled)
.count(); .count();
let active_authorities = Authorities::<T>::get(&session_index) let active_authorities = Authorities::<T>::get(&session_index)
.len() .len()
.saturating_sub(disabled_authorites); .saturating_sub(disabled_authorities);
let received_claps_key = (session_index, &clap.transaction_hash, &clap_unique_hash); let received_claps_key = (session_index, &clap.transaction_hash, &clap_unique_hash);
@ -637,12 +645,12 @@ impl<T: Config> Pallet<T> {
.cloned() .cloned()
.collect::<BTreeSet<T::AuthorityId>>(); .collect::<BTreeSet<T::AuthorityId>>();
let disabled_authorites = ClapsInSession::<T>::get(&prev_session_index) let disabled_authorities = ClapsInSession::<T>::get(&prev_session_index)
.values() .values()
.filter(|info| info.disabled) .filter(|info| info.disabled)
.count(); .count();
let active_authorities = prev_authorities.len().saturating_sub(disabled_authorites); let active_authorities = prev_authorities.len().saturating_sub(disabled_authorities);
let summary_authority_claps_length = curr_received_claps let summary_authority_claps_length = curr_received_claps
.symmetric_difference(&prev_received_claps) .symmetric_difference(&prev_received_claps)

View File

@ -710,7 +710,7 @@ fn should_throw_error_if_validator_disabled_and_ignore_later() {
assert_eq!(Session::disable_index(0), true); assert_eq!(Session::disable_index(0), true);
assert_err!( assert_err!(
do_clap_from(session_index, network_id, 0, false), do_clap_from(session_index, network_id, 0, false),
Error::<Runtime>::CurrentValidatorIsDisabled DispatchError::Other("Invalid signing address")
); );
assert_eq!(pallet::ReceivedClaps::<Runtime>::get(&storage_key).len(), 0); assert_eq!(pallet::ReceivedClaps::<Runtime>::get(&storage_key).len(), 0);