-
Notifications
You must be signed in to change notification settings - Fork 752
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 PeerDAS KZG lib integration (construction & KZG verification) #6212
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, ok to move the code to kzg_utils
I'm looking into the windows CI failure. |
crypto/kzg/src/lib.rs
Outdated
// | ||
// Note: One can also use `from_json` to initialize it from the consensus-specs | ||
// json string. | ||
let peerdas_trusted_setup = PeerDASTrustedSetup::default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's an embedded trusted setup here, so we're loading the same setup twice right? so maybe we can at least add an equivalence check here if there's no way to consolidate the two yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that's right. Yeah I think equivalence check is a good idea, or potentially cloning the values from existing trusted setup. There are a few more things I've done on another WIP branch, but I'm still thinking about whether it's a good idea:
- Should we only load this if PeerDAS is scheduled (
None
otherwise), so we don't impact mainnet code path now (I have a branch here that does this) - Load PeerDAS setup from existing
trusted_setup
using clone (code), so we avoid reading file system and also avoid breaking--trusted-setup
flag - although we don't really use this anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to cherry-pick both changes into this branch.
With (2), I just did a bench
on both approaches (loading from json / clone and encode existing trusted setup) - cloning is actually slightly faster than re-loading from json (-20ms), plus we get consistency, and we won't need to perform equivalent check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't done #1, it actually involves touching a lot of files and I'm not sure if it's worth it, as loading the PeerDAS trusted setup only adds ~550ms on startup and ~100mb of memory for storing the precomputation. Existing Deneb code path still uses c-kzg so should be unaffected.
Once both libraries are feature complete and stable for deneb and PeerDAS, we could do this properly and only load one library with a cli flag.
What do you think @realbigsean ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced loading embedded trusted setup with cloning the existing trusted setup values.
11c53a8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added conditionally load KZG on startup only if PeerDAS is enabled: 6881981
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once both libraries are feature complete and stable for deneb and PeerDAS, we could do this properly and only load one library with a cli flag.
That sounds good!
…nnecessary `needless_lifetimes`. Co-authored-by: realbigsean <sean@sigmaprime.io>
…y and maintain `--trusted-setup` functionality.
crypto/kzg/src/lib.rs
Outdated
/// A wrapper over a kzg library that holds the trusted setup parameters. | ||
#[derive(Debug)] | ||
pub struct Kzg { | ||
trusted_setup: KzgSettings, | ||
context: DASContext, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to conditionally load the DAS context for peerdas networks only? It's kindoff a bad penalty to force mainnet users to pay the extra 110MB in memory for an unused feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 6881981
6881981
to
856fa89
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@mergify queue |
✅ The pull request has been merged automaticallyThe pull request has been merged automatically at 6dc614f |
…gp#6212) * Add peerdas KZG library and use it for data column construction and cell kzg verification (sigp#5701, sigp#5941, sigp#6118, sigp#6179) Co-authored-by: kevaundray <kevtheappdev@gmail.com> * Update `rust_eth_kzg` crate to published version. * Update kzg metrics buckets. * Merge branch 'unstable' into peerdas-kzg * Update KZG version to fix windows mem allocation. * Refactor common logic from build sidecar and reconstruction. Remove unnecessary `needless_lifetimes`. Co-authored-by: realbigsean <sean@sigmaprime.io> * Copy existing trusted setup into `PeerDASTrustedSetup` for consistency and maintain `--trusted-setup` functionality. * Merge branch 'unstable' into peerdas-kzg * Merge branch 'peerdas-kzg' of github.com:jimmygchen/lighthouse into peerdas-kzg * Merge branch 'unstable' into peerdas-kzg * Merge branch 'unstable' into peerdas-kzg * Load PeerDAS KZG only if PeerDAS is enabled.
…gp#6212) * Add peerdas KZG library and use it for data column construction and cell kzg verification (sigp#5701, sigp#5941, sigp#6118, sigp#6179) Co-authored-by: kevaundray <kevtheappdev@gmail.com> * Update `rust_eth_kzg` crate to published version. * Update kzg metrics buckets. * Merge branch 'unstable' into peerdas-kzg * Update KZG version to fix windows mem allocation. * Refactor common logic from build sidecar and reconstruction. Remove unnecessary `needless_lifetimes`. Co-authored-by: realbigsean <sean@sigmaprime.io> * Copy existing trusted setup into `PeerDASTrustedSetup` for consistency and maintain `--trusted-setup` functionality. * Merge branch 'unstable' into peerdas-kzg * Merge branch 'peerdas-kzg' of github.com:jimmygchen/lighthouse into peerdas-kzg * Merge branch 'unstable' into peerdas-kzg * Merge branch 'unstable' into peerdas-kzg * Load PeerDAS KZG only if PeerDAS is enabled.
Issue Addressed
Add PeerDAS KZG library and use it for data column construction and KZG verification.
Proposed Changes
Upstream PRs:
c-kzg
. #5701Thanks @kevaundray for the PRs!
Additional Info
I've also moved
build_data_column_sidecars
andreconstruct_data_columns
functions fromconsensus/types
tokzg_utils
in thebeacon_chain
crates, where all other KZG related logic are located.This PR doesn't include the following, in order to keep the PR size moderate and solely focused on KZG lib integration: