resolve merge conflict and migrate il service to new pardigmn

This commit is contained in:
Eitan Seri-Levi
2025-05-21 12:43:43 -07:00
358 changed files with 11541 additions and 6759 deletions

View File

@@ -6,11 +6,11 @@ use ssz::Encode;
use ssz_derive::{Decode, Encode};
use std::collections::{HashMap, HashSet};
use superstruct::superstruct;
use tracing::info;
use types::{
AttestationShufflingId, ChainSpec, Checkpoint, Epoch, EthSpec, ExecutionBlockHash,
FixedBytesExtended, Hash256, Slot,
};
use tracing::info;
// Define a "legacy" implementation of `Option<usize>` which uses four bytes for encoding the union
// selector.
@@ -1075,6 +1075,21 @@ impl ProtoArray {
})
.map(|node| node.root)
}
/// Returns all nodes that have zero children and are descended from the finalized checkpoint.
///
/// For informational purposes like the beacon HTTP API, we use this as the list of known heads,
/// even though some of them might not be viable. We do this to maintain consistency between the
/// definition of "head" used by pruning (which does not consider viability) and fork choice.
pub fn heads_descended_from_finalization<E: EthSpec>(&self) -> Vec<&ProtoNode> {
self.nodes
.iter()
.filter(|node| {
node.best_child.is_none()
&& self.is_finalized_checkpoint_or_descendant::<E>(node.root)
})
.collect()
}
}
/// A helper method to calculate the proposer boost based on the given `justified_balances`.

View File

@@ -858,10 +858,18 @@ impl ProtoArrayForkChoice {
}
/// See `ProtoArray::iter_nodes`
pub fn iter_nodes<'a>(&'a self, block_root: &Hash256) -> Iter<'a> {
pub fn iter_nodes(&self, block_root: &Hash256) -> Iter {
self.proto_array.iter_nodes(block_root)
}
/// See `ProtoArray::iter_block_roots`
pub fn iter_block_roots(
&self,
block_root: &Hash256,
) -> impl Iterator<Item = (Hash256, Slot)> + use<'_> {
self.proto_array.iter_block_roots(block_root)
}
pub fn as_bytes(&self) -> Vec<u8> {
SszContainer::from(self).as_ssz_bytes()
}
@@ -887,6 +895,11 @@ impl ProtoArrayForkChoice {
pub fn core_proto_array_mut(&mut self) -> &mut ProtoArray {
&mut self.proto_array
}
/// Returns all nodes that have zero children and are descended from the finalized checkpoint.
pub fn heads_descended_from_finalization<E: EthSpec>(&self) -> Vec<&ProtoNode> {
self.proto_array.heads_descended_from_finalization::<E>()
}
}
/// Returns a list of `deltas`, where there is one delta for each of the indices in