-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Refactor Subnet Search #8048
Refactor Subnet Search #8048
Conversation
// for a subnet. So that even in the event of poor peer | ||
// connectivity, we can still broadcast an attestation. | ||
func (s *Service) hasPeerWithSubnet(topic string) bool { | ||
return len(s.pubsub.ListPeers(topic+s.Encoding().ProtocolSuffix())) >= 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is the only way you can access this information, but i worry it will be expensive. We might want to add HasPeer(topic string) to libp2p-pubsub. Just a thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good point, although the API isn't in our direct control and any proposed changes will take some time to be discussed/implemented upstream
beacon-chain/p2p/subnets.go
Outdated
go func() { | ||
wg.Add(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go func() { | |
wg.Add(1) | |
wg.Add(1) | |
go func() { |
I think you need to add this outside of the anonymous function.
…/geth-sharding into revampSubnetSearch
beacon-chain/p2p/iterator.go
Outdated
|
||
// filterNodes wraps an iterator such that Next only returns nodes for which | ||
// the 'check' function returns true. This custom implementation also | ||
// checks for context deadlines so that t |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
godoc incomplete. It would be nice to have an explanation for why we are writing a custom iterator in Prysm
beacon-chain/p2p/subnets.go
Outdated
@@ -18,10 +17,14 @@ var attestationSubnetCount = params.BeaconNetworkConfig().AttestationSubnetCount | |||
|
|||
var attSubnetEnrKey = params.BeaconNetworkConfig().AttSubnetKey | |||
|
|||
const peersRequiredInSubnetSearch = 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be a config parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
beacon-chain/p2p/subnets.go
Outdated
@@ -18,10 +17,14 @@ var attestationSubnetCount = params.BeaconNetworkConfig().AttestationSubnetCount | |||
|
|||
var attSubnetEnrKey = params.BeaconNetworkConfig().AttSubnetKey | |||
|
|||
const peersRequiredInSubnetSearch = 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
What type of PR is this?
Feature Improvement
What does this PR do? Why is it needed?
semantics behind it.
to multiple subnets, this is a saner way to approach filtering for more valid peers.
Which issues(s) does this PR fix?
Fixes #
Other notes for review