Skip to content

Commit

Permalink
fix: protogen scripts were not generating the Any types correctly (ev…
Browse files Browse the repository at this point in the history
…mos#1084)

* Remove local copy of third party proto files

* Update protogen scripts to work as the cosmos-sdk ones

* Move protoc swagger script to scripts folder

* Update protoc-swagger-gen.sh script to not use local copies of third party proto files

* Commit updated go.mod & go.sum

* Apply buf mod update after ethermint proto was uploaded to buf.build

* Update makefile proto commands (except for proto-update-deps for now)

* Add --network host to docker run command for linux compatibility

* Cleanup buf yaml files

* Update protocgen script to mirror working version in Ethermint repo

* Update dependecy to use cosmos/gogoproto v1.4.3

* Commit generated files after updating protocgen script

* add newlines to buf yaml files to address linter

* make protoc-swagger-gen.sh executable

* address shellcheck output

* use cosmos/proto-builder docker image for proto-format

* apply make proto-format

* address more linter comments

* comment out proto-swagger-gen and add todo

* remove proto-swagger-gen from Makefile .PHONY

* Use protolint for make proto-lint

* Rename clang-format file so that it is used in make proto-format command

* Sort Protobuf imports

* Address protolint comments in all proto files

* Generate Proto go implementations after adjusting proto files

* address review comments

Co-authored-by: Federico Kunze Küllmer <[email protected]>
  • Loading branch information
MalteHerrmann and fedekunze authored Nov 22, 2022
1 parent a10d3f6 commit 0a648de
Show file tree
Hide file tree
Showing 203 changed files with 1,362 additions and 13,119 deletions.
6 changes: 6 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
Language: Proto
BasedOnStyle: google
ColumnLimit: 120
IndentWidth: 2
...
6 changes: 3 additions & 3 deletions .protolint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ lint:
- for
- at
- of
# # The specific keywords including prepositions to ignore. E.g. end_of_support is a term you would like to use, and skip checking.
# excludes:
# - end_of_support
# The specific keywords including prepositions to ignore. E.g. end_of_support is a term you would like to use, and skip checking.
excludes:
- duration_of_decay

# # REPEATED_FIELD_NAMES_PLURALIZED rule option.
# ## The spec for each rules follows the implementation of https://github.com/gertd/go-pluralize.
Expand Down
57 changes: 43 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ BUILDDIR ?= $(CURDIR)/build
SIMAPP = ./app
HTTPS_GIT := https://github.com/evmos/evmos.git
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
NAMESPACE := tharsishq
PROJECT := evmos
DOCKER_IMAGE := $(NAMESPACE)/$(PROJECT)
Expand Down Expand Up @@ -247,7 +246,7 @@ else
endif

tools: tools-stamp
tools-stamp: contract-tools docs-tools proto-tools statik runsim
tools-stamp: contract-tools docs-tools statik runsim
# Create dummy file to satisfy dependency and avoid
# rebuilding when this Makefile target is hit twice
# in a row.
Expand All @@ -263,7 +262,7 @@ docs-tools-stamp: docs-tools
# in a row.
touch $@

.PHONY: runsim statik tools contract-tools docs-tools proto-tools tools-stamp tools-clean docs-tools-stamp
.PHONY: runsim statik tools contract-tools docs-tools tools-stamp tools-clean docs-tools-stamp

go.sum: go.mod
echo "Ensure dependencies have not been modified ..." >&2
Expand Down Expand Up @@ -444,27 +443,58 @@ format:
### Protobuf ###
###############################################################################

containerProtoVer=v0.7
containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer)
containerProtoGen=cosmos-sdk-proto-gen-$(containerProtoVer)
containerProtoGenSwagger=cosmos-sdk-proto-gen-swagger-$(containerProtoVer)
containerProtoFmt=cosmos-sdk-proto-fmt-$(containerProtoVer)
# ------
# NOTE: Link to the tendermintdev/sdk-proto-gen docker images:
# https://hub.docker.com/r/tendermintdev/sdk-proto-gen/tags
#
protoVer=v0.7
protoImageName=tendermintdev/sdk-proto-gen:$(protoVer)
protoImage=$(DOCKER) run --network host --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)
# ------
# NOTE: cosmos/proto-builder image is needed because clang-format is not installed
# on the tendermintdev/sdk-proto-gen docker image.
# Link to the cosmos/proto-builder docker images:
# https://github.com/cosmos/cosmos-sdk/pkgs/container/proto-builder
#
protoCosmosVer=0.11.2
protoCosmosName=ghcr.io/cosmos/proto-builder:$(protoCosmosVer)
protoCosmosImage=$(DOCKER) run --network host --rm -v $(CURDIR):/workspace --workdir /workspace $(protoCosmosName)
# ------
# NOTE: Link to the yoheimuta/protolint docker images:
# https://hub.docker.com/r/yoheimuta/protolint/tags
#
protolintVer=0.42.2
protolintName=yoheimuta/protolint:$(protolintVer)
protolintImage=$(DOCKER) run --network host --rm -v $(CURDIR):/workspace --workdir /workspace $(protolintName)


