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

feat: tweak stream handling #298

Merged
merged 3 commits into from
Jul 11, 2022
Merged

feat: tweak stream handling #298

merged 3 commits into from
Jul 11, 2022

Conversation

wemeetagain
Copy link
Member

The ovararching problem with our previous approach is that we're too carefree about managing streams for this protocol.
Specific problems include:

  • creating multiple duplicate outbound streams.
  • relying solely on a topology to trigger an outbound stream.

Creation and tracking of new streams is tweaked:

  • Add an outbound stream queue
    This used to ensure that outbound streams are created sequentially.
    This stops multiple duplicate streams from being created for a single peer.
  • Attempt to create an outbound stream when an inbound stream is created.
    This allows us to connect to peers that haven't yet been registered by the topology but want to connect to us.
  • Remove PeerStreams usage in favor of managing inbound/outbound streams separately
    PeerStreams works, but obscures some lingering issues. It's also quite inflexible and annoying to modify it since PeerStreams implements an interface in @libp2p/interface-pubsub.

@wemeetagain wemeetagain requested a review from a team as a code owner July 8, 2022 22:43
@codecov-commenter
Copy link

codecov-commenter commented Jul 8, 2022

Codecov Report

Merging #298 (6425378) into master (e1a8586) will increase coverage by 31.90%.
The diff coverage is 91.26%.

@@             Coverage Diff             @@
##           master     #298       +/-   ##
===========================================
+ Coverage   49.58%   81.48%   +31.90%     
===========================================
  Files          43       44        +1     
  Lines        9310     9447      +137     
  Branches      463      917      +454     
===========================================
+ Hits         4616     7698     +3082     
+ Misses       4694     1749     -2945     
Impacted Files Coverage Δ
src/score/peer-score.ts 87.66% <0.00%> (+33.88%) ⬆️
src/index.ts 70.63% <88.05%> (+8.47%) ⬆️
src/stream.ts 100.00% <100.00%> (ø)
test/2-nodes.spec.ts 99.49% <100.00%> (+67.43%) ⬆️
test/gossip.spec.ts 94.70% <100.00%> (+77.05%) ⬆️
test/signature-policy.spec.ts 99.06% <100.00%> (ø)
test/utils/create-pubsub.ts 78.18% <100.00%> (+3.67%) ⬆️
src/utils/time-cache.ts 91.52% <0.00%> (+1.69%) ⬆️
src/message-cache.ts 79.09% <0.00%> (+5.64%) ⬆️
... and 23 more

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 e1a8586...6425378. Read the comment docs.

Copy link
Member

@mpetrunic mpetrunic left a comment

Choose a reason for hiding this comment

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

Have you already tried this in lodestar? Any improvements?

@wemeetagain
Copy link
Member Author

Yeah I've linked it against lodestar and it works well.
No more duplicate outbound streams.
No more connections with zero outbound streams.

Also seems like we're getting beacon blocks more on time? I'm seeing a smaller head drift.

@wemeetagain wemeetagain merged commit 7eda34b into master Jul 11, 2022
@wemeetagain wemeetagain deleted the feat/stream-handling branch July 11, 2022 15:21
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.

3 participants