perf: improve process_attestation() for gloas#9664
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors getAttestationParticipationStatus to return both flags and isSameSlotAttestation, allowing the removal of the isAttestationSameSlot function and avoiding redundant state root lookups. Feedback suggests further optimizing this hot path by caching and reusing the isMatchingBlockRoot computation to avoid duplicate byteArrayEquals and isAttestationSameSlotRootCache calls.
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.
The gloas is_attestation_same_slot implementation was renamed to isAttestationSameSlotRootCache; point the ethspecify search string at the new name so the spec-refs check passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Performance Report✔️ no performance regression detected Full benchmark results
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #9664 +/- ##
=========================================
Coverage 52.49% 52.50%
=========================================
Files 848 848
Lines 60485 60480 -5
Branches 4466 4466
=========================================
- Hits 31754 31753 -1
+ Misses 28670 28666 -4
Partials 61 61 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a56aba338c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| rootCache: RootCache, | ||
| executionPayloadAvailability: BitArray | null | ||
| ): number { | ||
| ): {flags: number; isSameSlotAttestation: boolean} { |
There was a problem hiding this comment.
Preserve the numeric participation return value
This function is exported from the package root (src/index.ts), so changing it from returning the participation bitfield to returning an object is a breaking runtime change for consumers that do const flags = getAttestationParticipationStatus(...) and then apply bitwise checks; in JavaScript, flags & TIMELY_SOURCE on this object evaluates as 0, silently dropping all rewards/flags. Please keep the public function returning the numeric flags and add a separate helper/option for the same-slot boolean.
Useful? React with 👍 / 👎.
| /** | ||
| * Use cached block roots to avoid repeated state root lookups while matching the spec's is_attestation_same_slot behavior. | ||
| */ | ||
| export function isAttestationSameSlotRootCache(rootCache: RootCache, data: AttestationData): boolean { |
There was a problem hiding this comment.
Keep the exported same-slot helper available
Renaming the exported isAttestationSameSlot helper removes it from @lodestar/state-transition because util/index.ts re-exports gloas.ts and the root index re-exports util; downstream users importing the spec-shaped helper will fail at module/type resolution even though this perf change only needs an additional RootCache-based variant internally. Please retain a compatibility wrapper with the original name/signature while using the cached helper in the hot path.
Useful? React with 👍 / 👎.
ensi321
left a comment
There was a problem hiding this comment.
looks good. no comment to add
Motivation
glamsterdam-devnet-7by panda tool, hope this fixes itDescription
isAttestationSameSlotRootCache()once per block transitionAI Assistance Disclosure