From 10dbd773c7d8356e018f3bc3f885f57cb66a0739 Mon Sep 17 00:00:00 2001 From: Eugene Kabanov Date: Sat, 20 Jan 2024 01:34:11 +0200 Subject: [PATCH] Address issue #5758. (#5762) --- beacon_chain/rpc/rest_beacon_api.nim | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/beacon_chain/rpc/rest_beacon_api.nim b/beacon_chain/rpc/rest_beacon_api.nim index 5d7e52f3c..5cb4b82ee 100644 --- a/beacon_chain/rpc/rest_beacon_api.nim +++ b/beacon_chain/rpc/rest_beacon_api.nim @@ -44,6 +44,19 @@ proc validateBeaconApiQueries*(key: string, value: string): int = else: 1 +const + AllValidatorFilterKinds = { + ValidatorFilterKind.PendingInitialized, + ValidatorFilterKind.PendingQueued, + ValidatorFilterKind.ActiveOngoing, + ValidatorFilterKind.ActiveExiting, + ValidatorFilterKind.ActiveSlashed, + ValidatorFilterKind.ExitedUnslashed, + ValidatorFilterKind.ExitedSlashed, + ValidatorFilterKind.WithdrawalPossible, + ValidatorFilterKind.WithdrawalDone + } + proc validateFilter(filters: seq[ValidatorFilter]): Result[ValidatorFilter, cstring] = var res: ValidatorFilter @@ -51,17 +64,8 @@ proc validateFilter(filters: seq[ValidatorFilter]): Result[ValidatorFilter, if res * item != {}: return err("Validator status must be unique") res.incl(item) - if res == {}: - res = {ValidatorFilterKind.PendingInitialized, - ValidatorFilterKind.PendingQueued, - ValidatorFilterKind.ActiveOngoing, - ValidatorFilterKind.ActiveExiting, - ValidatorFilterKind.ActiveSlashed, - ValidatorFilterKind.ExitedUnslashed, - ValidatorFilterKind.ExitedSlashed, - ValidatorFilterKind.WithdrawalPossible, - ValidatorFilterKind.WithdrawalDone} + return ok(AllValidatorFilterKinds) ok(res) proc getStatus(validator: Validator, @@ -413,7 +417,7 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) = Http400, InvalidRequestBodyError, $error) let ids = request.ids.valueOr: @[] - filter = request.status.valueOr: {} + filter = request.status.valueOr: AllValidatorFilterKinds (ids, filter) sid = state_id.valueOr: return RestApiResponse.jsonError(Http400, InvalidStateIdValueError,