Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: take into account only active suspensions #5359

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion state-chain/pallets/cf-validator/src/rotation_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use sp_std::collections::btree_set::BTreeSet;
pub struct RotationState<Id, Amount> {
primary_candidates: Vec<Id>,
secondary_candidates: Vec<Id>,
banned: BTreeSet<Id>,
pub banned: BTreeSet<Id>,
pub bond: Amount,
pub new_epoch_index: EpochIndex,
}
Expand Down
14 changes: 13 additions & 1 deletion state-chain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,19 @@ impl_runtime_apis! {
}

fn cf_suspended_validators() -> Vec<(Offence, u32)> {
pallet_cf_reputation::Suspensions::<Runtime>::iter().map(|(key, elem)| (key, elem.len() as u32)).collect()
let suspended_for_keygen = match pallet_cf_validator::Pallet::<Runtime>::current_rotation_phase() {
pallet_cf_validator::RotationPhase::KeygensInProgress(rotation_state) |
pallet_cf_validator::RotationPhase::KeyHandoversInProgress(rotation_state) |
pallet_cf_validator::RotationPhase::ActivatingKeys(rotation_state) |
pallet_cf_validator::RotationPhase::NewKeysActivated(rotation_state) => { rotation_state.banned.len() as u32 },
_ => {0u32}
};
pallet_cf_reputation::Suspensions::<Runtime>::iter().map(|(key, _)| {
if key == pallet_cf_threshold_signature::PalletOffence::FailedKeygen.into() {
return (key, suspended_for_keygen);
}
(key, pallet_cf_reputation::Pallet::<Runtime>::validators_suspended_for(&[key]).len() as u32)
}).collect()
}
fn cf_epoch_state() -> EpochState {
let auction_params = Validator::auction_parameters();
Expand Down
Loading