diff --git a/beacon_node/Cargo.toml b/beacon_node/Cargo.toml index 309d7a83f..4cdd4c1df 100644 --- a/beacon_node/Cargo.toml +++ b/beacon_node/Cargo.toml @@ -20,6 +20,7 @@ withdrawals-processing = [ "execution_layer/withdrawals-processing", "http_api/withdrawals-processing", ] +spec-minimal = ["beacon_chain/spec-minimal"] [dependencies] eth2_config = { path = "../common/eth2_config" } diff --git a/beacon_node/beacon_chain/Cargo.toml b/beacon_node/beacon_chain/Cargo.toml index c53a4355b..87ed0e8e5 100644 --- a/beacon_node/beacon_chain/Cargo.toml +++ b/beacon_node/beacon_chain/Cargo.toml @@ -17,6 +17,7 @@ withdrawals-processing = [ "execution_layer/withdrawals-processing", "operation_pool/withdrawals-processing" ] +spec-minimal = ["kzg/minimal-spec"] [dev-dependencies] maplit = "1.0.2" diff --git a/beacon_node/beacon_chain/src/kzg_utils.rs b/beacon_node/beacon_chain/src/kzg_utils.rs index 7e62e0c31..48a3f6e8a 100644 --- a/beacon_node/beacon_chain/src/kzg_utils.rs +++ b/beacon_node/beacon_chain/src/kzg_utils.rs @@ -1,13 +1,12 @@ -use kzg::{Error as KzgError, Kzg}; +use kzg::{Error as KzgError, Kzg, BYTES_PER_BLOB}; use types::{Blob, BlobsSidecar, EthSpec, Hash256, KzgCommitment, KzgProof, Slot}; -// TODO(pawan): make this generic over blob size -fn ssz_blob_to_crypto_blob(blob: Blob) -> Option<[u8; 131072]> { - if blob.len() != 131072 { +fn ssz_blob_to_crypto_blob(blob: Blob) -> Option<[u8; BYTES_PER_BLOB]> { + if blob.len() != BYTES_PER_BLOB { return None; } let blob_vec: Vec = blob.into(); - let mut arr = [0; 131072]; + let mut arr = [0; BYTES_PER_BLOB]; arr.copy_from_slice(&blob_vec); Some(arr) } diff --git a/crypto/kzg/Cargo.toml b/crypto/kzg/Cargo.toml index d61745e14..aff195310 100644 --- a/crypto/kzg/Cargo.toml +++ b/crypto/kzg/Cargo.toml @@ -18,5 +18,9 @@ eth2_serde_utils = "0.1.1" hex = "0.4.2" eth2_hashing = "0.3.0" ethereum-types = "0.12.1" -c-kzg = {git = "https://github.com/pawanjay176/c-kzg-4844", rev = "669a13800a8a0d094c5387db58e06936ef194a25" } +c-kzg = {git = "https://github.com/pawanjay176/c-kzg-4844", rev = "48c048b12a7d29ae3e7bf09000e07870da4cb701" } +[features] +default = ["mainnet-spec"] +mainnet-spec = ["c-kzg/mainnet-spec"] +minimal-spec = ["c-kzg/minimal-spec"] \ No newline at end of file diff --git a/crypto/kzg/src/lib.rs b/crypto/kzg/src/lib.rs index 914157fec..350dff8cb 100644 --- a/crypto/kzg/src/lib.rs +++ b/crypto/kzg/src/lib.rs @@ -3,11 +3,12 @@ mod kzg_proof; pub use crate::{kzg_commitment::KzgCommitment, kzg_proof::KzgProof}; pub use c_kzg::bytes_to_g1; -use c_kzg::{Error as CKzgError, KZGSettings, BYTES_PER_FIELD_ELEMENT, FIELD_ELEMENTS_PER_BLOB}; +pub use c_kzg::{ + Error as CKzgError, KZGSettings, BYTES_PER_BLOB, BYTES_PER_FIELD_ELEMENT, + FIELD_ELEMENTS_PER_BLOB, +}; use std::path::PathBuf; -const BYTES_PER_BLOB: usize = FIELD_ELEMENTS_PER_BLOB * BYTES_PER_FIELD_ELEMENT; - /// The consensus type `Blob` is generic over EthSpec, so it cannot be imported /// in this crate without creating a cyclic dependency between the kzg and consensus/types crates. /// So need to use a Vec here unless we think of a smarter way of doing this @@ -32,7 +33,7 @@ pub struct Kzg { impl Kzg { pub fn new_from_file(file_path: PathBuf) -> Result { Ok(Self { - trusted_setup: KZGSettings::load_trusted_setup(file_path) + trusted_setup: KZGSettings::load_trusted_setup_file(file_path) .map_err(Error::InvalidTrustedSetup)?, }) } diff --git a/lighthouse/Cargo.toml b/lighthouse/Cargo.toml index 3b4dd5753..8af376d55 100644 --- a/lighthouse/Cargo.toml +++ b/lighthouse/Cargo.toml @@ -17,7 +17,7 @@ modern = ["bls/supranational-force-adx"] # Uses the slower Milagro BLS library, which is written in native Rust. milagro = ["bls/milagro"] # Support minimal spec (used for testing only). -spec-minimal = [] +spec-minimal = ["beacon_node/spec-minimal"] # Support Gnosis spec and Gnosis Beacon Chain. gnosis = [] # Support slasher MDBX backend.