-
Notifications
You must be signed in to change notification settings - Fork 15
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5359 +/- ##
======================================
- Coverage 72% 71% -0%
======================================
Files 495 495
Lines 86276 86152 -124
Branches 86276 86152 -124
======================================
- Hits 61717 61525 -192
- Misses 21783 21837 +54
- Partials 2776 2790 +14 ☔ 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 |
* keep into account only active suspensions * filter out duplicates and properly count keygen suspensions * addressed comments --------- Co-authored-by: dandanlen <3168260+dandanlen@users.noreply.github.com>
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.