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

quic: Update to quic-go v0.36.2 #2424

Merged
merged 23 commits into from Jul 13, 2023
Merged

quic: Update to quic-go v0.36.2 #2424

merged 23 commits into from Jul 13, 2023

Conversation

MarcoPolo
Copy link
Contributor

@MarcoPolo MarcoPolo commented Jul 11, 2023

quic-go changed its API in v0.35, this PR updates our usage.

Most of the changes in this PR are due to renaming things from conn -> transport. Previously we could only share a underlying socket by sharing the "connection" between quic-go dialers/listeners. quic-go v0.35.0 introduces a Transport that represents QUIC on a socket. This Transport is what is shared between different dialers/listeners to reuse the same socket. I think that's a better abstraction since it's clear when something is getting shared vs not.

A lot of the renaming is to make clear what is happening. For example, reuse.Listen is now called reuse.TransportForListen since what we actually get back from the call is a quic.Transport. Similarly most things that were previously referencing a "conn" (as in packetconn) now reference a transport. Hopefully this also clears up any confusion about different "connection" like objects.

@MarcoPolo MarcoPolo marked this pull request as draft July 11, 2023 19:47
@MarcoPolo MarcoPolo requested a review from sukunrt July 12, 2023 03:55
Copy link
Member

@sukunrt sukunrt left a comment

Choose a reason for hiding this comment

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

I don't think we should rename like

reuse.Listen is now called reuse.TransportForListen

  1. For our purposes the PacketConn is now replaced by Transport. This renaming makes things clearer right now but given that this will be the API of quic-go going forward, these names will feel out of place 2-3 months from now.
  2. The type system already provides the type of the return value so it's clear what sort of object we are getting. Plus most(all?) of these are internal to transport/quic so the expected type of object is also clear from the context.

IMO we should just add a long explanation in the changelog / commit message.

p2p/transport/quicreuse/reuse.go Outdated Show resolved Hide resolved
p2p/transport/quicreuse/connmgr.go Outdated Show resolved Hide resolved
p2p/transport/quicreuse/connmgr.go Outdated Show resolved Hide resolved
p2p/transport/quicreuse/connmgr.go Show resolved Hide resolved
p2p/transport/quicreuse/reuse.go Outdated Show resolved Hide resolved
p2p/transport/quicreuse/reuse.go Outdated Show resolved Hide resolved
@MarcoPolo
Copy link
Contributor Author

MarcoPolo commented Jul 12, 2023

I don't think we should rename like

reuse.Listen is now called reuse.TransportForListen

  1. For our purposes the PacketConn is now replaced by Transport. This renaming makes things clearer right now but given that this will be the API of quic-go going forward, these names will feel out of place 2-3 months from now.

What do you mean by the names will feel out of place? As long as quic-go gives us a transport and as long as we are getting a Transport for listening from this method, the new name makes sense.

  1. The type system already provides the type of the return value so it's clear what sort of object we are getting. Plus most(all?) of these are internal to transport/quic so the expected type of object is also clear from the context.

It's really confusing for a Listen method to not return a listener, just like it's confusing for Dial to not return a connection to another node. This makes the API clearer because you aren't getting a Listener, you're getting the thing that can Listen (Transport).

IMO we should just add a long explanation in the changelog / commit message.

While better than nothing, I think this isn't enough. We are already breaking the API by no longer returning a PacketConn we should update the API to make it clear what we are doing and returning. A method called Listen should return a Listener-like thing that you can call Accept on.

I'm open to changing the name from TransportForListen to something else as long as it's not Listen. Maybe ListenQuicTransport? It would be in line with Go std's ListenTCP/ListenUDP/ListenPacket/ListenX

@marten-seemann
Copy link
Contributor

quic-go v0.36.2 just shipped: https://github.com/quic-go/quic-go/releases/tag/v0.36.2.

@sukunrt
Copy link
Member

sukunrt commented Jul 12, 2023

A method called Listen should return a Listener-like thing that you can call Accept on.

I see your point. Thanks for the explanation.
My point was the pConn had the same interface as transport and the method wasn't named pConnForListen. But maybe it should have.

These names will feel out of place 2-3 months from now.

I meant Transport in the name was redundant with the returned type

But I am convinced about the renaming. I suggest we either keep it as is(the new names, TransporForListen and TransportForDial) or rename struct reuse to reuseTransport and name the methods ForListen and ForDial so it reads like reuseTransport.ForListen

I do not like naming along the lines ListenTCP because the returned object is a listener of type TCP which doesn't fit in with what we're doing. So TransportForListen is better.

conn = c
return nil, errors.New("listen error")
if runtime.GOOS == "windows" {
t.Skip("skipping on windows. Not sure why this fails")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marten-seemann Any clue off the top of your head why this fails? https://github.com/libp2p/go-libp2p/actions/runs/5537794470/jobs/10107022242#step:8:4371.

Presumably this means that on windows after calling OptimizeConn the returned conn isn't a (quic.OOBCapablePacketConn)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that’s right. It’s using a basicConn on Windows: https://github.com/quic-go/quic-go/blob/418b866e3260b65496eb0d4420465e9d11b07e5f/sys_conn.go#L104

I’m becoming more and more convinced that OptimizeConn is not the right API. We should change that in a future release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I think if Transport has a WriteTo that would be better. The problem is I can't treat the conn from OptimizeConn as a normal PacketConn once I give it to the Transport.

Copy link
Contributor

Choose a reason for hiding this comment

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

We'll make that change in the v0.37 release (which drops support for Go 1.19, so we won't be able to use that release until mid August).

Do you see any blockers for this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this is fine for now. And the change will be very straightforward

@MarcoPolo MarcoPolo marked this pull request as ready for review July 13, 2023 01:28
@MarcoPolo MarcoPolo changed the title quic: Update to quic-go v0.36.1 quic: Update to quic-go v0.36.2 Jul 13, 2023
Copy link
Member

@sukunrt sukunrt left a comment

Choose a reason for hiding this comment

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

Just a couple of nits.

p2p/transport/quicreuse/reuse.go Show resolved Hide resolved
p2p/transport/quicreuse/reuse.go Outdated Show resolved Hide resolved
p2p/transport/webtransport/transport.go Outdated Show resolved Hide resolved
Copy link
Member

@sukunrt sukunrt left a comment

Choose a reason for hiding this comment

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

This is nicer. Thanks. I think this one comment is the last renaming left.

Comment on lines +18 to +19
// Used to send packets directly around QUIC. Useful for hole punching.
WriteTo([]byte, net.Addr) (int, error)
Copy link
Member

Choose a reason for hiding this comment

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

👍

p2p/transport/quicreuse/connmgr.go Show resolved Hide resolved
@MarcoPolo MarcoPolo merged commit 8a60a68 into master Jul 13, 2023
20 checks passed
marten-seemann pushed a commit that referenced this pull request Jul 14, 2023
* Update go.mod files

* Update to new quic-go API

* More renaming

* Add test back in

* Workaround quic-go#3947

* Fix transitive dep

* Use own pointer to packetConn

* Update to quic-go v0.36.2

* Remove workaround

* Embed quic.Transport

* Downgrade qtls-go1-20

* Rename ConnManager.metricsTracer to mt

* Close transport after test ends

* Close conn when transport closes

* Return better error

* Avoid conflicts with parallel tests

* Skip conn assert on windows

* Add metrics tracer back in

* Don't use tracers here

* Add comment to WriteTo

* Finish renaming conn -> transport where appropriate

* Back out unrelated change

* One more rename
@MarcoPolo MarcoPolo mentioned this pull request Jul 14, 2023
29 tasks
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

3 participants