Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(proto)!: upgrade proto to cosmos sdk v0.47 #2225

Draft
wants to merge 1 commit into
base: cosmos-sdk-v0.47
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 99 additions & 80 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -198,98 +198,117 @@ tofnd-client:
### Protobuf ###
###############################################################################

proto-all: proto-update-deps proto-format proto-lint proto-gen
proto-all: proto-format proto-lint proto-gen

protoVer=0.13.0
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

proto-gen:
@echo "Generating Protobuf files"
@DOCKER_BUILDKIT=1 docker build -t axelar/proto-gen -f ./Dockerfile.protocgen .
@$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace axelar/proto-gen sh ./scripts/protocgen.sh
@$(protoImage) sh ./scripts/protocgen.sh

proto-swagger-gen:
@make clean
@echo "Downloading Protobuf dependencies"
@make proto-swagger-download-dep

@echo "Generating Protobuf Swagger endpoint"
@$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace axelar/proto-gen sh ./scripts/protoc-swagger-gen.sh
@statik -src=./client/docs/static -dest=./client/docs -f -m
@$(protoImage) sh ./scripts/protoc-swagger-gen.sh

proto-format:
@echo "Formatting Protobuf files"
@$(DOCKER) run --rm -v $(CURDIR):/workspace \
--workdir /workspace tendermintdev/docker-build-proto \
$( find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; )
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;

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

proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main

TM_URL = https://raw.githubusercontent.com/cometbft/cometbft/v0.34.27/proto/tendermint
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
GOOGLE_PROTOBUF_URL = https://raw.githubusercontent.com/protocolbuffers/protobuf/main/src/google/protobuf
GOOGLE_API_URL = https://raw.githubusercontent.com/googleapis/googleapis/master/google/api
COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master
CONFIO_URL = https://raw.githubusercontent.com/confio/ics23/go/v0.9.0

TM_CRYPTO_TYPES = third_party/proto/tendermint/crypto
TM_ABCI_TYPES = third_party/proto/tendermint/abci
TM_TYPES = third_party/proto/tendermint/types
TM_VERSION = third_party/proto/tendermint/version
TM_LIBS = third_party/proto/tendermint/libs/bits
TM_P2P = third_party/proto/tendermint/p2p

GOGO_PROTO_TYPES = third_party/proto/gogoproto
GOOGLE_API_TYPES = third_party/proto/google/api
GOOGLE_PROTOBUF_TYPES = third_party/proto/google/protobuf
COSMOS_PROTO_TYPES = third_party/proto/cosmos_proto
# For some reason ibc expects confio proto files to be in the main folder
CONFIO_TYPES = third_party/proto

proto-update-deps:
@echo "Updating Protobuf deps"
@mkdir -p $(GOGO_PROTO_TYPES)
@curl -sSL $(GOGO_PROTO_URL)/gogoproto/gogo.proto > $(GOGO_PROTO_TYPES)/gogo.proto

@mkdir -p $(GOOGLE_API_TYPES)
@curl -sSL $(GOOGLE_API_URL)/annotations.proto > $(GOOGLE_API_TYPES)/annotations.proto
@curl -sSL $(GOOGLE_API_URL)/http.proto > $(GOOGLE_API_TYPES)/http.proto

@mkdir -p $(COSMOS_PROTO_TYPES)
@curl -sSL $(COSMOS_PROTO_URL)/cosmos.proto > $(COSMOS_PROTO_TYPES)/cosmos.proto

## Importing of tendermint protobuf definitions currently requires the
## use of `sed` in order to build properly with cosmos-sdk's proto file layout
## (which is the standard Buf.build FILE_LAYOUT)
## Issue link: https://github.com/tendermint/tendermint/issues/5021
@mkdir -p $(TM_ABCI_TYPES)
@curl -sSL $(TM_URL)/abci/types.proto > $(TM_ABCI_TYPES)/types.proto

@mkdir -p $(TM_VERSION)
@curl -sSL $(TM_URL)/version/types.proto > $(TM_VERSION)/types.proto

@mkdir -p $(TM_TYPES)
@curl -sSL $(TM_URL)/types/types.proto > $(TM_TYPES)/types.proto
@curl -sSL $(TM_URL)/types/evidence.proto > $(TM_TYPES)/evidence.proto
@curl -sSL $(TM_URL)/types/params.proto > $(TM_TYPES)/params.proto
@curl -sSL $(TM_URL)/types/validator.proto > $(TM_TYPES)/validator.proto
@curl -sSL $(TM_URL)/types/block.proto > $(TM_TYPES)/block.proto

@mkdir -p $(TM_CRYPTO_TYPES)
@curl -sSL $(TM_URL)/crypto/proof.proto > $(TM_CRYPTO_TYPES)/proof.proto
@curl -sSL $(TM_URL)/crypto/keys.proto > $(TM_CRYPTO_TYPES)/keys.proto

@mkdir -p $(TM_LIBS)
@curl -sSL $(TM_URL)/libs/bits/types.proto > $(TM_LIBS)/types.proto

