Skip to content

Comments

feat: add spec references, a mapping of spec to implementation#8778

Merged
ensi321 merged 4 commits intoChainSafe:unstablefrom
jtraglia:specrefs
Jan 26, 2026
Merged

feat: add spec references, a mapping of spec to implementation#8778
ensi321 merged 4 commits intoChainSafe:unstablefrom
jtraglia:specrefs

Conversation

@jtraglia
Copy link
Contributor

@jtraglia jtraglia commented Jan 23, 2026

Motivation

This PR adds a directory with specification references. These are used to map specification items (configs, presets, functions, etc) to client implementations (code in Lodestar). These specification references are meant to (1) help developers keep track of specification changes and (2) make it easier for third-parties (eg EF Protocol Security) to verify clients adhere to the specifications.

Our team is working to do this for all clients.

Note: The function mappings are the only weak-spot. It's quite difficult to map some of these because of implementation differences & the fact that not everything is implemented (eg Gloas functions). The specref functions will most likely require some additional work, but this PR does identify most functions.

AI Assistance Disclosure

Yes, I used Claude Code to identify/map most of these.

Fixes: #7477

@jtraglia jtraglia requested a review from a team as a code owner January 23, 2026 04:15
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jtraglia, 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 introduces a robust system for tracking and verifying the client's adherence to Ethereum specifications. By creating a dedicated 'specrefs' directory and leveraging the 'ethspecify' tool, the project aims to improve development efficiency in managing specification changes and enhance the auditability of client implementations against the official Ethereum protocols.

Highlights

  • Introduction of Specification References: A new 'specrefs' directory has been added to systematically map Ethereum specification items (configs, constants, containers, dataclasses, functions, presets, and types) to their corresponding client implementations.
  • ethspecify Tool Integration: This PR integrates the 'ethspecify' tool, which helps developers track specification changes and enables third-parties to verify client adherence to the Ethereum specifications.
  • Comprehensive Mapping: The new system provides detailed mappings for various components across multiple Ethereum forks (Phase0, Altair, Bellatrix, Capella, Deneb, Electra, Fulu, Gloas), including explicit exceptions for un-implemented items.

🧠 New Feature in Public Preview: You can now enable Memory 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.

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/check-specrefs.yml
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.

@jtraglia jtraglia changed the title Add spec references, a mapping of spec to implementation feat: add spec references, a mapping of spec to implementation Jan 23, 2026
Copy link
Contributor

@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 introduces a new specrefs directory to map specification items to their implementations in the codebase, using the ethspecify tool. This is a great initiative for improving spec compliance and maintainability. The new configuration files are well-structured, and the process is documented in a new README. I've found a small typo in the README and suggested an improvement to make the search patterns in the configuration more robust. Overall, this is a valuable addition to the repository.

- name: AGGREGATE_DUE_BPS
sources:
- file: packages/config/src/chainConfig/configs/mainnet.ts
search: "AGGREGATE_DUE_BPS:"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The search pattern "AGGREGATE_DUE_BPS:" is a bit weak and could potentially match unintended lines, such as in comments. For better robustness, I suggest using a more specific regex that anchors the search to the start of the line and accounts for leading whitespace. This improvement should be applied to other similar simple string searches in this file for consistency and maintainability.

      search: '^\s+AGGREGATE_DUE_BPS:'
      regex: true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nah, if it also matches a comment, ethspecify will throw an ambiguous search error:

For example:

image

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Member

@nflaig nflaig left a comment

Choose a reason for hiding this comment

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

generally looks good to me, thanks @jtraglia

jtraglia and others added 2 commits January 23, 2026 07:15
Co-authored-by: Nico Flaig <nflaig@protonmail.com>
Copy link
Member

@nflaig nflaig left a comment

Choose a reason for hiding this comment

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

LGTM - waiting for @ensi321 to give this a final pass

@nflaig
Copy link
Member

nflaig commented Jan 23, 2026

this should be closing #7477 once merged

Copy link
Contributor

@ensi321 ensi321 left a comment

Choose a reason for hiding this comment

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

I think this is great. Minor maintenance effort from our side. And we can be monitor the exception list to see if Lodestar is missing something from the spec.

sources: []
spec: |
<spec fn="_fft_field" fork="fulu" hash="d9de8aaf">
def _fft_field(
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, I don't see the point of having content of each function here. It could be a good reference but generally something like link should be enough? Same with containers and data classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As it is right now, the link style is broken. It tries to link to the specs GitHub repo and not everything has a link. I should update ethspecify to use https://ethspec.tools/#specs/ links. That way everything has a well defined link. I'll add this to my todo list too.

Personally, I think full is the best style here because it's instantly clear what changed when bumping versions. With a link, all you'd see is that the hash changed but it wouldn't be very easy to tell what exactly changed. I will leave this up to y'all though; happy to do whatever you think is best.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey again @ensi321. I have added this functionality to ethspecify v0.3.6. If you wanted to use the link style in some places, that's an option now. It would look something like:

image

@@ -0,0 +1,11986 @@
- name: _fft_field
sources: []
Copy link
Contributor

Choose a reason for hiding this comment

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

For those that are under exceptions, is it possible to not generate them here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good idea. I would need to publish a new version of ethspecify with an option for this though. I will add that to my todo list for Monday.

Note: There is a auto_add_missing_entries setting which defaults to true. We could simple disable that but it wouldn't populate new spec items when bumping the version. Also, I think there is some benefit in keeping functions which aren't mappable (because of implementation differences) but stuff like KZG functions really could be deleted without any harm.

Copy link
Contributor

@ensi321 ensi321 left a comment

Choose a reason for hiding this comment

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

lgtm. Can always make improvement on this later on.

@ensi321 ensi321 merged commit a210743 into ChainSafe:unstable Jan 26, 2026
26 of 28 checks passed
@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.04%. Comparing base (b6d377a) to head (19778b0).
⚠️ Report is 19 commits behind head on unstable.

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #8778   +/-   ##
=========================================
  Coverage     52.04%   52.04%           
=========================================
  Files           848      848           
  Lines         64584    64584           
  Branches       4762     4762           
=========================================
  Hits          33612    33612           
  Misses        30903    30903           
  Partials         69       69           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nflaig
Copy link
Member

nflaig commented Jan 26, 2026

we already broke the spec ref CI on unstable branch 😁

should have rebased this branch before merging

ensi321 pushed a commit that referenced this pull request Jan 27, 2026
**Motivation**

This PR is follow up from:

* #8778

**Description**

This PR enables a few optional features:

* `auto_add_missing_entries`: Add missing spec items to the relevant
mapping files. It _will not_ add missing spec items if there's an
exception for that spec item.
* `auto_standardize_names`: Automatically add `#fork` tags to specref
names, for explicitness.
* `require_exceptions_have_fork`: Require exceptions include a `#fork`
tag.

It also removes the KZG functions (which clients do not implement) from
the `functions.yml` file. @ensi321 could you give me a list of other
items we want to remove?

And it also
[fixes](da91b29)
the search query for `get_committee_assignment` which was moved before
the first PR was merged.

**AI Assistance Disclosure**

- [x] External Contributors: I have read the [contributor
guidelines](https://github.com/ChainSafe/lodestar/blob/unstable/CONTRIBUTING.md#ai-assistance-notice)
and disclosed my usage of AI below.

I used AI to remove the KZG functions.
@wemeetagain
Copy link
Member

🎉 This PR is included in v1.40.0 🎉

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.

Explore ethspecify integration

4 participants