add state root endpoint

This commit is contained in:
Marin Petrunić 2020-05-30 12:54:13 +02:00
parent 8a936ef387
commit 2d522dc3a4
No known key found for this signature in database
GPG Key ID: 834D07135E110DA5
5 changed files with 128 additions and 92 deletions

View File

@ -0,0 +1,17 @@
get:
operationId: "getStateRoot"
summary: "Get state SSZ HashTreeRoot"
description: "Calculates HashTreeRoot for state with given 'stateId'. If stateId is root, same value will be returned."
tags:
- Beacon
parameters:
- name: stateId
$ref: '../../../beacon-node-oapi.yaml#/components/parameters/StateId'
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: '../../../beacon-node-oapi.yaml#/components/schemas/Root'

View File

@ -32,6 +32,9 @@ paths:
/v1/beacon/genesis:
$ref: "./apis/beacon/genesis.yaml"
/v1/beacon/states/{stateId}/root:
$ref: "./apis/beacon/states/root.yaml"
# /v1/beacon/fork:
# $ref: "./apis/beacon/fork.yaml#/single"
# /v1/beacon/fork/stream:
@ -69,6 +72,8 @@ paths:
components:
schemas:
BeaconState:
$ref: './types/state.yaml#/BeaconState'
BeaconBlock:
$ref: './types/block.yaml#/schemas/BeaconBlock'
SignedBeaconBlock:
@ -105,6 +110,11 @@ components:
$ref: './types/primitive.yaml#/schemas/Root'
Signature:
$ref: './types/primitive.yaml#/schemas/Signature'
parameters:
StateId:
$ref: './params/index.yaml#/StateId'
responses:
InvalidRequest:
$ref: './types/http.yaml#/responses/InvalidRequest'

1
dist/index.html vendored
View File

@ -42,6 +42,7 @@
url: "https://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
showExtensions: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset

9
params/index.yaml Normal file
View File

@ -0,0 +1,9 @@
StateId:
name: stateId
in: path
required: true
schema:
type: string
description: |
State identifier.
Can be one of: "head" (canonical head in node's view), "genesis", "finalized", "justified", \<slot\>, \<stateRoot\>.

View File

@ -1,4 +1,3 @@
schemas:
BeaconState:
type: object
description: "The [`BeaconState`](https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#beaconblock) object from the Eth2.0 spec."