-
Notifications
You must be signed in to change notification settings - Fork 169
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
Define endpoints for light client sync #247
Conversation
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.
2338e1f
to
acc7526
Compare
If beacon light client provide def calculate_merkle_root(leaf: Bytes32, proof: Sequence[Bytes32], index: GeneralizedIndex) -> Root:
assert len(proof) == get_generalized_index_length(index)
for i, h in enumerate(proof):
if get_generalized_index_bit(index, i):
leaf = hash(h + leaf)
else:
leaf = hash(leaf + h)
return leaf |
Proofs are not specific to light clients, and should be introduced separately, e.g., as part of the They need a separate discussion as there are different possible designs regarding supported complexity and serialization formats. e.g., should it support querying "the last validator's balance" without knowing the number of validators / should it support querying multiple items at a time / should it support proofs for historic states. For the popular use case of EL block hash to have end-to-end proof of |
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.
Looks great!
Implements the latest proposal for providing LC data via REST, as of ethereum/beacon-APIs#247 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`
Implemented in Nimbus at status-im/nimbus-eth2#4213 with a Sample endpoint: |
Implements the latest proposal for providing LC data via REST, as of ethereum/beacon-APIs#247 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`
Only thought on this is that to be useful for light client purposes, it should not be put under the |
LGTM. Raised teku ticket for prioritisation. |
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.
Looks like plenty of approval to merge this...
The LC REST API has been merged into the ethereum/beacon-APIs specs: - ethereum/beacon-APIs#247 Update URLs to v1 and update REST tests. Note that REST tests do not start with Altair, so the tested BN will return empty / error responses.
The LC REST API has been merged into the ethereum/beacon-APIs specs: - ethereum/beacon-APIs#247 Update URLs to v1 and update REST tests. Note that REST tests do not start with Altair, so the tested BN will return empty / error responses.
Implements the latest proposal for providing LC data via REST, as of ethereum/beacon-APIs#247 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`
The LC REST API has been merged into the ethereum/beacon-APIs specs: - ethereum/beacon-APIs#247 Update URLs to v1 and update REST tests. Note that REST tests do not start with Altair, so the tested BN will return empty / error responses.
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.mdEndpoints 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-itemversion
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:
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.