diff --git a/beacon_node/network/src/sync/backfill_sync/mod.rs b/beacon_node/network/src/sync/backfill_sync/mod.rs index 657aff9662..36816fb5d6 100644 --- a/beacon_node/network/src/sync/backfill_sync/mod.rs +++ b/beacon_node/network/src/sync/backfill_sync/mod.rs @@ -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::() - .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(); diff --git a/beacon_node/network/src/sync/block_lookups/mod.rs b/beacon_node/network/src/sync/block_lookups/mod.rs index 15b5594747..91af931e46 100644 --- a/beacon_node/network/src/sync/block_lookups/mod.rs +++ b/beacon_node/network/src/sync/block_lookups/mod.rs @@ -178,8 +178,13 @@ impl BlockLookups { peer_id: PeerId, cx: &mut SyncNetworkContext, ) -> 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 BlockLookups { // 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 BlockLookups { peer_source: &[PeerId], cx: &mut SyncNetworkContext, ) -> 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 BlockLookups { 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, + // 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, ) -> 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 BlockLookups { } // `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 BlockLookups { }) => { if self.search_parent_of_child( parent_root, - parent_block_hash, + &PeerType::new(parent_block_hash), block_root, &peers, cx, diff --git a/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs b/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs index fef6d6b2b2..32006e65c5 100644 --- a/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs +++ b/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs @@ -149,12 +149,22 @@ impl PayloadRequest { /// 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) -> Self { + match parent_block_hash { + Some(execution_hash) => PeerType::GloasChild(execution_hash), + None => PeerType::Block, + } + } } #[derive(Educe)] @@ -198,8 +208,8 @@ impl SingleBlockLookup { 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 SingleBlockLookup { /// 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 SingleBlockLookup { 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 SingleBlockLookup { .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);