From 81534145b525655898d74b72c651e60ce26706aa Mon Sep 17 00:00:00 2001
From: NC <17676176+ensi321@users.noreply.github.com>
Date: Wed, 21 Aug 2024 10:57:15 +0800
Subject: [PATCH] feat: electra light client
---
apis/beacon/light_client/bootstrap.yaml | 1 +
apis/beacon/light_client/finality_update.yaml | 1 +
.../light_client/optimistic_update.yaml | 1 +
apis/beacon/light_client/updates.yaml | 4 +-
beacon-node-oapi.yaml | 8 ++
types/electra/light_client.yaml | 75 +++++++++++++++++++
6 files changed, 89 insertions(+), 1 deletion(-)
create mode 100644 types/electra/light_client.yaml
diff --git a/apis/beacon/light_client/bootstrap.yaml b/apis/beacon/light_client/bootstrap.yaml
index 89b7f1fd..ebf86c7a 100644
--- a/apis/beacon/light_client/bootstrap.yaml
+++ b/apis/beacon/light_client/bootstrap.yaml
@@ -32,6 +32,7 @@ get:
anyOf:
- $ref: '../../../beacon-node-oapi.yaml#/components/schemas/Altair.LightClientBootstrap'
- $ref: '../../../beacon-node-oapi.yaml#/components/schemas/Capella.LightClientBootstrap'
+ - $ref: '../../../beacon-node-oapi.yaml#/components/schemas/Electra.LightClientBootstrap'
application/octet-stream:
schema:
description: "SSZ serialized `LightClientBootstrap` bytes. Use Accept header to choose this response type"
diff --git a/apis/beacon/light_client/finality_update.yaml b/apis/beacon/light_client/finality_update.yaml
index c1a395d3..4c06fb8a 100644
--- a/apis/beacon/light_client/finality_update.yaml
+++ b/apis/beacon/light_client/finality_update.yaml
@@ -27,6 +27,7 @@ get:
anyOf:
- $ref: '../../../beacon-node-oapi.yaml#/components/schemas/Altair.LightClientFinalityUpdate'
- $ref: '../../../beacon-node-oapi.yaml#/components/schemas/Capella.LightClientFinalityUpdate'
+ - $ref: '../../../beacon-node-oapi.yaml#/components/schemas/Electra.LightClientFinalityUpdate'
application/octet-stream:
schema:
description: "SSZ serialized `LightClientFinalityUpdate` bytes. Use Accept header to choose this response type"
diff --git a/apis/beacon/light_client/optimistic_update.yaml b/apis/beacon/light_client/optimistic_update.yaml
index dea560e5..ddb29b19 100644
--- a/apis/beacon/light_client/optimistic_update.yaml
+++ b/apis/beacon/light_client/optimistic_update.yaml
@@ -27,6 +27,7 @@ get:
anyOf:
- $ref: '../../../beacon-node-oapi.yaml#/components/schemas/Altair.LightClientOptimisticUpdate'
- $ref: '../../../beacon-node-oapi.yaml#/components/schemas/Capella.LightClientOptimisticUpdate'
+ - $ref: '../../../beacon-node-oapi.yaml#/components/schemas/Electra.LightClientOptimisticUpdate'
application/octet-stream:
schema:
description: "SSZ serialized `LightClientOptimisticUpdate` bytes. Use Accept header to choose this response type"
diff --git a/apis/beacon/light_client/updates.yaml b/apis/beacon/light_client/updates.yaml
index 4823d071..1ed3fdf1 100644
--- a/apis/beacon/light_client/updates.yaml
+++ b/apis/beacon/light_client/updates.yaml
@@ -37,6 +37,7 @@ get:
anyOf:
- $ref: '../../../beacon-node-oapi.yaml#/components/schemas/Altair.LightClientUpdate'
- $ref: '../../../beacon-node-oapi.yaml#/components/schemas/Capella.LightClientUpdate'
+ - $ref: '../../../beacon-node-oapi.yaml#/components/schemas/Electra.LightClientUpdate'
application/octet-stream:
schema:
description: |
@@ -60,7 +61,8 @@ get:
| ------------------------------------------------------------------- | ------------------------------------- |
| `GENESIS_FORK_VERSION` | n/a |
| `ALTAIR_FORK_VERSION` through `BELLATRIX_FORK_VERSION` | `altair.LightClientUpdate` |
- | `CAPELLA_FORK_VERSION` and later | `capella.LightClientUpdate` |
+ | `CAPELLA_FORK_VERSION` through `DENEB_FORK_VERSION` | `capella.LightClientUpdate` |
+ | `ELECTRA_FORK_VERSION` and later | `electra.LightClientUpdate` |
"400":
description: Malformed or missing request parameter
content:
diff --git a/beacon-node-oapi.yaml b/beacon-node-oapi.yaml
index c3608a84..669c1703 100644
--- a/beacon-node-oapi.yaml
+++ b/beacon-node-oapi.yaml
@@ -387,6 +387,14 @@ components:
$ref: './types/electra/attester_slashing.yaml#/Electra/AttesterSlashing'
Electra.SignedAggregateAndProof:
$ref: './types/electra/validator.yaml#/Electra/SignedAggregateAndProof'
+ Electra.LightClientBootstrap:
+ $ref: './types/electra/light_client.yaml#/Electra/LightClientBootstrap'
+ Electra.LightClientUpdate:
+ $ref: './types/electra/light_client.yaml#/Electra/LightClientUpdate'
+ Electra.LightClientFinalityUpdate:
+ $ref: './types/electra/light_client.yaml#/Electra/LightClientFinalityUpdate'
+ Electra.LightClientOptimisticUpdate:
+ $ref: './types/electra/light_client.yaml#/Electra/LightClientOptimisticUpdate'
Node:
$ref: './types/fork_choice.yaml#/Node'
ExtraData:
diff --git a/types/electra/light_client.yaml b/types/electra/light_client.yaml
new file mode 100644
index 00000000..efadea2c
--- /dev/null
+++ b/types/electra/light_client.yaml
@@ -0,0 +1,75 @@
+Electra:
+ FinalityBranch:
+ type: array
+ items:
+ $ref: '../primitive.yaml#/Root'
+ description: "Merkle proof consisting of [`log2trunc(FINALIZED_ROOT_GINDEX_ELECTRA])`](https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/light-client/sync-protocol.md#constants) roots"
+ minItems: 7
+ maxItems: 7
+ CurrentSyncCommitteeBranch:
+ type: array
+ items:
+ $ref: '../primitive.yaml#/Root'
+ description: "Merkle proof consisting of [`log2trunc(CURRENT_SYNC_COMMITTEE_GINDEX_ELECTRA])`](https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/light-client/sync-protocol.md#constants) roots"
+ minItems: 6
+ maxItems: 6
+ NextSyncCommitteeBranch:
+ type: array
+ items:
+ $ref: '../primitive.yaml#/Root'
+ description: "Merkle proof consisting of [`log2trunc(NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA])`](https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/light-client/sync-protocol.md#constants) roots"
+ minItems: 6
+ maxItems: 6
+
+ LightClientBootstrap:
+ type: object
+ required: [header, current_sync_committee, current_sync_committee_branch]
+ properties:
+ header:
+ $ref: '../capella/light_client.yaml#/Capella/LightClientHeader'
+ current_sync_committee:
+ $ref: '../altair/sync_committee.yaml#/Altair/SyncCommittee'
+ current_sync_committee_branch:
+ $ref: '#/Electra/CurrentSyncCommitteeBranch'
+ LightClientUpdate:
+ type: object
+ required: [attested_header, next_sync_committee, next_sync_committee_branch, finalized_header, finality_branch, sync_aggregate, signature_slot]
+ properties:
+ attested_header:
+ $ref: '../capella/light_client.yaml#/Capella/LightClientHeader'
+ next_sync_committee:
+ $ref: '../altair/sync_committee.yaml#/Altair/SyncCommittee'
+ next_sync_committee_branch:
+ $ref: '#/Electra/NextSyncCommitteeBranch'
+ finalized_header:
+ $ref: '../capella/light_client.yaml#/Capella/LightClientHeader'
+ finality_branch:
+ $ref: '#/Electra/FinalityBranch'
+ sync_aggregate:
+ $ref: '../altair/sync_aggregate.yaml#/Altair/SyncAggregate'
+ signature_slot:
+ $ref: '../primitive.yaml#/Uint64'
+ LightClientFinalityUpdate:
+ type: object
+ required: [attested_header, finalized_header, finality_branch, sync_aggregate, signature_slot]
+ properties:
+ attested_header:
+ $ref: '../capella/light_client.yaml#/Capella/LightClientHeader'
+ finalized_header:
+ $ref: '../capella/light_client.yaml#/Capella/LightClientHeader'
+ finality_branch:
+ $ref: '#/Electra/FinalityBranch'
+ sync_aggregate:
+ $ref: '../altair/sync_aggregate.yaml#/Altair/SyncAggregate'
+ signature_slot:
+ $ref: '../primitive.yaml#/Uint64'
+ LightClientOptimisticUpdate:
+ type: object
+ required: [attested_header, sync_aggregate, signature_slot]
+ properties:
+ attested_header:
+ $ref: '../capella/light_client.yaml#/Capella/LightClientHeader'
+ sync_aggregate:
+ $ref: '../altair/sync_aggregate.yaml#/Altair/SyncAggregate'
+ signature_slot:
+ $ref: '../primitive.yaml#/Uint64'