Compare commits
No commits in common. "a3ed395689aa55a2a48b3f12bc3dffa9ea3537c2" and "0e750c0261dfcff84efe7d6089c7bf543f2e4918" have entirely different histories.
a3ed395689
...
0e750c0261
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ghost-slow-clap"
|
name = "ghost-slow-clap"
|
||||||
version = "0.3.50"
|
version = "0.3.47"
|
||||||
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
|
||||||
|
|||||||
@ -9,7 +9,7 @@ use frame_support::{
|
|||||||
pallet_prelude::*,
|
pallet_prelude::*,
|
||||||
traits::{
|
traits::{
|
||||||
tokens::fungible::{Inspect, Mutate},
|
tokens::fungible::{Inspect, Mutate},
|
||||||
DisabledValidators, EstimateNextSessionRotation, Get, OneSessionHandler, ValidatorSet,
|
EstimateNextSessionRotation, Get, OneSessionHandler, ValidatorSet,
|
||||||
ValidatorSetWithIdentification,
|
ValidatorSetWithIdentification,
|
||||||
},
|
},
|
||||||
WeakBoundedVec,
|
WeakBoundedVec,
|
||||||
@ -199,7 +199,6 @@ pub mod pallet {
|
|||||||
IdentificationTuple<Self>,
|
IdentificationTuple<Self>,
|
||||||
ThrottlingOffence<IdentificationTuple<Self>>,
|
ThrottlingOffence<IdentificationTuple<Self>>,
|
||||||
>;
|
>;
|
||||||
type DisabledValidators: DisabledValidators;
|
|
||||||
|
|
||||||
#[pallet::constant]
|
#[pallet::constant]
|
||||||
type MaxAuthorities: Get<u32>;
|
type MaxAuthorities: Get<u32>;
|
||||||
@ -399,14 +398,6 @@ 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));
|
||||||
|
|
||||||
@ -515,14 +506,14 @@ impl<T: Config> Pallet<T> {
|
|||||||
Error::<T>::CurrentValidatorIsDisabled
|
Error::<T>::CurrentValidatorIsDisabled
|
||||||
);
|
);
|
||||||
|
|
||||||
let disabled_authorities = claps_in_session
|
let disabled_authorites = 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_authorities);
|
.saturating_sub(disabled_authorites);
|
||||||
|
|
||||||
let received_claps_key = (session_index, &clap.transaction_hash, &clap_unique_hash);
|
let received_claps_key = (session_index, &clap.transaction_hash, &clap_unique_hash);
|
||||||
|
|
||||||
@ -645,12 +636,12 @@ impl<T: Config> Pallet<T> {
|
|||||||
.cloned()
|
.cloned()
|
||||||
.collect::<BTreeSet<T::AuthorityId>>();
|
.collect::<BTreeSet<T::AuthorityId>>();
|
||||||
|
|
||||||
let disabled_authorities = ClapsInSession::<T>::get(&curr_session_index)
|
let disabled_authorites = 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_authorities);
|
let active_authorities = prev_authorities.len().saturating_sub(disabled_authorites);
|
||||||
|
|
||||||
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)
|
||||||
@ -1113,18 +1104,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
|
|
||||||
Validators::<T>::insert(&session_index, bounded_validators);
|
Validators::<T>::insert(&session_index, bounded_validators);
|
||||||
Authorities::<T>::set(&session_index, bounded_authorities);
|
Authorities::<T>::set(&session_index, bounded_authorities);
|
||||||
|
ClapsInSession::<T>::set(&session_index, Default::default());
|
||||||
let mut disabled_validators: BTreeMap<AuthIndex, SessionAuthorityInfo> = Default::default();
|
|
||||||
for disabled_index in T::DisabledValidators::disabled_validators().iter() {
|
|
||||||
let _ = disabled_validators.insert(
|
|
||||||
*disabled_index,
|
|
||||||
SessionAuthorityInfo {
|
|
||||||
claps: 0u32,
|
|
||||||
disabled: true,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
ClapsInSession::<T>::set(&session_index, disabled_validators);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_history(target_session_index: &SessionIndex) {
|
fn clear_history(target_session_index: &SessionIndex) {
|
||||||
|
|||||||
@ -206,7 +206,6 @@ impl Config for Runtime {
|
|||||||
type NetworkDataHandler = Networks;
|
type NetworkDataHandler = Networks;
|
||||||
type BlockNumberProvider = System;
|
type BlockNumberProvider = System;
|
||||||
type ReportUnresponsiveness = OffenceHandler;
|
type ReportUnresponsiveness = OffenceHandler;
|
||||||
type DisabledValidators = Session;
|
|
||||||
|
|
||||||
type MaxAuthorities = ConstU32<5>;
|
type MaxAuthorities = ConstU32<5>;
|
||||||
type ApplauseThreshold = ConstU32<50>;
|
type ApplauseThreshold = ConstU32<50>;
|
||||||
|
|||||||
@ -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),
|
||||||
DispatchError::Other("Invalid signing address")
|
Error::<Runtime>::CurrentValidatorIsDisabled
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(pallet::ReceivedClaps::<Runtime>::get(&storage_key).len(), 0);
|
assert_eq!(pallet::ReceivedClaps::<Runtime>::get(&storage_key).len(), 0);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user