Skip to content

Commit

Permalink
Merge pull request #205 from rolfyone/ssz-block-production
Browse files Browse the repository at this point in the history
Add ssz format for block production.
  • Loading branch information
mpetrunic authored May 5, 2022
2 parents 3d2bdc3 + 86ca66b commit 409e11a
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- run: npm i -g @apidevtools/swagger-cli@4 @stoplight/spectral-cli@6.2.0
- run: npm i -g @apidevtools/swagger-cli@4 @stoplight/spectral-cli@6.3.0
- run: spectral --version

- name: Lint spec
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
deploy
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ Api spec is checked for lint errors before merge.

To run lint locally, install linter with
```
npm install -g @stoplight/spectral-cli@6.2.1
npm install -g @stoplight/spectral-cli@6.3.0
# OR
yarn global add @stoplight/spectral-cli@6.2.1
yarn global add @stoplight/spectral-cli@6.3.0
```
and run lint with
```
Expand Down
10 changes: 10 additions & 0 deletions apis/beacon/blocks/blinded_blocks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ post:
therefore validate the block internally, however blocks which fail the validation are still
broadcast but a different status code is returned (202). Pre-Bellatrix, this endpoint will accept
a `SignedBeaconBlock`.
parameters:
- in: header
schema:
$ref: '../../../beacon-node-oapi.yaml#/components/schemas/ConsensusVersion'
required: false
name: Eth-Consensus-Version
description: "Version of the block being submitted, if using SSZ encoding."
requestBody:
description: "The `SignedBlindedBeaconBlock` object composed of `BlindedBeaconBlock` object (produced by beacon node) and validator signature."
required: true
Expand All @@ -24,6 +31,9 @@ post:
- $ref: '../../../beacon-node-oapi.yaml#/components/schemas/SignedBeaconBlock'
- $ref: "../../../beacon-node-oapi.yaml#/components/schemas/Altair.SignedBeaconBlock"
- $ref: "../../../beacon-node-oapi.yaml#/components/schemas/Bellatrix.SignedBlindedBeaconBlock"
application/octet-stream:
schema:
description: "SSZ serialized block bytes. Use content type header to indicate that SSZ data is contained in the request body."
responses:
"200":
description: "The block was validated successfully and has been broadcast. It has also been integrated into the beacon node's database."
Expand Down
10 changes: 10 additions & 0 deletions apis/beacon/blocks/blocks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ post:
successful. The beacon node is expected to integrate the new block into its state, and
therefore validate the block internally, however blocks which fail the validation are still
broadcast but a different status code is returned (202)
parameters:
- in: header
schema:
$ref: '../../../beacon-node-oapi.yaml#/components/schemas/ConsensusVersion'
required: false
name: Eth-Consensus-Version
description: "Version of the block being submitted, if using SSZ encoding."
requestBody:
description: "The `SignedBeaconBlock` object composed of `BeaconBlock` object (produced by beacon node) and validator signature."
required: true
Expand All @@ -21,6 +28,9 @@ post:
- $ref: '../../../beacon-node-oapi.yaml#/components/schemas/SignedBeaconBlock'
- $ref: "../../../beacon-node-oapi.yaml#/components/schemas/Altair.SignedBeaconBlock"
- $ref: "../../../beacon-node-oapi.yaml#/components/schemas/Bellatrix.SignedBeaconBlock"
application/octet-stream:
schema:
description: "SSZ serialized block bytes. Use content type header to indicate that SSZ data is contained in the request body."
responses:
"200":
description: "The block was validated successfully and has been broadcast. It has also been integrated into the beacon node's database."
Expand Down
3 changes: 3 additions & 0 deletions apis/validator/blinded_block.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ get:
- $ref: '../../beacon-node-oapi.yaml#/components/schemas/BeaconBlock'
- $ref: "../../beacon-node-oapi.yaml#/components/schemas/Altair.BeaconBlock"
- $ref: "../../beacon-node-oapi.yaml#/components/schemas/Bellatrix.BlindedBeaconBlock"
application/octet-stream:
schema:
description: "SSZ serialized block bytes. Use Accept header to choose this response type, version string is sent in header `Eth-Consensus-Version`."
"400":
description: "Invalid block production request"
content:
Expand Down
6 changes: 6 additions & 0 deletions apis/validator/block.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ get:
responses:
"200":
description: Success response
headers:
Eth-Consensus-Version:
$ref: '../../beacon-node-oapi.yaml#/components/headers/Eth-Consensus-Version'
content:
application/json:
schema:
Expand All @@ -46,6 +49,9 @@ get:
- $ref: '../../beacon-node-oapi.yaml#/components/schemas/BeaconBlock'
- $ref: "../../beacon-node-oapi.yaml#/components/schemas/Altair.BeaconBlock"
- $ref: "../../beacon-node-oapi.yaml#/components/schemas/Bellatrix.BeaconBlock"
application/octet-stream:
schema:
description: "SSZ serialized block bytes. Use Accept header to choose this response type, version string is sent in header `Eth-Consensus-Version`."
"400":
description: "Invalid block production request"
content:
Expand Down
9 changes: 5 additions & 4 deletions beacon-node-oapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ components:
$ref: './types/bellatrix/block.yaml#/Bellatrix/BlindedBeaconBlock'
Bellatrix.SignedBlindedBeaconBlock:
$ref: './types/bellatrix/block.yaml#/Bellatrix/SignedBlindedBeaconBlock'

ConsensusVersion:
enum: [phase0, altair, bellatrix]
example: "phase0"
parameters:
StateId:
$ref: './params/index.yaml#/StateId'
Expand All @@ -290,7 +292,6 @@ components:
headers:
Eth-Consensus-Version:
description: Required in response so client can deserialize returned json or ssz data more effectively.
required: true
schema:
type: string
enum: [phase0, altair, bellatrix]
example: "phase0"
$ref: '#/components/schemas/ConsensusVersion'

0 comments on commit 409e11a

Please sign in to comment.