mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
When looking for peers, skip peers with error instead of aborting the whole function (#15815)
* `findPeersWithSubnets`: If the `filter` function returns an error for a given peer, log an error and skip the peer instead of aborting the whole function. * `computeIndicesByRootByPeer`: If the loop returns an error for a given peer, log an error and skip the peer instead of aborting the whole function. * Add changelog. --------- Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
|||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/go-bitfield"
|
"github.com/prysmaticlabs/go-bitfield"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -223,8 +224,14 @@ func (s *Service) findPeersWithSubnets(
|
|||||||
// Skip nodes that are not subscribed to any of the defective subnets.
|
// Skip nodes that are not subscribed to any of the defective subnets.
|
||||||
nodeSubnets, err := filter(node)
|
nodeSubnets, err := filter(node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "filter node")
|
log.WithError(err).WithFields(logrus.Fields{
|
||||||
|
"nodeID": node.ID(),
|
||||||
|
"topicFormat": topicFormat,
|
||||||
|
}).Debug("Could not get needed subnets from peer")
|
||||||
|
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(nodeSubnets) == 0 {
|
if len(nodeSubnets) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1022,17 +1022,20 @@ func computeIndicesByRootByPeer(
|
|||||||
peersByIndex := make(map[uint64]map[goPeer.ID]bool)
|
peersByIndex := make(map[uint64]map[goPeer.ID]bool)
|
||||||
headSlotByPeer := make(map[goPeer.ID]primitives.Slot)
|
headSlotByPeer := make(map[goPeer.ID]primitives.Slot)
|
||||||
for peer := range peers {
|
for peer := range peers {
|
||||||
|
log := log.WithField("peerID", peer)
|
||||||
|
|
||||||
// Computes the custody columns for each peer
|
// Computes the custody columns for each peer
|
||||||
nodeID, err := prysmP2P.ConvertPeerIDToNodeID(peer)
|
nodeID, err := prysmP2P.ConvertPeerIDToNodeID(peer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "convert peer ID to node ID for peer %s", peer)
|
log.WithError(err).Debug("Failed to convert peer ID to node ID")
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
custodyGroupCount := p2p.CustodyGroupCountFromPeer(peer)
|
custodyGroupCount := p2p.CustodyGroupCountFromPeer(peer)
|
||||||
|
|
||||||
dasInfo, _, err := peerdas.Info(nodeID, custodyGroupCount)
|
dasInfo, _, err := peerdas.Info(nodeID, custodyGroupCount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "peerdas info for peer %s", peer)
|
log.WithError(err).Debug("Failed to get peer DAS info")
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for column := range dasInfo.CustodyColumns {
|
for column := range dasInfo.CustodyColumns {
|
||||||
@@ -1045,11 +1048,13 @@ func computeIndicesByRootByPeer(
|
|||||||
// Compute the head slot for each peer
|
// Compute the head slot for each peer
|
||||||
peerChainState, err := p2p.Peers().ChainState(peer)
|
peerChainState, err := p2p.Peers().ChainState(peer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "get chain state for peer %s", peer)
|
log.WithError(err).Debug("Failed to get peer chain state")
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if peerChainState == nil {
|
if peerChainState == nil {
|
||||||
return nil, errors.Errorf("chain state is nil for peer %s", peer)
|
log.Debug("Peer chain state is nil")
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Our view of the head slot of a peer is not updated in real time.
|
// Our view of the head slot of a peer is not updated in real time.
|
||||||
|
|||||||
3
changelog/manu-skip-bad-peers.md
Normal file
3
changelog/manu-skip-bad-peers.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
### Fixed
|
||||||
|
- `findPeersWithSubnets`: If the filter function returns an error for a given peer, log an error and skip the peer instead of aborting the whole function.
|
||||||
|
- `computeIndicesByRootByPeer`: If the loop returns an error for a given peer, log an error and skip the peer instead of aborting the whole function.
|
||||||
Reference in New Issue
Block a user