Skip to content

refactor: update APIs related to voluntary exits - #378

Closed
spiral-ladder wants to merge 2 commits into
mainfrom
bing/vol-exits
Closed

refactor: update APIs related to voluntary exits#378
spiral-ladder wants to merge 2 commits into
mainfrom
bing/vol-exits

Conversation

@spiral-ladder

@spiral-ladder spiral-ladder commented May 25, 2026

Copy link
Copy Markdown
Member

In lodestar, once a SignedVoluntaryExit is received via gossip, we deserialize and deal with the object directly, same with the functions in lodestar-z. So we deal with passing it as a js object and walking its properties to build a native struct (which should be cheap anyway since the struct is small)

part of #347

In lodestar, once a `SignedVoluntaryExit` is received via gossip, we
deserialize and deal with the object directly, same with the functions
in lodestar-z. So we deal with passing it as a js object and walking its
properties to build a native struct (which should be cheap anyway since
the struct is small)
@spiral-ladder spiral-ladder self-assigned this May 25, 2026
@spiral-ladder
spiral-ladder requested a review from a team as a code owner May 25, 2026 13:38
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 refactors the voluntary exit validation APIs to improve developer experience and consistency with how Lodestar handles these objects. By moving from raw byte array inputs to structured JavaScript objects, the code becomes more readable and easier to integrate with existing Lodestar components that already work with these objects as native JS structures.

Highlights

  • API Refactoring: Updated getVoluntaryExitValidity and isValidVoluntaryExit to accept a JavaScript object representing a SignedVoluntaryExit instead of raw byte arrays.
  • Native Integration: Implemented signedVoluntaryExitFromJsValue in Zig to handle the conversion and validation of the JS object properties directly into the native SignedVoluntaryExit struct.
  • Type Definitions: Added VoluntaryExit and SignedVoluntaryExit interfaces to index.d.ts to provide proper TypeScript support for the new API signature.
New Features

🧠 You can now enable Memory (public preview) 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.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the 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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. 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.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the voluntary exit validation logic in BeaconStateView to accept JavaScript objects instead of serialized byte arrays, including updates to the TypeScript definitions and test suites. The reviewer feedback highlights several violations of the repository's style guide, specifically the requirement for a minimum assertion density of two per function and the need to minimize variable scope by declaring variables closer to their usage.

Comment thread bindings/napi/BeaconStateView.zig
Comment thread bindings/napi/BeaconStateView.zig
@@ -705,15 +712,13 @@ pub fn getVoluntaryExitValidity(self: *const BeaconStateView, signed_exit_bytes:
return .{ .val = try env.createStringUtf8(@tagName(validity)) };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Call js.env() directly here since the variable was removed from the top of the function to shrink its scope per Rule 353.

    return .{ .val = try js.env().createStringUtf8(@tagName(validity)) };
References
  1. Declare variables at the smallest possible scope to reduce the probability that variables are misused. (link)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not removed?

Comment thread bindings/napi/BeaconStateView.zig
@spiral-ladder

Copy link
Copy Markdown
Member Author

out of date, lets close this

@wemeetagain
wemeetagain deleted the bing/vol-exits branch August 17, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready

Development

Successfully merging this pull request may close these issues.

3 participants