Skip to content
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

Simplify nim bindings #482

Merged
merged 10 commits into from
Aug 15, 2024
Merged

Simplify nim bindings #482

merged 10 commits into from
Aug 15, 2024

Conversation

jtraglia
Copy link
Member

I would like to simplify the Nim bindings before the big v2.0 release. This PR does the following:

  • Remove the "zero overhead aliases" which I find pretty confusing.
    • I think one could argue that these are over-complicated & prone to issues.
    • When adding EIP-7594 support, I made several mistakes.
  • Remove duplicate tests, only use reference tests.
    • The tests for each API (kzg, kzg_abi, kzg_ex) were too much.
    • It's okay to only run through the reference tests.
  • Use a global KzgCtx like the other bindings do.
    • This is simpler & also less prone to mistakes.
    • Requires that free_trusted_setup is called on exit.

Some thoughts on this from our discussion on discord:
image

Opening as a draft until @agnxsh tests it.

I would also appreciate a review from @jangko, the author of these bindings.

Copy link
Contributor

@jangko jangko left a comment

Choose a reason for hiding this comment

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

LGTM. Besides loadTrustedSetupFromString, Nim actually can optimize it further via compile time mechanism to load baked in array from executable binary. But that better put into another PR.

@jtraglia
Copy link
Member Author

@jangko Oh cool. Yes let's do that in another PR.

Any thoughts on the optimization issue on Windows? I've disabled compiler optimizations as a bandaid fix until we figure it out. I asked about it on Discord (in Nimbus's PeerDAS channel):

Also, I think I've run into a Nim compiler bug. For some reason, the Windows release build will crash when calling computeCellsAndKzgProofs. The debug build works and the release build with --opt:none works too. I spent a couple hours trying to figure it out. No issues on Linux either. Is there a Nim expert that could look into this?

To be clear, this happens when the high level wrapper function (computeCellsAndKzgProofs), not the ABI function, is called & it is not crashing due to anything the function is doing. I put an echo before the function was called and another at the top of the function. Only the first one printed.

@jtraglia
Copy link
Member Author

Thank you @jangko for identifying the issue:

Maybe related to completeStruct pragma being absent from KzgCell? Because I see other types/struct are using completeStruct. Not completely sure though.

After adding this to the type, the Windows CI tests pass again.

@jtraglia jtraglia marked this pull request as ready for review August 13, 2024 13:33
@jtraglia
Copy link
Member Author

This branch was tested by Agnish (nimbus dev) and confirmed it compiles & passes the reference tests. Going to merge.

@jtraglia jtraglia merged commit 714f5a8 into ethereum:main Aug 15, 2024
38 checks passed
@jtraglia jtraglia deleted the simple-nim-bindings branch August 15, 2024 12:30
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.

2 participants