Revert "remove removed Debug/getDebugChainHeads V1 (#4970)" (#5057)

This reverts commit 6ebcbbdf4e.
This commit is contained in:
tersec 2023-06-10 08:08:01 +00:00 committed by GitHub
parent 6ebcbbdf4e
commit 1b77831758
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 0 deletions

View File

@ -61,6 +61,13 @@ proc installDebugApiHandlers*(router: var RestRouter, node: BeaconNode) =
RestApiResponse.jsonError(Http500, InvalidAcceptError) RestApiResponse.jsonError(Http500, InvalidAcceptError)
return RestApiResponse.jsonError(Http404, StateNotFoundError) return RestApiResponse.jsonError(Http404, StateNotFoundError)
# https://ethereum.github.io/beacon-APIs/#/Debug/getDebugChainHeads
router.api(MethodGet,
"/eth/v1/debug/beacon/heads") do () -> RestApiResponse:
return RestApiResponse.jsonResponse(
node.dag.heads.mapIt((root: it.root, slot: it.slot))
)
# https://ethereum.github.io/beacon-APIs/#/Debug/getDebugChainHeadsV2 # https://ethereum.github.io/beacon-APIs/#/Debug/getDebugChainHeadsV2
router.api(MethodGet, router.api(MethodGet,
"/eth/v2/debug/beacon/heads") do () -> RestApiResponse: "/eth/v2/debug/beacon/heads") do () -> RestApiResponse:

View File

@ -13,6 +13,11 @@ import
export chronos, client, rest_types, eth2_rest_serialization export chronos, client, rest_types, eth2_rest_serialization
proc getDebugChainHeads*(): RestResponse[GetDebugChainHeadsResponse] {.
rest, endpoint: "/eth/v1/debug/beacon/heads",
meth: MethodGet.}
## https://ethereum.github.io/beacon-APIs/#/Beacon/getDebugChainHeads
proc getStateV2Plain*(state_id: StateIdent): RestPlainResponse {. proc getStateV2Plain*(state_id: StateIdent): RestPlainResponse {.
rest, endpoint: "/eth/v2/debug/beacon/states/{state_id}", rest, endpoint: "/eth/v2/debug/beacon/states/{state_id}",
accept: preferSSZ, accept: preferSSZ,

View File

@ -466,6 +466,14 @@ Equivalent call in the official REST API:
curl http://localhost:5052/eth/v2/debug/beacon/states/head -s | jq curl http://localhost:5052/eth/v2/debug/beacon/states/head -s | jq
``` ```
### [`get_v1_debug_beacon_heads`](https://ethereum.github.io/eth2.0-APIs/#/Debug/getDebugChainHeads)
Equivalent call in the official REST API:
```
curl http://localhost:5052/eth/v1/debug/beacon/heads -s | jq
```
## Nimbus extensions ## Nimbus extensions
### getBeaconHead ### getBeaconHead

View File

@ -2817,6 +2817,18 @@
"body": [{"operator": "jstructcmps", "start": ["data"], "value": {"chain_id": "", "address": ""}}] "body": [{"operator": "jstructcmps", "start": ["data"], "value": {"chain_id": "", "address": ""}}]
} }
}, },
{
"topics": ["debug"],
"request": {
"url": "/eth/v1/debug/beacon/heads",
"headers": {"Accept": "application/json"}
},
"response": {
"status": {"operator": "equals", "value": "200"},
"headers": [{"key": "Content-Type", "value": "application/json", "operator": "equals"}],
"body": [{"operator": "jstructcmps", "start": ["data"], "value": [{"root": "", "slot": ""}]}]
}
},
{ {
"topics": ["debug", "beacon_states_head_slow", "slow"], "topics": ["debug", "beacon_states_head_slow", "slow"],
"request": { "request": {