-
Notifications
You must be signed in to change notification settings - Fork 189
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
go-ipfs gossipsub produces invalid protobuf messages #361
Comments
For reference, here is the gossipsub proto used in rust-gossipsub master. I can get the whole thing to work by changing messageid to bytes, but I would rather not... https://github.com/libp2p/rust-libp2p/blob/master/protocols/gossipsub/src/rpc.proto |
The message ID is not really expected to be a UTF8 string; the type in the protobuf should probably bytes instead. |
cc @raulk -- we might have to change the protobuf definitions for this, as some implementations expect strings to be utf8. |
The id is just an opaque thing to identify a message. It is randomly chosen (does not seem to be sequential from what I have seen). I see no good reason to constrain it to utf8. So maybe just change the .proto to bytes? It seems to be the right thing to do disregarding issues of backwards compatibility... |
If we change the proto so the message id is bytes, so accept bytes but only emit utf8 strings for some time, this change should be backwards compatible... |
bytes and strings have the same wire representation, there is no compatibility breakage by changing the protobuf type. Note that the message IDs were never valid UTF8 strings to begin with. |
Well, you basically promised for 2 years that the message ids are strings by publishing the .proto . Or does it say that these are arbitrary blobs in the specs? In any case, what people typically do when implementing a protocol is going to the repo of the most mature impl (in this case go-ipfs) and grabbing the .proto files from there. But I agree that changing this is the best way forward, since the old .protos are a lie and there are plenty of non-utf8 message ids in in the wild... |
The promise was wrong, I didn't think it through :) |
Well, shit happens. I am still a bit shocked though that the default golang protobuf lib allows you to emit non-utf8 (so not protobuf spec compliant) byte sequences where it says string in the .proto... |
This is interesting. The spec had the protobuf as strings. For content addressing we were using base64 encoding to ensure utf-8 compatibility. I guess bytes makes more sense and we can relax the encoding. |
Yeah, the spec was wrong. But on the positive side, I like bytes much better here. Having to base64 encode obvious things like hashes is not nice. |
@vyzo is this issue closed? |
yes, I think we can close. |
I am trying a rust-gossipsub based program to work with go-ipfs. I was having some strange intermittent problems.
After 3 days I nailed it down to this: go-ipfs under some circumstances produces protobuf messages that do not conform to the protobuf format used in go-ipfs.
The gossipsub protobuf has message ids as strings since a long time. See e.g.
go-libp2p-pubsub/pb/rpc.proto
Line 33 in b565e59
But I am getting messages that are overall valid protobuf messages, but where the messageid is not a valid utf8 byte string.
Here are the messages from an instrumented version of the rust gossipsub:
For some reason the frequency of these corrupt messages depends on the exact way the node was connected to. See discussion in libp2p/rust-libp2p#1671 (comment)
The node in question is a go-ipfs 0.4.22 node that is in production. We are currently migrating these nodes to 0.6.0, but I want to make sure the issue is no longer present in 0.6.0.
The text was updated successfully, but these errors were encountered: