-
Notifications
You must be signed in to change notification settings - Fork 17
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
Introduce Wrapped Libp2p Transport Protocol #331
Introduce Wrapped Libp2p Transport Protocol #331
Conversation
Codecov Report
@@ Coverage Diff @@
## feat/refactor-transport-part-1 #331 +/- ##
==================================================================
+ Coverage 52.39% 54.80% +2.40%
==================================================================
Files 26 28 +2
Lines 2670 2854 +184
==================================================================
+ Hits 1399 1564 +165
- Misses 1096 1111 +15
- Partials 175 179 +4
|
|
||
// MessageVersionFromString parses a string into a message version | ||
func MessageVersionFromString(versionString string) (MessageVersion, error) { | ||
versions := strings.Split(versionString, ".") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we have a stringjoin
representation here, maybe something we can add in later
could also use the new CustomType stuff in bindnode to put MessageVersion
in the struct itself
@@ -35,3 +36,8 @@ type TransferMessage struct { | |||
Request nullable TransferRequest | |||
Response nullable TransferResponse | |||
} | |||
|
|||
type WrappedTransferMessage struct { | |||
TransportID TransportID (rename "ID") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So how strict can we be here? I assume that because we have an explicit list of transports we support that we get to be very strict with the values that can appear here. Because if we can, then maybe this should be a keyed union:
type WrappedTransferMessage union {
Message "1.2.0"
} representation keyed
We get more compact representation and very strict matching on allowable version(s), and we can adjust the Message
format with version changes.
Looks mostly OK to me. Wrt to the versioning options - I'm still finding this set of tradeoffs difficult to make clear decisions on. We have a number of places we can do this, none of which stand out as the obviously right way to do it. Maybe it's the case that using libp2p protocol negotiation would be a better option than having to decode messages to discover they are the wrong format? Not being able to connect might be better than connecting and not understanding each other. 🤷 |
1076301
to
7fa9bb2
Compare
move the network to a subdirectory, also cleanup usage of all selector, move gstestdata to the itest directory
introduces a new wrapped protocol that encodes the transport id so that we can support multiple transports using the network protocol
351d16e
to
4478974
Compare
Goals
Support multiple transports on the libp2p protocol
Implementation
For Discussion
Put simply, cause right now bindnode & schemas are pretty rough to work with across modules. I tried this way first, gave up, and put it all in message. Maybe this will help: ipld/go-ipld-prime#364 ? I'm not sure. Even then we have all the go types all spread out.
Well, this is the state of affairs at the moment cause of some of the hacks we employed to make everything work. At one point we introduced a 1.2.0 protocol without changing the message format, solely so Graphsync could figure out what protocols the other side supports to decide what extensions to encode (eek).
That's why we have a message1_1 but a protocol 1.2 and various graphsync extensions rated 1.2.0 or 1.1.0
Yea I wonder about this, specifically cause of the versioning issue above that created the mess we're in. I wonder if a transport should have an identifier and a version.
I once again wonder if we should just byte the bullet and register lots of libp2p protocols of the scheme
/datatransfer/message-version/transport-id/transport-version
What's the harm? It would mean no more wrapping (though maybe we keep it to be safe and for record keeping). It would mean registering lots of protocols, but my impression is that's low cost to do so, and ultimately we get a big win in terms of protocol negotiation by doing so.
That feels needed at this point maybe?