mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 04:48:21 +00:00
sync tx blobs
This commit is contained in:
@@ -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())
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user