mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 22:04:44 +00:00
beacon: consensus: implement engine api getBlobs
This commit is contained in:
@@ -232,7 +232,7 @@ impl<E: EthSpec> From<BeaconBlockBodyMerge<E, FullPayload<E>>>
|
||||
deposits,
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: FullPayload { execution_payload },
|
||||
execution_payload: FullPayload { execution_payload, blobs_bundle },
|
||||
} = body;
|
||||
|
||||
(
|
||||
@@ -272,7 +272,7 @@ for (
|
||||
deposits,
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: FullPayload { execution_payload },
|
||||
execution_payload: FullPayload { execution_payload, blobs_bundle },
|
||||
blob_kzg_commitments,
|
||||
} = body;
|
||||
|
||||
@@ -324,7 +324,7 @@ impl<E: EthSpec> BeaconBlockBodyMerge<E, FullPayload<E>> {
|
||||
deposits,
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: FullPayload { execution_payload },
|
||||
execution_payload: FullPayload { execution_payload, blobs_bundle },
|
||||
} = self;
|
||||
|
||||
BeaconBlockBodyMerge {
|
||||
@@ -356,7 +356,7 @@ impl<E: EthSpec> BeaconBlockBodyEip4844<E, FullPayload<E>> {
|
||||
deposits,
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: FullPayload { execution_payload },
|
||||
execution_payload: FullPayload { execution_payload, blobs_bundle },
|
||||
blob_kzg_commitments,
|
||||
} = self;
|
||||
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
use ssz_types::VariableList;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use ssz::{Decode, DecodeError, Encode};
|
||||
use crate::test_utils::RngCore;
|
||||
use crate::bls_field_element::BlsFieldElement;
|
||||
use crate::EthSpec;
|
||||
use crate::{EthSpec, Uint256};
|
||||
use crate::test_utils::TestRandom;
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Hash, Clone, Serialize, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct Blob<T: EthSpec>(pub VariableList<BlsFieldElement, T::FieldElementsPerBlob>);
|
||||
pub struct Blob<T: EthSpec>(pub VariableList<BlsFieldElement, T::FieldElementsPerBlob>);
|
||||
|
||||
impl <T: EthSpec> TestRandom for Blob<T> {
|
||||
fn random_for_test(rng: &mut impl RngCore) -> Self {
|
||||
let mut res = Blob(VariableList::empty());
|
||||
for i in 0..4096 {
|
||||
let slice = ethereum_types::U256([rng.next_u64(), rng.next_u64(), rng.next_u64(), rng.next_u64()]);
|
||||
let elem =BlsFieldElement(slice);
|
||||
res.0.push(elem);
|
||||
}
|
||||
res
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{test_utils::TestRandom, *};
|
||||
use crate::{test_utils::TestRandom, test_utils::RngCore, *, kzg_commitment::KzgCommitment, kzg_proof::KzgProof, blob::Blob};
|
||||
use derivative::Derivative;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use ssz::Encode;
|
||||
@@ -43,6 +43,24 @@ pub struct ExecutionPayload<T: EthSpec> {
|
||||
pub transactions: Transactions<T>,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Default, Debug, Clone, Serialize, Deserialize, Derivative,
|
||||
)]
|
||||
#[serde(bound = "T: EthSpec")]
|
||||
pub struct BlobsBundle<T: EthSpec> {
|
||||
pub block_hash: Hash256,
|
||||
pub kzgs: Vec<KzgCommitment>,
|
||||
pub blobs: Vec<Blob<T>>,
|
||||
pub aggregated_proof: KzgProof,
|
||||
}
|
||||
|
||||
|
||||
impl <T: EthSpec> TestRandom for BlobsBundle<T> {
|
||||
fn random_for_test(rng: &mut impl RngCore) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> ExecutionPayload<T> {
|
||||
pub fn empty() -> Self {
|
||||
Self::default()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{test_utils::TestRandom, *};
|
||||
use crate::{test_utils::TestRandom, test_utils::RngCore, *};
|
||||
use derivative::Derivative;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -8,6 +8,8 @@ use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
use test_random_derive::TestRandom;
|
||||
use tree_hash::TreeHash;
|
||||
use execution_payload::BlobsBundle;
|
||||
use core::hash::Hasher;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum BlockType {
|
||||
@@ -218,16 +220,37 @@ impl<T: EthSpec> Encode for BlindedPayload<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, Serialize, Deserialize, TestRandom, Derivative)]
|
||||
#[derivative(PartialEq, Hash(bound = "T: EthSpec"))]
|
||||
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(bound = "T: EthSpec")]
|
||||
pub struct FullPayload<T: EthSpec> {
|
||||
pub execution_payload: ExecutionPayload<T>,
|
||||
pub blobs_bundle: Option<BlobsBundle<T>>,
|
||||
}
|
||||
|
||||
impl <T: EthSpec> TestRandom for FullPayload<T> {
|
||||
fn random_for_test(rng: &mut impl RngCore) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl <T: EthSpec> PartialEq for FullPayload<T> {
|
||||
fn eq(&self, other: &FullPayload<T>) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl <T: EthSpec> Hash for FullPayload<T> {
|
||||
fn hash<H: Hasher>(&self, into: &mut H) {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> From<ExecutionPayload<T>> for FullPayload<T> {
|
||||
fn from(execution_payload: ExecutionPayload<T>) -> Self {
|
||||
Self { execution_payload }
|
||||
Self {
|
||||
execution_payload,
|
||||
blobs_bundle: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +288,7 @@ impl<T: EthSpec> Decode for FullPayload<T> {
|
||||
fn from_ssz_bytes(bytes: &[u8]) -> Result<Self, DecodeError> {
|
||||
Ok(FullPayload {
|
||||
execution_payload: Decode::from_ssz_bytes(bytes)?,
|
||||
blobs_bundle: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ impl<E: EthSpec> SignedBeaconBlockMerge<E, BlindedPayload<E>> {
|
||||
deposits,
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: FullPayload { execution_payload },
|
||||
execution_payload: FullPayload { execution_payload: execution_payload, blobs_bundle: None },
|
||||
},
|
||||
},
|
||||
signature,
|
||||
@@ -357,7 +357,7 @@ impl<E: EthSpec> SignedBeaconBlockEip4844<E, BlindedPayload<E>> {
|
||||
deposits,
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: FullPayload { execution_payload },
|
||||
execution_payload: FullPayload { execution_payload: execution_payload, blobs_bundle: None },
|
||||
blob_kzg_commitments,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user