-
Notifications
You must be signed in to change notification settings - Fork 1
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
Switch to Google Proto #1
Conversation
@@ -148,3 +141,189 @@ func iotest(writer protoio.WriteCloser, reader protoio.ReadCloser) error { | |||
} | |||
return nil | |||
} | |||
|
|||
// Everything below this line is borrowed from the generated test code in gogoproto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gogoproto
has some magic options to generate test helpers. Now that we are not using gogoproto
I had to recreate their test fixtures, generate the code with Google Protobuf, and then copy and paste over the test helpers below. It's not pretty.
package test; | ||
option go_package = "github.com/libp2p/go-msgio/test"; | ||
|
||
message NinOptNative { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message is borrowed from gogoproto
's test suite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
It's not clear to me when is the uvarint reader/writer used, but assuming it's in all general length-prefixed cases, then the blast radius can be quite wide. It seems that |
@mkobetic no intention to push this upstream. Changing the underlying proto library would be a huge breaking change for all users of the library. |
FWIW, their existing test suite all passes with my changes, so I'm fairly confident that the methods are functionally equivalent for encoding/decoding. |
Summary
I was tasked by @jazzz to help out with some Protobuf encoding issues. This solution is not my favorite, but I'm struggling to come up with a less bad option.
Here's the background:
go-waku
usesgogoproto
instead of the Google Protobuf library to generate codegogoproto
is currently unmaintained and doesn't support newer versions of Protobuf, which our protos implicitly require. When trying to compile our protos usinggogoproto
we get an error. Even if we could rewrite our protos to avoid the error, it still seems unwise to hitch our wagon to a library that is completely dead.protoio
to read and write protobufs to length delimited lib2p2 streams. That library is tied togogoproto
types.This is a fork of
protoio
that is compatible with vanilla Google ProtobufAlternatives Considered
protoio
csproto
is not a complete replacement for Google Protobuf and we would still have to rely on the Google Protobuf message interfaceprotoio
protoio
inxmtp-node-go
gogoproto
to fix our immediate problemgogoproto
which apparently works.Notes
gogoproto
'sMarshalTo
method. Their code already provides a fallback for types that do not have aMarshalTo
method but I have no idea what the implications are for the fallback