-
Notifications
You must be signed in to change notification settings - Fork 174
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
Add lightclient routes #181
Conversation
@@ -73,6 +74,17 @@ get: | |||
value: | | |||
event: contribution_and_proof | |||
data: {"message": {"aggregator_index": "997", "contribution": {"slot": "168097", "beacon_block_root": "0x56f1fd4262c08fa81e27621c370e187e621a67fc80fe42340b07519f84b42ea1", "subcommittee_index": "0", "aggregation_bits": "0xffffffffffffffffffffffffffffffff", "signature": "0x85ab9018e14963026476fdf784cc674da144b3dbdb47516185438768774f077d882087b90ad642469902e782a8b43eed0cfc1b862aa9a473b54c98d860424a702297b4b648f3f30bdaae8a8b7627d10d04cb96a2cc8376af3e54a9aa0c8145e3"}, "selection_proof": "0x87c305f04bfe5db27c2b19fc23e00d7ac496ec7d3e759cbfdd1035cb8cf6caaa17a36a95a08ba78c282725e7b66a76820ca4eb333822bd399ceeb9807a0f2926c67ce67cfe06a0b0006838203b493505a8457eb79913ce1a3bcd1cc8e4ef30ed"}, "signature": "0xac118511474a94f857300b315c50585c32a713e4452e26a6bb98cdb619936370f126ed3b6bb64469259ee92e69791d9e12d324ce6fd90081680ce72f39d85d50b0ff977260a8667465e613362c6d6e6e745e1f9323ec1d6f16041c4e358839ac"} | |||
lightclient_head_update: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a need for _update
here; the event is, by definition, an update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, tho I'm unsure if lightclient_head
can also be confusing since you can get multiple events for the same head which is not the same behavior as the head
event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was called lightlcient_head_update
because the data structure emitted is called a LightClientHeadUpdate
somewhere.
Similar to the LightClientUpdate
in the specs.
Not saying its a great name, just saying..
The node has received a new or better lightclient head update. `header` is the block header signed by `sync_aggregate`. | ||
Updates may be collected via | ||
- Next block's syncAggregate field | ||
- Aggregating messages from gossip topic `sync_committee_contribution_and_proof` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this considered safe, if this information is not yet in a (voted upon) block? Is there any way of knowing the level of finality of the provided head?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this considered safe, if this information is not yet in a (voted upon) block?
Yes, adding the SyncAggregate is only useful to give on-chain incentives to sync committee members. Gathering the data from gossip topics is identical.
Is there any way of knowing the level of finality of the provided head?
Not really, the main data points lightclients can rely on are:
- participation of this SyncAggregate
- if the block is finalized or not
apis/lightclient/head_update.yaml
Outdated
summary: Get latest best head update | ||
description: | | ||
Returns the latest best head update available. Clients should use the SSE type `lightclient_head_update` | ||
unless to get the very first head update after syncing, or if SSE are not supported by the server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Events are part of the spec so the latter part is not a relevant comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the latter part is not a relevant comment.
Do you refer to the part where SSE may not be supported by the server? At least Lodestar allows to disable the events namespace individually. Also some reverse proxies may not support SSE depending on their buffering configuration.
apis/lightclient/proof.yaml
Outdated
"200": | ||
description: Success | ||
content: | ||
application/octet-stream: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a JSON response here as well. This will also give a location to explain the structure of the multiproof.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSON representation of this format is widely inefficient. Since JSON is the default I'll argue into only offering application/octet-stream
to force consumers to use the efficient path
@@ -96,6 +98,15 @@ paths: | |||
/eth/v1/debug/beacon/heads: | |||
$ref: './apis/debug/heads.yaml' | |||
|
|||
/eth/v1/lightclient/committee_updates: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API has historically defined committee
as a beacon committee, and sync_committee
as a sync committee, so I believe you want the latter here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if it's scoped in the lightclient namespace is there a risk of confusion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support using sync_committee
for clarity here.
This is great as a draft, but believe it's good to settle on a p2p protocol before enshrining / merging it such that implementations don't have to maintain two views of the same data that are slightly different - this work has started in ethereum/consensus-specs#2267 and should be completed first - we are in the process of implementing it and will be providing updates soon. The long-term idea here would be that beacon nodes serve light client data via p2p just like they serve blocks which enables a very fast consensus sync in general and where serving the data would be part of the standard feature set offered by clients via P2P (to later be mirrored in the REST API). |
A few generic questions:
|
RE @mcdee
Good point! Tho at least one block ID value is not suitable "genesis". Also if you use head you will have to guess the block_root if you want to validate the merkle proof. If you want a SyncCommittee trusting the node you can just query
The config, genesis_time and genesis_validators_root of the network should be known ahead of time by the lightclient consumer. Then you can compute sync periods from slots. Using sync periods allows to put a cache layer in front of the node to speed up responses. If using slots, the same response can be requested with way more different requests.
This can be easily computed knowing the config, genesis_time and genesis_validators_root of the network |
RE: @arnetheduck
Thanks! Tho I believe there's value in iterating both publicly at the same time. Lodestar will tackle p2p next so happy to give feedback on ethereum/consensus-specs#2267 then |
Will cc myself and @ryanio in here. |
Feedback from discussions at Devconnect AMS: See libp2p PR discussion: ethereum/consensus-specs#2802 (comment)
|
Would also change from |
Adopts the light client data REST API used by Lodestar as defined in ethereum/beacon-APIs#181 with a v0 suffix. Requests: - `/eth/v0/light_client/bootstrap/{block_root}` - `/eth/v0/light_client/updates?from={from}&to={to}` - `/eth/v0/light_client/finality_update` - `/eth/v0/light_client/optimistic_update` HTTP Server-Sent Events (SSE): - `light_client_finality_update_v0` - `light_client_optimistic_update_v0` More work is needed to adopt the proofs endpoint, it is not included.
Adopts the light client data REST API used by Lodestar as defined in ethereum/beacon-APIs#181 with a v0 suffix. Requests: - `/eth/v0/light_client/bootstrap/{block_root}` - `/eth/v0/light_client/updates?from={from}&to={to}` - `/eth/v0/light_client/finality_update` - `/eth/v0/light_client/optimistic_update` HTTP Server-Sent Events (SSE): - `light_client_finality_update_v0` - `light_client_optimistic_update_v0` More work is needed to adopt the proofs endpoint, it is not included.
Adopts the light client data REST API used by Lodestar as defined in ethereum/beacon-APIs#181 with a v0 suffix. Requests: - `/eth/v0/light_client/bootstrap/{block_root}` - `/eth/v0/light_client/updates?from={from}&to={to}` - `/eth/v0/light_client/finality_update` - `/eth/v0/light_client/optimistic_update` HTTP Server-Sent Events (SSE): - `light_client_finality_update_v0` - `light_client_optimistic_update_v0` More work is needed to adopt the proofs endpoint, it is not included.
Adopts the light client data REST API used by Lodestar as defined in ethereum/beacon-APIs#181 with a v0 suffix. Requests: - `/eth/v0/light_client/bootstrap/{block_root}` - `/eth/v0/light_client/updates?from={from}&to={to}` - `/eth/v0/light_client/finality_update` - `/eth/v0/light_client/optimistic_update` HTTP Server-Sent Events (SSE): - `light_client_finality_update_v0` - `light_client_optimistic_update_v0` More work is needed to adopt the proofs endpoint, it is not included.
Adopts the light client data REST API used by Lodestar as defined in ethereum/beacon-APIs#181 with a v0 suffix. Requests: - `/eth/v0/light_client/bootstrap/{block_root}` - `/eth/v0/light_client/updates?start_period={start}&count={count}` - `/eth/v0/light_client/finality_update` - `/eth/v0/light_client/optimistic_update` HTTP Server-Sent Events (SSE): - `light_client_finality_update_v0` - `light_client_optimistic_update_v0` More work is needed to adopt the proofs endpoint, it is not included.
Adopts the light client data REST API used by Lodestar as defined in ethereum/beacon-APIs#181 with a v0 suffix. Requests: - `/eth/v0/beacon/light_client/bootstrap/{block_root}` - `/eth/v0/beacon/light_client/updates?start_period={start_period}&count={count}` - `/eth/v0/beacon/light_client/finality_update` - `/eth/v0/beacon/light_client/optimistic_update` HTTP Server-Sent Events (SSE): - `light_client_finality_update_v0` - `light_client_optimistic_update_v0` More work is needed to adopt the proofs endpoint, it is not included.
Adopts the light client data REST API used by Lodestar as defined in ethereum/beacon-APIs#181 with a v0 suffix. Requests: - `/eth/v0/beacon/light_client/bootstrap/{block_root}` - `/eth/v0/beacon/light_client/updates?start_period={start_period}&count={count}` - `/eth/v0/beacon/light_client/finality_update` - `/eth/v0/beacon/light_client/optimistic_update` HTTP Server-Sent Events (SSE): - `light_client_finality_update_v0` - `light_client_optimistic_update_v0` More work is needed to adopt the proofs endpoint, it is not included.
Adopted with a v0 suffix in Nimbus (without proofs endpoint) Requests:
HTTP Server-Sent Events (SSE):
|
* adopt LC REST API with v0 suffix (without proofs) Adopts the light client data REST API used by Lodestar as defined in ethereum/beacon-APIs#181 with a v0 suffix. Requests: - `/eth/v0/beacon/light_client/bootstrap/{block_root}` - `/eth/v0/beacon/light_client/updates?start_period={start_period}&count={count}` - `/eth/v0/beacon/light_client/finality_update` - `/eth/v0/beacon/light_client/optimistic_update` HTTP Server-Sent Events (SSE): - `light_client_finality_update_v0` - `light_client_optimistic_update_v0` More work is needed to adopt the proofs endpoint, it is not included. * initialize event queues * register event topics
It would be useful if all requests support returning SSZ data if the |
The format is not that simple, as each element could be from different forks. The list does not solely contain On Gossipsub, this is solved by prepending the fork digest to each item (similar encoding as a SSZ union, but not processed as a SSZ union as some legacy endpoints also support having an empty fork digest to indicate phase0). Technically, you could also peek into the first 8 bytes of the SSZ response to determine Note that SSZ unions are not well-supported in all SSZ encoding libraries. (or only pseudo-supported with a type of 0). |
@etan-status something like this would be valuable for the beacon -> validator API too. Some previous discussion on how to handle fork versioning |
After discussing with @etan-status its best to separate the proof route into a different namespace TBD |
Introduces additional REST endpoints for light client sync, compatible with the libp2p specification defined in `ethereum/consensus-specs`: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/p2p-interface.md Endpoints are defined to be fork-aware to allow potential optimizations such as including EL block hash into `BeaconBlockHeader` in the future. The `getLightClientUpdatesByRange` endpoint is a new kind of endpoint, as it introduces the concept of list responses. Each list item could potentially be of a different fork. Likewise, for the events stream, the fork may update between events. Both the list response and the event are additionall wrapped with a per-item `version` indicator in JSON. For SSZ, the list items are encoded as length/version/payload triples. Note that the events endpoint does not support the SSZ format. This builds on prior work from: - @dapplion at ethereum#181 The proof endpoint in that PR is out-of-scope here, but could be useful as part of the debug API as an `eth_getProof` equivalent for CL data.
Introduces additional REST endpoints for light client sync, compatible with the libp2p specification defined in `ethereum/consensus-specs`: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/p2p-interface.md Endpoints are defined to be fork-aware to allow potential optimizations such as including EL block hash into `BeaconBlockHeader` in the future. The `getLightClientUpdatesByRange` endpoint is a new kind of endpoint, as it introduces the concept of list responses. Each list item could potentially be of a different fork. Likewise, for the events stream, the fork may update between events. Both the list response and the event are additionall wrapped with a per-item `version` indicator in JSON. For SSZ, the list items are encoded as length/version/payload triples. Note that the events endpoint does not support the SSZ format. This builds on prior work from: - @dapplion at ethereum#181 The proof endpoint in that PR is out-of-scope here, but could be useful as part of the debug API as an `eth_getProof` equivalent for CL data.
Introduces additional REST endpoints for light client sync, compatible with the libp2p specification defined in `ethereum/consensus-specs`: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/p2p-interface.md Endpoints are defined to be fork-aware to allow potential optimizations such as including EL block hash into `BeaconBlockHeader` in the future. The `getLightClientUpdatesByRange` endpoint is a new kind of endpoint, as it introduces the concept of list responses. Each list item could potentially be of a different fork. Likewise, for the events stream, the fork may update between events. Both the list response and the event are additionall wrapped with a per-item `version` indicator in JSON. For SSZ, the list items are encoded as length/version/payload triples. Note that the events endpoint does not support the SSZ format. This builds on prior work from: - @dapplion at ethereum#181 The proof endpoint in that PR is out-of-scope here, but could be useful as part of the debug API as an `eth_getProof` equivalent for CL data.
Proofs endpoint should be tackled separately |
Introduces additional REST endpoints for light client sync, compatible with the libp2p specification defined in `ethereum/consensus-specs`: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/p2p-interface.md Endpoints are defined to be fork-aware to allow potential optimizations such as including EL block hash into `BeaconBlockHeader` in the future. The `getLightClientUpdatesByRange` endpoint is a new kind of endpoint, as it introduces the concept of list responses. Each list item could potentially be of a different fork. Likewise, for the events stream, the fork may update between events. Both the list response and the event are additionall wrapped with a per-item `version` indicator in JSON. For SSZ, the list items are encoded as length/version/payload triples. Note that the events endpoint does not support the SSZ format. This builds on prior work from: - @dapplion at ethereum/beacon-APIs#181 The proof endpoint in that PR is out-of-scope here, but could be useful as part of the debug API as an `eth_getProof` equivalent for CL data.
Adds minimal set of lightclient routes to super a server-based trust-less censorable lightclient.
Sample usage flow for these APIs:
/eth/v1/lightclient/snapshot/{block_root}
to get an initial SyncCommittee/eth/v1/lightclient/committee_updates
4.1. Subscribe to
/eth/v1/events?topics=lightclient_head_update
4.2. If SSE are not available or to get the first head event faster, poll
/eth/v1/lightclient/head_update
/eth/v1/lightclient/committee_updates
For a sample implementation of this routes see:
Live demo: https://lodestar-light-client-demo.netlify.app