-
Notifications
You must be signed in to change notification settings - Fork 127
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
Add library prefix to all ckzg symbols #312
Comments
Hello, that seems like a promising approach to solving the problem, and requires less tinkering of the audited code than making |
digging this approach 🎉 |
So, I pushed #313 which includes some cursed macro code 2c58b2a that gets used around the codebase 6253751 . To use this cursed feature you need to define a Would this work for you guys? Either way, I think we should probably wait until Justin is back from OOO to see if this is acceptable in terms of code quality. I don't really like it, but if it's a needed feature I can probably turn a blind eye. |
@asn-d6 That looks like it would work for us, and I don't think the macros are too bad from an aesthetics/maintainability PoV. If I get some time I'll try to re-work the Rust bindings and confirm that it works end-to-end. Thanks for your work on that! |
Yeah, let's wait for his comment, but I think the PR already looks good. |
Reviewed the PR yesterday. I'm not ecstatic about it either, but I think it's a clever solution with minimal changes. I want to look into how complicated it would be to do it "properly". Maybe we do it this way now & the complicated way later. |
Fixed in #317. Closing. |
Currently the
c-kzg
library uses#define
constants for the mainnet/minimal paramaters likeFIELD_ELEMENTS_PER_BLOB
:c-kzg-4844/src/c_kzg_4844.h
Lines 39 to 43 in cfdd9e5
This makes it very hard (but not impossible*) to link two copies of the library to enable switching between mainnet and minimal configurations at runtime.
*My attempt at doing this is documented here: sigp/lighthouse#4276. I had to use
objcopy
to renamec-kzg
's symbols so that they wouldn't conflict. Needless to say this is not a sensible approach to take.To do this better I was thinking the library could accept another
#define
constant which it prepends to all symbol names. Then the downstream consumer of the library could easily avoid collisions, with names likeckzg_blob_to_kzg_commitment
andckzgmin_blob_to_kzg_commitment
instead of justblob_to_kzg_commitment
. Theckzg
prefix could be the default if no prefix is specified.The text was updated successfully, but these errors were encountered: