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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion state-chain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,8 @@ 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 current_block = <frame_system::Pallet<Runtime>>::block_number();
pallet_cf_reputation::Suspensions::<Runtime>::iter().map(|(key, elem)| (key, elem.iter().filter(|(suspended_until, _)| *suspended_until < current_block).collect::<Vec<_>>().len() as u32)).collect()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be > (or >=)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pallet_cf_reputation::Suspensions::<Runtime>::iter().map(|(key, elem)| (key, elem.iter().filter(|(suspended_until, _)| *suspended_until < current_block).collect::<Vec<_>>().len() as u32)).collect()
pallet_cf_reputation::Suspensions::<Runtime>::iter().map(|(key, elem)| (key, elem.iter().filter(|(suspended_until, _)| *suspended_until > current_block).count() as u32)).collect()

}
fn cf_epoch_state() -> EpochState {
let auction_params = Validator::auction_parameters();
Expand Down
Loading