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

Endpoint for EIP-4881 Deposit Contract Snapshot #245

Merged
merged 4 commits into from
Nov 22, 2022
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
34 changes: 34 additions & 0 deletions apis/beacon/deposit_snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
get:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be support for downloading historical snapshots? ie when checkpoint-syncing, one will want to have a matching snapshot to the state that's being synced, which may or may not (due to race conditions or checkpoint age choice) be the same as the snapshot being served by "default"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the main idea is just to get a starting point rather than download the whole deposit log, so I think there's probably not a need currently to get historical snapshots...

operationId: getDepositSnapshot
summary: "Get Deposit Tree Snapshot"
description: |
Retrieve [EIP-4881](https://eips.ethereum.org/EIPS/eip-4881) Deposit Tree Snapshot.
Depending on `Accept` header it can be returned either as json or as bytes serialzed by SSZ
tags:
- Beacon
responses:
"200":
description: Success
content:
application/json:
schema:
type: object
title: GetDepositSnapshotResponse
properties:
data:
$ref: '../../beacon-node-oapi.yaml#/components/schemas/DepositSnapshotResponse'
application/octet-stream:
schema:
description: "SSZ serialized block bytes. Use Accept header to choose this response type"
"404":
description: "No Finalized Snapshot Available"
content:
application/json:
schema:
allOf:
- $ref: "../../beacon-node-oapi.yaml#/components/schemas/ErrorMessage"
- example:
code: 404
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use 404 for when the "thing" is known not to exist (for example an empty slot) - a different code would probably be useful here for ephemeral error conditions (503/syncing for example)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do tend to agree 404 isn't ideal (a server with a route that is missing is also 404) - even if it was a 400, or potentially 503 might work... I'll see if i can get some more opinions on this one.

message: "No Finalized Snapshot Available"
"500":
$ref: '../../beacon-node-oapi.yaml#/components/responses/InternalError'
4 changes: 4 additions & 0 deletions beacon-node-oapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ paths:
$ref: "./apis/beacon/blocks/root.yaml"
/eth/v1/beacon/blocks/{block_id}/attestations:
$ref: "./apis/beacon/blocks/attestations.yaml"
/eth/v1/beacon/deposit_snapshot:
$ref: "./apis/beacon/deposit_snapshot.yaml"
/eth/v1/beacon/rewards/blocks/{block_id}:
$ref: "./apis/beacon/rewards/blocks.yaml"
/eth/v1/beacon/rewards/attestations/{epoch}:
Expand Down Expand Up @@ -193,6 +195,8 @@ components:
$ref: './types/state.yaml#/BeaconState'
BeaconBlock:
$ref: './types/block.yaml#/BeaconBlock'
DepositSnapshotResponse:
$ref: './types/api.yaml#/DepositSnapshotResponse'
SignedBeaconBlock:
$ref: './types/block.yaml#/SignedBeaconBlock'
SignedBeaconBlockHeader:
Expand Down
19 changes: 19 additions & 0 deletions types/api.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# API specific types

DepositSnapshotResponse:
type: object
properties:
finalized:
type: array
items:
allOf:
- $ref: './primitive.yaml#/Root'
minItems: 3
maxItems: 3
deposit_root:
$ref: './primitive.yaml#/Root'
deposit_count:
$ref: './primitive.yaml#/Uint64'
execution_block_hash:
$ref: './primitive.yaml#/Root'
execution_block_height:
$ref: './primitive.yaml#/Uint64'

ValidatorResponse:
type: object
properties:
Expand Down