add new traits

This commit is contained in:
realbigsean
2023-01-20 16:04:35 -05:00
parent 3cb8fb7973
commit eb9feed784
4 changed files with 284 additions and 142 deletions

View File

@@ -7,7 +7,7 @@ use crate::attester_cache::{AttesterCache, AttesterCacheKey};
use crate::beacon_proposer_cache::compute_proposer_duties_from_head;
use crate::beacon_proposer_cache::BeaconProposerCache;
use crate::blob_cache::BlobCache;
use crate::blob_verification::{AvailableBlock, BlockWrapper, IntoAvailableBlock};
use crate::blob_verification::{AsBlock, AvailableBlock, BlockWrapper, IntoAvailableBlock};
use crate::block_times_cache::BlockTimesCache;
use crate::block_verification::{
check_block_is_finalized_descendant, check_block_relevancy, get_block_root,
@@ -2367,22 +2367,19 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
let children = chain_segment
.iter()
.skip(1)
.map(|block| (block.block().parent_root(), block.slot()))
.map(|block| (block.parent_root(), block.slot()))
.collect::<Vec<_>>();
for (i, block) in chain_segment.into_iter().enumerate() {
// Ensure the block is the correct structure for the fork at `block.slot()`.
if let Err(e) = block.block().fork_name(&self.spec) {
if let Err(e) = block.as_block().fork_name(&self.spec) {
return Err(ChainSegmentResult::Failed {
imported_blocks,
error: BlockError::InconsistentFork(e),
});
}
let block_root = get_block_root(block.block());
//FIXME(sean)
let available_block = block.into_available_block(block_root);
let block_root = get_block_root(block.as_block());
if let Some((child_parent_root, child_slot)) = children.get(i) {
// If this block has a child in this chain segment, ensure that its parent root matches
@@ -2406,7 +2403,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}
}
match check_block_relevancy(block.block(), block_root, self) {
match check_block_relevancy(block.as_block(), block_root, self) {
// If the block is relevant, add it to the filtered chain segment.
Ok(_) => filtered_chain_segment.push((block_root, block)),
// If the block is already known, simply ignore this block.