fix: return available light client updates instead of throwing on missing periods#8906
fix: return available light client updates instead of throwing on missing periods#8906lodekeeper wants to merge 4 commits intoChainSafe:unstablefrom
Conversation
Summary of ChangesHello @lodekeeper, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the robustness and compliance of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where getLightClientUpdatesByRange would fail if the requested range included periods without available updates. The change replaces Promise.all with a sequential loop to fetch updates, ensuring that available consecutive updates are returned as per the beacon API specification. While this fixes the bug, it introduces a performance degradation by fetching updates sequentially. I've suggested an alternative using Promise.allSettled to maintain parallel fetching while still correctly handling missing updates.
…sing periods When getLightClientUpdatesByRange is called with a range that extends beyond the current sync committee period, it returns a 500 error because Promise.all rejects when any period throws 'No partialUpdate available'. Per the beacon API spec, servers 'MUST respond with at least the earliest known result within the requested range, and MUST send results in consecutive order (by period)'. Changes: - getUpdate() now throws LightClientServerError(RESOURCE_UNAVAILABLE) instead of generic Error, consistent with other light client methods - REST API handler skips leading unavailable periods to find the earliest known result, then collects consecutive updates until a gap is hit. Only catches RESOURCE_UNAVAILABLE; unexpected errors are rethrown. Returns empty array (not 500) if no updates exist in range. - P2P req/resp handler stops yielding gracefully on unavailable periods instead of throwing RESOURCE_UNAVAILABLE error response Closes ChainSafe#8902
df6317e to
bf87869
Compare
|
/gemini review |
packages/beacon-node/src/network/reqresp/handlers/lightClientUpdatesByRange.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Code Review
The pull request correctly implements the logic to return available light client updates instead of failing on missing periods, adhering to the beacon API specification. The handling of leading gaps and consecutive results is well-implemented in both REST and P2P handlers. The main area for improvement is the performance of the REST API handler, which currently processes database requests sequentially.
Description
When
getLightClientUpdatesByRangeis called with a range that extends beyond the current sync committee period (e.g.,start_period=1172&count=128where 1172 is the latest period), it returns a 500 error becausePromise.allrejects when any period throwsNo partialUpdate available.Per the beacon API spec:
Changes
getUpdate()— consistent error type:LightClientServerError(RESOURCE_UNAVAILABLE)instead of genericError, consistent with all other light client server methods (getBootstrap,getCommitteeRoot)REST API handler (
/eth/v1/beacon/light_client/updates):Promise.allwith sequential iterationRESOURCE_UNAVAILABLE; unexpected errors are rethrown (no silent swallowing)P2P req/resp handler (
light_client_updates_by_range):RESOURCE_UNAVAILABLEerror responseBefore
After
Closes #8902
Note
This PR was authored with AI assistance 🤖