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

[Feature] Use kzg-rs for KZG point evaluation #1017

Open
leruaa opened this issue Jul 4, 2024 · 5 comments
Open

[Feature] Use kzg-rs for KZG point evaluation #1017

leruaa opened this issue Jul 4, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@leruaa
Copy link
Contributor

leruaa commented Jul 4, 2024

Component

consensus, eips, genesis

Describe the feature you would like

Currently, alloy uses c-kzg for KZG point evaluation. It would be useful to have a [no_std] endpoint for this, which kzg-rs can be used for.

For instance, it would allow to use alloy consensus and eips in a SP1 zkVM context.

I'm starting to work on a PR.

Additional context

No response

@leruaa leruaa added the enhancement New feature or request label Jul 4, 2024
@mattsse
Copy link
Member

mattsse commented Jul 4, 2024

not opposed to making the kzg backend configurable, but configuration must be very simple and should not leak across many crates.

we need to ensure that this doesn't cause any big issues if both features are enabled, c-kzg and rs-kzg, not sure yet what the best solution here is:

mutually exclusive features, what takes precedence if both enabled? compiler error?

@leruaa
Copy link
Contributor Author

leruaa commented Jul 5, 2024

Thanks for your comment @mattsse

As you seen in the draft PR, I used cfg-if with c-kzg taking precedence over kzg-rs.

Also, for our use case where we want to avoid c-kzg to be loaded in a SP1 zkVM context, we'll need the kzg-rs feature added to reth-primitives and c-kzg replaced by kgz-rs in the default features:

https://github.com/paradigmxyz/reth/blob/b2bbd002572469a83ae053d0b7b3bc7472673493/crates/primitives/Cargo.toml#L86

Is this possible?

@mattsse
Copy link
Member

mattsse commented Jul 5, 2024

if we can have a consistent API, then I think it would be

@blackcats1999
Copy link

In the centos 7.9 environment, cargo build --release failed. I don't know how to deal with it.

warning: [email protected]: /home/test_blog/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c-kzg-1.0.2/src/c_kzg_4844.c:1724:19: error: redefinition of ‘i’
warning: [email protected]:      for (uint64_t i = 0; i < n2; i++) {
warning: [email protected]:                    ^
warning: [email protected]: /home/test_blog/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c-kzg-1.0.2/src/c_kzg_4844.c:1711:19: note: previous definition of ‘i’ was here
warning: [email protected]:      for (uint64_t i = 0; i < n1; i++) {
warning: [email protected]:                    ^
warning: [email protected]: /home/test_blog/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c-kzg-1.0.2/src/c_kzg_4844.c:1724:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
warning: [email protected]:      for (uint64_t i = 0; i < n2; i++) {
warning: [email protected]:      ^

error: failed to run custom build command for `c-kzg v1.0.2`

Caused by:
  process didn't exit successfully: `/home/test_rs/target/release/build/c-kzg-9208ef64d2acffdf/build-script-build` (exit status: 101)
  --- stdout
  OUT_DIR = Some(/home/test_blog/code/web3-blog-rs/blog-rs/target/release/build/c-kzg-8d7925e43891e0bd/out)
  TARGET = Some(x86_64-unknown-linux-gnu)
  OPT_LEVEL = Some(3)
  HOST = Some(x86_64-unknown-linux-gnu)
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
  CC_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
  CC_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(false)

@DaniPopes
Copy link
Member

@blackcats1999 please report upstream in https://github.com/ethereum/c-kzg-4844

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants