Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

update proto generation and testing pipelines #358

Merged
merged 22 commits into from Nov 16, 2021
Merged

Conversation

williambanfield
Copy link
Contributor

@williambanfield williambanfield commented Nov 9, 2021

This pull request aims to make it possible to generate, format, and lint the protos within this repo.
To accomplish that end, the Dockerfile containing common tools for building the tendermint protos has been moved into this repository. A related github workflow for building that dockerfile has been added to this repo (and removed from the tendermint repository). Additionally, a buf.yaml and buf.gen.yaml have been added for working with the buf tool that we use for compiling our protos. A
./third_party directory with the gogoproto proto file has been added to the root of the repo so that the proto compiler can find this dependency.

The go_package variable has been removed from all of the protos. This variable was set to github.com/tendermint/tendermint/{PACKAGE} which does not make any sense since this is not the tendermint repository. This variable is now set when the protos are built within the tendermint repo. This does present the downside that users who wish to build this protos in go will also need to manually add this option. The community of users doing that seems likely to be small, and we can provide support to them with the scripts that are added in: tendermint/tendermint#7269.

Copy link
Contributor

@creachadair creachadair left a comment

Choose a reason for hiding this comment

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

One simplification suggestion, otherwise LGTM.

proto/Dockerfile Outdated Show resolved Hide resolved
@@ -1,8 +1,6 @@
syntax = "proto3";
package tendermint.abci;

option go_package = "github.com/tendermint/tendermint/abci/types";
Copy link
Contributor

Choose a reason for hiding this comment

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

what the new process here? generate in spec then move over?

I think for go this is required? (I can't remember exactly)

Copy link
Contributor

Choose a reason for hiding this comment

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

when this is imported into Tendermint, will it not cause package issues?

package tendermint_abci

Copy link
Contributor

Choose a reason for hiding this comment

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

whoops, never mind, I read the other PR now.

The only downside of doing it this way is, users of our photo files will need to append option go_package as well, this could cause confusion. Before it was plug and play.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, this is really a downside of hosting the protos in the spec repo in general. If users were to try to generate these protos themselves using the old option, they would have created protos with import paths that do not match their local module name. As a result of this, they would have two options, both of which are not ideal.

Option 1. Rewrite the import paths locally, either before or after proto generation so that the paths match the local module. This is effectively what we are changing Tendermint to do.
Option 2. Shove the protos into the vendor directory, where packages are allowed to have a name that does not match the module name, but is also a directory that go programmers frequently cede to the go mod tooling to manage.

Neither option is great, and I think we can all agree that using the module name github.com/tendermint/tendermint in this package is strictly incorrect. If this solution causes serious headache for users who are attempting to vendor these protos into their local vendor directory, we can reconsider, but it also seems odd to me that a user would do that and not simply import the generated protos that exist within the Tendermint repository instead since they are effectively equivalent.

Copy link
Contributor

Choose a reason for hiding this comment

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

The issue is that when the user imports the proto file into there proto file and generate their files the go import will be set to something else that isn't actually importing a file. This is how it is currently done for all go projects.

It's fine if we break this, wanted to make note of it mainly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, do you know of people doing this?

mergify bot pushed a commit to tendermint/tendermint that referenced this pull request Nov 15, 2021
This pull request updates the `protocgen.sh` script to insert the `go_package` option to all of the downloaded proto files. A related pull request into the spec repo removes this options from the .proto files: tendermint/spec#358

This pull requests, along with the related spec PR, aim to move the creation of the `tendermintdev/docker-build-proto` container into the spec repo. This change also relies on several fixes to that container that are made in the PR into the spec repo.
.github/workflows/proto-check.yml Outdated Show resolved Hide resolved
.github/workflows/proto-dockerfile.yml Show resolved Hide resolved
buf.gen.yaml Outdated Show resolved Hide resolved
buf.gen.yaml Outdated Show resolved Hide resolved
proto/Dockerfile Outdated Show resolved Hide resolved
proto/Dockerfile Outdated Show resolved Hide resolved
proto/Dockerfile Outdated Show resolved Hide resolved
third_party/proto/gogoproto/gogo.proto Outdated Show resolved Hide resolved
williambanfield and others added 7 commits November 16, 2021 12:02
Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
@williambanfield williambanfield merged commit a00de71 into master Nov 16, 2021
@williambanfield williambanfield deleted the wb/proto-fixes branch November 16, 2021 19:34
tychoish pushed a commit to tychoish/tendermint that referenced this pull request Nov 19, 2021
…dermint#7269)

This pull request updates the `protocgen.sh` script to insert the `go_package` option to all of the downloaded proto files. A related pull request into the spec repo removes this options from the .proto files: tendermint/spec#358

This pull requests, along with the related spec PR, aim to move the creation of the `tendermintdev/docker-build-proto` container into the spec repo. This change also relies on several fixes to that container that are made in the PR into the spec repo.
evan-forbes pushed a commit to celestiaorg/celestia-core that referenced this pull request Feb 2, 2022
This pull request updates the `protocgen.sh` script to insert the `go_package` option to all of the downloaded proto files. A related pull request into the spec repo removes this options from the .proto files: tendermint/spec#358

This pull requests, along with the related spec PR, aim to move the creation of the `tendermintdev/docker-build-proto` container into the spec repo. This change also relies on several fixes to that container that are made in the PR into the spec repo.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants