-
Notifications
You must be signed in to change notification settings - Fork 999
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
rust-libp2p hashes pubsub topics which prevents Go/JS interoperability #473
Comments
@vyzo Any thoughts here? Rust is doing the right thing here by hashing*. But Go and JS are both doing the wrong thing in a compatible way. What should we do? @Stebalien and I talked about asking Rust to add a flag to do the wrong thing (no hashing) while simultaneously upgrading Go and JS to do the right thing (hash the topic) and then all 3 would be both forward and backwards compatible. But getting Go and JS to make a change like at the same time is hard. (*Assuming the hash is computed over the descriptor and the topic string, which I didn't check.) |
I did this out of ignorance (or lack of specifications). I mistakenly guessed that it was supposed to be hashed.
Sounds good to me, although I'm not sure if it's worth doing so as I don't think anyone uses rust-floodsub at the moment. |
I think you actually did the "right" thing (according to the consensus opinion here in Palo Alto. Let's see what @vyzo thinks. For now, I can workaround in my demo by giving Go and JS the hashed topic to match rust. (I have all three languages communicating on a pubsub topic now!) |
The original intent was for topic descriptors to be CIDs, which would be hashed. |
I've started developing extending floodsub to gossipsub, with the intention to use it for Ethereum 2.0. So it'd be better to make a change sooner rather than later. It should be compatible if you use
Just need to coerce |
I'm using for a demo at web3. WIP here. Also, we'll need to fix this eventually once we have better interop testing and clear spec for implementors. |
There isn't necessarily much benefit in hashing any sort publicly known identifier all by itself. You could make this an opaque type though:
|
It should probably be hashed by default for privacy but optionally able to use the topic name/ID instead. |
The privacy argument is compelling, but it's going to be practically hard to change as it would break existing code. |
I'm thinking that we need to have a way to make safe changes in the protocol spec and not be constrained by "this is how go and js implemented it." With the benefit of hindsight, the topic id should probably be a typed value (like a cid) instead of a free-form text string. Something to think about for the Specs 2.0 project. |
I've taken a look again, and the reason why the topic is hashed in the Rust impl is because of this line: https://github.com/libp2p/go-floodsub/blob/900095341be1eeba1a0d6c1e08ab61d1242c6cb4/pb/rpc.proto#L48 If there is no hashing going on, I suppose that the whole |
Right, I could've pointed that out, but thanks for doing so! I thought that line was added in the Rust impl but I see now that it is also in the Go impl.
Well it can certainly come in use in future e.g. for encryption and authentication, even if not used now.
Looks like the comment conflicts with this statement so it should be edited for consistency, either that or change implementations to be able to use both the Looks like it's worthwhile to do the latter option eventually, so in the long-run it would be less development time to just do that, rather than an interim option, then that option later. |
IMO it's usually a good idea to remove unused code, in order to not confuse readers, like I got confused in this situation for example. |
And my contention is that this code is exactly right per the spec and original intentions (hence my thumbs down).
Yes, but I don't think you should remove correct behavior just because Go and JS are broken. The suggestion (originally from @Stebalien) that I was advocating for above, and that @jamesray1 seems to be agreeing with, is that we support both
@jamesray1 Where do you see it in the Go implementation? The user-level behavior of the Go implementation is definitely not to hash the topic, so if that code is in the Go implementation we must be forgetting to make a function call somewhere. |
At this point it is arguable whether it's the spec that broken or the extant implementations. |
Sorry, to clarify, I meant that single comment line in the rpc.proto file that was originally implemented in the Go impl, the same line that @tomaka linked above: https://github.com/libp2p/go-floodsub/blob/900095341be1eeba1a0d6c1e08ab61d1242c6cb4/pb/rpc.proto#L48. And yes, I agree, it seems that the most practical way given the IPFS upgrade limitation is to update implementations for forward and backwards compatibility, as you suggest with a flag to use OTOH, removing the |
See libp2p/specs#94, "Add a note to say that |
If people can approve libp2p/specs#94 that would be great. I need that merged so that I can start making changes to the Rust impl which will be used in gossipsub as well as floodsub. |
What about having |
I'm in favor. Are the other languages upgrading to a `/floodsub/2.0.0`?
Otherwise, I can foresee weird compatibility bugs popping up in the future,
though if the protocol negotiations works right, they should downgrade to
the lowest common denominator of 1.0.0 and all use topic name I suppose.
…On Thu, Nov 8, 2018 at 2:52 AM Pierre Krieger ***@***.***> wrote:
What about having /floodsub/1.0.0 use the topic name and /floodsub/2.0.0
the topic hash?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#473 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AANvV8oILCA0NHLZOcOqEuqqYbkmuM9sks5utA0GgaJpZM4WmTTw>
.
|
FWIW I've partly implemented something similar for message IDs and message hashes with gossipsub at #767. |
@mgoelzer @vyzo @tomaka Is there a consensus on whether to change the topic to the topic hash? From the go-libp2p-pubsub, it seems the plaintext is still used on the wire. Just wondering if this change is still under consideration. Thanks! |
No consensus has been reached, but will accept a patch in |
Thank you for the prompt reply!:) Another question: is the usage of topic hash because of the Another thing I just came up with: if changing to topic hash, the type of |
We probably want the pubsub library doing the hashing, not the user. |
I suspect the topic in pubsub pb messages also needs to be changed as well? Like this one. Otherwise, IIUC projects like py-libp2p would probably fail to initialize that pb message in Python. |
Good point. Not sure about wire compatibility of the two though, I think it should be ok; iirc strings and bytes have the same representation on the wire in protobuf. |
Yeah, strings seem to be encoded with UTF-8 in serialization. Sorry for being pedantic: I guess the problem is that protobuf requires the string text to be the UTF-8 format[1]. In Python protobuf, [1]: protobuf language guide, scalar value types, string https://developers.google.com/protocol-buffers/docs/proto3#json |
So for |
Sorry if I understand it wrong: And for instance in py-libp2p we can just define the topic field in protobuf as bytes, and pre-serialize it from string repr to bytes, and then fill it directly to the pb message? It sounds working. |
For what it's worth, I'd accept a PR that optionally disables the hashing. One has been submitted a long time ago but turned into a zombie PR. |
@tomaka Your suggestion seems like the best one. @vyzo Do you think we should update this paragraph:
to make it clear that regardless of what byte string you choose for the topic name, it will be treated as a literal (no-hash)? Then rust-libp2p with the option @tomaka suggests enabled would be conformant, and future implementers won't be confused if they are studying the rust source code, |
yeah, that's fine. |
My two cents here.
I agree with @burdges that topic names are better left opaque. That way, the application choses its naming scheme based on the tradeoffs above. |
…o pass through whatever the application provides as a topic identifier, leaving hashing (or not hashing) up to the application.
…o pass through whatever the application provides as a topic identifier, leaving hashing (or not hashing) up to the application.
…o pass through whatever the application provides as a topic identifier, leaving hashing (or not hashing) up to the application.
…o pass through whatever the application provides as a topic identifier, leaving hashing (or not hashing) up to the application.
…o pass through whatever the application provides as a topic identifier, leaving hashing (or not hashing) up to the application.
…o pass through whatever the application provides as a topic identifier, leaving hashing (or not hashing) up to the application.
…o pass through whatever the application provides as a topic identifier, leaving hashing (or not hashing) up to the application.
…o pass through whatever the application provides as a topic identifier, leaving hashing (or not hashing) up to the application.
#1395) * Addressing #473 ... if I understood the ticket right, we want to pass through whatever the application provides as a topic identifier, leaving hashing (or not hashing) up to the application. * Remove TopicDescriptor and use Topic newtype everywhere * PR feedback Use From<Topic> instead of Into<String> Use impl Into<Topic> instead of Topic in public API Co-authored-by: Peat Bakke <peat@peat.org>
For floodsub, the hashing is now disabled. For gossipsub, the hashing is configurable, with the default being disabled. So I think this can be closed now. |
I'm trying to demonstrate floodsub interoperability between Go, JS and Rust. In all cases, the topic name is
libp2p-demo-chat
. Go and JS use that topic string verbatim, but rust-libp2p hashes it toRDEpsjSPrAZF9JCK5REt3tao
.Thoughts? I'd really like to demo the 3 languages inter-operating at some conferences this fall. Guessing you did this for privacy reasons @tomaka?
Example output below. This one is a Go peer connecting to my bootstrapper:
Now a JS peer connecting:
Now a rust peer connecting:
The text was updated successfully, but these errors were encountered: