-
Notifications
You must be signed in to change notification settings - Fork 52
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
minprotobuf does not handle proto3
repeated uint32
fields.
#1035
Comments
You're looking for
|
Tested that and it does indeed work by calling |
Thank you very much. @richard-ramos could you resolve the related issue on Waku side with this help? |
Yes, thank you, @kaiserd and @arnetheduck . We should be able to solve the issue with that function. However, I'd say that having to know the details on how the serialization works for the different proto versions in order to effectively use minprotobuff is just adding extra difficulty to the development workflow, specially since the library itself is not documented at all, and I can imagine a different developer running into a situation like this in the future. Also, is there any plans in the future to create a higher level library that uses minprotobuf and abstracts you from these details? or even generates code similar to Rust's https://docs.rs/prost-build/latest/prost_build/ or the code generators from https://github.com/golang/protobuf? Ideally you should be able to use protobuffers without having to be familiar with how the encoding for protobuffers work |
You're looking for https://github.com/status-im/nim-protobuf-serialization - the part with Nim objects works fairly well. There is a basic macro that parses .proto files and generates Nim objects from there (without a separate code generation step that you'd need with rust/golang), but it probably needs a good weekend of hacking to get it into a usable state. |
This is fine when consuming protocols, but when designing them, I highly recommend getting intimately familiar with the encoding as there are many beginner traps, such as thinking that protobuf encodings are deterministic (a mistake that many enthusiastic protobuf users make, including libp2p), that defaults are handled the same way in all languages (they're not) and that required fields are useful (they break forward compatibility). It also opens up knowledge about how to compose them (you can concat byte streams) and what security issues you might run into (you can make an infinately large protobuf stream that decoded looks like a single field, hiding spam and invalid data in the stream etc) The good news is that all knowledge about proto2 and proto3 can be derived from the wire encoding document I linked, which is fairly simple - proto2/3 are just two slightly different packagings of the same underlying thing. |
For the following protobuffer:
if we were to encode:
{"cluster_id": 16, "shards": [32]}
, we'd get the following output:0810120120
08101020
(can be verified with https://www.protobufpal.com/)
minprotobuf does handle correctly the encoding/decoding of the field
shards
(2), as long as we useproto2
. If we useproto3
, it will not:cc: @Ivansete-status , @igor-sirotin
The text was updated successfully, but these errors were encountered: