From a00de7199f5558cdd6245bbbcd1d8405ccfb8129 Mon Sep 17 00:00:00 2001 From: William Banfield <4561443+williambanfield@users.noreply.github.com> Date: Tue, 16 Nov 2021 14:34:42 -0500 Subject: [PATCH] update proto generation and testing pipelines (#358) 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 and several accompanying changes were made to streamline the proto generation process. --- .clang-format | 11 ++ .github/workflows/proto-check.yml | 24 ++++ .github/workflows/proto-dockerfile.yml | 60 ++++++++++ .gitignore | 1 + Makefile | 31 ++++++ buf.gen.yaml | 14 +++ buf.yaml | 16 +++ proto/Dockerfile | 25 +++++ proto/tendermint/blocksync/types.proto | 8 +- proto/tendermint/consensus/types.proto | 29 +++-- proto/tendermint/crypto/keys.proto | 2 - proto/tendermint/crypto/proof.proto | 2 - proto/tendermint/libs/bits/types.proto | 7 ++ proto/tendermint/mempool/types.proto | 2 - proto/tendermint/p2p/conn.proto | 2 - proto/tendermint/p2p/pex.proto | 8 +- proto/tendermint/p2p/types.proto | 10 +- proto/tendermint/statesync/types.proto | 5 +- proto/tendermint/types/block.proto | 2 - proto/tendermint/types/evidence.proto | 14 ++- proto/tendermint/types/params.proto | 6 +- proto/tendermint/types/types.proto | 70 +++++++----- proto/tendermint/types/validator.proto | 2 - proto/tendermint/version/types.proto | 8 +- third_party/proto/gogoproto/gogo.proto | 147 +++++++++++++++++++++++++ 25 files changed, 421 insertions(+), 85 deletions(-) create mode 100644 .clang-format create mode 100644 .github/workflows/proto-check.yml create mode 100644 .github/workflows/proto-dockerfile.yml create mode 100644 Makefile create mode 100644 buf.gen.yaml create mode 100644 buf.yaml create mode 100644 proto/Dockerfile create mode 100644 proto/tendermint/libs/bits/types.proto create mode 100644 third_party/proto/gogoproto/gogo.proto diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..dd819a18f --- /dev/null +++ b/.clang-format @@ -0,0 +1,11 @@ +--- +Language: Proto +BasedOnStyle: Google +IndentWidth: 2 +ColumnLimit: 0 +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true +SpacesInSquareBrackets: true +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true diff --git a/.github/workflows/proto-check.yml b/.github/workflows/proto-check.yml new file mode 100644 index 000000000..6f2751c86 --- /dev/null +++ b/.github/workflows/proto-check.yml @@ -0,0 +1,24 @@ +name: Proto Check +# Protobuf runs buf (https://buf.build/) lint and check-breakage +# This workflow is only run when a file in the proto directory +# has been modified. +on: + workflow_dispatch: # allow running workflow manually + pull_request: + paths: + - "proto/*" +jobs: + proto-lint: + runs-on: ubuntu-latest + timeout-minutes: 4 + steps: + - uses: actions/checkout@v2.4.0 + - name: lint + run: make proto-lint + proto-breakage: + runs-on: ubuntu-latest + timeout-minutes: 4 + steps: + - uses: actions/checkout@v2.4.0 + - name: check-breakage + run: make proto-check-breaking-ci diff --git a/.github/workflows/proto-dockerfile.yml b/.github/workflows/proto-dockerfile.yml new file mode 100644 index 000000000..50cbd37b1 --- /dev/null +++ b/.github/workflows/proto-dockerfile.yml @@ -0,0 +1,60 @@ +# This workflow (re)builds and pushes a Docker image containing the +# protobuf build tools used by the other workflows. +# +# When making changes that require updates to the builder image, you +# should merge the updates first and wait for this workflow to complete, +# so that the changes will be available for the dependent workflows. +# +# TODO(#7272): Update the target location of the builder image. + +name: Build & Push TM Proto Builder +on: + pull_request: + paths: + - "proto/*" + push: + branches: + - master + paths: + - "proto/*" + schedule: + # run this job once a month to recieve any go or buf updates + - cron: "* * 1 * *" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.4.0 + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=tendermintdev/docker-build-proto + VERSION=noop + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + elif [[ $GITHUB_REF == refs/heads/* ]]; then + VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') + if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then + VERSION=latest + fi + fi + TAGS="${DOCKER_IMAGE}:${VERSION}" + echo ::set-output name=tags::${TAGS} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1.6.0 + + - name: Login to DockerHub + uses: docker/login-action@v1.10.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Publish to Docker Hub + uses: docker/build-push-action@v2.7.0 + with: + context: ./proto + file: ./proto/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.prep.outputs.tags }} diff --git a/.gitignore b/.gitignore index 1270055c1..81d5093bf 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ *.gz *.dvi .idea +*.pb.go diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..040da6d14 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +DOCKER_PROTO_BUILDER := docker run -v $(shell pwd):/workspace --workdir /workspace tendermintdev/docker-build-proto +HTTPS_GIT := https://github.com/tendermint/spec.git + +############################################################################### +### Protobuf ### +############################################################################### + +proto-all: proto-lint proto-check-breaking +.PHONY: proto-all + +proto-gen: + @echo "Generating Protobuf files" + @$(DOCKER_PROTO_BUILDER) buf generate --template=./buf.gen.yaml --config ./buf.yaml +.PHONY: proto-gen + +proto-lint: + @$(DOCKER_PROTO_BUILDER) buf lint --error-format=json --config ./buf.yaml +.PHONY: proto-lint + +proto-format: + @echo "Formatting Protobuf files" + @$(DOCKER_PROTO_BUILDER) find . -name '*.proto' -path "./proto/*" -exec clang-format -i {} \; +.PHONY: proto-format + +proto-check-breaking: + @$(DOCKER_PROTO_BUILDER) buf breaking --against .git --config ./buf.yaml +.PHONY: proto-check-breaking + +proto-check-breaking-ci: + @$(DOCKER_PROTO_BUILDER) buf breaking --against $(HTTPS_GIT) --config ./buf.yaml +.PHONY: proto-check-breaking-ci diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 000000000..335e25241 --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,14 @@ +# The version of the generation template (required). +# The only currently-valid value is v1beta1. +version: v1beta1 + +# The plugins to run. +plugins: + # The name of the plugin. + - name: gogofaster + # The directory where the generated proto output will be written. + # The directory is relative to where the generation tool was run. + out: proto + # Set options to assign import paths to the well-known types + # and to enable service generation. + opt: Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration,plugins=grpc,paths=source_relative diff --git a/buf.yaml b/buf.yaml new file mode 100644 index 000000000..cc4aced57 --- /dev/null +++ b/buf.yaml @@ -0,0 +1,16 @@ +version: v1beta1 + +build: + roots: + - proto + - third_party/proto +lint: + use: + - BASIC + - FILE_LOWER_SNAKE_CASE + - UNARY_RPC + ignore: + - gogoproto +breaking: + use: + - FILE diff --git a/proto/Dockerfile b/proto/Dockerfile new file mode 100644 index 000000000..a3582d494 --- /dev/null +++ b/proto/Dockerfile @@ -0,0 +1,25 @@ +# This Dockerfile defines an image containing tools for linting, formatting, +# and compiling the Tendermint protos. + +FROM bufbuild/buf:latest as buf + +FROM golang:1.17-alpine + +# Install a commonly used set of programs for use with our protos. +# clang-extra-tools is included here because it provides clang-format, +# used to format the .proto files. +RUN apk add --update --no-cache build-base clang-extra-tools curl git && \ + apk add --update --no-cache build-base clang-extra-tools curl git go && \ + rm -rf /var/cache/apk/* + +ENV GOLANG_PROTOBUF_VERSION=1.3.1 \ + GOGO_PROTOBUF_VERSION=1.3.2 + +# Retrieve the go protoc programs and copy them into the PATH +RUN go install github.com/golang/protobuf/protoc-gen-go@v${GOLANG_PROTOBUF_VERSION} && \ + go install github.com/gogo/protobuf/protoc-gen-gogo@v${GOGO_PROTOBUF_VERSION} && \ + go install github.com/gogo/protobuf/protoc-gen-gogofaster@v${GOGO_PROTOBUF_VERSION} && \ + mv "$(go env GOPATH)"/bin/* /usr/local/bin/ + +# Copy the 'buf' program out of the buildbuf/buf container. +COPY --from=buf /usr/local/bin/* /usr/local/bin/ diff --git a/proto/tendermint/blocksync/types.proto b/proto/tendermint/blocksync/types.proto index 8c187c793..999a6db7f 100644 --- a/proto/tendermint/blocksync/types.proto +++ b/proto/tendermint/blocksync/types.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package tendermint.blocksync; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/blocksync"; - import "tendermint/types/block.proto"; // BlockRequest requests a block for a specific height @@ -10,7 +8,8 @@ message BlockRequest { int64 height = 1; } -// NoBlockResponse informs the node that the peer does not have block at the requested height +// NoBlockResponse informs the node that the peer does not have block at the +// requested height message NoBlockResponse { int64 height = 1; } @@ -21,8 +20,7 @@ message BlockResponse { } // StatusRequest requests the status of a peer. -message StatusRequest { -} +message StatusRequest {} // StatusResponse is a peer response to inform their status. message StatusResponse { diff --git a/proto/tendermint/consensus/types.proto b/proto/tendermint/consensus/types.proto index 6e1f41371..fd0e427d0 100644 --- a/proto/tendermint/consensus/types.proto +++ b/proto/tendermint/consensus/types.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package tendermint.consensus; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/consensus"; - import "gogoproto/gogo.proto"; import "tendermint/types/types.proto"; import "tendermint/libs/bits/types.proto"; @@ -17,15 +15,18 @@ message NewRoundStep { int32 last_commit_round = 5; } -// NewValidBlock is sent when a validator observes a valid block B in some round r, -//i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r. +// NewValidBlock is sent when a validator observes a valid block B in some round +// r, +// i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in +// the round r. // In case the block is also committed, then IsCommit flag is set to true. message NewValidBlock { int64 height = 1; int32 round = 2; - tendermint.types.PartSetHeader block_part_set_header = 3 [(gogoproto.nullable) = false]; - tendermint.libs.bits.BitArray block_parts = 4; - bool is_commit = 5; + tendermint.types.PartSetHeader block_part_set_header = 3 + [(gogoproto.nullable) = false]; + tendermint.libs.bits.BitArray block_parts = 4; + bool is_commit = 5; } // Proposal is sent when a new block is proposed. @@ -37,7 +38,8 @@ message Proposal { message ProposalPOL { int64 height = 1; int32 proposal_pol_round = 2; - tendermint.libs.bits.BitArray proposal_pol = 3 [(gogoproto.nullable) = false]; + tendermint.libs.bits.BitArray proposal_pol = 3 + [(gogoproto.nullable) = false]; } // BlockPart is sent when gossipping a piece of the proposed block. @@ -65,16 +67,19 @@ message VoteSetMaj23 { int64 height = 1; int32 round = 2; tendermint.types.SignedMsgType type = 3; - tendermint.types.BlockID block_id = 4 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; + tendermint.types.BlockID block_id = 4 + [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; } -// VoteSetBits is sent to communicate the bit-array of votes seen for the BlockID. +// VoteSetBits is sent to communicate the bit-array of votes seen for the +// BlockID. message VoteSetBits { int64 height = 1; int32 round = 2; tendermint.types.SignedMsgType type = 3; - tendermint.types.BlockID block_id = 4 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; - tendermint.libs.bits.BitArray votes = 5 [(gogoproto.nullable) = false]; + tendermint.types.BlockID block_id = 4 + [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; + tendermint.libs.bits.BitArray votes = 5 [(gogoproto.nullable) = false]; } message Message { diff --git a/proto/tendermint/crypto/keys.proto b/proto/tendermint/crypto/keys.proto index d66f9fc0c..faaaed6fc 100644 --- a/proto/tendermint/crypto/keys.proto +++ b/proto/tendermint/crypto/keys.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package tendermint.crypto; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto"; - import "gogoproto/gogo.proto"; // PublicKey defines the keys available for use with Tendermint Validators diff --git a/proto/tendermint/crypto/proof.proto b/proto/tendermint/crypto/proof.proto index 975df7685..bde5a4ff9 100644 --- a/proto/tendermint/crypto/proof.proto +++ b/proto/tendermint/crypto/proof.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package tendermint.crypto; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto"; - import "gogoproto/gogo.proto"; message Proof { diff --git a/proto/tendermint/libs/bits/types.proto b/proto/tendermint/libs/bits/types.proto new file mode 100644 index 000000000..1ea81d33f --- /dev/null +++ b/proto/tendermint/libs/bits/types.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; +package tendermint.libs.bits; + +message BitArray { + int64 bits = 1; + repeated uint64 elems = 2; +} diff --git a/proto/tendermint/mempool/types.proto b/proto/tendermint/mempool/types.proto index b55d9717b..7fa53ef79 100644 --- a/proto/tendermint/mempool/types.proto +++ b/proto/tendermint/mempool/types.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package tendermint.mempool; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/mempool"; - message Txs { repeated bytes txs = 1; } diff --git a/proto/tendermint/p2p/conn.proto b/proto/tendermint/p2p/conn.proto index b12de6c82..62abd4f5f 100644 --- a/proto/tendermint/p2p/conn.proto +++ b/proto/tendermint/p2p/conn.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package tendermint.p2p; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p"; - import "gogoproto/gogo.proto"; import "tendermint/crypto/keys.proto"; diff --git a/proto/tendermint/p2p/pex.proto b/proto/tendermint/p2p/pex.proto index 8a73ca30a..374047b0f 100644 --- a/proto/tendermint/p2p/pex.proto +++ b/proto/tendermint/p2p/pex.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package tendermint.p2p; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p"; - import "gogoproto/gogo.proto"; message PexAddress { @@ -18,9 +16,9 @@ message PexResponse { } message PexMessage { - reserved 1, 2; // See https://github.com/tendermint/spec/pull/352 + reserved 1, 2; // See https://github.com/tendermint/spec/pull/352 oneof sum { - PexRequest pex_request = 3; - PexResponse pex_response = 4; + PexRequest pex_request = 3; + PexResponse pex_response = 4; } } diff --git a/proto/tendermint/p2p/types.proto b/proto/tendermint/p2p/types.proto index 216a6d8d0..e4e86434a 100644 --- a/proto/tendermint/p2p/types.proto +++ b/proto/tendermint/p2p/types.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package tendermint.p2p; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p"; - import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; @@ -36,7 +34,9 @@ message PeerInfo { message PeerAddressInfo { string address = 1; - google.protobuf.Timestamp last_dial_success = 2 [(gogoproto.stdtime) = true]; - google.protobuf.Timestamp last_dial_failure = 3 [(gogoproto.stdtime) = true]; - uint32 dial_failures = 4; + google.protobuf.Timestamp last_dial_success = 2 + [(gogoproto.stdtime) = true]; + google.protobuf.Timestamp last_dial_failure = 3 + [(gogoproto.stdtime) = true]; + uint32 dial_failures = 4; } diff --git a/proto/tendermint/statesync/types.proto b/proto/tendermint/statesync/types.proto index ac21b5d7b..12f7a1d23 100644 --- a/proto/tendermint/statesync/types.proto +++ b/proto/tendermint/statesync/types.proto @@ -5,8 +5,6 @@ import "gogoproto/gogo.proto"; import "tendermint/types/types.proto"; import "tendermint/types/params.proto"; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/statesync"; - message Message { oneof sum { SnapshotsRequest snapshots_request = 1; @@ -58,5 +56,6 @@ message ParamsRequest { message ParamsResponse { uint64 height = 1; - tendermint.types.ConsensusParams consensus_params = 2 [(gogoproto.nullable) = false]; + tendermint.types.ConsensusParams consensus_params = 2 + [(gogoproto.nullable) = false]; } diff --git a/proto/tendermint/types/block.proto b/proto/tendermint/types/block.proto index 84e9bb15d..8a713b7dc 100644 --- a/proto/tendermint/types/block.proto +++ b/proto/tendermint/types/block.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package tendermint.types; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; - import "gogoproto/gogo.proto"; import "tendermint/types/types.proto"; import "tendermint/types/evidence.proto"; diff --git a/proto/tendermint/types/evidence.proto b/proto/tendermint/types/evidence.proto index 451b8dca3..d42c84363 100644 --- a/proto/tendermint/types/evidence.proto +++ b/proto/tendermint/types/evidence.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package tendermint.types; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; - import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; import "tendermint/types/types.proto"; @@ -15,22 +13,26 @@ message Evidence { } } -// DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes. +// 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]; + 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. +// 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; repeated tendermint.types.Validator byzantine_validators = 3; int64 total_voting_power = 4; - google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + google.protobuf.Timestamp timestamp = 5 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; } message EvidenceList { diff --git a/proto/tendermint/types/params.proto b/proto/tendermint/types/params.proto index cc926b64e..b8a37a23e 100644 --- a/proto/tendermint/types/params.proto +++ b/proto/tendermint/types/params.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package tendermint.types; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; - import "gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; @@ -43,8 +41,8 @@ message EvidenceParams { google.protobuf.Duration max_age_duration = 2 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; - // This sets the maximum size of total evidence in bytes that can be committed in a single block. - // and should fall comfortably under the max block bytes. + // This sets the maximum size of total evidence in bytes that can be committed + // in a single block. and should fall comfortably under the max block bytes. // Default is 1048576 or 1MB int64 max_bytes = 3; } diff --git a/proto/tendermint/types/types.proto b/proto/tendermint/types/types.proto index 8d4f00972..d9e6973e9 100644 --- a/proto/tendermint/types/types.proto +++ b/proto/tendermint/types/types.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package tendermint.types; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; - import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; import "tendermint/crypto/proof.proto"; @@ -14,10 +12,13 @@ enum BlockIDFlag { option (gogoproto.goproto_enum_stringer) = true; option (gogoproto.goproto_enum_prefix) = false; - BLOCK_ID_FLAG_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "BlockIDFlagUnknown"]; - BLOCK_ID_FLAG_ABSENT = 1 [(gogoproto.enumvalue_customname) = "BlockIDFlagAbsent"]; - BLOCK_ID_FLAG_COMMIT = 2 [(gogoproto.enumvalue_customname) = "BlockIDFlagCommit"]; - BLOCK_ID_FLAG_NIL = 3 [(gogoproto.enumvalue_customname) = "BlockIDFlagNil"]; + BLOCK_ID_FLAG_UNKNOWN = 0 + [(gogoproto.enumvalue_customname) = "BlockIDFlagUnknown"]; + BLOCK_ID_FLAG_ABSENT = 1 + [(gogoproto.enumvalue_customname) = "BlockIDFlagAbsent"]; + BLOCK_ID_FLAG_COMMIT = 2 + [(gogoproto.enumvalue_customname) = "BlockIDFlagCommit"]; + BLOCK_ID_FLAG_NIL = 3 [(gogoproto.enumvalue_customname) = "BlockIDFlagNil"]; } // SignedMsgType is a type of signed message in the consensus. @@ -25,13 +26,17 @@ enum SignedMsgType { option (gogoproto.goproto_enum_stringer) = true; option (gogoproto.goproto_enum_prefix) = false; - SIGNED_MSG_TYPE_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "UnknownType"]; + SIGNED_MSG_TYPE_UNKNOWN = 0 + [(gogoproto.enumvalue_customname) = "UnknownType"]; // Votes - SIGNED_MSG_TYPE_PREVOTE = 1 [(gogoproto.enumvalue_customname) = "PrevoteType"]; - SIGNED_MSG_TYPE_PRECOMMIT = 2 [(gogoproto.enumvalue_customname) = "PrecommitType"]; + SIGNED_MSG_TYPE_PREVOTE = 1 + [(gogoproto.enumvalue_customname) = "PrevoteType"]; + SIGNED_MSG_TYPE_PRECOMMIT = 2 + [(gogoproto.enumvalue_customname) = "PrecommitType"]; // Proposals - SIGNED_MSG_TYPE_PROPOSAL = 32 [(gogoproto.enumvalue_customname) = "ProposalType"]; + SIGNED_MSG_TYPE_PROPOSAL = 32 + [(gogoproto.enumvalue_customname) = "ProposalType"]; } // PartsetHeader @@ -60,7 +65,8 @@ message Header { tendermint.version.Consensus version = 1 [(gogoproto.nullable) = false]; string chain_id = 2 [(gogoproto.customname) = "ChainID"]; int64 height = 3; - google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + google.protobuf.Timestamp time = 4 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; // prev block info BlockID last_block_id = 5 [(gogoproto.nullable) = false]; @@ -74,7 +80,8 @@ message Header { bytes next_validators_hash = 9; // validators for the next block bytes consensus_hash = 10; // consensus params for current block bytes app_hash = 11; // state after txs from the previous block - bytes last_results_hash = 12; // root hash of all results from the txs from the previous block + bytes last_results_hash = + 12; // root hash of all results from the txs from the previous block // consensus info bytes evidence_hash = 13; // evidence included in the block @@ -95,8 +102,10 @@ message Vote { SignedMsgType type = 1; int64 height = 2; int32 round = 3; - BlockID block_id = 4 - [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"]; // zero if vote is nil. + BlockID block_id = 4 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "BlockID" + ]; // zero if vote is nil. google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; bytes validator_address = 6; @@ -104,11 +113,13 @@ message Vote { bytes signature = 8; } -// Commit contains the evidence that a block was committed by a set of validators. +// 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"]; + int64 height = 1; + int32 round = 2; + BlockID block_id = 3 + [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"]; repeated CommitSig signatures = 4 [(gogoproto.nullable) = false]; } @@ -122,11 +133,12 @@ message CommitSig { } message Proposal { - SignedMsgType type = 1; - int64 height = 2; - int32 round = 3; - int32 pol_round = 4; - BlockID block_id = 5 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; + SignedMsgType type = 1; + int64 height = 2; + int32 round = 3; + int32 pol_round = 4; + BlockID block_id = 5 + [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; google.protobuf.Timestamp timestamp = 6 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; bytes signature = 7; @@ -143,13 +155,15 @@ message LightBlock { } message BlockMeta { - BlockID block_id = 1 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; - int64 block_size = 2; - Header header = 3 [(gogoproto.nullable) = false]; - int64 num_txs = 4; + BlockID block_id = 1 + [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; + int64 block_size = 2; + Header header = 3 [(gogoproto.nullable) = false]; + int64 num_txs = 4; } -// TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree. +// TxProof represents a Merkle proof of the presence of a transaction in the +// Merkle tree. message TxProof { bytes root_hash = 1; bytes data = 2; diff --git a/proto/tendermint/types/validator.proto b/proto/tendermint/types/validator.proto index 49860b96d..4ab5e4c32 100644 --- a/proto/tendermint/types/validator.proto +++ b/proto/tendermint/types/validator.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package tendermint.types; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; - import "gogoproto/gogo.proto"; import "tendermint/crypto/keys.proto"; diff --git a/proto/tendermint/version/types.proto b/proto/tendermint/version/types.proto index 3c4e4cc53..d7d4cc09f 100644 --- a/proto/tendermint/version/types.proto +++ b/proto/tendermint/version/types.proto @@ -1,13 +1,11 @@ syntax = "proto3"; package tendermint.version; -option go_package = "github.com/tendermint/tendermint/proto/tendermint/version"; - import "gogoproto/gogo.proto"; -// Consensus captures the consensus rules for processing a block in the blockchain, -// including all blockchain data structures and the rules of the application's -// state transition machine. +// Consensus captures the consensus rules for processing a block in the +// blockchain, including all blockchain data structures and the rules of the +// application's state transition machine. message Consensus { option (gogoproto.equal) = true; diff --git a/third_party/proto/gogoproto/gogo.proto b/third_party/proto/gogoproto/gogo.proto new file mode 100644 index 000000000..31c516cd0 --- /dev/null +++ b/third_party/proto/gogoproto/gogo.proto @@ -0,0 +1,147 @@ +// Protocol Buffers for Go with Gadgets +// +// Copied from https://github.com/gogo/protobuf/blob/master/gogoproto/gogo.proto +// +// Copyright (c) 2013, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto2"; +package gogoproto; + +import "google/protobuf/descriptor.proto"; + +option java_package = "com.google.protobuf"; +option java_outer_classname = "GoGoProtos"; +option go_package = "github.com/gogo/protobuf/gogoproto"; + +extend google.protobuf.EnumOptions { + optional bool goproto_enum_prefix = 62001; + optional bool goproto_enum_stringer = 62021; + optional bool enum_stringer = 62022; + optional string enum_customname = 62023; + optional bool enumdecl = 62024; +} + +extend google.protobuf.EnumValueOptions { + optional string enumvalue_customname = 66001; +} + +extend google.protobuf.FileOptions { + optional bool goproto_getters_all = 63001; + optional bool goproto_enum_prefix_all = 63002; + optional bool goproto_stringer_all = 63003; + optional bool verbose_equal_all = 63004; + optional bool face_all = 63005; + optional bool gostring_all = 63006; + optional bool populate_all = 63007; + optional bool stringer_all = 63008; + optional bool onlyone_all = 63009; + + optional bool equal_all = 63013; + optional bool description_all = 63014; + optional bool testgen_all = 63015; + optional bool benchgen_all = 63016; + optional bool marshaler_all = 63017; + optional bool unmarshaler_all = 63018; + optional bool stable_marshaler_all = 63019; + + optional bool sizer_all = 63020; + + optional bool goproto_enum_stringer_all = 63021; + optional bool enum_stringer_all = 63022; + + optional bool unsafe_marshaler_all = 63023; + optional bool unsafe_unmarshaler_all = 63024; + + optional bool goproto_extensions_map_all = 63025; + optional bool goproto_unrecognized_all = 63026; + optional bool gogoproto_import = 63027; + optional bool protosizer_all = 63028; + optional bool compare_all = 63029; + optional bool typedecl_all = 63030; + optional bool enumdecl_all = 63031; + + optional bool goproto_registration = 63032; + optional bool messagename_all = 63033; + + optional bool goproto_sizecache_all = 63034; + optional bool goproto_unkeyed_all = 63035; +} + +extend google.protobuf.MessageOptions { + optional bool goproto_getters = 64001; + optional bool goproto_stringer = 64003; + optional bool verbose_equal = 64004; + optional bool face = 64005; + optional bool gostring = 64006; + optional bool populate = 64007; + optional bool stringer = 67008; + optional bool onlyone = 64009; + + optional bool equal = 64013; + optional bool description = 64014; + optional bool testgen = 64015; + optional bool benchgen = 64016; + optional bool marshaler = 64017; + optional bool unmarshaler = 64018; + optional bool stable_marshaler = 64019; + + optional bool sizer = 64020; + + optional bool unsafe_marshaler = 64023; + optional bool unsafe_unmarshaler = 64024; + + optional bool goproto_extensions_map = 64025; + optional bool goproto_unrecognized = 64026; + + optional bool protosizer = 64028; + optional bool compare = 64029; + + optional bool typedecl = 64030; + + optional bool messagename = 64033; + + optional bool goproto_sizecache = 64034; + optional bool goproto_unkeyed = 64035; +} + +extend google.protobuf.FieldOptions { + optional bool nullable = 65001; + optional bool embed = 65002; + optional string customtype = 65003; + optional string customname = 65004; + optional string jsontag = 65005; + optional string moretags = 65006; + optional string casttype = 65007; + optional string castkey = 65008; + optional string castvalue = 65009; + + optional bool stdtime = 65010; + optional bool stdduration = 65011; + optional bool wktpointer = 65012; + + optional string castrepeated = 65013; +}