-
Notifications
You must be signed in to change notification settings - Fork 2
chore: refactor spec test runner #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: nc/spec-test
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @wemeetagain, 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 significantly refactors the spec test runner infrastructure, particularly for operations tests. The primary goal is to streamline the test generation and execution process, making it more robust and extensible. Key improvements include consolidating test logic, removing a custom logger in favor of native Zig testing features, and enhancing the handling of configuration parameters like BLS settings and presets. This change sets a clearer path for future additions of new test types and improves the overall maintainability of the test suite. Highlights
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.
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 is a great refactoring of the spec test runner, consolidating logic and improving the structure for future extensions. The changes make the test generation and execution more modular and easier to understand.
I've found a few issues:
- A critical bug in the handling of attestations for different forks in
test/spec/test_type/operations.zig
. - A couple of correctness issues in
src/preset/preset.zig
andtest/spec/test_case.zig
. - Some opportunities to improve code quality by reducing duplication and adhering more closely to the style guide, particularly regarding assertions.
Once these points are addressed, this will be a solid improvement.
test/spec/writer/operations.zig
Outdated
\\ | ||
; | ||
|
||
pub fn writeOperationsTests(comptime forks: []const ForkSeq, writer: std.io.AnyWriter) !void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this file reading logic will be reused so many times for other runners.
Better write a generic version of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, bring back listAllDirectories? It can be used in the innermost loop here. But the outer loops can't really be reused since we're not iterating thru file contents, generically, rather iterating thru fork and operation slices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok take a look now (at write_spec_tests.zig
). More of a framework for handling different runners and handlers and a unified directory walker there.
const BLSPubkey = ssz.primitive.BLSPubkey.Type; | ||
const ValidatorIndex = ssz.primitive.ValidatorIndex.Type; | ||
const preset = @import("preset").preset; | ||
const Preset = @import("preset").Preset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this and @import("preset").preset
to be pretty confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah its not great, suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#66 (comment) possible suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a deeper look at the preset module in another PR, it needs a bit of love
Co-authored-by: bing <[email protected]>
const Index2PubkeyCache = state_transition.Index2PubkeyCache; | ||
const syncPubkeys = state_transition.syncPubkeys; | ||
const interopPubkeysCached = @import("./interop_pubkeys.zig").interopPubkeysCached; | ||
const active_chain_config = if (preset.preset == Preset.mainnet) mainnet_chain_config else minimal_chain_config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're already depending on build_options
, can we just do this maybe?
const active_chain_config = if (preset.preset == Preset.mainnet) mainnet_chain_config else minimal_chain_config; | |
const preset_str = @import("build_options").preset; | |
const active_chain_config = if (std.mem.eql(u8, preset_str, "mainnet")) mainnet_chain_config else minimal_chain_config; |
if i'm not wrong, the preset
field is only used to check this, so we can just get rid of that if we do this possibly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preset
is used in a few places in this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By preset
field, I meant preset.preset
(the enum stored in the preset struct)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, you're talking about preset.preset
.
I'd like to do some refactoring of the preset
module in another PR to have the following behavior:
- move all preset constants for the active preset to be re-exported from the root (eg
@import("preset").SHUFFLE_ROUND_COUNT
)- its annoying and duplicative to store the values on a decl named
preset
- its annoying and duplicative to store the values on a decl named
- re-export
active_preset
from the root (eg@import("preset").active_preset
)- its a nice quality-of-life feature to have the active
Preset
to compare against (doing string comparison everywhere against the build_options preset is sloppy) - could be named
preset_base
or something else ifactive_preset
is confusing (this name is taken from lodestar)
- its a nice quality-of-life feature to have the active
- re-export the
Preset
struct from the root- no change from existing behavior
- re-export each set of preset constants under a decl on the root (eg
@import("preset").minimal.SHUFFLE_ROUND_COUNT
)- we're already declaring this stuff, may as well make it available for general usage
--summary all
)meta.yaml
)-Dpreset=minimal
) (there are currently bugs, the minimal preset needs work)test/spec/test_types
that handles running the runner typetest/spec/writer
that handles writing the tests for that runner type (and add it intest/spec/writer/root
test/spec/write_spec_tests.zig
test/spec/root.zig