medibloc / panacea-core

MediBloc Blockchain Core
https://medibloc.com
Other
60 stars 19 forks source link

fix: update `go_package` option to v2 in proto files #627

Closed youngjoon-lee closed 1 year ago

youngjoon-lee commented 1 year ago

To make proto files to be imported by proto files in other Go projects such as https://github.com/medibloc/panacea-oracle/pull/79#discussion_r1094239242, we should put v2 into go_package options in our proto files. This practice can be found in Osmosis proto files.

TODO: We should update v2 to v3 before releasing panacea-core v3.x.x. We will probably be able to adapt a bot that Osmosis uses.

@inchori @audtlr24 @H4NLee I'm adding details to help you reviewing this PR. From the panacea-core point of view, adding v2 into go_package options doesn't make any difference. But, let's imagine what will happen in panacea-oracle that contains proto files as below, without merging this PR.

// `foo.proto` in panacea-oracle repo

import "panacea/datadeal/v2/consent.proto";

message Foo {
  panacea.datadeal.v2.Certificate certificate = 1;
}

This proto file, foo.proto, imports a consent.proto defined in panacea-core repo. This can be compiled to foo.pb.go without any error. Everything looks good. But, the problem is that the foo.pb.go will have an import statement as below.

// `foo.pb.go` in panacea-oracle repo

import (
  types "github.com/medibloc/panacea-core/x/datadeal/types"
)

Then, Go compiler will raise an error: github.com/medibloc/panacea-core/x/datadeal/types package not found, because the panacea-core is released as v2.x.x. To resolve this issue, we have to import Go packages as github.com/medibloc/panacea-core/v2/x/.... Of course, it is prohibited to modify auto-generated *.pb.go file. The recommended way is putting v2 into go_package options in original proto files defined in panacea-core repo. This PR is for that. If panacea-oracle imports proto files fixed by this PR, the foo.pb.go will be generated as below. Then, Go compiler won't complain anything.

// `foo.pb.go` in panacea-oracle repo

import (
  types "github.com/medibloc/panacea-core/v2/x/datadeal/types"
)
0xHansLee commented 1 year ago

lgtm