Closed richard-ramos closed 3 years ago
Oh man, that's a long time ago. I don't have a strong opinion on this, pragmatically this is up to status-go as that's the only implementation using it. It isn't clear to me if the latest version is used there or not?
As for solution, whatever is simplest to get things to work in status-go seems fine by me. We can update the specs if that's easier.
cc @staheri14 as new editor for MVDS FYI
@richard-ramos unfortunately there's no easy way to distinguish two protobuf messages as the protocol is not self-describing and information about the type of message is not transmitted over the wire, so in that way is ambiguous, you need to know which protobuf you are receiving, or you would have to fingerprint the message based on the fields, as we do. I think the commit above will need to be reverted, as status-go is using the old numbering, which allow distinguishing between the two messages, and in any case it would be a pain to make it backward compatible between clients and improve the fingerprinting, to my knowledge there's no production code using the new numbering, so there's should not be any impact.
This commit is causing status-go to fail at correctly decoding a message
Notice that both
ApplicationMetadataMessage
andPayload
first two fields have the same data typebytes
and field id numbers now:In status-go, the code will attempt to determine if this bytearray is a datasync message or not in here . The bytearray can be either an
ApplicationMetadataMessage
or aPayload
. If the bytearray is anApplicationMetadataMessage
the decoding will fail due to the similarity between both protobuffers. For example, with the following marshalledApplicationMetadataMessage
:unwrap will not fail, succesfully unmarshalling a protobuffer containing invalid data:
Then, when
IsValid()
is executed, it will return true, mainly because the following code assumes that an unmarshalledPayload
containing data is valid. This is an incorrect assumption to make since it is not possible to correctly distinguish the field types that compose a protobuffer while it is being unmarshalled. I'm not sure how to fix this, though https://github.com/vacp2p/mvds/blob/d6b27d3843ffae66806cc969596af342c6e7a839/protobuf/payload.go#L5-L7It is not possible then to use this version of mvds in status-go for the time being unless we either change the id numbers in mvds, or change the logic in status-go to determine if some byte array is a datasync message or a normal message.