Skip to content

Commit 875882d

Browse files
authored
Add SSZ support to builder api (#104)
* Add SSZ support to builder api * Add electra to consensus version
1 parent 5cb324e commit 875882d

File tree

4 files changed

+98
-2
lines changed

4 files changed

+98
-2
lines changed

apis/builder/blinded_blocks.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ post:
1111
failure.
1212
1313
After Deneb, this endpoint will additionally return the associated blobs in the response.
14+
15+
Note: SSZ support can be determined by requesting an SSZ encoded response in the `getHeader`
16+
request.
1417
tags:
1518
- Builder
1619
parameters:
1720
- in: header
1821
schema:
19-
$ref: '../../beacon-apis/beacon-node-oapi.yaml#/components/schemas/ConsensusVersion'
22+
$ref: "../../builder-oapi.yaml#/components/schemas/ConsensusVersion"
2023
required: false
2124
name: Eth-Consensus-Version
2225
description: "Version of the block being submitted"
@@ -40,10 +43,16 @@ post:
4043
$ref: "../../builder-oapi.yaml#/components/examples/Deneb.SignedBlindedBeaconBlock"
4144
electra:
4245
$ref: "../../builder-oapi.yaml#/components/examples/Electra.SignedBlindedBeaconBlock"
43-
46+
application/octet-stream:
47+
schema:
48+
description: "SSZ serialized `SignedBlindedBeaconBlock` bytes. Use content type header to indicate that SSZ data is contained in the request body."
4449
responses:
4550
"200":
4651
description: Success response.
52+
headers:
53+
Eth-Consensus-Version:
54+
$ref: "../../beacon-apis/beacon-node-oapi.yaml#/components/headers/Eth-Consensus-Version"
55+
required: false
4756
content:
4857
application/json:
4958
schema:
@@ -69,6 +78,9 @@ post:
6978
$ref: "../../builder-oapi.yaml#/components/examples/Deneb.ExecutionPayloadAndBlobsBundle"
7079
electra:
7180
$ref: "../../builder-oapi.yaml#/components/examples/Deneb.ExecutionPayloadAndBlobsBundle"
81+
application/octet-stream:
82+
schema:
83+
description: "SSZ serialized `ExecutionPayload` or `ExecutionPayloadAndBlobsBundle` bytes. Use Accept header to choose this response type"
7284
"400":
7385
description: Error response.
7486
content:
@@ -79,5 +91,9 @@ post:
7991
- example:
8092
code: 400
8193
message: "Invalid block: missing signature"
94+
"406":
95+
$ref: "../../builder-oapi.yaml#/components/responses/NotAcceptable"
96+
"415":
97+
$ref: "../../builder-oapi.yaml#/components/responses/UnsupportedMediaType"
8298
"500":
8399
$ref: "../../builder-oapi.yaml#/components/responses/InternalError"

apis/builder/header.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ get:
3535
responses:
3636
"200":
3737
description: Success response.
38+
headers:
39+
Eth-Consensus-Version:
40+
$ref: "../../builder-oapi.yaml#/components/headers/Eth-Consensus-Version"
41+
required: false
3842
content:
3943
application/json:
4044
schema:
@@ -61,6 +65,9 @@ get:
6165
$ref: "../../builder-oapi.yaml#/components/examples/Deneb.SignedBuilderBid"
6266
electra:
6367
$ref: "../../builder-oapi.yaml#/components/examples/Electra.SignedBuilderBid"
68+
application/octet-stream:
69+
schema:
70+
description: "SSZ serialized `SignedBuilderBid` bytes. Use Accept header to choose this response type"
6471
"204":
6572
description: No header is available.
6673
"400":
@@ -74,5 +81,7 @@ get:
7481
value:
7582
code: 400
7683
message: "Unknown hash: missing parent hash"
84+
"406":
85+
$ref: "../../builder-oapi.yaml#/components/responses/NotAcceptable"
7786
"500":
7887
$ref: "../../builder-oapi.yaml#/components/responses/InternalError"

builder-oapi.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ info:
66
API specification for external builder nodes. This interface enables
77
validators to delegate block building duties.
88
9+
All requests by default send and receive JSON, and as such should have either or both of the "Content-Type: application/json"
10+
and "Accept: application/json" headers. In addition, some requests can send and receive data in the SSZ format. The header
11+
"Content-Type: application/octet-stream" should be set in requests that contain SSZ data; a preference to receive SSZ data in
12+
response can be indicated by setting the "Accept: application/octet-stream;q=1.0,application/json;q=0.9" header. Note that
13+
only a subset of requests can respond with data in SSZ format; these are noted in each individual request.
14+
15+
When handling requests, the server should return a 415 status code if the "Content-Type" header in the request specifies a format
16+
that is not supported. Similarly, it should return a 406 status code if it cannot produce a response in the format accepted by
17+
the client as specified in the "Accept" header; if no "Accept" header is provided then it is assumed to be "application/json".
18+
In any case, the server should indicate the format of the response by setting the corresponding "Content-Type" header.
19+
920
API endpoints are individually versioned. As such, there is no direct
1021
relationship between all v1 endpoints, all v2 endpoints, _etc._ and no such
1122
relationship should be inferred. The rules that require an increase in
@@ -57,6 +68,10 @@ components:
5768
$ref: "./beacon-apis/types/primitive.yaml#/Pubkey"
5869
ErrorMessage:
5970
$ref: "./beacon-apis/types/http.yaml#/ErrorMessage"
71+
ConsensusVersion:
72+
$ref: "./beacon-apis/beacon-node-oapi.yaml#/components/schemas/ConsensusVersion"
73+
enum: [ bellatrix, capella, deneb, electra ]
74+
example: "bellatrix"
6075
Bellatrix.ExecutionPayload:
6176
$ref: "./beacon-apis/types/bellatrix/execution_payload.yaml#/Bellatrix/ExecutionPayload"
6277
Bellatrix.SignedBlindedBeaconBlock:
@@ -85,6 +100,16 @@ components:
85100
responses:
86101
InternalError:
87102
$ref: "./types/http.yaml#/InternalError"
103+
NotAcceptable:
104+
$ref: "./types/http.yaml#/NotAcceptable"
105+
UnsupportedMediaType:
106+
$ref: "./types/http.yaml#/UnsupportedMediaType"
107+
108+
headers:
109+
Eth-Consensus-Version:
110+
$ref: "./beacon-apis/beacon-node-oapi.yaml#/components/headers/Eth-Consensus-Version"
111+
schema:
112+
$ref: "#/components/schemas/ConsensusVersion"
88113

89114
examples:
90115
Bellatrix.SignedBlindedBeaconBlock:

types/http.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,49 @@ InternalError:
2121
example:
2222
code: 500
2323
message: "Internal server error"
24+
NotAcceptable:
25+
description: "Accepted media type is not supported."
26+
content:
27+
application/json:
28+
schema:
29+
type: object
30+
required: [code, message]
31+
properties:
32+
code:
33+
description: "The media type in \"Accept\" header is unsupported, and the request has been rejected. This occurs when the server cannot produce a response in the format accepted by the client."
34+
type: number
35+
example: 406
36+
message:
37+
description: "Message describing error"
38+
type: string
39+
stacktraces:
40+
description: "Optional stacktraces, sent when node is in debug mode"
41+
type: array
42+
items:
43+
type: string
44+
example:
45+
code: 406
46+
message: "Accepted media type not supported"
47+
UnsupportedMediaType:
48+
description: "Supplied content-type is not supported."
49+
content:
50+
application/json:
51+
schema:
52+
type: object
53+
required: [code, message]
54+
properties:
55+
code:
56+
description: "The media type in \"Content-Type\" header is unsupported, and the request has been rejected. This occurs when a HTTP request supplies a payload in a content-type that the server is not able to handle."
57+
type: number
58+
example: 415
59+
message:
60+
description: "Message describing error"
61+
type: string
62+
stacktraces:
63+
description: "Optional stacktraces, sent when node is in debug mode"
64+
type: array
65+
items:
66+
type: string
67+
example:
68+
code: 415
69+
message: "Cannot read the supplied content type."

0 commit comments

Comments
 (0)