refactor: update APIs related to voluntary exits - #378
Conversation
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)
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 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
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 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 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 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
|
There was a problem hiding this comment.
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.
| @@ -705,15 +712,13 @@ pub fn getVoluntaryExitValidity(self: *const BeaconStateView, signed_exit_bytes: | |||
| return .{ .val = try env.createStringUtf8(@tagName(validity)) }; | |||
There was a problem hiding this comment.
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
- Declare variables at the smallest possible scope to reduce the probability that variables are misused. (link)
|
out of date, lets close this |
In lodestar, once a
SignedVoluntaryExitis 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