mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-28 02:03:32 +00:00
Remove c-kzg (#8930)
#7330 Removes `c-kzg` from our `kzg` crate and rely fully on the `rust_eth_kzg` crate. This removes the old `Blob` type entirely and instead handles `rust_eth_kzg::KzgBlobRef`s directly which allows us to avoid some extra stack allocations . Similarly, we make `Bytes32` and `Bytes48` type aliases rather than structs as this fits better with the new `rust_eth_kzg` API. Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use c_kzg::BYTES_PER_COMMITMENT;
|
||||
use crate::{Bytes48, BYTES_PER_COMMITMENT};
|
||||
use educe::Educe;
|
||||
use ethereum_hashing::hash_fixed;
|
||||
use serde::de::{Deserialize, Deserializer};
|
||||
@@ -14,7 +14,7 @@ pub const VERSIONED_HASH_VERSION_KZG: u8 = 0x01;
|
||||
#[derive(Educe, Clone, Copy, Encode, Decode)]
|
||||
#[educe(PartialEq, Eq, Hash)]
|
||||
#[ssz(struct_behaviour = "transparent")]
|
||||
pub struct KzgCommitment(pub [u8; c_kzg::BYTES_PER_COMMITMENT]);
|
||||
pub struct KzgCommitment(pub [u8; BYTES_PER_COMMITMENT]);
|
||||
|
||||
impl KzgCommitment {
|
||||
pub fn calculate_versioned_hash(&self) -> Hash256 {
|
||||
@@ -24,13 +24,13 @@ impl KzgCommitment {
|
||||
}
|
||||
|
||||
pub fn empty_for_testing() -> Self {
|
||||
KzgCommitment([0; c_kzg::BYTES_PER_COMMITMENT])
|
||||
KzgCommitment([0; BYTES_PER_COMMITMENT])
|
||||
}
|
||||
}
|
||||
|
||||
impl From<KzgCommitment> for c_kzg::Bytes48 {
|
||||
impl From<KzgCommitment> for Bytes48 {
|
||||
fn from(value: KzgCommitment) -> Self {
|
||||
value.0.into()
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user