@mkdir -p $(TM_P2P)
@curl -sSL $(TM_URL)/p2p/types.proto > $(TM_P2P)/types.proto

@mkdir -p $(CONFIO_TYPES)
@curl -sSL $(CONFIO_URL)/proofs.proto > $(CONFIO_TYPES)/proofs.proto
## insert go package option into proofs.proto file
## Issue link: https://github.com/confio/ics23/issues/32
@./scripts/sed.sh $(CONFIO_TYPES)/proofs.proto

@./scripts/proto-copy-cosmos-sdk.sh

.PHONY: proto-all proto-gen proto-gen-any proto-format proto-lint proto-check-breaking proto-update-deps
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main

###############################################################################
# Swagger Configuration #
###############################################################################

SWAGGER_DIR=./swagger-proto
THIRD_PARTY_DIR=$(SWAGGER_DIR)/third_party

# Dependency versions
# COSMOS_SDK_VERSION=$(go list -m -json github.com/cosmos/cosmos-sdk | jq -r .Version)
# IBC_VERSION=$(go list -m all | grep "github.com/cosmos/ibc-go" | cut -d' ' -f2)
# WASMD_VERSION=$(go list -m -json github.com/CosmWasm/wasmd | jq -r .Version)
COSMOS_SDK_VERSION=v0.47.15
IBC_VERSION=v7.8.0
WASMD_VERSION=v0.46.0

proto-swagger-download-deps:
@make clean
mkdir -p "$(THIRD_PARTY_DIR)/cosmos_tmp" && \
cd "$(THIRD_PARTY_DIR)/cosmos_tmp" && \
git init && \
git remote add origin "https://github.com/cosmos/cosmos-sdk.git" && \
git config core.sparseCheckout true && \
printf "proto\n" > .git/info/sparse-checkout && \
git fetch origin ${COSMOS_SDK_VERSION} && \
git checkout FETCH_HEAD && \
rm -f ./proto/buf.* && \
mv ./proto/* ..
rm -rf "$(THIRD_PARTY_DIR)/cosmos_tmp"

mkdir -p "$(THIRD_PARTY_DIR)/ibc_tmp" && \
cd "$(THIRD_PARTY_DIR)/ibc_tmp" && \
git init && \
git remote add origin "https://github.com/cosmos/ibc-go.git" && \
git config core.sparseCheckout true && \
printf "proto\n" > .git/info/sparse-checkout && \
git fetch origin ${IBC_VERSION} && \
git checkout FETCH_HEAD && \
rm -f ./proto/buf.* && \
mv ./proto/* ..
rm -rf "$(THIRD_PARTY_DIR)/ibc_tmp"


mkdir -p "$(THIRD_PARTY_DIR)/wasmd_tmp" && \
cd "$(THIRD_PARTY_DIR)/wasmd_tmp" && \
git init && \
git remote add origin "https://github.com/CosmWasm/wasmd.git" && \
git config core.sparseCheckout true && \
printf "proto\n" > .git/info/sparse-checkout && \
git fetch origin ${WASMD_VERSION} && \
git checkout FETCH_HEAD && \
rm -f ./proto/buf.* && \
mv ./proto/* ..
rm -rf "$(THIRD_PARTY_DIR)/wasmd_tmp"

mkdir -p "$(THIRD_PARTY_DIR)/cosmos_proto_tmp" && \
cd "$(THIRD_PARTY_DIR)/cosmos_proto_tmp" && \
git init && \
git remote add origin "https://github.com/cosmos/cosmos-proto.git" && \
git config core.sparseCheckout true && \
printf "proto\n" > .git/info/sparse-checkout && \
git pull origin main && \
rm -f ./proto/buf.* && \
mv ./proto/* ..
rm -rf "$(THIRD_PARTY_DIR)/cosmos_proto_tmp"

mkdir -p "$(THIRD_PARTY_DIR)/cosmos/ics23/v1" && \
curl -sSL https://raw.githubusercontent.com/cosmos/ics23/master/proto/cosmos/ics23/v1/proofs.proto > "$(THIRD_PARTY_DIR)/cosmos/ics23/v1/proofs.proto"

mkdir -p "$(THIRD_PARTY_DIR)/gogoproto" && \
curl -SSL https://raw.githubusercontent.com/cosmos/gogoproto/main/gogoproto/gogo.proto > "$(THIRD_PARTY_DIR)/gogoproto/gogo.proto"

mkdir -p "$(THIRD_PARTY_DIR)/google/api" && \
curl -sSL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto > "$(THIRD_PARTY_DIR)/google/api/annotations.proto"
curl -sSL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto > "$(THIRD_PARTY_DIR)/google/api/http.proto"

clean:
rm -rf \
tmp-swagger-gen/ \
swagger-proto


.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking proto-swagger-download-deps clean

guard-%:
@ if [ -z '${${*}}' ]; then echo 'Environment variable $* not set' && exit 1; fi
3 changes: 3 additions & 0 deletions buf.work.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v1
directories:
- proto
19 changes: 0 additions & 19 deletions buf.yaml

This file was deleted.

Loading
Loading