more work

This commit is contained in:
realbigsean
2023-04-11 13:13:13 -04:00
parent 66e09f49d7
commit 25ff6e8a5f
13 changed files with 918 additions and 477 deletions

View File

@@ -2880,9 +2880,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
Availability::PendingBlock(block_root) => {
Ok(AvailabilityProcessingStatus::PendingBlock(block_root))
}
Availability::PendingBlobs(block_root, blob_ids) => {
Ok(AvailabilityProcessingStatus::PendingBlobs(block_root, blob_ids))
}
Availability::PendingBlobs(block_root, blob_ids) => Ok(
AvailabilityProcessingStatus::PendingBlobs(block_root, blob_ids),
),
}
}

View File

@@ -146,7 +146,7 @@ pub enum BlockError<T: EthSpec> {
///
/// It's unclear if this block is valid, but it cannot be processed without already knowing
/// its parent.
ParentUnknown(BlockWrapper<T>),
ParentUnknown(MaybeAvailableBlock<T>),
/// The block skips too many slots and is a DoS risk.
TooManySkippedSlots {
parent_slot: Slot,
@@ -311,7 +311,6 @@ pub enum BlockError<T: EthSpec> {
parent_root: Hash256,
},
BlobValidation(BlobError),
AvailabilityCheck(AvailabilityCheckError),
}
impl<T: EthSpec> From<BlobError> for BlockError<T> {
@@ -1332,7 +1331,7 @@ impl<T: BeaconChainTypes> ExecutionPendingBlock<T> {
// because it will revert finalization. Note that the finalized block is stored in fork
// choice, so we will not reject any child of the finalized block (this is relevant during
// genesis).
return Err(BlockError::ParentUnknown(block.into_block_wrapper()));
return Err(BlockError::ParentUnknown(block));
}
// Reject any block that exceeds our limit on skipped slots.
@@ -1796,7 +1795,7 @@ pub fn check_block_is_finalized_checkpoint_or_descendant<
block_parent_root: block.parent_root(),
})
} else {
Err(BlockError::ParentUnknown(block.into_block_wrapper()))
Err(BlockError::ParentUnknown(block))
}
}
}
@@ -1877,7 +1876,7 @@ fn verify_parent_block_is_known<T: BeaconChainTypes>(
{
Ok((proto_block, block))
} else {
Err(BlockError::ParentUnknown(block.into_block_wrapper()))
Err(BlockError::ParentUnknown(block))
}
}
@@ -1908,7 +1907,7 @@ fn load_parent<T: BeaconChainTypes, B: AsBlock<T::EthSpec>>(
.fork_choice_read_lock()
.contains_block(&block.parent_root())
{
return Err(BlockError::ParentUnknown(block.into_block_wrapper()));
return Err(BlockError::ParentUnknown(block));
}
let block_delay = chain

View File

@@ -426,7 +426,7 @@ impl<T: EthSpec, S: SlotClock> DataAvailabilityChecker<T, S> {
BlobRequirements::PreDeneb => VerifiedBlobs::PreDeneb,
BlobRequirements::Required => {
return Ok(MaybeAvailableBlock::AvailabilityPending(
AvailabilityPendingBlock { block },
AvailabilityPendingBlock { block, blobs },
))
}
};
@@ -547,9 +547,22 @@ pub enum BlobRequirements {
#[derive(Clone, Debug, PartialEq)]
pub struct AvailabilityPendingBlock<E: EthSpec> {
block: Arc<SignedBeaconBlock<E>>,
missing_blob_ids: Vec<BlobIdentifier>,
}
impl<E: EthSpec> AvailabilityPendingBlock<E> {
pub fn get_missing_blob_ids(&self) -> &Vec<BlobIdentifier> {
&self.missing_blob_ids
}
pub fn has_blob(mut self, blob_id: &BlobIdentifier) -> bool {
if let Some(Some(blob)) = self.blobs.get(blob_id.index as usize) {
blob.block_root == blob_id.block_root
} else {
false
}
}
pub fn num_blobs_expected(&self) -> usize {
self.kzg_commitments()
.map_or(0, |commitments| commitments.len())
@@ -623,6 +636,13 @@ impl<E: EthSpec> AvailableBlock<E> {
&self.block
}
pub fn da_check_required(&self) -> bool {
match self.blobs {
VerifiedBlobs::PreDeneb | VerifiedBlobs::NotRequired => false,
VerifiedBlobs::EmptyBlobs | VerifiedBlobs::Available(_) => true,
}
}
pub fn deconstruct(self) -> (Arc<SignedBeaconBlock<E>>, Option<BlobSidecarList<E>>) {
match self.blobs {
VerifiedBlobs::EmptyBlobs | VerifiedBlobs::NotRequired | VerifiedBlobs::PreDeneb => {