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

making the network middleware peer manager and connection gating optional #1040

Merged
merged 7 commits into from
Jul 29, 2021

Conversation

vishalchangrani
Copy link
Contributor

@vishalchangrani vishalchangrani commented Jul 27, 2021

Currently, for the regular (staked) network we have connection gating and peer manager ON by default.

  • Connection gating whitelists the connection allowing a node to only accept inbound connections from a node ID that is part of the identity list.
  • Peer Manager adds and removes peers periodically

For the unstaked Access Node network, we don't want either of these since the participants of the network are not known upfront and for peer management we could directly use the libp2p's PeerDiscovery.

This change makes those two features configurable in the middleware and switches them off for the access node on the unstaked network.

Closes: https://github.com/dapperlabs/flow-go/issues/5703

@codecov-commenter
Copy link

codecov-commenter commented Jul 27, 2021

Codecov Report

Merging #1040 (6b81002) into master (8e0d32b) will decrease coverage by 0.04%.
The diff coverage is 8.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1040      +/-   ##
==========================================
- Coverage   53.38%   53.33%   -0.05%     
==========================================
  Files         318      318              
  Lines       21491    21506      +15     
==========================================
- Hits        11472    11471       -1     
- Misses       8450     8468      +18     
+ Partials     1569     1567       -2     
Flag Coverage Δ
unittests 53.33% <8.33%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
network/p2p/middleware.go 0.00% <0.00%> (ø)
network/test/testUtil.go 95.72% <100.00%> (+0.07%) ⬆️
...sus/approvals/assignment_collector_statemachine.go 47.11% <0.00%> (-2.89%) ⬇️
engine/common/synchronization/engine.go 64.01% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e0d32b...6b81002. Read the comment docs.

Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

That now makes sense to me thanks to your comment!

I left a few nits, which should not be blocking.

// unicastMessageTimeout is the timeout used for unicast messages
// connectionGating if set to True, restricts this node to only talk to other nodes which are part of the identity list
// managePeerConnections if set to True, enables the default PeerManager which continuously updates the node's peer connections
// validators are the set of the different message validators that each inbound messages is passed through
func NewMiddleware(log zerolog.Logger,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: do we want to log an issue for refactoring this long list of configuration options to a cfg struct with a functional options pattern, or stg similar to how internal libp2p config options work? That's probably also valid for our LibP2P Host and its long sequence of configs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created this issue - https://github.com/dapperlabs/flow-go/issues/5713 to track that work

Comment on lines 390 to 391
if m.managePeerConnections {
m.peerManager.RequestPeerUpdate()
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: that works, but there's a naked nil peerManager in the middleware that's a crash waiting to happen if it's one day accessed without checking the flag. Could we use a getter here?

err = m.libP2PNode.UpdateAllowList(identityList(idsMap))
if err != nil {
return fmt.Errorf("failed to update approved peer list: %w", err)
// update libp2pNode's approve lists is this middleware also does connection gating
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
// update libp2pNode's approve lists is this middleware also does connection gating
// update libp2pNode's approve lists if this middleware also does connection gating

@vishalchangrani vishalchangrani merged commit 5764ee7 into master Jul 29, 2021
@vishalchangrani vishalchangrani deleted the vishal/middleware_optional_peermanager branch July 29, 2021 23:33
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.

None yet

4 participants