mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Offloading KZG Proof Computation from the beacon node (#7117)
Addresses #7108 - Add EL integration for `getPayloadV5` and `getBlobsV2` - Offload proof computation and use proofs from EL RPC APIs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::beacon_block_body::{KzgCommitments, BLOB_KZG_COMMITMENTS_INDEX};
|
||||
use crate::test_utils::TestRandom;
|
||||
use crate::BeaconStateError;
|
||||
use crate::{BeaconBlockHeader, Epoch, EthSpec, Hash256, KzgProofs, SignedBeaconBlockHeader, Slot};
|
||||
use crate::{BeaconBlockHeader, Epoch, EthSpec, Hash256, SignedBeaconBlockHeader, Slot};
|
||||
use bls::Signature;
|
||||
use derivative::Derivative;
|
||||
use kzg::Error as KzgError;
|
||||
@@ -56,7 +56,7 @@ pub struct DataColumnSidecar<E: EthSpec> {
|
||||
pub column: DataColumn<E>,
|
||||
/// All the KZG commitments and proofs associated with the block, used for verifying sample cells.
|
||||
pub kzg_commitments: KzgCommitments<E>,
|
||||
pub kzg_proofs: KzgProofs<E>,
|
||||
pub kzg_proofs: VariableList<KzgProof, E::MaxBlobCommitmentsPerBlock>,
|
||||
pub signed_block_header: SignedBeaconBlockHeader,
|
||||
/// An inclusion proof, proving the inclusion of `blob_kzg_commitments` in `BeaconBlockBody`.
|
||||
pub kzg_commitments_inclusion_proof: FixedVector<Hash256, E::KzgCommitmentsInclusionProofDepth>,
|
||||
|
||||
@@ -4,8 +4,8 @@ use safe_arith::SafeArith;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ssz_types::typenum::{
|
||||
bit::B0, UInt, U0, U1, U10, U1024, U1048576, U1073741824, U1099511627776, U128, U131072,
|
||||
U134217728, U16, U16777216, U17, U2, U2048, U256, U262144, U32, U4, U4096, U512, U625, U64,
|
||||
U65536, U8, U8192,
|
||||
U134217728, U16, U16777216, U17, U2, U2048, U256, U262144, U32, U33554432, U4, U4096, U512,
|
||||
U625, U64, U65536, U8, U8192,
|
||||
};
|
||||
use std::fmt::{self, Debug};
|
||||
use std::str::FromStr;
|
||||
@@ -146,6 +146,11 @@ pub trait EthSpec:
|
||||
/// Must be set to `BytesPerFieldElement * FieldElementsPerCell`.
|
||||
type BytesPerCell: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
|
||||
/// The maximum number of cell commitments per block
|
||||
///
|
||||
/// FieldElementsPerExtBlob * MaxBlobCommitmentsPerBlock
|
||||
type MaxCellsPerBlock: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
|
||||
/*
|
||||
* New in Electra
|
||||
*/
|
||||
@@ -421,6 +426,7 @@ impl EthSpec for MainnetEthSpec {
|
||||
type FieldElementsPerExtBlob = U8192;
|
||||
type BytesPerBlob = U131072;
|
||||
type BytesPerCell = U2048;
|
||||
type MaxCellsPerBlock = U33554432;
|
||||
type KzgCommitmentInclusionProofDepth = U17;
|
||||
type KzgCommitmentsInclusionProofDepth = U4; // inclusion of the whole list of commitments
|
||||
type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count
|
||||
@@ -474,6 +480,7 @@ impl EthSpec for MinimalEthSpec {
|
||||
type MaxWithdrawalRequestsPerPayload = U2;
|
||||
type FieldElementsPerCell = U64;
|
||||
type FieldElementsPerExtBlob = U8192;
|
||||
type MaxCellsPerBlock = U33554432;
|
||||
type BytesPerCell = U2048;
|
||||
type KzgCommitmentsInclusionProofDepth = U4;
|
||||
|
||||
@@ -566,6 +573,7 @@ impl EthSpec for GnosisEthSpec {
|
||||
type MaxPendingDepositsPerEpoch = U16;
|
||||
type FieldElementsPerCell = U64;
|
||||
type FieldElementsPerExtBlob = U8192;
|
||||
type MaxCellsPerBlock = U33554432;
|
||||
type BytesPerCell = U2048;
|
||||
type KzgCommitmentsInclusionProofDepth = U4;
|
||||
|
||||
|
||||
@@ -272,7 +272,14 @@ pub type Address = fixed_bytes::Address;
|
||||
pub type ForkVersion = [u8; 4];
|
||||
pub type BLSFieldElement = Uint256;
|
||||
pub type Blob<E> = FixedVector<u8, <E as EthSpec>::BytesPerBlob>;
|
||||
pub type KzgProofs<E> = VariableList<KzgProof, <E as EthSpec>::MaxBlobCommitmentsPerBlock>;
|
||||
// Note on List limit:
|
||||
// - Deneb to Electra: `MaxBlobCommitmentsPerBlock`
|
||||
// - Fulu: `MaxCellsPerBlock`
|
||||
// We choose to use a single type (with the larger value from Fulu as `N`) instead of having to
|
||||
// introduce a new type for Fulu. This is to avoid messy conversions and having to add extra types
|
||||
// with no gains - as `N` does not impact serialisation at all, and only affects merkleization,
|
||||
// which we don't current do on `KzgProofs` anyway.
|
||||
pub type KzgProofs<E> = VariableList<KzgProof, <E as EthSpec>::MaxCellsPerBlock>;
|
||||
pub type VersionedHash = Hash256;
|
||||
pub type Hash64 = alloy_primitives::B64;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user