Add PeerDAS KZG lib integration (construction & KZG verification)#6212
Conversation
dapplion
left a comment
There was a problem hiding this comment.
LGTM, ok to move the code to kzg_utils
|
I'm looking into the windows CI failure. |
| // | ||
| // 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.
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.
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 (
Noneotherwise), so we don't impact mainnet code path now (I have a branch here that does this) - Load PeerDAS setup from existing
trusted_setupusing clone (code), so we avoid reading file system and also avoid breaking--trusted-setupflag - although we don't really use this anymore
There was a problem hiding this comment.
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.
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.
Replaced loading embedded trusted setup with cloning the existing trusted setup values.
11c53a8
There was a problem hiding this comment.
Added conditionally load KZG on startup only if PeerDAS is enabled: 6881981
There was a problem hiding this comment.
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.
| #[derive(Debug)] | ||
| pub struct Kzg { | ||
| trusted_setup: KzgSettings, | ||
| context: DASContext, |
There was a problem hiding this comment.
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
6881981 to
856fa89
Compare
|
@mergify queue |
✅ The pull request has been merged automaticallyDetailsThe 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_sidecarsandreconstruct_data_columnsfunctions fromconsensus/typestokzg_utilsin thebeacon_chaincrates, 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: