Skip to content

Commit

Permalink
Add finalized flag to chain data requests (#254)
Browse files Browse the repository at this point in the history
Whether or not a request pertains to the finalized section of the chain
(per the view of the client fork choice) is somewhat cumbersome to
discover.

This PR adds a boolean that allows clients to distinguish a response
that has been finalized and thus is unlikely to change from one that may
still change over time (specially when using slot-based requests).

A flag like this can also be used for the purpose of verifying that a
checkpoint root indeed is part of chain history and is likely to remain
as such, as discussed in
#226

* fix dots

Co-authored-by: Paul Harris <paul.harris@consensys.net>
  • Loading branch information
arnetheduck and rolfyone authored Nov 9, 2022
1 parent f597910 commit b3c4def
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 4 deletions.
4 changes: 3 additions & 1 deletion apis/beacon/blocks/attestations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ get:
in: path
required: true
$ref: '../../../beacon-node-oapi.yaml#/components/parameters/BlockId'

responses:
"200":
description: Success
Expand All @@ -21,6 +21,8 @@ get:
properties:
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
type: array
items:
Expand Down
2 changes: 2 additions & 0 deletions apis/beacon/blocks/blinded_block.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ get:
example: "phase0"
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
oneOf:
- $ref: "../../../beacon-node-oapi.yaml#/components/schemas/SignedBeaconBlock"
Expand Down
4 changes: 3 additions & 1 deletion apis/beacon/blocks/block.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ get:
example: "phase0"
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
oneOf:
- $ref: "../../../beacon-node-oapi.yaml#/components/schemas/SignedBeaconBlock"
Expand All @@ -37,7 +39,7 @@ get:
- $ref: "../../../beacon-node-oapi.yaml#/components/schemas/Capella.SignedBeaconBlock"
application/octet-stream:
schema:

description: "SSZ serialized block bytes. Use Accept header to choose this response type"
"400":
description: "The block ID supplied could not be parsed"
Expand Down
2 changes: 2 additions & 0 deletions apis/beacon/blocks/header.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ get:
properties:
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
type: object
properties:
Expand Down
4 changes: 3 additions & 1 deletion apis/beacon/blocks/headers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ get:
allOf:
- $ref: "../../../beacon-node-oapi.yaml#/components/schemas/Root"
- example: ""

responses:
"200":
description: Success
Expand All @@ -31,6 +31,8 @@ get:
properties:
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
type: array
items:
Expand Down
2 changes: 2 additions & 0 deletions apis/beacon/blocks/root.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ get:
properties:
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
type: object
properties:
Expand Down
2 changes: 2 additions & 0 deletions apis/beacon/states/committee.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ get:
properties:
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
type: array
items:
Expand Down
2 changes: 2 additions & 0 deletions apis/beacon/states/finality_checkpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ get:
properties:
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
type: object
properties:
Expand Down
2 changes: 2 additions & 0 deletions apis/beacon/states/fork.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ get:
properties:
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
$ref: '../../../beacon-node-oapi.yaml#/components/schemas/Fork'

Expand Down
2 changes: 2 additions & 0 deletions apis/beacon/states/randao.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ get:
properties:
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
type: object
properties:
Expand Down
2 changes: 2 additions & 0 deletions apis/beacon/states/root.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ get:
properties:
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
type: object
properties:
Expand Down
2 changes: 2 additions & 0 deletions apis/beacon/states/sync_committees.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ get:
properties:
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
$ref: '../../../beacon-node-oapi.yaml#/components/schemas/Altair.SyncCommittee'

Expand Down
2 changes: 2 additions & 0 deletions apis/beacon/states/validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ get:
properties:
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
$ref: '../../../beacon-node-oapi.yaml#/components/schemas/ValidatorResponse'
"400":
Expand Down
2 changes: 2 additions & 0 deletions apis/beacon/states/validator_balances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ get:
properties:
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
type: array
items:
Expand Down
2 changes: 2 additions & 0 deletions apis/beacon/states/validators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ get:
properties:
execution_optimistic:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
type: array
items:
Expand Down
2 changes: 2 additions & 0 deletions apis/debug/state.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ get:
example: "phase0"
execution_optimistic:
$ref: "../../beacon-node-oapi.yaml#/components/schemas/ExecutionOptimistic"
finalized:
$ref: "../../beacon-node-oapi.yaml#/components/schemas/Finalized"
data:
oneOf:
- $ref: '../../beacon-node-oapi.yaml#/components/schemas/BeaconState'
Expand Down
2 changes: 1 addition & 1 deletion apis/validator/duties/attester.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ post:
- event.block otherwise
The dependent_root value is `get_block_root_at_slot(state, compute_start_slot_at_epoch(epoch - 1) - 1)`
or the genesis block root in the case of underflow."
parameters:
Expand Down
2 changes: 2 additions & 0 deletions beacon-node-oapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ components:
$ref: './types/primitive.yaml#/DependentRoot'
ExecutionOptimistic:
$ref: './types/primitive.yaml#/ExecutionOptimistic'
Finalized:
$ref: './types/primitive.yaml#/Finalized'
Root:
$ref: './types/primitive.yaml#/Root'
Hex:
Expand Down
6 changes: 6 additions & 0 deletions types/primitive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ ExecutionOptimistic:
- example: false
- description: "True if the response references an unverified execution payload. Optimistic information may be invalidated at a later time. If the field is not present, assume the False value."

Finalized:
allOf:
- type: boolean
- example: false
- description: "True if the response references the finalized history of the chain, as determined by fork choice. If the field is not present, additional calls are necessary to compare the epoch of the requested information with the finalized checkpoint."

Root:
type: string
format: hex
Expand Down

0 comments on commit b3c4def

Please sign in to comment.