# ------
# NOTE: If you are experiencing problems running these commands, try deleting
# the docker images and execute the desired command again.
#
proto-all: proto-format proto-lint proto-gen

proto-gen:
@echo "Generating Protobuf files"
$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen sh ./scripts/protocgen.sh
$(protoImage) sh ./scripts/protocgen.sh

# TODO: Rethink API docs generation
# proto-swagger-gen:
# @echo "Generating Protobuf Swagger"
# $(protoImage) sh ./scripts/protoc-swagger-gen.sh

proto-format:
@echo "Formatting Protobuf files"
find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \;
$(protoCosmosImage) find ./ -name *.proto -exec clang-format -i {} \;

# NOTE: The linter configuration lives in .protolint.yaml
proto-lint:
@$(DOCKER_BUF) lint --error-format=json
@echo "Linting Protobuf files"
$(protolintImage) lint ./proto

proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main
@echo "Checking Protobuf files for breaking changes"
$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main


TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.20/proto/tendermint
Expand Down Expand Up @@ -503,8 +533,7 @@ proto-update-deps:
@curl -sSL $(TM_URL)/crypto/keys.proto > $(TM_CRYPTO_TYPES)/keys.proto



.PHONY: proto-all proto-gen proto-gen-any proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps
.PHONY: proto-all proto-gen proto-format proto-lint proto-check-breaking proto-update-deps

###############################################################################
### Localnet ###
Expand Down
1 change: 0 additions & 1 deletion buf.work.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: v1
directories:
- proto
- third_party/proto
115 changes: 0 additions & 115 deletions clang-format

This file was deleted.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/armon/go-metrics v0.4.1
github.com/cosmos/cosmos-sdk v0.46.5
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.3
github.com/cosmos/ibc-go/v5 v5.1.0
github.com/ethereum/go-ethereum v1.10.19
github.com/evmos/ethermint v0.20.0-rc2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ github.com/cosmos/cosmos-sdk/ics23/go v0.8.0/go.mod h1:2a4dBq88TUoqoWAU5eu0lGvpF
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/gogoproto v1.4.3 h1:RP3yyVREh9snv/lsOvmsAPQt8f44LgL281X0IOIhhcI=
github.com/cosmos/gogoproto v1.4.3/go.mod h1:0hLIG5TR7IvV1fme1HCFKjfzW9X2x0Mo+RooWXCnOWU=
github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y=
github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
github.com/cosmos/iavl v0.19.4 h1:t82sN+Y0WeqxDLJRSpNd8YFX5URIrT+p8n6oJbJ2Dok=
Expand Down
8 changes: 8 additions & 0 deletions proto/buf.gen.gogo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: v1
plugins:
- name: gocosmos
out: .
opt: plugins=grpc
- name: grpc-gateway
out: .
opt: logtostderr=true,allow_colon_final_segments=true
4 changes: 2 additions & 2 deletions buf.gen.swagger.yaml → proto/buf.gen.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins:
- name: gocosmos
out: .
opt:
- plugins=interfacetype+grpc
- plugins=grpc

- name: grpc-gateway
out: .
Expand All @@ -18,4 +18,4 @@ plugins:
- logtostderr=true
- fqn_for_swagger_name=true
- simple_operation_ids=true
strategy: all
strategy: all
20 changes: 18 additions & 2 deletions proto/buf.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: cosmos
repository: cosmos-proto
commit: 1935555c206d4afb9e94615dfd0fad31
- remote: buf.build
owner: cosmos
repository: cosmos-sdk
commit: 508e19f5f37549e3a471a2a59b903c00
- remote: buf.build
owner: cosmos
repository: gogo-proto
commit: 34d970b699f84aa382f3c29773a60836
- remote: buf.build
owner: evmos
repository: evmos
commit: ed3b422c3b484804b054a02f82a39603
repository: ethermint
commit: f0f1df1cd49a49d9b03eadd4235481af
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 783e4b5374fa488ab068d08af9658438
8 changes: 6 additions & 2 deletions proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
version: v1
name: buf.build/evmos/evmos
deps:
- buf.build/evmos/evmos
- buf.build/cosmos/cosmos-sdk
- buf.build/cosmos/cosmos-proto
- buf.build/cosmos/gogo-proto
- buf.build/evmos/ethermint
- buf.build/googleapis/googleapis
lint:
use:
- DEFAULT
Expand All @@ -19,4 +23,4 @@ lint:
- COMMENT_MESSAGE
breaking:
use:
- FILE
- FILE
Loading

0 comments on commit 0a648de

Please sign in to comment.