Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engine API: define Open RPC schema #379

Merged
merged 9 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ methodFiles.forEach(file => {
];
});

methodsBase = "src/engine/openrpc/methods/";
methodFiles = fs.readdirSync(methodsBase);
methodFiles.forEach(file => {
console.log(file);
let raw = fs.readFileSync(methodsBase + file);
let parsed = yaml.load(raw);
methods = [
...methods,
...parsed,
];
});

let schemas = {};
let schemasBase = "src/schemas/"
let schemaFiles = fs.readdirSync(schemasBase);
Expand All @@ -42,6 +54,19 @@ schemaFiles.forEach(file => {
...parsed,
};
});

schemasBase = "src/engine/openrpc/schemas/"
schemaFiles = fs.readdirSync(schemasBase);
schemaFiles.forEach(file => {
console.log(file);
let raw = fs.readFileSync(schemasBase + file);
let parsed = yaml.load(raw);
schemas = {
...schemas,
...parsed,
};
});

const doc = {
openrpc: "1.2.4",
info: {
Expand Down
1 change: 1 addition & 0 deletions spellcheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ matrix:
aspell:
lang: en
d: en_US
ignore-case: true
run-together: true
run-together-min: 2
run-together-limit: 256
Expand Down
18 changes: 18 additions & 0 deletions src/engine/openrpc/methods/capabilities.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- name: engine_exchangeCapabilities
summary: Exchanges list of supported Engine API methods
externalDocs:
description: Method specification
url: https://github.com/ethereum/execution-apis/blob/main/src/engine/common.md#engine_exchangecapabilities
params:
- name: Consensus client methods
required: true
schema:
type: array
items:
type: string
result:
name: Execution client methods
schema:
type: array
items:
type: string
46 changes: 46 additions & 0 deletions src/engine/openrpc/methods/forkchoice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
- name: engine_forkchoiceUpdatedV1
summary: Updates the forkchoice state
externalDocs:
description: Method specification
url: https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#engine_forkchoiceupdatedv1
params:
- name: Forkchoice state
required: true
schema:
$ref: '#/components/schemas/ForkchoiceStateV1'
- name: Payload attributes
required: false
schema:
$ref: '#/components/schemas/PayloadAttributesV1'
result:
name: Response object
schema:
$ref: '#/components/schemas/ForkchoiceUpdatedResponseV1'
errors:
- code: -38002
message: Invalid forkchoice state
- code: -38003
message: Invalid payload attributes
- name: engine_forkchoiceUpdatedV2
summary: Updates the forkchoice state
externalDocs:
description: Method specification
url: https://github.com/ethereum/execution-apis/blob/main/src/engine/shanghai.md#engine_forkchoiceupdatedv2
params:
- name: Forkchoice state
required: true
schema:
$ref: '#/components/schemas/ForkchoiceStateV1'
- name: Payload attributes
required: false
schema:
$ref: '#/components/schemas/PayloadAttributesV2'
result:
name: Response object
schema:
$ref: '#/components/schemas/ForkchoiceUpdatedResponseV1'
errors:
- code: -38002
message: Invalid forkchoice state
- code: -38003
message: Invalid payload attributes
123 changes: 123 additions & 0 deletions src/engine/openrpc/methods/payload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
- name: engine_newPayloadV1
summary: Runs execution payload validation
externalDocs:
description: Method specification
url: https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#engine_newpayloadv1
params:
- name: Execution payload
required: true
schema:
$ref: '#/components/schemas/ExecutionPayloadV1'
result:
name: Payload status
schema:
$ref: '#/components/schemas/PayloadStatusV1'
- name: engine_newPayloadV2
summary: Runs execution payload validation
externalDocs:
description: Method specification
url: https://github.com/ethereum/execution-apis/blob/main/src/engine/shanghai.md#engine_newpayloadv2
params:
- name: Execution payload
required: true
schema:
oneOf:
- $ref: '#/components/schemas/ExecutionPayloadV1'
- $ref: '#/components/schemas/ExecutionPayloadV2'
result:
name: Payload status
schema:
$ref: '#/components/schemas/PayloadStatusNoInvalidBlockHash'
errors:
- code: -32602
message: Invalid params
- name: engine_getPayloadV1
summary: Obtains execution payload from payload build process
externalDocs:
description: Method specification
url: https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#engine_getpayloadv1
params:
- name: Payload id
required: true
schema:
$ref: '#/components/schemas/bytes8'
result:
name: Execution payload
schema:
$ref: '#/components/schemas/ExecutionPayloadV1'
errors:
- code: -38001
message: Unknown payload
- name: engine_getPayloadV2
summary: Obtains execution payload from payload build process
externalDocs:
description: Method specification
url: https://github.com/ethereum/execution-apis/blob/main/src/engine/shanghai.md#engine_getpayloadv2
params:
- name: Payload id
required: true
schema:
$ref: '#/components/schemas/bytes8'
result:
name: Response object
schema:
type: object
required:
- executionPayload
- blockValue
properties:
executionPayload:
title: Execution payload
oneOf:
- $ref: '#/components/schemas/ExecutionPayloadV1'
- $ref: '#/components/schemas/ExecutionPayloadV2'
blockValue:
title: Expected fee value
$ref: '#/components/schemas/uint256'
errors:
- code: -38001
message: Unknown payload
- name: engine_getPayloadBodiesByHashV1
summary: Given block hashes returns bodies of the corresponding execution payloads
externalDocs:
description: Method specification
url: https://github.com/ethereum/execution-apis/blob/main/src/engine/shanghai.md#engine_getpayloadbodiesbyhashv1
params:
- name: Array of block hashes
required: true
schema:
type: array
items:
$ref: '#/components/schemas/hash32'
result:
name: Execution payload bodies
schema:
type: array
items:
$ref: '#/components/schemas/ExecutionPayloadBodyV1'
errors:
- code: -38004
message: Too large request
- name: engine_getPayloadBodiesByRangeV1
summary: Given a range of block numbers returns bodies of the corresponding execution payloads
externalDocs:
description: Method specification
url: https://github.com/ethereum/execution-apis/blob/main/src/engine/shanghai.md#engine_getpayloadbodiesbyrangev1
params:
- name: Starting block number
required: true
schema:
$ref: '#/components/schemas/uint64'
- name: Number of blocks to return
required: true
schema:
$ref: '#/components/schemas/uint64'
result:
name: Execution payload bodies
schema:
type: array
items:
$ref: '#/components/schemas/ExecutionPayloadBodyV1'
errors:
- code: -38004
message: Too large request
14 changes: 14 additions & 0 deletions src/engine/openrpc/methods/transition_configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- name: engine_exchangeTransitionConfigurationV1
summary: Exchanges transition configuration
externalDocs:
description: Method specification
url: https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#engine_exchangetransitionconfigurationv1
params:
- name: Consensus client configuration
required: true
schema:
$ref: '#/components/schemas/TransitionConfigurationV1'
result:
name: Execution client configuration
schema:
$ref: '#/components/schemas/TransitionConfigurationV1'
66 changes: 66 additions & 0 deletions src/engine/openrpc/schemas/forkchoice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
ForkchoiceStateV1:
title: Forkchoice state object V1
type: object
required:
- headBlockHash
- safeBlockHash
- finalizedBlockHash
properties:
headBlockHash:
title: Head block hash
$ref: '#/components/schemas/hash32'
safeBlockHash:
title: Safe block hash
$ref: '#/components/schemas/hash32'
finalizedBlockHash:
title: Finalized block hash
$ref: '#/components/schemas/hash32'
ForkchoiceUpdatedResponseV1:
title: Forkchoice updated response
type: object
required:
- payloadStatus
properties:
payloadStatus:
title: Payload status
$ref: '#/components/schemas/RestrictedPayloadStatusV1'
payloadId:
title: Payload id
$ref: '#/components/schemas/bytes8'
PayloadAttributesV1:
title: Payload attributes object V1
type: object
required:
- timestamp
- prevRandao
- suggestedFeeRecipient
properties:
timestamp:
title: Timestamp
$ref: '#/components/schemas/uint64'
prevRandao:
title: Previous randao value
$ref: '#/components/schemas/bytes32'
suggestedFeeRecipient:
title: Suggested fee recipient
$ref: '#/components/schemas/address'
PayloadAttributesV2:
title: Payload attributes object V2
type: object
required:
- timestamp
- prevRandao
- suggestedFeeRecipient
- withdrawals
properties:
timestamp:
$ref: '#/components/schemas/PayloadAttributesV1/properties/timestamp'
prevRandao:
$ref: '#/components/schemas/PayloadAttributesV1/properties/prevRandao'
suggestedFeeRecipient:
$ref: '#/components/schemas/PayloadAttributesV1/properties/suggestedFeeRecipient'
withdrawals:
title: Withdrawals
type: array
items:
$ref: '#/components/schemas/WithdrawalV1'
Loading