-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
Serve Lightclient related data via p2p #4365
Conversation
…ate via p2p resp/req
Performance Report✔️ no performance regression detected Full benchmark results
|
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 know its not quite ready, just giving this a light pass
Looks good so far
requestBody: altair.LightClientUpdateByRangeRequest, | ||
chain: IBeaconChain | ||
): AsyncIterable<altair.LightClientUpdate[]> { | ||
yield await chain.lightClientServer.getUpdates(requestBody.startPeriod, requestBody.count); |
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.
should be wrapped in try/catch?
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 intentionally left out the try/catch since the spec did not explicitly say RESOURCE_UNAVAILABLE
should be returned as it did in the other cases. I will look into this again, and if need be, make a PR to the spec.
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.
it makes sense to have RESOURCE_UNAVAILABLE
response, may be the spec just missed it
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.
wrapped in try/catch and made a PR to update the spec 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.
Alternative is to just return an empty result, or omit the periods that are unavailable, same as for beaconBlocksByRange / beaconBlocksByRoot.
…nt_optimistic_update available via the gossip domain
private waitOneThirdOfSlot = async (slot: number): Promise<void> => { | ||
const minPubTime = computeTimeAtSlot(this.config, slot, this.chain.genesisTime) + this.config.SECONDS_PER_SLOT / 3; | ||
const waitTime = minPubTime - Date.now() / 1000; | ||
await sleep(waitTime, this.signal); |
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.
sleep takes miliseconds, looks like it's passing seconds which would cause the sleep to wait 1000 times less than expected. Fixing on a commit locally, will push soon
I pushed some commits on top addressing some unaddressed comments to help expedite this. |
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.
LGMT, some comments for future work:
- Do not re-calculate
light_client_updates_by_range
replies every time. Store in DB an SSZ compressed version of that data and just stream. This optimization should be done also for block by range - Consider moving lightclient class outside of Chain so it has access to network. It's now really something like the sync class
- Should the lightclient server validate messages before broadcasting?
- Emit logic from the lightclient server provider probably requires more validation
- Apply
is_better_update
consistently in our lightclient data generator code, ref https://github.com/ethereum/consensus-specs/blob/be3c774069e16e89145660be511c1b183056017e/specs/altair/light-client/sync-protocol.md#is_better_update
Motivation
Adds ability for a lodestar full node to serve light client related data via p2p. Implements the Altair Light Client -- Networking spec
Description
Confirmed the new gossip messages get's published. Also confirmed that changes did not break existing lightclient which uses the REST endpoint and SSE:
Using a minimalist libp2p node with gossip enabled (see here), the optimistic update message got picked up:
Consuming the light client related data will be implemented in #4618
Partially closes #3077