Comments (7)
I opened a PR to add a grpc-transport
feature: #230
We can potentially investigate moving to a build.rs-based approach, but I think that's a bigger decision than just this feature, and it wasn't too difficult to add on top of the pre-generated code.
from cosmos-rust.
There have been a few PRs that attempted to do this: #88 #90 #97 #157
It's a feature we're open to supporting, however none of the PRs actually implemented the functionality in such a way that avoided breaking non-WASM gRPC clients
from cosmos-rust.
I think the main reason for this is the use of git submodules to pull proto files. If we generate code for .proto
files in build.rs
, we can manage tonic
and tonic-build
features at compile time.
It is a bit difficult to do in current design because code for .proto
files is generated by proto-build
that doesn't know anything about compile time features of cosmos-sdk-proto
. Also, we cannot generate code for .proto
files in build.rs
of cosmos-sdk-proto
because we're using submodules and I'm not sure how that will work when someone adds cosmos-sdk-proto
as their dependency and build it.
The right solution should be to include .proto
files in comsos-sdk-proto
's source and build Rust code using build.rs
.
from cosmos-rust.
The downside of this (beyond longer build times) is protoc must be installed to compile the crate
I think the main reason for this is the use of git submodules to pull proto files.
Even if we did move to a build.rs-based approach, we would still need to vendor the proto files into the crate somehow, similar to how the generated code is currently vendored, and that requires a source of truth for the protos, which is currently a 3rd party git repository (i.e. cosmos-sdk)
Whether or not we use a git submodule to do that seems orthogonal, but also, given that requirement I'm not sure what approach would be better than a git submodule.
from cosmos-rust.
protoc must be installed to compile the crate
prost-build
builds it if it is not installed.
Even if we did move to a build.rs-based approach, we would still need to vendor the proto files into the crate somehow, similar to how the generated code is currently vendored, and that requires a source of truth for the protos, which is currently a 3rd party git repository (i.e. cosmos-sdk)
Yes. We'll have to include .proto
files in crate sources. The problem with git submodules is that it pulls all the source code of the repository and we only need .proto
files. It'll be better if we can only extract .proto
files from git repository and include those in sources of cosmos-sdk-proto
.
Whether or not we use a git submodule to do that seems orthogonal, but also, given that requirement I'm not sure what approach would be better than a git submodule.
One approach is that instead of having a proto-build
crate, just create a proto-copy
script which copies .proto
files from each git submodule to cosmos-sdk-proto
based on configured versions. Then cosmos-sdk-proto
's build.rs
can generate rust code.
from cosmos-rust.
prost-build
builds it if it is not installed.
It does? That must be new. Does it compile protoc from source, and if so, does that require an entire C++ toolchain must be present? If so, that still seems bad.
One approach is that instead of having a
proto-build
crate, just create aproto-copy
script which copies.proto
files from each git submodule tocosmos-sdk-proto
based on configured versions. Thencosmos-sdk-proto
'sbuild.rs
can generate rust code.
That sounds exactly like what I just described. Note that this approach does not get rid of the git submodule which is the source of truth for the protos. It just replaces copying the generated Rust code with copying the protos.
from cosmos-rust.
Here's what the prost-build
docs say:
https://github.com/tokio-rs/prost/blob/master/prost-build/README.md
prost-build
usesprotoc
to parse the proto files. There are a few ways to makeprotoc
available forprost-build
.The first option is to include
protoc
in yourPATH
this
can be done by following theprotoc
install instructions. In addition, its possible to
pass thePROTOC=<my/path/to/protoc>
environment variable.The second option is to provide the
vendored
feature flag toprost-build
. This will
forceprost-build
to compileprotoc
from the bundled source. This will require that
you have the correct dependencies installed include a C++ toolchain, cmake, etc. For
more info on what the required dependencies are check here.
...so there is a vendored
option we could enable, but it would require compiling protoc from source, which would add considerably to compile times and requires an entire C++ toolchain is available
from cosmos-rust.
Related Issues (20)
- Fail building any smart contract with cosmos-sdk-proto as dependency HOT 2
- TallyParams Undocumented Decimal Type HOT 2
- Enable cosmrs support `no_std` HOT 5
- Maybe Can Use only one crate `cosmos-sdk-proto` or `ibc-proto-rs` HOT 6
- Sync versions with tendermint-rs?
- wasm-bindgen issue when using cosmrs in CosmWasm HOT 10
- Type URLs for x/authz messages not present HOT 4
- Add additional derive macros to Prost generated types HOT 19
- gov/v1 HOT 2
- Does this crate only supports gRPC for querying contracts states? HOT 4
- proto build fails because of deprecated buf template HOT 1
- Update crypto lib HOT 2
- Error: failed to load state at height 0; version mismatch on immutable IAVL tree; version does not exist. Version has either been pruned, or is for a future block height (latest height: 0): invalid request HOT 1
- 405 Method Not Allowed HOT 2
- Update ibc-go types HOT 1
- Error with user entered invalid UTF8 for protobuf structs.
- bug: cargo run ends in an error
- proto-build: bump COSMOS_SDK_REV to v0.47 or higher HOT 3
- Querying `minimum_gas_price` HOT 3
- How to output the private key and print it to the terminal? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cosmos-rust.