proto: buf for everything (#5650)

## Description

- remove installation of protoc
- use buf protoc to generate proto stubs

prior to approving could someone test locally. I restarted my docker instance and its been stuck for 20+ minutes

Closes: #XXX
This commit is contained in:
Marko
2020-11-12 12:15:18 +01:00
committed by GitHub
parent eb0d353767
commit 95cff1efb4
7 changed files with 32 additions and 46 deletions

View File

@@ -106,12 +106,12 @@ specify exactly the dependency you want to update, eg.
We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along with [gogoproto](https://github.com/gogo/protobuf) to generate code for use across Tendermint Core.
For linting and checking breaking changes, we use [buf](https://buf.build/). If you would like to run linting and check if the changes you have made are breaking then you will need to have docker running locally. Then the linting cmd will be `make proto-lint` and the breaking changes check will be `make proto-check-breaking`.
For linting, checking breaking changes and generating proto stubs, we use [buf](https://buf.build/). If you would like to run linting and check if the changes you have made are breaking then you will need to have docker running locally. Then the linting cmd will be `make proto-lint` and the breaking changes check will be `make proto-check-breaking`.
There are two ways to generate your proto stubs.
1. Use Docker, pull an image that will generate your proto stubs with no need to install anything. `make proto-gen-docker`
2. Run `make proto-gen` after installing `protoc` and gogoproto, you can do this by running `make protobuf`.
2. Run `make proto-gen` after installing `buf` and `gogoproto`, you can do this by running `make protobuf`.
### Installation Instructions

View File

@@ -52,8 +52,8 @@ all: check build test install
.PHONY: all
# The below include contains the tools.
include tools.mk
include tests.mk
include tools/Makefile
include test/Makefile
###############################################################################
### Build Tendermint ###

View File

@@ -17,20 +17,20 @@ message Evidence {
// DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes.
message DuplicateVoteEvidence {
tendermint.types.Vote vote_a = 1;
tendermint.types.Vote vote_b = 2;
int64 total_voting_power = 3;
int64 validator_power = 4;
google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
tendermint.types.Vote vote_a = 1;
tendermint.types.Vote vote_b = 2;
int64 total_voting_power = 3;
int64 validator_power = 4;
google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
// LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client.
message LightClientAttackEvidence {
tendermint.types.LightBlock conflicting_block = 1;
int64 common_height = 2;
tendermint.types.LightBlock conflicting_block = 1;
int64 common_height = 2;
repeated tendermint.types.Validator byzantine_validators = 3;
int64 total_voting_power = 4;
google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
int64 total_voting_power = 4;
google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
message EvidenceList {

View File

@@ -106,10 +106,10 @@ message Vote {
// Commit contains the evidence that a block was committed by a set of validators.
message Commit {
int64 height = 1;
int32 round = 2;
BlockID block_id = 3 [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"];
repeated CommitSig signatures = 4 [(gogoproto.nullable) = false];
int64 height = 1;
int32 round = 2;
BlockID block_id = 3 [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"];
repeated CommitSig signatures = 4 [(gogoproto.nullable) = false];
}
// CommitSig is a part of the Vote included in a Commit.

View File

@@ -4,7 +4,7 @@ set -eo pipefail
proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
for dir in $proto_dirs; do
protoc \
buf protoc \
-I "proto" \
-I "third_party/proto" \
--gogofaster_out=\

View File

@@ -43,6 +43,11 @@ TOOLS_DESTDIR ?= $(GOPATH)/bin
CERTSTRAP = $(TOOLS_DESTDIR)/certstrap
PROTOBUF = $(TOOLS_DESTDIR)/protoc
GOODMAN = $(TOOLS_DESTDIR)/goodman
BUF_VERSION = "0.30.0"
BINARY_NAME = "buf"
BIN = "/usr/local/bin"
OS = $(shell uname -s)
ARCH = $(shell uname -m)
all: tools
.PHONY: all
@@ -71,6 +76,14 @@ $(PROTOBUF):
@go get github.com/gogo/protobuf/protoc-gen-gogofaster@v1.3.1
.PHONY: protobuf
buf:
@echo "Install Buf"
curl -sSL \
"https://github.com/bufbuild/buf/releases/download/v$(BUF_VERSION)/$(BINARY_NAME)-$(OS)-$(ARCH)" \
-o "${BIN}/${BINARY_NAME}" && \
chmod +x "${BIN}/${BINARY_NAME}"
.PHONY: buf
goodman: $(GOODMAN)
$(GOODMAN):
@echo "Get Goodman"
@@ -80,32 +93,5 @@ $(GOODMAN):
tools-clean:
rm -f $(CERTSTRAP) $(PROTOBUF) $(GOX) $(GOODMAN)
rm -f tools-stamp
rm -rf /usr/local/include/google/protobuf
rm -f /usr/local/bin/protoc
rm -f "${BIN}/${BINARY_NAME}"
.PHONY: tooks-clean
###
# Non Go tools
###
# Choose protobuf binary based on OS (only works for 64bit Linux and Mac).
# NOTE: On Mac, installation via brew (brew install protoc) might be favorable.
PROTOC_ZIP=""
ifneq ($(OS),Windows_NT)
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
PROTOC_ZIP="protoc-3.10.1-linux-x86_64.zip"
endif
ifeq ($(UNAME_S),Darwin)
PROTOC_ZIP="protoc-3.10.1-osx-x86_64.zip"
endif
endif
protoc:
@echo "Get Protobuf"
@echo "In case of any errors, please install directly from https://github.com/protocolbuffers/protobuf/releases"
@curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.10.1/$(PROTOC_ZIP)
@unzip -o $(PROTOC_ZIP) -d /usr/local bin/protoc
@unzip -o $(PROTOC_ZIP) -d /usr/local 'include/*'
@rm -f $(PROTOC_ZIP)
.PHONY: protoc