blob production

This commit is contained in:
realbigsean
2022-10-05 17:14:45 -04:00
parent 91efb9d4c7
commit b5b4ce9509
17 changed files with 623 additions and 168 deletions

View File

@@ -1,5 +1,5 @@
use crate::kzg_proof::KzgProof;
use crate::{Blob, EthSpec, Hash256, Slot};
use crate::{BeaconBlock, Blob, EthSpec, Hash256, SignedRoot, Slot};
use serde_derive::{Deserialize, Serialize};
use ssz::Encode;
use ssz_derive::{Decode, Encode};
@@ -9,14 +9,17 @@ use tree_hash_derive::TreeHash;
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, PartialEq, Default)]
pub struct BlobsSidecar<E: EthSpec> {
#[serde(bound = "T: EthSpec")]
pub struct BlobsSidecar<T: EthSpec> {
pub beacon_block_root: Hash256,
pub beacon_block_slot: Slot,
pub blobs: VariableList<Blob<E>, E::MaxBlobsPerBlock>,
pub blobs: VariableList<Blob<T>, T::MaxBlobsPerBlock>,
pub kzg_aggregate_proof: KzgProof,
}
impl<E: EthSpec> BlobsSidecar<E> {
impl<T: EthSpec> SignedRoot for BlobsSidecar<T> {}
impl<T: EthSpec> BlobsSidecar<T> {
pub fn empty() -> Self {
Self::default()
}
@@ -24,6 +27,6 @@ impl<E: EthSpec> BlobsSidecar<E> {
// Fixed part
Self::empty().as_ssz_bytes().len()
// Max size of variable length `blobs` field
+ (E::max_blobs_per_block() * <Blob<E> as Encode>::ssz_fixed_len())
+ (T::max_blobs_per_block() * <Blob<T> as Encode>::ssz_fixed_len())
}
}

View File

@@ -8,7 +8,17 @@ use tree_hash_derive::TreeHash;
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, PartialEq)]
pub struct SignedBlobsSidecar<E: EthSpec> {
pub message: BlobsSidecar<E>,
#[serde(bound = "T: EthSpec")]
pub struct SignedBlobsSidecar<T: EthSpec> {
pub message: BlobsSidecar<T>,
pub signature: Signature,
}
impl<T: EthSpec> SignedBlobsSidecar<T> {
pub fn from_blob(blob: BlobsSidecar<T>, signature: Signature) -> Self {
Self {
message: blob,
signature,
}
}
}