Closed BearGuy closed 3 years ago
Tagging @batzor here for maybe more feedback on this issue in general
I'm a big fan of using default libs to do stuff. But yesterday I tried finding anything JS-library-ish that could handle Rust-bincode. Just to see if there's something in that direction. Didn't find anything that looked hopeful.
One of them in my mind is will the Rust version be the only version that is allowed to run consensus?
I could imagine that locking in now to this might be an issue later. Especially if there's no bincode support in other languages (But maybe there's chance this will be added in the future?).
How to send/receive data with a npm-module later on?
Related bincode-repo issues:
For the lack of alternatives this sounds most reasonable
Related projects:
I am not a big fan of implementing such things in a custom way, mostly because of the mentioned cons
One big downside of protobufs is that the entire protobuf spec becomes part of our spec. The upside is we might get considerable performance benefits.
I think bincode isn't a viable long-term solution.
"Would require recreating it for each new implementation in another language". I view this as a "pro" for custom serializers, not a con. The encoding scheme must be implementable in arbitrary languages.
I will just leave it here. Benchmarking code of protobuf and bincode. https://gist.github.com/ilblackdragon/88ab377bf0da7ff721af80cb8a11fe28
Just though I'd mention, benchmarking and tests of these different solutions exist in the serialization
branch here in this repo for anyone who's curious or wishes to help us extend testing.
Linking the mentioned branches:
Can this be closed?
Thank you for the discussion everyone!
We are implementing custom serialization at this point.
Hey folks,
There has been some internal discussion about serialization and encoding, so I thought it would make sense to document some of the ideas in these discussions more publicly.
Rust gives quite a few methods to implement serialization, and currently there's a short list of the ones that have been discussed, each containing their own sets of pros and cons.
Serde/bincode
Pros
google/tarpc
a Rust implementation of RPC that requires no additional tooling or languages to create a message schema.Serde
using thebincode
crate.Cons
Protocol buffers
Pros
Cons
Serde/Custom Serializer
Pros
Cons
There's a few other open-ended questions to factor into this conversation that will influence the decision. One of them in my mind is will the Rust version be the only version that is allowed to run consensus? If so, being as tightly coupled to Rust isn't as big of an issue.
Personally, at time of writing I'm leaning most towards Protocol buffers. It's a good compromise of dev complexity, language agnosticism, and efficiency that gives us decent flexibility moving forward.
If there are other standards that should be considered, please mention them! Now is the time to lay it out before anything gets implemented.