ethereum / c-kzg-4844

A minimal implementation of the Polynomial Commitments API for EIP-4844 and EIP-7594, written in C.
Apache License 2.0
112 stars 105 forks source link

Split C code into more files #471

Closed jtraglia closed 1 month ago

jtraglia commented 1 month ago

This PR continues to split the core C code into more manageable files.

Four new directories have been created:

We needed to include the C source directory in the Rust bindings generator so the updated includes would work.

There are various other small changes, but no changes to the implementation have been made here.

Added InsertNewlineAtEOF: true to the clang formatter configuration file. Several of my new files did not contain a newline at the bottom, which showed an ugly crossed out circle on GitHub.

asn-d6 commented 1 month ago

This looks great!

Some thoughts:

Both points above are just personal preference, and I hold no strong opinions.

asn-d6 commented 1 month ago

Some thoughts after reviewing this PR.

As a personal preference, I find oversplitting can sometimes be counterproductive. Having files that hold a single function or type can introduce a mental overhead when trying to locate specific functions, and it can also create a practical overhead in terms of handling numerous files.

IMO for c-kzg, file splitting should aim to highlight the responsibilities of each module, and to specify the scope of objects. On this regard, I think this PR takes good directions by moving generic algebra functionality to common/ and keeping the Ethereum protocol functonality into eip4844/ and eip7594/. We have also agreed that it's OK for eip7594/ to import eip4844/ because that's how the spec does it, but the opposite direction is not OK.

Some notes on the PR: