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

fix(yamux): doesn't work in a Relayv2 connection #979

Merged
merged 4 commits into from
Nov 21, 2023

Conversation

diegomrsantos
Copy link
Collaborator

@diegomrsantos diegomrsantos commented Nov 6, 2023

Trying to use the circuit relay v2 with Yamux raises some issues:

  • The direction of the RelayConnection wasn't rightly set creating an error. To go deeper, this is a description of what happened:
    • A connects to Relay (A direction is outbound and Relay direction is inbound)
    • A reserves a slot on Relay
    • B connects to Relay (B direction is outbound and Relay direction is inbound)
    • B connects to A through the Relay (A and B direction were both outbound, which is wrong, causing an error to be raised).
  • As we didn't make the YamuxChannel inherit from BufferStream, we had to manage the isEof which was not implemented. The main reason as to why we didn't use BufferStream is because the way it works would have made the creation of the YamuxChannel harder to implement (for example BufferStream manage its backpressure with the number of message received, YamuxChannel uses the number of bytes received).
  • Some issues with the tests

@diegomrsantos diegomrsantos changed the title Yamux relay bug Yamux doesn't work in a relay connection Nov 10, 2023
@diegomrsantos diegomrsantos changed the title Yamux doesn't work in a relay connection Yamux doesn't work in a Relayv2 connection Nov 10, 2023
@diegomrsantos diegomrsantos changed the title Yamux doesn't work in a Relayv2 connection fix(yamux): doesn't work in a Relayv2 connection Nov 18, 2023
@lchenut lchenut marked this pull request as ready for review November 20, 2023 16:08
Copy link

codecov bot commented Nov 20, 2023

Codecov Report

Merging #979 (d282f52) into unstable (fb05f5a) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head d282f52 differs from pull request most recent head 1b001c0. Consider uploading reports for the commit 1b001c0 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           unstable     #979   +/-   ##
=========================================
  Coverage     83.19%   83.20%           
=========================================
  Files            91       91           
  Lines         15317    15328   +11     
=========================================
+ Hits          12743    12753   +10     
- Misses         2574     2575    +1     
Files Coverage Δ
libp2p/builders.nim 94.44% <100.00%> (+0.19%) ⬆️
libp2p/muxers/yamux/yamux.nim 89.72% <100.00%> (+1.38%) ⬆️
libp2p/protocols/connectivity/relay/rconn.nim 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

@diegomrsantos
Copy link
Collaborator Author

Looks great, thanks a lot @lchenut.

lchenut
lchenut previously approved these changes Nov 21, 2023
@diegomrsantos diegomrsantos enabled auto-merge (squash) November 21, 2023 13:20
@kaiserd kaiserd self-requested a review November 21, 2023 13:21
Copy link
Collaborator

@kaiserd kaiserd left a comment

Choose a reason for hiding this comment

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

LGTM ❇️

@@ -19,14 +19,22 @@ import ./helpers
import std/times
import stew/byteutils

proc createSwitch(r: Relay): Switch =
result = SwitchBuilder.new()
proc createSwitch(r: Relay = nil, useYamux: bool = false): Switch =
Copy link
Collaborator

Choose a reason for hiding this comment

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

r: Relay = nil

Should we not generally use an Option in such cases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For a test, I believe it's not critical. What are your thoughts?

@diegomrsantos diegomrsantos merged commit 1f4b090 into unstable Nov 21, 2023
8 checks passed
@diegomrsantos diegomrsantos deleted the yamux-relay-bug branch November 21, 2023 15:03
romanzac pushed a commit that referenced this pull request Nov 30, 2023
Co-authored-by: Ludovic Chenut <ludovic@status.im>
dryajov pushed a commit that referenced this pull request Dec 4, 2023
Co-authored-by: Ludovic Chenut <ludovic@status.im>
romanzac pushed a commit that referenced this pull request Dec 13, 2023
Co-authored-by: Ludovic Chenut <ludovic@status.im>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: done
Development

Successfully merging this pull request may close these issues.

3 participants