From fca8559acc2a15125ef24b3d62481163924bac0a Mon Sep 17 00:00:00 2001 From: Divma <26765164+divagant-martian@users.noreply.github.com> Date: Mon, 10 Apr 2023 19:05:01 -0500 Subject: [PATCH] Update kzg to get windows going, expose blst features (#4177) * fmt * update kzg * use commit from main repo --- Cargo.lock | 28 +++++++++++++++++++++++-- beacon_node/http_api/src/lib.rs | 4 ++-- crypto/kzg/Cargo.toml | 2 +- crypto/kzg/src/lib.rs | 16 +++++++------- validator_client/src/validator_store.rs | 5 +++-- 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9868c7db2..9a0b97d2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -704,6 +704,27 @@ dependencies = [ "shlex", ] +[[package]] +name = "bindgen" +version = "0.64.0" +source = "git+https://github.com/rust-lang/rust-bindgen?rev=0de11f0a521611ac8738b7b01d19dddaf3899e66#0de11f0a521611ac8738b7b01d19dddaf3899e66" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.13", + "which", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -925,8 +946,11 @@ dependencies = [ [[package]] name = "c-kzg" version = "0.1.0" -source = "git+https://github.com/ethereum/c-kzg-4844?rev=549739fcb3aaec6fe5651e1912f05c604b45621b#549739fcb3aaec6fe5651e1912f05c604b45621b" +source = "git+https://github.com/ethereum/c-kzg-4844?rev=fd24cf8e1e2f09a96b4e62a595b4e49f046ce6cf#fd24cf8e1e2f09a96b4e62a595b4e49f046ce6cf" dependencies = [ + "bindgen 0.64.0", + "cc", + "glob", "hex", "libc", "serde", @@ -4816,7 +4840,7 @@ name = "mdbx-sys" version = "0.11.6-4" source = "git+https://github.com/sigp/libmdbx-rs?tag=v0.1.4#096da80a83d14343f8df833006483f48075cd135" dependencies = [ - "bindgen", + "bindgen 0.59.2", "cc", "cmake", "libc", diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 5d1838fa0..9f92ef2e9 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -32,8 +32,8 @@ use beacon_chain::{ pub use block_id::BlockId; use directory::DEFAULT_ROOT_DIR; use eth2::types::{ - self as api_types, EndpointVersion, SignedBlockContents, ForkChoice, ForkChoiceNode, SkipRandaoVerification, - ValidatorId, ValidatorStatus, + self as api_types, EndpointVersion, ForkChoice, ForkChoiceNode, SignedBlockContents, + SkipRandaoVerification, ValidatorId, ValidatorStatus, }; use lighthouse_network::{types::SyncState, EnrExt, NetworkGlobals, PeerId, PubsubMessage}; use lighthouse_version::version_with_platform; diff --git a/crypto/kzg/Cargo.toml b/crypto/kzg/Cargo.toml index 0645b3a2b..5c4a499e9 100644 --- a/crypto/kzg/Cargo.toml +++ b/crypto/kzg/Cargo.toml @@ -16,7 +16,7 @@ serde_derive = "1.0.116" eth2_serde_utils = "0.1.1" hex = "0.4.2" eth2_hashing = "0.3.0" -c-kzg = {git = "https://github.com/ethereum/c-kzg-4844", rev = "549739fcb3aaec6fe5651e1912f05c604b45621b" } +c-kzg = {git = "https://github.com/ethereum/c-kzg-4844", rev = "fd24cf8e1e2f09a96b4e62a595b4e49f046ce6cf" } arbitrary = { version = "1.0", features = ["derive"], optional = true } [features] diff --git a/crypto/kzg/src/lib.rs b/crypto/kzg/src/lib.rs index cd28c8529..5379d36ed 100644 --- a/crypto/kzg/src/lib.rs +++ b/crypto/kzg/src/lib.rs @@ -5,7 +5,7 @@ mod trusted_setup; pub use crate::{kzg_commitment::KzgCommitment, kzg_proof::KzgProof, trusted_setup::TrustedSetup}; use c_kzg::Bytes48; pub use c_kzg::{ - Blob, Error as CKzgError, KZGSettings, BYTES_PER_BLOB, BYTES_PER_FIELD_ELEMENT, + Blob, Error as CKzgError, KzgSettings, BYTES_PER_BLOB, BYTES_PER_FIELD_ELEMENT, FIELD_ELEMENTS_PER_BLOB, }; use std::path::PathBuf; @@ -21,7 +21,7 @@ pub enum Error { /// A wrapper over a kzg library that holds the trusted setup parameters. pub struct Kzg { - trusted_setup: KZGSettings, + trusted_setup: KzgSettings, } impl Kzg { @@ -32,7 +32,7 @@ impl Kzg { /// The number of G2 points should be equal to 65. pub fn new_from_trusted_setup(trusted_setup: TrustedSetup) -> Result { Ok(Self { - trusted_setup: KZGSettings::load_trusted_setup( + trusted_setup: KzgSettings::load_trusted_setup( trusted_setup.g1_points(), trusted_setup.g2_points(), ) @@ -47,7 +47,7 @@ impl Kzg { #[deprecated] pub fn new_from_file(file_path: PathBuf) -> Result { Ok(Self { - trusted_setup: KZGSettings::load_trusted_setup_file(file_path) + trusted_setup: KzgSettings::load_trusted_setup_file(file_path) .map_err(Error::InvalidTrustedSetup)?, }) } @@ -58,7 +58,7 @@ impl Kzg { blob: Blob, kzg_commitment: KzgCommitment, ) -> Result { - c_kzg::KZGProof::compute_blob_kzg_proof(blob, kzg_commitment.into(), &self.trusted_setup) + c_kzg::KzgProof::compute_blob_kzg_proof(blob, kzg_commitment.into(), &self.trusted_setup) .map_err(Error::KzgProofComputationFailed) .map(|proof| KzgProof(proof.to_bytes().into_inner())) } @@ -70,7 +70,7 @@ impl Kzg { kzg_commitment: KzgCommitment, kzg_proof: KzgProof, ) -> Result { - c_kzg::KZGProof::verify_blob_kzg_proof( + c_kzg::KzgProof::verify_blob_kzg_proof( blob, kzg_commitment.into(), kzg_proof.into(), @@ -100,7 +100,7 @@ impl Kzg { .map(|proof| Bytes48::from_bytes(&proof.0)) .collect::, _>>() .map_err(Error::InvalidBytes)?; - c_kzg::KZGProof::verify_blob_kzg_proof_batch( + c_kzg::KzgProof::verify_blob_kzg_proof_batch( blobs, &commitments_bytes, &proofs_bytes, @@ -111,7 +111,7 @@ impl Kzg { /// Converts a blob to a kzg commitment. pub fn blob_to_kzg_commitment(&self, blob: Blob) -> Result { - c_kzg::KZGCommitment::blob_to_kzg_commitment(blob, &self.trusted_setup) + c_kzg::KzgCommitment::blob_to_kzg_commitment(blob, &self.trusted_setup) .map_err(Error::InvalidBlob) .map(|com| KzgCommitment(com.to_bytes().into_inner())) } diff --git a/validator_client/src/validator_store.rs b/validator_client/src/validator_store.rs index f80ae74f3..811d7bb16 100644 --- a/validator_client/src/validator_store.rs +++ b/validator_client/src/validator_store.rs @@ -24,8 +24,9 @@ use types::{ ContributionAndProof, Domain, Epoch, EthSpec, Fork, Graffiti, Hash256, Keypair, PublicKeyBytes, SelectionProof, Signature, SignedAggregateAndProof, SignedBeaconBlock, SignedBlobSidecar, SignedBlobSidecarList, SignedContributionAndProof, SignedRoot, SignedValidatorRegistrationData, - Slot, SyncAggregatorSelectionData, SyncCommitteeContribution, SyncCommitteeMessage, - SyncSelectionProof, SyncSubnetId, ValidatorRegistrationData, SignedVoluntaryExit, VoluntaryExit, + SignedVoluntaryExit, Slot, SyncAggregatorSelectionData, SyncCommitteeContribution, + SyncCommitteeMessage, SyncSelectionProof, SyncSubnetId, ValidatorRegistrationData, + VoluntaryExit, }; use validator_dir::ValidatorDir;