mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-29 18:53:32 +00:00
Blob references in ckzg (#4723)
* Move to using references in ckzg functions * cleanup TrustedSetup a bit * Remove BYTES_PER_FIELD_ELEMENT from KzgPreset
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use c_kzg::{BYTES_PER_G1_POINT, BYTES_PER_G2_POINT, FIELD_ELEMENTS_PER_BLOB};
|
||||
use c_kzg::{BYTES_PER_G1_POINT, BYTES_PER_G2_POINT};
|
||||
use serde::{
|
||||
de::{self, Deserializer, Visitor},
|
||||
Deserialize, Serialize,
|
||||
@@ -22,7 +22,6 @@ struct G2Point([u8; BYTES_PER_G2_POINT]);
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct TrustedSetup {
|
||||
#[serde(rename = "setup_G1_lagrange")]
|
||||
#[serde(deserialize_with = "deserialize_g1_points")]
|
||||
g1_points: Vec<G1Point>,
|
||||
#[serde(rename = "setup_G2")]
|
||||
g2_points: Vec<G2Point>,
|
||||
@@ -134,23 +133,6 @@ impl<'de> Deserialize<'de> for G2Point {
|
||||
}
|
||||
}
|
||||
|
||||
fn deserialize_g1_points<'de, D>(deserializer: D) -> Result<Vec<G1Point>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let mut decoded: Vec<G1Point> = serde::de::Deserialize::deserialize(deserializer)?;
|
||||
// FIELD_ELEMENTS_PER_BLOB is a compile time parameter that
|
||||
// depends on whether lighthouse is compiled with minimal or mainnet features.
|
||||
// Minimal and mainnet trusted setup parameters differ only by the
|
||||
// number of G1 points they contain.
|
||||
//
|
||||
// Hence, we truncate the number of G1 points after deserialisation
|
||||
// to ensure that we have the right number of g1 points in the
|
||||
// trusted setup.
|
||||
decoded.truncate(FIELD_ELEMENTS_PER_BLOB);
|
||||
Ok(decoded)
|
||||
}
|
||||
|
||||
fn strip_prefix(s: &str) -> &str {
|
||||
if let Some(stripped) = s.strip_prefix("0x") {
|
||||
stripped
|
||||
|
||||
Reference in New Issue
Block a user