sync tx blobs

This commit is contained in:
realbigsean
2022-02-19 15:00:45 -07:00
parent 4cdf1b546d
commit 4008da6c60
13 changed files with 157 additions and 15 deletions

View File

@@ -1,14 +1,27 @@
use crate::{Blob, EthSpec, Hash256, SignedBeaconBlock, Slot};
use serde_derive::{Deserialize, Serialize};
use ssz_derive::Encode;
use ssz_derive::{Encode, Decode};
use ssz_types::VariableList;
use tree_hash::TreeHash;
use tree_hash_derive::TreeHash;
use ssz::{Decode, Encode};
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive(Debug, Clone, Serialize, Deserialize, Encode, TreeHash)]
#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, PartialEq, Default)]
pub struct BlobWrapper<E: EthSpec> {
pub beacon_block_root: Hash256,
pub beacon_block_slot: Slot,
pub blobs: VariableList<Blob<E::ChunksPerBlob>, E::MaxObjectListSize>,
}
impl <E: EthSpec> BlobWrapper<E> {
pub fn empty() -> Self {
Self::default()
}
pub fn max_size() -> usize {
// Fixed part
Self::empty().as_ssz_bytes().len()
// Max size of variable length `blobs` field
+ (E::max_object_list_size() * <Blob<E::ChunksPerBlob> as Encode>::ssz_fixed_len())
}
}

View File

@@ -227,6 +227,14 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
fn bytes_per_logs_bloom() -> usize {
Self::BytesPerLogsBloom::to_usize()
}
fn max_object_list_size() -> usize {
Self::MaxObjectListSize::to_usize()
}
fn chunks_per_blob() -> usize {
Self::ChunksPerBlob::to_usize()
}
}
/// Macro to inherit some type values from another EthSpec.

View File

@@ -169,6 +169,7 @@ pub use crate::validator_registration_data::*;
pub use crate::validator_subscription::ValidatorSubscription;
pub use crate::voluntary_exit::VoluntaryExit;
use serde_big_array::BigArray;
pub use crate::blob_wrapper::BlobWrapper;
pub type CommitteeIndex = u64;
pub type Hash256 = H256;