-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
feat: allow filtering of validators by top-level validator status #7143
feat: allow filtering of validators by top-level validator status #7143
Conversation
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.
Thanks for picking this up, some initial feedback
@@ -83,6 +83,51 @@ export async function getStateResponseWithRegen( | |||
return res; | |||
} | |||
|
|||
function mapToGeneralStatus(subStatus: string): string { |
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.
switch-case would be nicer here, we can also reuse ValidatorStatus
type, and potentially a extended type which includes top-level / general statuses as well
* Get the status of the validator | ||
* based on conditions outlined in https://hackmd.io/ofFJ5gOmQpu1jjHilHbdQQ | ||
*/ | ||
export function getValidatorStatus(validator: phase0.Validator, currentEpoch: Epoch): routes.beacon.ValidatorStatus { |
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.
why is this added here?
also note that |
I've updated the code based on the feedback:
|
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.
Looks good, can you please remove unrelated code updates, see #7143 (comment)
Co-authored-by: Nico Flaig <[email protected]>
e07a82b just removed the actual code, the unrelated code changes are still here |
Sorry for the inconvenience, solving the first issue. Thank you for the opportunity. |
Removed unrelated code |
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.
LGTM - thanks for the cleanup
Co-authored-by: Nico Flaig <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## unstable #7143 +/- ##
=========================================
Coverage 49.19% 49.19%
=========================================
Files 597 597
Lines 39725 39725
Branches 2073 2083 +10
=========================================
+ Hits 19542 19544 +2
+ Misses 20142 20140 -2
Partials 41 41 |
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.
LGTM
unrelated, commenting for posterity
ValidatorStatus
shouldn't contain "active"
yeah, let's get rid of this #7146 |
) * Fix ValidatorStatus type issue * refactor: use switch-case and typed general validator status mapping * Update packages/beacon-node/src/api/impl/beacon/state/utils.ts Co-authored-by: Nico Flaig <[email protected]> * refactor: deleted unrelated code * refactor: deleted unrelated code * Update packages/beacon-node/src/api/impl/beacon/state/utils.ts Co-authored-by: Nico Flaig <[email protected]> --------- Co-authored-by: Nico Flaig <[email protected]>
Add support for filtering validators by top-level status
This pull request implements support for filtering validators by top-level statuses such as
active
,pending
,exited
, andwithdrawal
as specified in the beacon-api spec.Changes:
mapToGeneralStatus
function to map detailed statuses to top-level statuses (active
,pending
,exited
, andwithdrawal
).filterStateValidatorsByStatus
to support filtering validators by both detailed and top-level statuses.Related issue:
Closes #7141