feat: add getStateBuilders endpoint - #9593
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e923627cb8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Code Review
This pull request introduces the getStateBuilders endpoint (POST /eth/v1/beacon/states/{state_id}/builders) to retrieve and filter builders from a Gloas state by ID and status. It includes updates to state views, types, helper functions, and unit tests. The review feedback points out a potential out-of-bounds issue where negative builder indices are not rejected as invalid, and suggests moving the uniqueness validation for statuses to the beginning of the handler to prevent it from being bypassed when builderIds are provided.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Performance Report🚀🚀 Significant benchmark improvement detected
Full benchmark results
|
nflaig
left a comment
There was a problem hiding this comment.
@lodekeeper please review/approve if it looks good
lodekeeper
left a comment
There was a problem hiding this comment.
LGTM — reviewed the full diff. Clean new endpoint that mirrors getStateValidators end-to-end:
getStateBuildersfollows the validators pattern exactly: pre-Gloas → 400, ids-path + full-scan path,assertUniqueItemson both ids and statuses, status filtering.getStateBuilderIndexmirrorsgetStateValidatorIndexand guards the edges correctly —< 0/ non-safe-integer → 400,>= getBuildersLength()→ 404 (future state), pre-Gloas throws. Linear pubkey scan is reasonable given there's no builder pubkey cache and the registry is small.- Good catch fixing the same negative-index gap in
getStateValidatorIndex(d7c793a5d7) and adding the regression tests. getBuilderStatus(exited → active → pending) reads clean and matches beacon-APIs #614.getBuildersLengthadded to both state views with pre-Gloas guards, memoized on the native view.
Bot threads all resolved. 👍
Addresses review feedback on #9593 by exporting a dedicated BuilderId route type and using it for builder state lookups instead of ValidatorId.\n\nVerification:\n- pnpm lint\n- pnpm build\n- pnpm check-types Co-authored-by: lodekeeper <lodekeeper@users.noreply.github.com>
Addresses review feedback on #9593 by adding explicit builder ID serdes aliases while preserving existing validator helper names for validator call sites. Changes: - Add `toBuilderIdsStr` / `fromBuilderIdsStr` aliases in API serdes - Use the builder aliases for `getStateBuilders` request serialization/parsing Verification: - `pnpm lint` - `pnpm build` - `pnpm check-types` Co-authored-by: lodekeeper <lodekeeper@users.noreply.github.com>
| | {valid: true; builderIndex: BuilderIndex} | ||
| | {valid: false; code: number; reason: string}; | ||
|
|
||
| export function getStateBuilderIndex( |
There was a problem hiding this comment.
this could also be made reusable between validators/builders but I don't like to be overly DRY for the sake of it, and it would definitely become less readable, we also don't wanna couple the code too much as there might be a drift in the future between builders and validators
There was a problem hiding this comment.
Agreed. I would keep the builder and validator paths separate here for readability and to avoid coupling them before we know whether the APIs drift. No code change from me on this thread.
| return (this.cachedState as CachedBeaconStateGloas).builders.getReadonly(index); | ||
| } | ||
|
|
||
| getBuildersLength(): number { |
There was a problem hiding this comment.
we might need a new binding for that cc @spiral-ladder
There was a problem hiding this comment.
Good point. This PR already adds the TypeScript state-view surface and the native wrapper call for getBuildersLength, and the current native portability check is passing on this head. If the underlying native binding implementation needs an explicit addition, I would leave that to the native binding follow-up/owner rather than adding more JS-side churn here.
nflaig
left a comment
There was a problem hiding this comment.
LGTM, did a final self-review
wemeetagain
left a comment
There was a problem hiding this comment.
LGTM
- Also created tracking issue ChainSafe/lodestar-z#470
## Description Introduces `state.getBuildersLength()` binding. Function placement reflects the one present in `nativeBeaconStateView.ts` (ChainSafe/lodestar#9593). Closes #470 Used Claude to audit changes.
|
🎉 This PR is included in v1.45.0 🎉 |
Motivation
Implement
POST /eth/v1/beacon/states/{state_id}/buildersadded to the beacon-api spec in ethereum/beacon-APIs#614.Description
getStateBuildersroute, filterable by builder ids (hex encoded public key or builder index) and statuses (pending,active,exited)getBuildersLength()to the beacon state view to enumerate the builder registry