flow-go icon indicating copy to clipboard operation
flow-go copied to clipboard

[Network] Refactor libp2pNode and peer manager into components

Open peterargue opened this issue 3 years ago • 2 comments

Closes: #2797 Closes: #2718

This is the first PR in a 2 part change.

Background

Access and Execution nodes run bitswap to sync ExecutionData amongst themselves. Bitswap has a limitation where it will only discover peers that connect after it has been started. This means we need instantiate bitswap before connecting to any peers.

Changes

This PR refactors p2p.Node and p2p.PeerManager so that their lifecycle can be controlled by the node builder. That's accomplished with the following changes

  • Convert libp2pNode into a component
  • Instantiate libp2pNode as a Component in scaffold, and inject into middleware
  • Convert peer manager into a component
  • Move peer manager from middleware into libp2pNode
  • Expose peer manager’s component interface via libp2pNode, and make it a scaffold Component

Next PR

The next PR will include changes that allow configuring the startup order of network components such that bitstwap can be started before connecting to peers

peterargue avatar Jul 15 '22 18:07 peterargue

Codecov Report

Merging #2808 (2d49d67) into master (6163d10) will decrease coverage by 0.33%. The diff coverage is 51.38%.

@@            Coverage Diff             @@
##           master    #2808      +/-   ##
==========================================
- Coverage   55.23%   54.89%   -0.34%     
==========================================
  Files         743      692      -51     
  Lines       67705    65151    -2554     
==========================================
- Hits        37399    35767    -1632     
+ Misses      27258    26391     -867     
+ Partials     3048     2993      -55     
Flag Coverage Δ
unittests 54.89% <51.38%> (-0.34%) :arrow_down:

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

Impacted Files Coverage Δ
cmd/execution_builder.go 0.00% <0.00%> (ø)
cmd/node_builder.go 93.87% <0.00%> (-4.00%) :arrow_down:
module/irrecoverable/unittest.go 0.00% <0.00%> (ø)
utils/unittest/unittest.go 7.50% <0.00%> (-0.22%) :arrow_down:
cmd/scaffold.go 18.15% <32.85%> (+0.89%) :arrow_up:
cmd/testUtil.go 100.00% <100.00%> (ø)
module/mempool/epochs/transactions.go 90.32% <0.00%> (-9.68%) :arrow_down:
engine/consensus/compliance/core.go 75.20% <0.00%> (ø)
engine/common/synchronization/engine.go 73.30% <0.00%> (ø)
network/p2p/connection/connManager.go
... and 54 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Jul 15 '22 18:07 codecov-commenter

Otherwise looks okay

synzhu avatar Aug 15 '22 22:08 synzhu

bors merge

peterargue avatar Oct 08 '22 21:10 peterargue