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

[Backport] Upgrade Go and libp2p versions #3779

Merged
merged 10 commits into from
Feb 12, 2024

Conversation

lukasz-zimnoch
Copy link
Member

This pull request backports #3771 to the releases/mainnet/v2.0.0-m7 branch.

Package `go-libp2p-core` has been deprecated and moved to `go-libp2p`.
Here we adjust all imports accordingly.

See: https://github.com/libp2p/go-libp2p/releases/tag/v0.22.0
(cherry picked from commit 95d60b8)
The `go-libp2p`'s TLS implementation used within the `transport` struct has a
new constructor that accepts the security protocol ID and a list of muxers.
Regarding the first, it's enough to pass the TLS protocol ID exposed by
`go-libp2p`. For the second, it's enough to pass `nil` as the Keep client does
not use Optimized Stream Multiplexer Selection so no mutex is determined
upfront.

Regarding `authenticatedConnection`, there is a need to implement
an additional method `ConnState` that exposes `ConnectionState`. This
can be fetched from the secure connection established by the TLS
encryption layer.

See:
- https://github.com/libp2p/go-libp2p/releases/tag/v0.24.0
- https://github.com/libp2p/specs/blob/50e2cd49c3261eeb71936e4e1b371bd3aa3d7d62/connections/inlined-muxer-negotiation.md

(cherry picked from commit ac01765)
This test used a dummy curve point that was not on the curve.
Since Go 1.19, such a behavior leads to a panic. Here we fix
that by using a proper point that is on the curve.

See: https://tip.golang.org/doc/go1.19 > Minor changes to the library > crypto/elliptic
(cherry picked from commit 50b6bd6)
`go-libp2p` versions prior to `v0.24.0` allowed to pass either a constructed
security transport instance or a constructor producing such an instance.
Starting from `v0.24.0` only the latter option is supported.

See: https://github.com/libp2p/go-libp2p/releases/tag/v0.24.0
(cherry picked from commit 110fbb3)
We are also taking an opportunity and bump `protoc-gen-go` to the
recent version.

(cherry picked from commit 8e07451)
Warnings were all about usage of functions that are deprecated in Go 1.20.
We are replacing them as recommended.

(cherry picked from commit a87eea3)
Setup of the security transport done after the recent libp2p upgrade was
wrong. We configured libp2p host to use `/keep/handshake/1.0.0` as the
security protocol but, in the same time, the security protocol implementation
(our own `net/libp2p.transport`) returned `/tls/1.0.0` as ID.

Here we fix that by using `/keep/handshake/1.0.0` everywhere and re-factoring
the security transport constructor passed to the `libp2p.Security` option.
Libp2p injects necessary parameters there and the constructor of
`net/libp2p.transport` should use them to create the instance.

Moreover, we are taking the opportunity and do some housekeeping around
Keep-specific protocol names. We now have `securityProtocolID` which holds
the ID of the encrypted transport protocol and `authProtocolID` which
denotes the custom authentication protocol used by Keep clients. We are leaving
original values to maintain backward compatibility with older clients.

(cherry picked from commit 6953b79)
@lukasz-zimnoch lukasz-zimnoch marked this pull request as ready for review February 12, 2024 09:28
@lukasz-zimnoch lukasz-zimnoch merged commit 5de6338 into releases/mainnet/v2.0.0-m7 Feb 12, 2024
@lukasz-zimnoch lukasz-zimnoch deleted the backport-upgrade-libp2p branch February 12, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants