-
Notifications
You must be signed in to change notification settings - Fork 14
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5359 +/- ##
======================================
- Coverage 71% 71% -0%
======================================
Files 496 496
Lines 86485 86361 -124
Branches 86485 86361 -124
======================================
- Hits 61751 61553 -198
- Misses 21971 22026 +55
- Partials 2763 2782 +19 ☔ View full report in Codecov by Sentry. |
state-chain/runtime/src/lib.rs
Outdated
@@ -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() |
There was a problem hiding this comment.
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 >=
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() |
Is there a better way to filter out duplicates without collecting to a set? |
Not really, and I believe even |
Pull Request
Closes: PRO-xxx
Checklist
Please conduct a thorough self-review before opening the PR.
Summary
Changed the way we count for suspensions, we now keep into account if the suspension is still valid, based on the current block.