Rename PeerType variants, add PeerType::new, run backfill test under gloas

- PeerType::PreGloas/PostGloas -> Block/GloasChild (names describe how a peer
  relates to the block, not the fork).
- Add PeerType::new(parent_block_hash) and use it; search_parent_of_child now
  takes peer_type: &PeerType instead of the raw parent_block_hash.
- request_batches_should_not_loop_infinitely: drop the bogus gloas skip and use
  8 validators (4 was too few for a Gloas genesis -> InvalidIndicesCount).
This commit is contained in:
dapplion
2026-06-04 23:17:06 +02:00
parent a99fbde676
commit 67e1048878
3 changed files with 37 additions and 36 deletions

View File

@@ -1227,17 +1227,9 @@ mod tests {
#[test]
fn request_batches_should_not_loop_infinitely() {
// Backfill sync doesn't yet support Gloas (the harness can't build a Gloas interop genesis
// here); skip under a Gloas genesis. TODO(gloas): support backfill sync.
if beacon_chain::test_utils::test_spec::<MinimalEthSpec>()
.fork_name_at_epoch(Epoch::new(0))
.gloas_enabled()
{
return;
}
let harness = BeaconChainHarness::builder(MinimalEthSpec)
.default_spec()
.deterministic_keypairs(4)
.deterministic_keypairs(8)
.fresh_ephemeral_store()
.build();

View File

@@ -178,8 +178,13 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
peer_id: PeerId,
cx: &mut SyncNetworkContext<T>,
) -> bool {
let parent_lookup_exists =
self.search_parent_of_child(parent_root, parent_block_hash, block_root, &[peer_id], cx);
let parent_lookup_exists = self.search_parent_of_child(
parent_root,
&PeerType::new(parent_block_hash),
block_root,
&[peer_id],
cx,
);
// Only create the child lookup if the parent exists
if parent_lookup_exists {
// `search_parent_of_child` ensures that the parent lookup exists so we can safely wait for it
@@ -190,10 +195,10 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
// On a `UnknownParentBlock` or `UnknownParentSidecarHeader` event the peer is not
// required to have the rest of the block components. Create the lookup with zero
// peers to house the block components. We don't know the child's fork yet, so use
// `PreGloas` conservatively; the correct peer set is established when the child's
// `Block` conservatively; the correct peer set is established when the child's
// block downloads and its FULL children begin attesting.
&[],
&PeerType::PreGloas,
&PeerType::Block,
cx,
)
} else {
@@ -211,7 +216,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
peer_source: &[PeerId],
cx: &mut SyncNetworkContext<T>,
) -> bool {
self.new_current_lookup(block_root, None, None, peer_source, &PeerType::PreGloas, cx)
self.new_current_lookup(block_root, None, None, peer_source, &PeerType::Block, cx)
}
/// A block or blob triggers the search of a parent.
@@ -224,17 +229,14 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
pub fn search_parent_of_child(
&mut self,
block_root_to_search: Hash256,
// Post-Gloas only: the child's bid `parent_block_hash` (the parent's execution hash). Peers
// that imported the FULL child can serve the parent's payload envelope and data columns.
parent_block_hash: Option<ExecutionBlockHash>,
// Classifies `peers` relative to the parent being searched: `GloasChild` when they imported
// the FULL child (and so can serve the parent's payload envelope and data columns), else
// `Block`.
peer_type: &PeerType,
child_block_root_trigger: Hash256,
peers: &[PeerId],
cx: &mut SyncNetworkContext<T>,
) -> bool {
let peer_type = match parent_block_hash {
Some(execution_hash) => PeerType::PostGloas(execution_hash),
None => PeerType::PreGloas,
};
let parent_chains = self.active_parent_lookups();
for (chain_idx, parent_chain) in parent_chains.iter().enumerate() {
@@ -323,7 +325,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
}
// `block_root_to_search` is a failed chain check happens inside new_current_lookup
self.new_current_lookup(block_root_to_search, None, None, peers, &peer_type, cx)
self.new_current_lookup(block_root_to_search, None, None, peers, peer_type, cx)
}
/// Searches for a single block hash. If the blocks parent is unknown, a chain of blocks is
@@ -622,7 +624,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
}) => {
if self.search_parent_of_child(
parent_root,
parent_block_hash,
&PeerType::new(parent_block_hash),
block_root,
&peers,
cx,

View File

@@ -149,12 +149,22 @@ impl<E: EthSpec> PayloadRequest<E> {
/// Classifies how a peer relates to a lookup, controlling which peer set it is added to.
pub enum PeerType {
/// Pre-Gloas: the peer can serve the block and its data columns.
PreGloas,
/// Post-Gloas: the peer claims to have imported a child of this block whose bid references
/// The peer can serve the looked-up block and (pre-Gloas) its data columns.
Block,
/// The peer claims to have imported a FULL child of this block whose bid references
/// `ExecutionBlockHash` as its parent. Such peers can serve this block's payload envelope and
/// data columns (only if this block is FULL).
PostGloas(ExecutionBlockHash),
/// data columns.
GloasChild(ExecutionBlockHash),
}
impl PeerType {
/// `GloasChild` when the block's bid `parent_block_hash` is known (post-Gloas), else `Block`.
pub fn new(parent_block_hash: Option<ExecutionBlockHash>) -> Self {
match parent_block_hash {
Some(execution_hash) => PeerType::GloasChild(execution_hash),
None => PeerType::Block,
}
}
}
#[derive(Educe)]
@@ -198,8 +208,8 @@ impl<T: BeaconChainTypes> SingleBlockLookup<T> {
let block_peers: PeerSet = Arc::new(RwLock::new(peers.iter().copied().collect()));
let mut gloas_child_peers = HashMap::new();
match peer_type {
PeerType::PreGloas => {}
PeerType::PostGloas(execution_hash) => {
PeerType::Block => {}
PeerType::GloasChild(execution_hash) => {
gloas_child_peers.insert(*execution_hash, block_peers.clone());
}
}
@@ -265,10 +275,7 @@ impl<T: BeaconChainTypes> SingleBlockLookup<T> {
/// Returns the `PeerType` to use when propagating this lookup's peers up to its parent lookup.
pub fn awaiting_parent_peer_type(&self) -> PeerType {
match self.bid_parent_block_hash() {
Some(execution_hash) => PeerType::PostGloas(execution_hash),
None => PeerType::PreGloas,
}
PeerType::new(self.bid_parent_block_hash())
}
/// Returns the time elapsed since this lookup was created
@@ -600,7 +607,7 @@ impl<T: BeaconChainTypes> SingleBlockLookup<T> {
pub fn add_peer(&mut self, peer_id: PeerId, peer_type: &PeerType) -> bool {
let mut added = false;
match peer_type {
PeerType::PostGloas(execution_hash) => {
PeerType::GloasChild(execution_hash) => {
// This peer claims to have imported a FULL child of this block whose bid references
// `execution_hash` as its parent. It is therefore proven to hold this block's
// payload envelope and data columns.
@@ -612,7 +619,7 @@ impl<T: BeaconChainTypes> SingleBlockLookup<T> {
.write()
.insert(peer_id);
}
PeerType::PreGloas => {}
PeerType::Block => {}
}
// Always add to the main block peers, they can at least serve the block.
added |= self.peers.write().insert(peer_id);