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

[AccessNode] Disable connection pruning for staked AN that supports unstaked AN #1254

Merged
merged 7 commits into from
Sep 7, 2021

Conversation

vishalchangrani
Copy link
Contributor

  1. Adds back the peer manager to the Staked AN which supports the unstaked AN.
  2. Allows the peer manager to skip connection pruning optionally.

@@ -572,29 +572,6 @@ func (builder *FlowAccessNodeBuilder) extraFlags() {
})
}

// initMiddleware creates the network.Middleware implementation with the libp2p factory function, metrics, peer update
// interval, and validators. The network.Middleware is then passed into the initNetwork function.
func (builder *FlowAccessNodeBuilder) initMiddleware(nodeID flow.Identifier,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Stake AN and the UAN no longer share the common middleware that was being generated by this function. Instead they each have their own version of this method - one with peer manager and one without.

validators ...network.MessageValidator) network.Middleware {

// disable connection pruning for the staked AN which supports the unstaked AN
peerManagerFactory := p2p.PeerManagerFactory([]p2p.Option{p2p.WithInterval(builder.PeerUpdateInterval)}, p2p.DisableConnectionPruning())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

use the stock PeerManager but don't prune connections

backoffConnector: connector,
host: host,
log: log,
}, nil
pruneConnections: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

default is to always prune

// connect to each of the peer.AddrInfo in pInfos
l.connectToPeers(ctx, peerIDs)

// disconnect from any other peers not in pInfos
l.trimAllConnectionsExcept(peerIDs)
if l.pruneConnections {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

THE check

@codecov-commenter
Copy link

codecov-commenter commented Sep 4, 2021

Codecov Report

Merging #1254 (4f5e16a) into master (7b0ae36) will increase coverage by 0.00%.
The diff coverage is 28.57%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1254   +/-   ##
=======================================
  Coverage   56.18%   56.18%           
=======================================
  Files         496      496           
  Lines       30179    30190   +11     
=======================================
+ Hits        16956    16963    +7     
- Misses      10921    10924    +3     
- Partials     2302     2303    +1     
Flag Coverage Δ
unittests 56.18% <28.57%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
network/p2p/libp2pConnector.go 0.00% <0.00%> (ø)
network/p2p/middleware.go 0.00% <0.00%> (ø)
network/p2p/peerManager.go 70.27% <54.54%> (-10.38%) ⬇️
network/test/testUtil.go 94.93% <100.00%> (ø)
cmd/util/ledger/migrations/storage_v4.go 42.16% <0.00%> (+0.60%) ⬆️
...sus/approvals/assignment_collector_statemachine.go 47.11% <0.00%> (+4.80%) ⬆️

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 7b0ae36...4f5e16a. 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.

Thanks a bunch! LGTM

func newLibp2pConnector(host host.Host, log zerolog.Logger) (*libp2pConnector, error) {
type ConnectorOption func(connector *Libp2pConnector)

func DisableConnectionPruning() ConnectorOption {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: WithConnectionPruning(b bool)?

@vishalchangrani
Copy link
Contributor Author

closes 5831 (https://github.com/dapperlabs/flow-go/issues/5831)

}

var _ Connector = &libp2pConnector{}
var _ Connector = &Libp2pConnector{}
Copy link
Contributor

Choose a reason for hiding this comment

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

@vishalchangrani what is the purpose of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a compile time check to make sure that Libp2pConnector implements the Connector interface

@@ -159,7 +161,7 @@ func DefaultValidators(log zerolog.Logger, flowID flow.Identifier) []network.Mes
}
}

func (m *Middleware) topologyPeers() (peer.IDSlice, error) {
func (m *Middleware) TopologyPeers() (peer.IDSlice, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to make this public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't ..good catch. switched it back.

@onflow onflow deleted a comment from bors bot Sep 7, 2021
@vishalchangrani
Copy link
Contributor Author

bors merge

@bors
Copy link
Contributor

bors bot commented Sep 7, 2021

@bors bors bot merged commit 9b83002 into master Sep 7, 2021
@bors bors bot deleted the vishal/injectable_peermanager branch September 7, 2021 20:41
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