holepunchto / hyperswarm

A distributed networking stack for connecting peers.
https://docs.holepunch.to
MIT License
1.04k stars 84 forks source link

Are v3 nodes expected to interact with v2 nodes? #102

Closed smoyer64 closed 2 years ago

smoyer64 commented 2 years ago

As noted in other issues, I've been working on a Go implementation and had originally created the required gRPC messages. I've now got v3 messages working (defined as a struct with field tags) and realized that if you ignore the UDP transmit pacing changes, I could in theory try to send a v3 message first and "back-off" to the v2 message format. Once a message is received, the header can be used to tell whether another node is v2 or v3. Theoretically, this could also be used to bridge v3-only nodes to v2-only nodes.

I've found that there's a new set of bootstrap nodes for v3 but I'm wondering what the network transition plan is. Is there a use for a node that's both v2 and v3? (Note that with some more work, my nodes could also be a version-agnostic bootstrap server).

mafintosh commented 2 years ago

We'll move everything to v3, as that's much more powerful than v2 - The v3 is still marked "next" as we're finalising the design, but the 99% of it stable (the last 1% is constants that might be tweaked). For v2, the bootstrappers will keep running for users on there, but we don't plan any "run both" modes, as you'll just always want to use v3 for the updated encryption and holepunching.

Unsure what you mean by gRPC, all of the swarm code used protobuf, and simple structs in v3.

smoyer64 commented 2 years ago

Yeah I meant protobuf (not gRPC). I'll archive my v2 compatible code and focus on v3 then. Thanks for the update!

mafintosh commented 2 years ago

I'm on our discord. Feel free to ping me for v3 questions (or v2 for that matter). I'm sure a lot of it requires commentary to understand fully.

smoyer64 commented 2 years ago

I didn't realize there was a discord but I'll be sure to join. I've got the wire protocol working including an efficient type-based codec implemented in Go and I can send and receive messages to the v3 bootstrap servers. I still have a bit of work to do to be able to keep my DHT in sync with the RI DHT. One beautiful part of this system is I can run both the RI, the Go implementation and the bootstrap servers locally!

I've been following the Swarm issue regarding documenting the protocol and could certainly help by writing the wire protocol parts. I'm still unsure of some of the timing related to pacing (did it start off as UTP?) and since the Go best-practice is to only export as little of the API as needed, I'm trying to mimic at least the hierarchical structure of the RI's code.

mafintosh commented 2 years ago

RI? https://chat.hypercore-protocol.org

smoyer64 commented 2 years ago

Reference Implementation (sorry)

mafintosh commented 2 years ago

TIL 😂

smoyer64 commented 2 years ago

Acronym soup (I was a Java programmer before I switched to Go six or so years ago). I'll connect with you on Discord ... an issue wasn't really appropriate for this type of question anyway.