Skip to content

Conversation

wemeetagain
Copy link
Member

  • Consolidate logic for the operations spec runner
  • Remove external test logger (tests can be more logged via --summary all)
  • Properly handle bls setting (eg by reading meta.yaml)
  • Properly handle preset (-Dpreset=minimal) (there are currently bugs, the minimal preset needs work)
  • Further runners can be added using a similar format:
    • Add a new file/struct in test/spec/test_types that handles running the runner type
    • Add a new file/function in test/spec/writer that handles writing the tests for that runner type (and add it in test/spec/writer/root
    • Add the runner to the supported runners in test/spec/write_spec_tests.zig
    • Add the generated file in test/spec/root.zig

Copy link

Summary of Changes

Hello @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

  • Operations Spec Runner Refactor: The core logic for the operations spec test runner has been consolidated and rewritten, moving from a monolithic test/spec/test_case/operations.zig to a more modular structure within test/spec/test_type/operations.zig and test/spec/writer/operations.zig.
  • External Test Logger Removal: The custom external test logger (test/spec/utils/test_logger.zig) has been removed, with tests now relying on standard Zig test output, which can be configured for detailed logging via --summary all.
  • BLS Setting Handling: The test runner now properly handles BLS settings by reading the bls_setting from meta.yaml files within test directories, allowing for more accurate test execution based on BLS requirements.
  • Preset Handling: The system now attempts to properly handle different presets (e.g., minimal) during test generation and execution, though the PR description notes that the minimal preset still requires further work.
  • New Runner Integration Guidelines: Clear guidelines have been established for adding new test runners, involving creating new files/structs in test/spec/test_type for running, new files/functions in test/spec/writer for writing tests, and updating test/spec/write_spec_tests.zig and test/spec/root.zig.
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 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 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

  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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 and test/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.

\\
;

pub fn writeOperationsTests(comptime forks: []const ForkSeq, writer: std.io.AnyWriter) !void {
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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;
Copy link
Contributor

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

Copy link
Member Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

#66 (comment) possible suggestion?

Copy link
Member Author

@wemeetagain wemeetagain Oct 15, 2025

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

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;
Copy link
Contributor

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?

Suggested change
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

Copy link
Member Author

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

Copy link
Contributor

@spiral-ladder spiral-ladder Oct 15, 2025

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)

Copy link
Member Author

@wemeetagain wemeetagain Oct 15, 2025

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
  • 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 if active_preset is confusing (this name is taken from lodestar)
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants