-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Compile protobuf messages to multiple languages for easier client development #7717
Comments
Thanks @clevinson . Just to make a few things clear, the SDK would be responsible for:
With this proposal the SDK would NOT:
I would note that it is already our responsibility to set language-specific options in our .proto files correctly. We just don't know what these are because haven't generated the Java or Python code for example. The benefits I see to doing this are:
|
It would be nice to have some client input here actually. @ethanfrey @webmaster128 would the CosmJs and CosmWasm teams find it useful if there were say auto-published NPM packages or rust crates with just the generated code? |
Thank you for the ping @aaronc. The .proto definition is a great universal interface language that many developers from many different ecosystem agree on. I appreciate the good intention, but from my perspective this proposal is a step in the wrong direction. This gets you into client development for too many too diverse technology, where you probably don't want to be in. Generating client code from a given set of proto files is highly subjective. While one client or client library might be happy with your code generation choices, the next one might not – even in the same languages. Here are some of the decisions we make for code generation that we want to control and the SDK team would have a hard time getting right in dialogue with external teams:
The next big problem is that even of this works somehow for common Cosmos SDK .protos, you need a concept to expand this to custom proto files from custom chains. Even the most simple message custom message type means you have generated code for some of your functionality, but not all of it. So you need to create a custom code generation process anyways. I agree not every app developer should do all of this work from scratch. A more scalable solution for this is having fully featured client libraries built by experts in the particular technology, like CosmJS is for JS. If you want to support client developers, I see auto-generating versioned, online .proto docs as a better tool. This promotes .proto files as the primary interface and encourages writing properly documented .proto files. See e.g. here for all the weave types. |
Thanks for the detailed feedback @webmaster128 ! Sounds like too big a can of worms. Maybe let's close this issue @clevinson and open one for proto docs? What tool did you use for that @webmaster128 ? |
My pleasure, as always.
See those scrips: |
I'd kind of like to reopen this now that buf schema registry exists and all the cosmos types are now in the registry: https://buf.build/cosmos/cosmos-sdk and they have remote plugin execution: https://docs.buf.build/bsr/remote-generation/remote-plugin-execution. Generating some basic setups for the official plugins should be quite easy now and lower the barrier to entry. People can always make a custom build in a different artifact if they have more custom needs or help us properly customize the buf.gen.yaml. |
Could you post the output for us to verify the issue? |
@jc0803kevin @marbar3778 could you move this issue into a separate ticket? #7717 is about a major strategy decision and it would be great to not start debugging language/tooling specific problems here. On the topic of #7717: To me the development of cosmjs-types and now Telescope shows that in practice code generation is and should be done by users who deeply understand their language and dev environment. The .proto files should remain the interface we all agree on. From there we have one or two language specific code generators or libraries that all app builders can utilize. I still don't see a need for the SDK team to own code generation. |
I 100% agree with this. Closing the issue for now. Lets reopen this if it becomes a larger discussion again |
Summary
Add a build script to the SDK for code generation for
.proto
files into several languages as packages. This can be executed through github actions on release tags/nightlies, and integrated with "Github Packages" to then publish packages on registries like npm, maven, etc.Problem Definition
Client developers need to be able to easily send transactions, and query state from a Cosmos SDK chain. Since Stargate (v0.40.0), the preferred client approach here requires clients to compile proto files into generated code, so they can build messages, transactions, or generate sign bytes locally and then communicate via grpc (or alternatively, a corresponding REST endpoint generated via grpc gateway).
An easy way to reduce overhead on clients is for us to take care of the code generation for common client languages, and publish packages with this generated code.
Proposal
Use github action scripts (triggered nightly and on release tags), which avoids us having generated client code checked-in to the repo. This can be integrated with github packages to allow for publishing of packages for use by client developers.
The script could compile generated code in the following languages:
The focus of these packages is on canonical types that clients can reference for published versions, as well as to have up to date versions for testing code that’s on master and RC's.
If we wanted to build out client libraries with basic grpc wiring and/or signbytes functions, that could be done later with a separate repo and build artifact.
For Admin Use
The text was updated successfully, but these errors were encountered: