diff --git a/Makefile b/Makefile index 0fd996c67..5ab7f0544 100644 --- a/Makefile +++ b/Makefile @@ -92,6 +92,10 @@ proto-gen: @$(DOCKER_PROTO_BUILDER) buf generate --template=./buf.gen.yaml --config ./buf.yaml .PHONY: proto-gen +abci-proto-gen: + ./scripts/abci-gen.sh +.PHONY: proto-gen + proto-lint: @$(DOCKER_PROTO_BUILDER) buf lint --error-format=json --config ./buf.yaml .PHONY: proto-lint diff --git a/proto/tendermint/abci/types.proto b/proto/tendermint/abci/types.proto index 6ee25c658..7b5f8e120 100644 --- a/proto/tendermint/abci/types.proto +++ b/proto/tendermint/abci/types.proto @@ -21,25 +21,25 @@ import "gogoproto/gogo.proto"; message Request { oneof value { - RequestEcho echo = 1; - RequestFlush flush = 2; - RequestInfo info = 3; - RequestInitChain init_chain = 4; - RequestQuery query = 5; - RequestBeginBlock begin_block = 6 [deprecated = true]; - RequestCheckTx check_tx = 7; - RequestDeliverTx deliver_tx = 8 [deprecated = true]; - RequestEndBlock end_block = 9 [deprecated = true]; - RequestCommit commit = 10; - RequestListSnapshots list_snapshots = 11; - RequestOfferSnapshot offer_snapshot = 12; - RequestLoadSnapshotChunk load_snapshot_chunk = 13; - RequestApplySnapshotChunk apply_snapshot_chunk = 14; - RequestPrepareProposal prepare_proposal = 15; - RequestProcessProposal process_proposal = 16; + RequestEcho echo = 1; + RequestFlush flush = 2; + RequestInfo info = 3; + RequestInitChain init_chain = 4; + RequestQuery query = 5; + RequestBeginBlock begin_block = 6 [deprecated = true]; + RequestCheckTx check_tx = 7; + RequestDeliverTx deliver_tx = 8 [deprecated = true]; + RequestEndBlock end_block = 9 [deprecated = true]; + RequestCommit commit = 10; + RequestListSnapshots list_snapshots = 11; + RequestOfferSnapshot offer_snapshot = 12; + RequestLoadSnapshotChunk load_snapshot_chunk = 13; + RequestApplySnapshotChunk apply_snapshot_chunk = 14; + RequestPrepareProposal prepare_proposal = 15; + RequestProcessProposal process_proposal = 16; RequestExtendVote extend_vote = 17; RequestVerifyVoteExtension verify_vote_extension = 18; - RequestFinalizeBlock finalize_block = 19; + RequestFinalizeBlock finalize_block = 19; } } @@ -122,18 +122,29 @@ message RequestApplySnapshotChunk { string sender = 3; } -message RequestPrepareProposal { - bytes hash = 1; - tendermint.types.Header header = 2 [(gogoproto.nullable) = false]; - // txs is an array of transactions that will be included in a block, - // sent to the app for possible modifications. - repeated bytes txs = 3; - ExtendedCommitInfo local_last_commit = 4 [(gogoproto.nullable) = false]; - repeated Evidence byzantine_validators = 5 [(gogoproto.nullable) = false]; - // the modified transactions cannot exceed this size. - int64 max_tx_bytes = 6; +// Extends a vote with application-side injection +message RequestExtendVote { + types.Vote vote = 1; } +// Verify the vote extension +message RequestVerifyVoteExtension { + types.Vote vote = 1; +} + +message RequestPrepareProposal { + // block_data is an array of transactions that will be included in a block, + // sent to the app for possible modifications. + // applications can not exceed the size of the data passed to it. + repeated bytes block_data = 1; + // If an application decides to populate block_data with extra information, they can not exceed this value. + int64 block_data_size = 2; + // votes includes all votes from the previous block. This contains vote extension data that can be used in proposal + // preparation. The votes here will then form the last commit that gets sent in the proposed block. + repeated tendermint.types.Vote votes = 3; +} + + message RequestProcessProposal { bytes hash = 1; tendermint.types.Header header = 2 [(gogoproto.nullable) = false]; @@ -142,20 +153,6 @@ message RequestProcessProposal { repeated Evidence byzantine_validators = 5 [(gogoproto.nullable) = false]; } -// Extends a vote with application-side injection -message RequestExtendVote { - bytes hash = 1; - int64 height = 2; -} - -// Verify the vote extension -message RequestVerifyVoteExtension { - bytes hash = 1; - bytes validator_address = 2; - int64 height = 3; - bytes vote_extension = 4; -} - message RequestFinalizeBlock { bytes hash = 1; tendermint.types.Header header = 2 [(gogoproto.nullable) = false]; @@ -169,26 +166,26 @@ message RequestFinalizeBlock { message Response { oneof value { - ResponseException exception = 1; - ResponseEcho echo = 2; - ResponseFlush flush = 3; - ResponseInfo info = 4; - ResponseInitChain init_chain = 5; - ResponseQuery query = 6; - ResponseBeginBlock begin_block = 7 [deprecated = true]; - ResponseCheckTx check_tx = 8; - ResponseDeliverTx deliver_tx = 9 [deprecated = true]; - ResponseEndBlock end_block = 10 [deprecated = true]; - ResponseCommit commit = 11; - ResponseListSnapshots list_snapshots = 12; - ResponseOfferSnapshot offer_snapshot = 13; - ResponseLoadSnapshotChunk load_snapshot_chunk = 14; - ResponseApplySnapshotChunk apply_snapshot_chunk = 15; - ResponsePrepareProposal prepare_proposal = 16; - ResponseProcessProposal process_proposal = 17; + ResponseException exception = 1; + ResponseEcho echo = 2; + ResponseFlush flush = 3; + ResponseInfo info = 4; + ResponseInitChain init_chain = 5; + ResponseQuery query = 6; + ResponseBeginBlock begin_block = 7 [deprecated = true]; + ResponseCheckTx check_tx = 8; + ResponseDeliverTx deliver_tx = 9 [deprecated = true]; + ResponseEndBlock end_block = 10 [deprecated = true]; + ResponseCommit commit = 11; + ResponseListSnapshots list_snapshots = 12; + ResponseOfferSnapshot offer_snapshot = 13; + ResponseLoadSnapshotChunk load_snapshot_chunk = 14; + ResponseApplySnapshotChunk apply_snapshot_chunk = 15; + ResponsePrepareProposal prepare_proposal = 16; + ResponseProcessProposal process_proposal = 17; ResponseExtendVote extend_vote = 18; ResponseVerifyVoteExtension verify_vote_extension = 19; - ResponseFinalizeBlock finalize_block = 20; + ResponseFinalizeBlock finalize_block = 20; } } @@ -315,14 +312,23 @@ message ResponseApplySnapshotChunk { } } +message ResponseExtendVote { + tendermint.types.VoteExtension vote_extension = 1; +} + +message ResponseVerifyVoteExtension { + Result result = 1; + + enum Result { + UNKNOWN = 0; // Unknown result, reject vote extension + ACCEPT = 1; // Vote extension verified, include the vote + SLASH = 2; // Vote extension verification aborted, continue but slash validator + REJECT = 3; // Vote extension invalidated + } +} + message ResponsePrepareProposal { - bool modified_tx = 1; - repeated TxRecord tx_records = 2; - bytes app_hash = 3; - repeated ExecTxResult tx_results = 4; - repeated ValidatorUpdate validator_updates = 5; - tendermint.types.ConsensusParams consensus_param_updates = 6; - repeated bytes app_signed_updates = 7; + repeated bytes block_data = 1; } message ResponseProcessProposal { @@ -333,19 +339,11 @@ message ResponseProcessProposal { tendermint.types.ConsensusParams consensus_param_updates = 5; } -message ResponseExtendVote { - bytes vote_extension = 1; -} - -message ResponseVerifyVoteExtension { - bool accept = 1; -} - message ResponseFinalizeBlock { repeated Event block_events = 1 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; repeated ExecTxResult tx_results = 2; - repeated ValidatorUpdate validator_updates = 3; + repeated ValidatorUpdate validator_updates = 3 [(gogoproto.nullable) = false]; tendermint.types.ConsensusParams consensus_param_updates = 4; bytes app_hash = 5; int64 retain_height = 6; @@ -401,20 +399,7 @@ message TxResult { int64 height = 1; uint32 index = 2; bytes tx = 3; - ResponseDeliverTx result = 4 [(gogoproto.nullable) = false]; -} - -message TxRecord { - TxAction action = 1; - bytes tx = 2; - - // TxAction contains App-provided information on what to do with a transaction that is part of a raw proposal - enum TxAction { - UNKNOWN = 0; // Unknown action - UNMODIFIED = 1; // The Application did not modify this transaction. - ADDED = 2; // The Application added this transaction. - REMOVED = 3; // The Application wants this transaction removed from the proposal and the mempool. - } + ExecTxResult result = 4 [(gogoproto.nullable) = false]; } //---------------------------------------- diff --git a/proto/tendermint/types/types.proto b/proto/tendermint/types/types.proto index d9e6973e9..459e3d222 100644 --- a/proto/tendermint/types/types.proto +++ b/proto/tendermint/types/types.proto @@ -1,6 +1,8 @@ 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"; @@ -111,6 +113,19 @@ message Vote { bytes validator_address = 6; int32 validator_index = 7; bytes signature = 8; + VoteExtension vote_extension = 9; +} + +// VoteExtension is app-defined additional information to the validator votes. +message VoteExtension { + bytes app_data_to_sign = 1; + bytes app_data_self_authenticating = 2; +} + +// VoteExtensionToSign is a subset of VoteExtension that is signed by the validators private key. +// VoteExtensionToSign is extracted from an existing VoteExtension. +message VoteExtensionToSign { + bytes app_data_to_sign = 1; } // Commit contains the evidence that a block was committed by a set of @@ -130,6 +145,7 @@ message CommitSig { google.protobuf.Timestamp timestamp = 3 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; bytes signature = 4; + VoteExtensionToSign vote_extension = 5; } message Proposal { diff --git a/scripts/abci-gen.sh b/scripts/abci-gen.sh new file mode 100755 index 000000000..de42e115f --- /dev/null +++ b/scripts/abci-gen.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -euo pipefail + +# By default, this script runs against the latest commit to the master branch +# in the Tendermint spec repository. To use this script with a different version +# of the spec repository, run it with the $VERS environment variable set to the +# desired branch name or commit hash from the spec repo. + + +MODNAME="$(go list -m)" +find ./proto/tendermint -name '*.proto' -not -path "./proto/tendermint/abci/types.proto" \ + -exec sh ./scripts/protopackage.sh {} "$MODNAME" ';' + +# For historical compatibility, the abci file needs to get a slightly different import name +# so that it can be moved into the ./abci/types directory. +sh ./scripts/protopackage.sh ./proto/tendermint/abci/types.proto $MODNAME "abci/types" + +make proto-gen + +mv ./proto/tendermint/abci/types.pb.go ./abci/types + +echo "proto files have been compiled" + +echo "removing copied files" + +find proto/tendermint/ -name '*.proto' -not -path "proto/tendermint/abci/types.proto" -not -path "proto/tendermint/types/types.proto" \ + | xargs -I {} git checkout {} + +find proto/tendermint/ -name '*.pb.go' -not -path "proto/tendermint/abci/types.pb.go" -not -path "proto/tendermint/types/types.pb.go" \ + | xargs -I {} git checkout {}