cosmos/ibc-proto-rs

Errors when re-compiling proto files

ancazamfir opened this issue · 1 comments

Crate

ibc-proto

Summary of Bug

ibc-rs doesn't build with the proto commits in proto/src/prost

Version

Steps to Reproduce

  • Clone a new repo, branch master.
  • Get the refpoints from COSMOS_.._COMMIT files:
$ cat proto/src/prost/COSMOS_SDK_COMMIT
21814558eaa47b018018711e5fe16e0b16811fce
cat proto/src/prost/COSMOS_IBC_COMMIT
333c1f338b2a14a1928a6f8ab64c37123c0e97b6
  • clone the proto repos:
$ cd proto-compiler
$ cargo run -- clone --out /tmp/cosmos --sdk-commit 21814558eaa47b018018711e5fe16e0b16811fce --ibc-go-commit 333c1f338b2a14a1928a6f8ab64c37123c0e97b6
  • compile protos:
    cargo run -- compile --sdk /tmp/cosmos/sdk --ibc /tmp/cosmos/ibc --out ../proto/src/prost

  • notice the changes where there shouldn't be any:

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   ../proto/src/prost/cosmos.upgrade.v1beta1.rs
  • try to build ibc-rs:
$ cd ..
$ cargo build
   Compiling ibc-relayer v0.1.1 (/Users/ancaz/rust/1ibc-rs/relayer)
error[E0432]: unresolved imports `ibc_proto::cosmos::upgrade::v1beta1::QueryCurrentPlanRequest`, `ibc_proto::cosmos::upgrade::v1beta1::QueryUpgradedConsensusStateRequest`
  --> relayer/src/chain/cosmos.rs:47:5
   |
47 |     QueryCurrentPlanRequest, QueryUpgradedConsensusStateRequest,
   |     ^^^^^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `QueryUpgradedConsensusStateRequest` in `cosmos::upgrade::v1beta1`
   |     |
   |     no `QueryCurrentPlanRequest` in `cosmos::upgrade::v1beta1`

error[E0433]: failed to resolve: could not find `query_client` in `v1beta1`
   --> relayer/src/chain/cosmos.rs:525:68
    |
525 |                 ibc_proto::cosmos::upgrade::v1beta1::query_client::QueryClient::connect(
    |                                                                    ^^^^^^^^^^^ not found in `ibc_proto::cosmos::upgrade::v1beta1::query_client`
    |

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate milestone (priority) applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

Some progress on debugging this:

The generated Rust code in cosmos.upgrade.v1beta1.rs is suffering changes because there are two separate .proto files that can be used to generate this code:

  1. upgrade.proto from cosmos-sdk

This .proto is the "good" definition which we want to use in generating our Rust code in cosmos.upgrade.v1beta1.rs

  1. upgrade.proto from ibc-go

This second .proto file is a dependency for client.proto from ibc-go.

So the problem is that our compile.rs script is first generating code from the "good" definition from the sdk, but then in the process of generating client.proto it also compiles the dependency called upgrade.proto from ibc-go, which overwrites the "good" file.

https://github.com/informalsystems/ibc-rs/blob/5b1f409356303bd1180808cc81eb0864ff607ebe/proto-compiler/src/cmd/compile.rs#L34-L35