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

move the circuit v2 code here #1174

Merged
merged 4 commits into from
Sep 7, 2021
Merged

move the circuit v2 code here #1174

merged 4 commits into from
Sep 7, 2021

Conversation

marten-seemann
Copy link
Contributor

As discussed in libp2p/go-libp2p-circuit#138, the circuit v2 implementation should live in go-libp2p, not in a separate package.

Commit history extracted from the original repo by running:

echo "github.com/libp2p/go-libp2p-circuit/v2==>github.com/libp2p/go-libp2p/p2p/host/circuitv2" >> replace.txt
git filter-repo --force --path v2/ --path-rename v2:p2p/host/circuitv2 --replace-text replace.txt

and then running

git rebase --committer-date-is-author-date origin/master --exec "go mod tidy"

as I couldn't figure out how to have git filter-repo do that in one step without writing a Python script.

* base limits on reservations issued

* switch default reservation limits per peer and per IP

* don't export the constructor for relay.constraints

* panic when reading from crypto/rand fails

* optimize IP-based reservation lookup

* use lists instead of maps to save reservations

* save expiry timestamp in reservations

* use slices instead of linked lists for reservations

* remove unused rand in constraints
vyzo and others added 2 commits September 2, 2021 20:25
* v2 client scaffolding

* gomod: go-libp2p-core and go-libp2p-transport-upgrader feature dependencies

* Conn implements network.ConnStat

* add reservation stub

* utilities

* dial scaffolding and v1 compat dialing

* stream handling scaffolding and v1 incoming connection handling

* implement hop tagging

* export timeout variables

* v2 protobuf

* v2 client protocol implementation

* implement Reserve

* go get go-libp2p-swarm@feat/transient-conns

* implement client.New

* rework pb status codes

* client responds with UNEXPECTED_MESSAGE when it's actually an unexpected message

* relay scaffolding, reservation implementation

* implement relaying

* implement missing details

* add options for resources/limit

* gc idle conn counts

* fix clown shoes in cancellation check

* end to end relay test

* untag peers with expired reservations

* add time limit test

* better debug log for accepted conns

* add data limit test

* add v2-v1 compatibility tests

* godocs

* add WithACL relay option

* only return public relay addrs in reservation record

* remove the refresh restriction madness

* set default limit Data to 128K

* fix typo in AllowReserve godoc

* fix some small issues

- remove context from constructor
- remove stream handler when closing the host
- remove the awkward cancellation check from handleStream

* fix tests

* address review comments

- Add deadline for Reserve calls
- Add deadline for dials
- Add some comments for things that confuse aarsh.

* humor aarsh and add initializers for slices

* comment nitpicks

* fix bug in slice pre-allocations

* add deadline to connectV1

* make Relay.Close thread-safe

* untag peers with reservations when closing the relay

* gomod: get go-libp2p-asn-util

* add IP/ASN reservation constraints

* gomod: update deps

* fix e2e test

* increase default limit duration to 2min

* update protocol for vouched relay addrs; provide absolute expiration time instead of TTL

* update for reservation changes

* add voucher to the reservation pb

* TODO about reservation vouchers

* deduplicate protocol ID definitions between relay and client

* add reservation vouchers

* emit and consume reservation vouchers

* improve limit data test

* deduplicate concurrent relay dials to the samke peer

* improve dialer deduplication

* add a short timeout to dialing the relay in order to aid deduplication

* gomod: fix go1.16 madness

* spec compliance: don't include p2p-circuit in reservation addrs

* spec compliance: refuse reservation and connection attempts over relayed connections

* test shim: add empty file in test directory

* spec compliance: update protobuf

* spec compliance: use libp2p envelopes for reservation vouchers

* fix staticcheck

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
@marten-seemann
Copy link
Contributor Author

After offline sync: we agreed to move . I suggest to keep the package name circuitv2 for now. #1058 will allow us to deprecate go-libp2p-circuit, and we can rename the package to circuit then.

@marten-seemann marten-seemann merged commit 964880b into master Sep 7, 2021
@Stebalien
Copy link
Member

This doesn't really belong in host, that's for host implementations. "relay" is there because it used to be a host wrapper (it really should move).

Maybe move both to a "relay" directory? Really, the "relay" belongs in some form of "relay" package, and the "client" part belongs in a "transports" package, but we don't need to get too fancy.

@marten-seemann
Copy link
Contributor Author

Looks like I was too fast merging this PR. I opened #1177.

@aschmahmann aschmahmann mentioned this pull request Dec 1, 2021
80 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.

3 participants