update to v1 of LC REST API (#4232)
The LC REST API has been merged into the ethereum/beacon-APIs specs: - https://github.com/ethereum/beacon-APIs/pull/247 Update URLs to v1 and update REST tests. Note that REST tests do not start with Altair, so the tested BN will return empty / error responses.
This commit is contained in:
parent
4b7bb4796f
commit
95aec9de12
|
@ -86,7 +86,6 @@ proc eventHandler*[T](response: HttpResponseRef,
|
||||||
|
|
||||||
proc installEventApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
proc installEventApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
# https://ethereum.github.io/beacon-APIs/#/Events/eventstream
|
# https://ethereum.github.io/beacon-APIs/#/Events/eventstream
|
||||||
# https://github.com/ethereum/beacon-APIs/pull/181
|
|
||||||
router.api(MethodGet, "/eth/v1/events") do (
|
router.api(MethodGet, "/eth/v1/events") do (
|
||||||
topics: seq[EventTopic]) -> RestApiResponse:
|
topics: seq[EventTopic]) -> RestApiResponse:
|
||||||
let eventTopics =
|
let eventTopics =
|
||||||
|
@ -151,12 +150,12 @@ proc installEventApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
if EventTopic.LightClientFinalityUpdate in eventTopics:
|
if EventTopic.LightClientFinalityUpdate in eventTopics:
|
||||||
doAssert node.dag.lcDataStore.serve
|
doAssert node.dag.lcDataStore.serve
|
||||||
let handler = response.eventHandler(node.eventBus.finUpdateQueue,
|
let handler = response.eventHandler(node.eventBus.finUpdateQueue,
|
||||||
"light_client_finality_update_v0")
|
"light_client_finality_update")
|
||||||
res.add(handler)
|
res.add(handler)
|
||||||
if EventTopic.LightClientOptimisticUpdate in eventTopics:
|
if EventTopic.LightClientOptimisticUpdate in eventTopics:
|
||||||
doAssert node.dag.lcDataStore.serve
|
doAssert node.dag.lcDataStore.serve
|
||||||
let handler = response.eventHandler(node.eventBus.optUpdateQueue,
|
let handler = response.eventHandler(node.eventBus.optUpdateQueue,
|
||||||
"light_client_optimistic_update_v0")
|
"light_client_optimistic_update")
|
||||||
res.add(handler)
|
res.add(handler)
|
||||||
res
|
res
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,9 @@ import ../beacon_node,
|
||||||
logScope: topics = "rest_light_client"
|
logScope: topics = "rest_light_client"
|
||||||
|
|
||||||
proc installLightClientApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
proc installLightClientApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
# https://github.com/ethereum/beacon-APIs/pull/181
|
# https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getLightClientBootstrap
|
||||||
router.api(MethodGet,
|
router.api(MethodGet,
|
||||||
"/eth/v0/beacon/light_client/bootstrap/{block_root}") do (
|
"/eth/v1/beacon/light_client/bootstrap/{block_root}") do (
|
||||||
block_root: Eth2Digest) -> RestApiResponse:
|
block_root: Eth2Digest) -> RestApiResponse:
|
||||||
doAssert node.dag.lcDataStore.serve
|
doAssert node.dag.lcDataStore.serve
|
||||||
let contentType =
|
let contentType =
|
||||||
|
@ -52,9 +52,9 @@ proc installLightClientApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
else:
|
else:
|
||||||
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
||||||
|
|
||||||
# https://github.com/ethereum/beacon-APIs/pull/181
|
# https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getLightClientUpdatesByRange
|
||||||
router.api(MethodGet,
|
router.api(MethodGet,
|
||||||
"/eth/v0/beacon/light_client/updates") do (
|
"/eth/v1/beacon/light_client/updates") do (
|
||||||
start_period: Option[SyncCommitteePeriod], count: Option[uint64]
|
start_period: Option[SyncCommitteePeriod], count: Option[uint64]
|
||||||
) -> RestApiResponse:
|
) -> RestApiResponse:
|
||||||
doAssert node.dag.lcDataStore.serve
|
doAssert node.dag.lcDataStore.serve
|
||||||
|
@ -113,9 +113,9 @@ proc installLightClientApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
else:
|
else:
|
||||||
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
||||||
|
|
||||||
# https://github.com/ethereum/beacon-APIs/pull/181
|
# https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getLightClientFinalityUpdate
|
||||||
router.api(MethodGet,
|
router.api(MethodGet,
|
||||||
"/eth/v0/beacon/light_client/finality_update") do (
|
"/eth/v1/beacon/light_client/finality_update") do (
|
||||||
) -> RestApiResponse:
|
) -> RestApiResponse:
|
||||||
doAssert node.dag.lcDataStore.serve
|
doAssert node.dag.lcDataStore.serve
|
||||||
let contentType =
|
let contentType =
|
||||||
|
@ -142,9 +142,9 @@ proc installLightClientApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
else:
|
else:
|
||||||
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
||||||
|
|
||||||
# https://github.com/ethereum/beacon-APIs/pull/181
|
# https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getLightClientOptimisticUpdate
|
||||||
router.api(MethodGet,
|
router.api(MethodGet,
|
||||||
"/eth/v0/beacon/light_client/optimistic_update") do (
|
"/eth/v1/beacon/light_client/optimistic_update") do (
|
||||||
) -> RestApiResponse:
|
) -> RestApiResponse:
|
||||||
doAssert node.dag.lcDataStore.serve
|
doAssert node.dag.lcDataStore.serve
|
||||||
let contentType =
|
let contentType =
|
||||||
|
|
|
@ -2648,9 +2648,9 @@ proc decodeString*(t: typedesc[EventTopic],
|
||||||
ok(EventTopic.ChainReorg)
|
ok(EventTopic.ChainReorg)
|
||||||
of "contribution_and_proof":
|
of "contribution_and_proof":
|
||||||
ok(EventTopic.ContributionAndProof)
|
ok(EventTopic.ContributionAndProof)
|
||||||
of "light_client_finality_update_v0":
|
of "light_client_finality_update":
|
||||||
ok(EventTopic.LightClientFinalityUpdate)
|
ok(EventTopic.LightClientFinalityUpdate)
|
||||||
of "light_client_optimistic_update_v0":
|
of "light_client_optimistic_update":
|
||||||
ok(EventTopic.LightClientOptimisticUpdate)
|
ok(EventTopic.LightClientOptimisticUpdate)
|
||||||
else:
|
else:
|
||||||
err("Incorrect event's topic value")
|
err("Incorrect event's topic value")
|
||||||
|
|
|
@ -2457,6 +2457,82 @@
|
||||||
},
|
},
|
||||||
"response": {"status": {"operator": "equals", "value": "400"}}
|
"response": {"status": {"operator": "equals", "value": "400"}}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"topics": ["beacon", "beacon_light_client_bootstrap_blockroot"],
|
||||||
|
"request": {
|
||||||
|
"url": "/eth/v1/beacon/light_client/bootstrap/0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"headers": {"Accept": "application/json"}
|
||||||
|
},
|
||||||
|
"response": {"status": {"operator": "equals", "value": "404"}}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"topics": ["beacon", "beacon_light_client_bootstrap_blockroot"],
|
||||||
|
"request": {
|
||||||
|
"url": "/eth/v1/beacon/light_client/bootstrap/head",
|
||||||
|
"headers": {"Accept": "application/json"}
|
||||||
|
},
|
||||||
|
"response": {"status": {"operator": "equals", "value": "400"}}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"topics": ["beacon", "beacon_light_client_updates"],
|
||||||
|
"request": {
|
||||||
|
"url": "/eth/v1/beacon/light_client/updates?start_period=0&count=50",
|
||||||
|
"headers": {"Accept": "application/json"}
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"status": {"operator": "equals", "value": "200"},
|
||||||
|
"headers": [{"key": "Content-Type", "value": "application/json", "operator": "equals"}],
|
||||||
|
"body": [{"operator": "jstructcmps", "start": [],"value": [[]]}]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"topics": ["beacon", "beacon_light_client_updates"],
|
||||||
|
"request": {
|
||||||
|
"url": "/eth/v1/beacon/light_client/updates?start_period=X&count=50",
|
||||||
|
"headers": {"Accept": "application/json"}
|
||||||
|
},
|
||||||
|
"response": {"status": {"operator": "equals", "value": "400"}}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"topics": ["beacon", "beacon_light_client_updates"],
|
||||||
|
"request": {
|
||||||
|
"url": "/eth/v1/beacon/light_client/updates?start_period=0&count=X",
|
||||||
|
"headers": {"Accept": "application/json"}
|
||||||
|
},
|
||||||
|
"response": {"status": {"operator": "equals", "value": "400"}}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"topics": ["beacon", "beacon_light_client_updates"],
|
||||||
|
"request": {
|
||||||
|
"url": "/eth/v1/beacon/light_client/updates?count=50",
|
||||||
|
"headers": {"Accept": "application/json"}
|
||||||
|
},
|
||||||
|
"response": {"status": {"operator": "equals", "value": "400"}}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"topics": ["beacon", "beacon_light_client_updates"],
|
||||||
|
"request": {
|
||||||
|
"url": "/eth/v1/beacon/light_client/updates?start_period=0",
|
||||||
|
"headers": {"Accept": "application/json"}
|
||||||
|
},
|
||||||
|
"response": {"status": {"operator": "equals", "value": "400"}}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"topics": ["beacon", "beacon_light_client_finality_update"],
|
||||||
|
"request": {
|
||||||
|
"url": "/eth/v1/beacon/light_client/finality_update",
|
||||||
|
"headers": {"Accept": "application/json"}
|
||||||
|
},
|
||||||
|
"response": {"status": {"operator": "equals", "value": "404"}}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"topics": ["beacon", "beacon_light_client_optimistic_update"],
|
||||||
|
"request": {
|
||||||
|
"url": "/eth/v1/beacon/light_client/optimistic_update",
|
||||||
|
"headers": {"Accept": "application/json"}
|
||||||
|
},
|
||||||
|
"response": {"status": {"operator": "equals", "value": "404"}}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"topics": ["beacon", "pool_attestations"],
|
"topics": ["beacon", "pool_attestations"],
|
||||||
"request": {
|
"request": {
|
||||||
|
|
|
@ -19,7 +19,7 @@ const
|
||||||
$RestTesterPatch
|
$RestTesterPatch
|
||||||
RestTesterIdent* = "RestTester/$1 ($2/$3)" % [RestTesterVersion,
|
RestTesterIdent* = "RestTester/$1 ($2/$3)" % [RestTesterVersion,
|
||||||
hostCPU, hostOS]
|
hostCPU, hostOS]
|
||||||
RestTesterCopyright* = "Copyright(C) 2021" &
|
RestTesterCopyright* = "Copyright(C) 2021-2022" &
|
||||||
" Status Research & Development GmbH"
|
" Status Research & Development GmbH"
|
||||||
RestTesterHeader* = RestTesterName & ", Version " & RestTesterVersion &
|
RestTesterHeader* = RestTesterName & ", Version " & RestTesterVersion &
|
||||||
" [" & hostOS & ": " & hostCPU & "]\r\n" &
|
" [" & hostOS & ": " & hostCPU & "]\r\n" &
|
||||||
|
|
Loading…
Reference in New Issue