Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed Changes
This uses some nasty hacks on my fork of
c-kzg
to enable two copies of the library to be linked: one with the mainnet spec, and one with the minimal spec. We can then select between them at runtime.The main complication is that the C library wants to use the same symbol names for both libraries, which is worked around by:
ckzgmin
vsckzg
).objcopy
to rename the public symbols when the minimal spec is enabled. Ackzgmin_
prefix is added.c_kzg_4844.h
header so that the function stub names match the renamed symbols in the object file.ckzgmin_
prefixed names back to the names without prefixes, so that the hand-written code that references them remains correct regardless of minimal/mainnet spec usage.See the
trusted_setup_minimal.rs
for a basic test that shows the two libraries working independently (deserializing the minimal JSON into the mainnet JSON or vice versa will fail).TODO
If we decide to take this approach:
crypto/kzg
library has to be thoroughly refactored to use type-level selection between minimal and mainnet specs. LikeEthSpec
, but probably notEthSpec
due to the circular dependency.objcopy
that works cross-platform. Maybe cargo-binutils.--discard-all
.