Skip to content

Commit

Permalink
`peersWithDataColumns: Do not filter any more on peer head slot.
Browse files Browse the repository at this point in the history
  • Loading branch information
nalepae committed Oct 3, 2024
1 parent f99a650 commit f42fb87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion beacon-chain/sync/initial-sync/blocks_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ func (f *blocksFetcher) retrieveMissingDataColumnsFromPeers(
}

// Filter peers.
filteredPeers, err := f.peersWithSlotAndDataColumns(peersToFilter, lastSlot, missingDataColumns)
filteredPeers, err := f.peersWithDataColumns(peersToFilter, lastSlot, missingDataColumns)
if err != nil {
return errors.Wrap(err, "peers with slot and data columns")
}
Expand Down
20 changes: 3 additions & 17 deletions beacon-chain/sync/initial-sync/blocks_fetcher_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,12 @@ func (f *blocksFetcher) calculateHeadAndTargetEpochs() (headEpoch, targetEpoch p
return headEpoch, targetEpoch, peers
}

// peersWithSlotAndDataColumns returns a list of peers that should custody all needed data columns for the given slot.
func (f *blocksFetcher) peersWithSlotAndDataColumns(
// peersWithDataColumns returns a list of peers that should custody all needed data columns.
func (f *blocksFetcher) peersWithDataColumns(
peers []peer.ID,
targetSlot primitives.Slot,
dataColumns map[uint64]bool,
) ([]peer.ID, error) {
peersCount := len(peers)

// TODO: Uncomment when we are not in devnet any more.
// TODO: Find a way to have this uncommented without being in devnet.
// // Filter peers based on the percentage of peers to be used in a request.
Expand All @@ -390,20 +388,8 @@ func (f *blocksFetcher) peersWithSlotAndDataColumns(
// TODO: Modify to retrieve data columns from all possible peers.
// TODO: If a peer does respond some of the request columns, do not re-request responded columns.

peersWithAdmissibleHeadSlot := make([]peer.ID, 0, peersCount)

// Filter out peers with head slot lower than the target slot.
for _, peer := range peers {
peerChainState, err := f.p2p.Peers().ChainState(peer)
if err != nil || peerChainState == nil || peerChainState.HeadSlot < targetSlot {
continue
}

peersWithAdmissibleHeadSlot = append(peersWithAdmissibleHeadSlot, peer)
}

// Filter out peers that do not have all the data columns needed.
finalPeers, err := f.custodyAllNeededColumns(peersWithAdmissibleHeadSlot, dataColumns)
finalPeers, err := f.custodyAllNeededColumns(peers, dataColumns)
if err != nil {
return nil, errors.Wrap(err, "custody all needed columns")
}
Expand Down

0 comments on commit f42fb87

Please sign in to comment.