Skip to content
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

Simplify proto gen #52

Merged
merged 13 commits into from
Apr 16, 2023
Merged

Conversation

neekolas
Copy link
Contributor

@neekolas neekolas commented Apr 16, 2023

Summary

Trying a different approach to generating protobuf code.

Advantages are:

  • No submodules or copying proto files
  • Simpler build.rs config with no special overrides needed for serialization.
  • Uses buf schema registry for our protos

Notes

Some things to watch out for:

  • Includes a generated .serde.rs file for all the protos. One side effect of this is that zero'd proto fields are no longer present in JSON output. I had to update one of your tests to accomodate the change.
  • I changed the grpc port for the tests to :5556, which may break your local setup
  • There may be subtle differences in serialization I'm not aware of. The only thing I checked is that bytes fields are serialized as base64 strings, which this generated Serde setup seems to do by default. But there may be other less desirable changes that I haven't noticed yet.
  • I have no idea why I can only make this work as a separate crate. I tried a bunch of ways to make it work inside xmtp-networking, but my knowledge of Rust modules is just not there to debug the issue. If you can make it work, that's probably better.

@michaelx11
Copy link
Contributor

Wow awesome I'll take a look!

Copy link
Contributor

@michaelx11 michaelx11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an amazing improvement. I was hunting for the reference to our protos, but it's in build.rs pointing at https://buf.build/xmtp/proto right?

Having a separate crate for protos is probably a better idea too!

@@ -0,0 +1,25 @@
// @generated
pub mod xmtp {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like a moron for having to handwrite this file myself in the original branch. I felt like a genius at the time for figuring out how to deal with our package names though 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man, I never would have figured that out on my own.

@michaelx11
Copy link
Contributor

Feel free to merge whenever!

@neekolas neekolas marked this pull request as ready for review April 16, 2023 21:23
@neekolas neekolas merged commit a742472 into michaelx-grpc_with_swift_bridge Apr 16, 2023
michaelx11 pushed a commit that referenced this pull request Apr 17, 2023
* feat: get gRPC compiling into networking crate

* fix: attempt to fix weird package name nesting situation

* fix: actually got it right

* feat: add silly grpc client test

* feat: added crappy grpc test

* wip: need to run local node to test

* wip: checkpoint, getting connection error detected: frame with invalid size, trying to add tls now

* feat: rountrip publish/query in Rust

* docs: fix up comments

* feat: do a full grpc roundtrip as a Swift test

* docs: remove warnings

* fix: return uint16 status code for grpc test too

* fix: chunk up auth token to avoid false positives in secret detection

* feat: everything builds, Generated code is populated, now need to hook up to xmtp-ios

* feat: Swift-Bridge, manually copy headers into include

* fix: strip out corecrypto for now, framework down to 230MB

* feat: add library size optimizations

* feat: refactor into publish and query with serialized versions

* feat: cleaned up and implemented query and publish

* style: ran clippy

* feat: full e2e build working, if jank

* test: added a failing base64 bytes encoding test

* fix: do a serde encoding override to base64 encode bytes fields in MessageApi

* feat: implement subscribe_once api

* Simplify proto gen (#52)

* Initial commit

* Include lib

* Add features

* Correct import

* Add feature

* Add pbjson

* Almost passing

* Add build.rs

* Add .gitignore

* Rename folder

* Remove generated code

* Gitignore generated

* Automatically install required dependency

* fix: Makefile change target dir to ./target workaround Cargo workspace

* Update gitignore

* Delete .gitmodules

* Delete Cargo.lock

* fix: remove bindings/xmtp_rust_swift from cargo workspace

* fix: remove xmtp_rust_swift from workspace to use size-optimized profiles

---------

Co-authored-by: Nicholas Molnar <65710+neekolas@users.noreply.github.com>
Co-authored-by: Nicholas Molnar <nicholas@xmtp.com>
neekolas added a commit that referenced this pull request Apr 19, 2023
* feat: get gRPC compiling into networking crate

* fix: attempt to fix weird package name nesting situation

* fix: actually got it right

* feat: add silly grpc client test

* feat: added crappy grpc test

* wip: need to run local node to test

* wip: checkpoint, getting connection error detected: frame with invalid size, trying to add tls now

* feat: rountrip publish/query in Rust

* docs: fix up comments

* feat: do a full grpc roundtrip as a Swift test

* docs: remove warnings

* fix: return uint16 status code for grpc test too

* fix: chunk up auth token to avoid false positives in secret detection

* feat: everything builds, Generated code is populated, now need to hook up to xmtp-ios

* feat: Swift-Bridge, manually copy headers into include

* fix: strip out corecrypto for now, framework down to 230MB

* feat: add library size optimizations

* feat: refactor into publish and query with serialized versions

* feat: cleaned up and implemented query and publish

* style: ran clippy

* feat: full e2e build working, if jank

* test: added a failing base64 bytes encoding test

* fix: do a serde encoding override to base64 encode bytes fields in MessageApi

* feat: implement subscribe_once api

* Simplify proto gen (#52)

* Initial commit

* Include lib

* Add features

* Correct import

* Add feature

* Add pbjson

* Almost passing

* Add build.rs

* Add .gitignore

* Rename folder

* Remove generated code

* Gitignore generated

* Automatically install required dependency

* fix: Makefile change target dir to ./target workaround Cargo workspace

* Update gitignore

* Delete .gitmodules

* Delete Cargo.lock

* fix: remove bindings/xmtp_rust_swift from cargo workspace

* fix: remove xmtp_rust_swift from workspace to use size-optimized profiles

* Rename repo

* Streaming support

* Rename back to subscription

* Make tests pass

* Update bindings

* Fix merge conflicts

* Include libxmtp-core and wasm bindings

* Make poll_subscription non-async

* Re-pin

---------

Co-authored-by: Michael Xu <michaeljxu11@gmail.com>
Co-authored-by: Michael Xu <michaelx@xmtp.com>
@jazzz jazzz deleted the simplify-proto-gen branch April 26, 2023 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants