Skip to content

Commit 44b38ef

Browse files
authored
Implement /eth/v1/validator/{beacon,sync}_committee_selections Beacon API end-points (#4760)
1 parent eb678be commit 44b38ef

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

beacon_chain/rpc/rest_constants.nim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,5 @@ const
226226
"Invalid BLS to execution change; it won't validate, so it's rejected"
227227
BlsToExecutionChangeValidationSuccess* =
228228
"BLS to execution change was broadcast"
229+
AggregationSelectionNotImplemented* =
230+
"Attestation and sync committee aggreggation selection are not implemented"

beacon_chain/rpc/rest_validator_api.nim

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,3 +993,27 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
993993
)
994994
)
995995
return RestApiResponse.jsonResponse(response)
996+
997+
# https://github.com/ethereum/beacon-APIs/blob/f087fbf2764e657578a6c29bdf0261b36ee8db1e/apis/validator/beacon_committee_selections.yaml
998+
router.api(MethodPost, "/eth/v1/validator/beacon_committee_selections") do (
999+
contentBody: Option[ContentBody]) -> RestApiResponse:
1000+
# "Consensus clients need not support this endpoint and may return a 501."
1001+
# https://github.com/ethereum/beacon-APIs/pull/224: "This endpoint need not
1002+
# be implemented on the CL side. Once a validator client is aware of it and
1003+
# able to use it when a feature flag is turned on, the intercepting
1004+
# middleware can handle and swallow the request. I suggest a CL either
1005+
# returns 501 Not Implemented [or] 400 Bad Request."
1006+
return RestApiResponse.jsonError(
1007+
Http501, AggregationSelectionNotImplemented)
1008+
1009+
# https://github.com/ethereum/beacon-APIs/blob/f087fbf2764e657578a6c29bdf0261b36ee8db1e/apis/validator/sync_committee_selections.yaml
1010+
router.api(MethodPost, "/eth/v1/validator/sync_committee_selections") do (
1011+
contentBody: Option[ContentBody]) -> RestApiResponse:
1012+
# "Consensus clients need not support this endpoint and may return a 501."
1013+
# https://github.com/ethereum/beacon-APIs/pull/224: "This endpoint need not
1014+
# be implemented on the CL side. Once a validator client is aware of it and
1015+
# able to use it when a feature flag is turned on, the intercepting
1016+
# middleware can handle and swallow the request. I suggest a CL either
1017+
# returns 501 Not Implemented [or] 400 Bad Request."
1018+
return RestApiResponse.jsonError(
1019+
Http501, AggregationSelectionNotImplemented)

ncli/resttest-rules.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,6 +3333,32 @@
33333333
"body": [{"operator": "jstructcmpns", "value": {"code": 400, "message": ""}}]
33343334
}
33353335
},
3336+
{
3337+
"topics": ["validator", "beacon_committee_selections"],
3338+
"request": {
3339+
"url": "/eth/v1/validator/beacon_committee_selections",
3340+
"method": "POST",
3341+
"headers": {"Accept": "application/json"}
3342+
},
3343+
"response": {
3344+
"status": {"operator": "equals", "value": "501"},
3345+
"headers": [{"key": "Content-Type", "value": "application/json", "operator": "equals"}],
3346+
"body": [{"operator": "jstructcmpns", "value": {"code": 501, "message": ""}}]
3347+
}
3348+
},
3349+
{
3350+
"topics": ["validator", "sync_committee_selections"],
3351+
"request": {
3352+
"url": "/eth/v1/validator/sync_committee_selections",
3353+
"method": "POST",
3354+
"headers": {"Accept": "application/json"}
3355+
},
3356+
"response": {
3357+
"status": {"operator": "equals", "value": "501"},
3358+
"headers": [{"key": "Content-Type", "value": "application/json", "operator": "equals"}],
3359+
"body": [{"operator": "jstructcmpns", "value": {"code": 501, "message": ""}}]
3360+
}
3361+
},
33363362
{
33373363
"topics": ["validator", "register_validators"],
33383364
"request": {

0 commit comments

Comments
 (0)