Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
chore: update proto make commands (#1471)
Browse files Browse the repository at this point in the history
* Update proto make commands to use cosmos docker image and add notes for possible problems

* Apply make proto-all with new docker container

* Remove stale DOCKER_BUF variable

* Revert to using the tendermintdev/sdk-proto-gen docker image

* remove '@' in proto-lint and proto-check-breaking for consistency with other commands

* Remove unnecessary go get from protocgen.sh (only works after adding --network host to docker run)

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

* use cosmos/proto-builder docker image for proto-format because clang-format is not installed on tendermintdev/sdk-proto-gen

* update swagger docs after recent additions to evm.proto in #1413

Co-authored-by: Tomas Guerra <54514587+GAtom22@users.noreply.github.com>
  • Loading branch information
MalteHerrmann and GAtom22 authored Nov 20, 2022
1 parent be40f2b commit f70dafd
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 18 deletions.
38 changes: 26 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ SIMAPP = ./app
HTTPS_GIT := https://github.com/evmos/ethermint.git
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.0.0-rc8
# RocksDB is a native dependency, so we don't assume the library is installed.
# Instead, it must be explicitly enabled and we warn when it is not.
ENABLE_ROCKSDB ?= false
Expand Down Expand Up @@ -422,33 +421,48 @@ format-fix:
### Protobuf ###
###############################################################################

protoVer=v0.2
# ------
# 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)
containerProtoGen=$(PROJECT_NAME)-proto-gen-$(protoVer)
containerProtoGenAny=$(PROJECT_NAME)-proto-gen-any-$(protoVer)
containerProtoGenSwagger=$(PROJECT_NAME)-proto-gen-swagger-$(protoVer)
containerProtoFmt=$(PROJECT_NAME)-proto-fmt-$(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: 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

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

proto-format:
@echo "Formatting Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi
$(protoCosmosImage) find ./ -name "*.proto" -exec clang-format -i {} \;

proto-lint:
@$(DOCKER_BUF) lint --error-format=json
@echo "Linting Protobuf files"
$(protoImage) buf lint --error-format=json

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


.PHONY: proto-all proto-gen proto-gen-any proto-swagger-gen proto-format proto-lint proto-check-breaking
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,11 @@ paths:
in: query
required: false
type: boolean
- name: trace_config.tracer_json_config
description: tracer config.
in: query
required: false
type: string
- name: block_number
description: block number.
in: query
Expand Down Expand Up @@ -3028,6 +3033,11 @@ paths:
in: query
required: false
type: boolean
- name: trace_config.tracer_json_config
description: tracer config.
in: query
required: false
type: string
- name: block_number
description: block number of requested transaction.
in: query
Expand Down Expand Up @@ -4107,6 +4117,9 @@ definitions:
enable_return_data:
type: boolean
title: enable return data capture
tracer_json_config:
type: string
title: tracer config
description: TraceConfig holds extra parameters to trace functions.
google.protobuf.Any:
type: object
Expand Down
4 changes: 2 additions & 2 deletions proto/ethermint/evm/v1/evm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ message TraceConfig {
// enable memory capture
bool enable_memory = 11 [(gogoproto.jsontag) = "enableMemory"];
// enable return data capture
bool enable_return_data = 12 [ (gogoproto.jsontag) = "enableReturnData" ];
bool enable_return_data = 12 [(gogoproto.jsontag) = "enableReturnData"];
// tracer config
string tracer_json_config = 13 [ (gogoproto.jsontag) = "tracerConfig" ];
string tracer_json_config = 13 [(gogoproto.jsontag) = "tracerConfig"];
}
7 changes: 4 additions & 3 deletions scripts/protocgen.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env bash

# --------------
# Commands to run locally
# docker run --network host --rm -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen:v0.7 sh ./protocgen.sh
#
set -eo pipefail

# get protoc executions
go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null

echo "Generating gogo proto code"
proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
for dir in $proto_dirs; do
Expand Down

0 comments on commit f70dafd

Please sign in to comment.