fix(epbs): always serve post-CL state for checkpoint sync, never FULL - #9030
fix(epbs): always serve post-CL state for checkpoint sync, never FULL#9030lodekeeper wants to merge 6 commits into
Conversation
When epoch boundary slot 0 is missed (no block), the checkpoint state API could 404 even though the state existed in cache: Root cause: processSlotsToNearestCheckpoint (called by prepareNextSlot) cached the epoch boundary state using the head block's payload status (FULL). But getCheckpointPayloadStatus correctly reports EMPTY for missed slots (processSlot clears executionPayloadAvailability). The API forced EMPTY lookups, both the primary and defensive fallback searched for EMPTY, and the FULL variant in cache was never tried. Two fixes: 1. processSlotsToNearestCheckpoint: always cache post-Gloas epoch boundary states as EMPTY (false). processSlots() never processes payloads, so the result is always a post-CL block state regardless of the source block's payload status. 2. getStateResponseWithRegen: add opposite-variant fallback. When both forced EMPTY and original checkpoint status miss, try the opposite payload variant as a last resort before returning 404. Ref: ethereum/beacon-APIs#572 discussion (potuz, sproul, twoeths agree finalized/justified should always serve post-CL state)
Summary of ChangesHello, 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 resolves a critical bug in the beacon node's API where requests for finalized/justified checkpoint states would incorrectly return a 404 error when an epoch boundary slot (specifically slot 0 of an epoch) was missed. The root cause was an inconsistency in how epoch boundary states were cached and retrieved, particularly concerning their payload status (FULL vs. EMPTY). The changes ensure that states are cached with the correct payload status and that the API has a robust fallback to find the state even if the initial lookup variant is incorrect, thereby improving the reliability of checkpoint state serving. 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 effectively addresses a bug where checkpoint state APIs would return a 404 for missed epoch boundary slots. The two-pronged fix is sound: correctly caching post-Gloas epoch boundary states as EMPTY and adding a fallback mechanism to try the opposite payload variant in getStateResponseWithRegen. The changes are logical and well-supported by new unit tests that validate both the fix and the original bug scenario. My only concern is the removal of existing tests for an unrelated function, which I've flagged in a specific comment.
Restores the original getStateValidatorIndex unit tests that were accidentally dropped when rewriting the test file for missed-slot checkpoint serving tests. Also fixes a type error in the existing getStateResponseWithRegen test by extracting the mock fn before casting to never.
Remove both defensive fallbacks that could serve the post-payload (FULL) state variant for finalized/justified checkpoint lookups. For checkpoint sync, serving the wrong variant is worse than 404 — the client retries with another server vs getting a state with payload applied. The regen fix (always cache epoch boundary states as EMPTY) ensures the EMPTY variant is always available, so the primary lookup should always succeed.
…ed handler API The handler was updated to use: - forkChoice.getFinalizedBlock().slot (was getFinalizedCheckpointSlot) - forkChoice.getHead() + getAllAncestorBlocks(head) (was getHeadRoot/getBlockHexDefaultStatus) - db.executionPayloadEnvelopeArchive.getBinary() (was get(), returns raw bytes) - chain.getSerializedExecutionPayloadEnvelope() (was db.executionPayloadEnvelope.get()) Update test mocks accordingly and rename test cases to reflect current behavior.
|
Squash-merged by Nico in c3cd2bb with lint/type fixes + payloadPresent propagation through processSlotsByCheckpoint. All core changes intact — closing. |
Summary
Fixes checkpoint state serving for post-Gloas finalized/justified lookups to always return the post-CL state (no payload applied). Ensures correct checkpoint sync behavior when epoch boundary slot 0 is missed.
Problem
Two issues combined to produce 404s on checkpoint state lookups:
Regen caching bug:
processSlotsToNearestCheckpoint()(called byprepareNextSlot) cached epoch boundary states using the head block's payload status (FULL). ButprocessSlots()never processes payloads — the resulting state is always post-CL regardless of the source block's status.Missed slot edge case: When epoch slot 0 is missed,
getCheckpointPayloadStatus()correctly reportsEMPTY(processSlot clears executionPayloadAvailability). The API forcesEMPTYlookups, but only theFULLvariant existed in cache → 404.Fix
Regen (
regen.ts): Always cache post-Gloas epoch boundary states asEMPTY(payloadPresent=false). This is correct becauseprocessSlots()only does epoch transitions — never processes payloads.API (
utils.ts): For post-Gloas finalized/justified, forceEMPTYlookup with no fallback to FULL. If EMPTY isn't found → 404 is the correct response. Serving a post-payload (FULL) state would break checkpoint sync for other clients. The regen fix guarantees the EMPTY variant is always cached.Testing
pnpm lint✅pnpm check-types✅ (0 errors in beacon-node)getStateValidatorIndex— existing tests (restored)getStateResponseWithRegen— 404 when only FULL variant exists (never serves post-payload state)Context
Notes
AI-assisted investigation and patch.