make sure that disabled validator will not be checked with is_good_actor
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
parent
9bdb7b5d5c
commit
b969081cbf
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-slow-clap"
|
||||
version = "0.3.37"
|
||||
version = "0.3.38"
|
||||
description = "Applause protocol for the EVM bridge"
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
@ -969,9 +969,9 @@ impl<T: Config> Pallet<T> {
|
||||
authorities_len: usize,
|
||||
) -> u32 {
|
||||
let mut claps_in_session = (0..authorities_len)
|
||||
.filter_map(|index| {
|
||||
.filter_map(|authority_index| {
|
||||
let clap_info = actual_claps_in_session
|
||||
.get(&(index as u32))
|
||||
.get(&(authority_index as AuthIndex))
|
||||
.copied()
|
||||
.unwrap_or_default();
|
||||
(!clap_info.disabled).then(|| clap_info.claps)
|
||||
@ -996,17 +996,21 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
fn is_good_actor(
|
||||
authority_index: usize,
|
||||
session_index: SessionIndex,
|
||||
median_claps: u32,
|
||||
claps_in_session: &BTreeMap<AuthIndex, SessionAuthorityInfo>,
|
||||
) -> bool {
|
||||
if median_claps == 0 {
|
||||
return true;
|
||||
}
|
||||
|
||||
let number_of_claps = ClapsInSession::<T>::get(session_index)
|
||||
.entry(authority_index as AuthIndex)
|
||||
.or_default()
|
||||
.claps;
|
||||
let number_of_claps = claps_in_session
|
||||
.get(&(authority_index as AuthIndex))
|
||||
.copied()
|
||||
.map(|info| match info.disabled {
|
||||
true => median_claps,
|
||||
false => info.claps,
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
let authority_deviation = if number_of_claps < median_claps {
|
||||
Perbill::from_rational(median_claps - number_of_claps, median_claps)
|
||||
@ -1089,14 +1093,14 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
|
||||
let session_index = T::ValidatorSet::session_index();
|
||||
let validators = T::ValidatorSet::validators();
|
||||
let authorities_len = Authorities::<T>::get(&session_index).len();
|
||||
let actual_claps_in_session = ClapsInSession::<T>::get(&session_index);
|
||||
let claps_in_session = ClapsInSession::<T>::get(&session_index);
|
||||
|
||||
let median_claps = Self::calculate_median_claps(&actual_claps_in_session, authorities_len);
|
||||
let median_claps = Self::calculate_median_claps(&claps_in_session, authorities_len);
|
||||
|
||||
let offenders = validators
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.filter(|(index, _)| !Self::is_good_actor(*index, session_index, median_claps))
|
||||
.filter(|(index, _)| !Self::is_good_actor(*index, median_claps, &claps_in_session))
|
||||
.filter_map(|(_, id)| {
|
||||
<T::ValidatorSet as ValidatorSetWithIdentification<T::AccountId>>::IdentificationOf::convert(
|
||||
id.clone(),
|
||||
|
Loading…
Reference in New Issue
Block a user