Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Fetch data columns from multiple peers instead of just supernodes #14977

Open
wants to merge 5 commits into
base: peerDAS
Choose a base branch
from

Conversation

niran
Copy link

@niran niran commented Feb 21, 2025

What type of PR is this?

Feature

What does this PR do? Why is it needed?

The initial implementation of data column sampling required all columns to be retrieved from the same peer (typically a supernode). This PR extracts the peer selection logic from the initial sync's block fetcher to be used when pending blocks are received as well. Requests for subsets of data columns are sent to each selected peer.

Which issues(s) does this PR fix?

Implements a portion of #14129

Other notes for review

Acknowledgements

@niran niran requested a review from a team as a code owner February 21, 2025 23:25
@niran niran requested review from terencechain, rkapka and dB2510 and removed request for a team February 21, 2025 23:25
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@nalepae nalepae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove all instances of AdmissibleCustodySamplingPeers.

// - A map, where the key of the map is the custody group, the value is the peer that custodies the group.
// - A slice of descriptions for non admissible peers.
// - An error if any.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

//
// It returns:
// - A map, where the key of the map is the peer, the value is the custody groups of the peer.
// - A map, where the key of the map is the custody group, the value is the peer that custodies the group.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// - A map, where the key of the map is the custody group, the value is the peer that custodies the group.
// - A map, where the key of the map is the custody group, the value is a list of peers that custody the group.

return dataColumnsFromSelectedPeers, nil
}

// custodyGroupsFromPeer compute all the custody groups indexed by peer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// custodyGroupsFromPeer compute all the custody groups indexed by peer.
// custodyGroupsFromPeer computes all the custody groups indexed by peer.

custodyGroupCount := s.CustodyGroupCountFromPeer(peer)

// Get the custody groups of the peer.
custodyGroups, err := peerdas.CustodyGroups(nodeID, custodyGroupCount)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use

peerdas.Info(...)

instead?

Rationale: The Info function uses cached results.

descriptions := make([]string, 0, peerCount)

// Compute custody groups for each peer.
dataColumnsByPeer, err := s.custodyGroupsFromPeer(peers)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dataColumnsByPeer is misnamed, since it corresponds to custody groups, and not data columns.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, we should get data columns from custody groups with peerdas.CustodyColumns.

sidecars, err := SendDataColumnSidecarsByRootRequest(ctx, s.cfg.clock, s.cfg.p2p, peerID, s.ctxMap, &request)
// Assemble the peers who can provide the needed data columns.
peers := s.getBestPeers()
dataColumnsByAdmissiblePeer, _, _, err := s.cfg.p2p.AdmissiblePeersForDataColumns(peers, nil)
if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap the error.

if err != nil {
return err
}
peersToFetchFrom, err := p2p.SelectPeersToFetchDataColumnsFrom(dataColumns, dataColumnsByAdmissiblePeer)
if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap the error.

return err
}
if len(peersToFetchFrom) == 0 {
return errors.Wrapf(errNoPeersForPending, "block root=%#x", blkRoot)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error does not really describe the issue.

return errors.Wrap(err, "send and save data column sidecars")
}

continue
}

// FIXME: Does this need to be in an else branch? It doesn't seem to apply if PeerDAS is active.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok, if peerDAS is active we'll never get here, thanks to the continue at on line 99.

@@ -9,18 +12,14 @@ import (
"github.com/prysmaticlabs/prysm/v5/config/params"
)

var _ DataColumnsHandler = (*Service)(nil)

// AdmissibleCustodyGroupsPeers returns a list of peers that custody a super set of the local node's custody groups.
func (s *Service) AdmissibleCustodyGroupsPeers(peers []peer.ID) ([]peer.ID, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should not be used at all.
Why is the issue when trying to get rid of it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants