diff --git a/.github/workflows/check-generated.yml b/.github/workflows/check-generated.yml index 6399d97576..c86e94d284 100644 --- a/.github/workflows/check-generated.yml +++ b/.github/workflows/check-generated.yml @@ -75,7 +75,15 @@ jobs: export GOBIN="${tools}/bin" go install github.com/bufbuild/buf/cmd/buf - go install github.com/cosmos/gogoproto/protoc-gen-gogofaster@latest + # Forked version of gogoproto plugin with fix https://github.com/cosmos/gogoproto/pull/150 + # go install github.com/cosmos/gogoproto/protoc-gen-gogofaster@latest + git clone --depth 1 --branch fix/panic-marshalto-nil-m \ + https://github.com/lklimek/gogoproto /tmp/gogoproto + pushd /tmp/gogoproto + go install ./protoc-gen-gogofaster + popd + rm -rf /tmp/gogoproto + # End of forked version installation make proto-gen diff --git a/Makefile b/Makefile index 10c3ab29e6..53e36ee2bf 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,9 @@ BUILD_IMAGE := ghcr.io/tendermint/docker-build-proto BASE_BRANCH ?= v0.8-dev DOCKER_PROTO := docker run -v $(shell pwd):/workspace --workdir /workspace $(BUILD_IMAGE) CGO_ENABLED ?= 1 -GOGOPROTO_PATH = $(shell go list -m -f '{{.Dir}}' github.com/cosmos/gogoproto) +# Fix for a gogoproto bug +# GOGOPROTO_PATH = $(shell go list -m -f '{{.Dir}}' github.com/cosmos/gogoproto) +GOGOPROTO_PATH = $(shell go list -m -f '{{.Dir}}' github.com/lklimek/gogoproto@564fd924f58c5d076b0ad8e3f1c6fb54d065cbbe) MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) CURR_DIR := $(dir $(MAKEFILE_PATH)) @@ -114,7 +116,8 @@ proto: proto-format proto-lint proto-doc proto-gen check-proto-deps: ifeq (,$(shell which protoc-gen-gogofaster)) - $(error "gogofaster plugin for protoc is required. Run 'go install github.com/cosmos/gogoproto/protoc-gen-gogofaster@latest' to install") +# $(error "gogofaster plugin for protoc is required. Run 'go install github.com/cosmos/gogoproto/protoc-gen-gogofaster@latest' to install") + $(error "gogofaster plugin for protoc is required. Run 'go install github.com/lklimek/gogoproto/protoc-gen-gogofaster@564fd924f58c5d076b0ad8e3f1c6fb54d065cbbe' to install") endif .PHONY: check-proto-deps diff --git a/abci/types/types.pb.go b/abci/types/types.pb.go index 178d8b1c57..31e385c2be 100644 --- a/abci/types/types.pb.go +++ b/abci/types/types.pb.go @@ -5211,6 +5211,9 @@ func (m *Request) MarshalTo(dAtA []byte) (int, error) { } func (m *Request) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -5233,6 +5236,9 @@ func (m *Request_Echo) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_Echo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Echo != nil { { @@ -5254,6 +5260,9 @@ func (m *Request_Flush) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_Flush) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Flush != nil { { @@ -5275,6 +5284,9 @@ func (m *Request_Info) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_Info) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Info != nil { { @@ -5296,6 +5308,9 @@ func (m *Request_InitChain) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_InitChain) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.InitChain != nil { { @@ -5317,6 +5332,9 @@ func (m *Request_Query) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_Query) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Query != nil { { @@ -5338,6 +5356,9 @@ func (m *Request_CheckTx) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_CheckTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.CheckTx != nil { { @@ -5359,6 +5380,9 @@ func (m *Request_ListSnapshots) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_ListSnapshots) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ListSnapshots != nil { { @@ -5380,6 +5404,9 @@ func (m *Request_OfferSnapshot) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_OfferSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.OfferSnapshot != nil { { @@ -5401,6 +5428,9 @@ func (m *Request_LoadSnapshotChunk) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_LoadSnapshotChunk) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.LoadSnapshotChunk != nil { { @@ -5422,6 +5452,9 @@ func (m *Request_ApplySnapshotChunk) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_ApplySnapshotChunk) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ApplySnapshotChunk != nil { { @@ -5443,6 +5476,9 @@ func (m *Request_PrepareProposal) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_PrepareProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.PrepareProposal != nil { { @@ -5464,6 +5500,9 @@ func (m *Request_ProcessProposal) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_ProcessProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ProcessProposal != nil { { @@ -5487,6 +5526,9 @@ func (m *Request_ExtendVote) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_ExtendVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ExtendVote != nil { { @@ -5510,6 +5552,9 @@ func (m *Request_VerifyVoteExtension) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_VerifyVoteExtension) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.VerifyVoteExtension != nil { { @@ -5533,6 +5578,9 @@ func (m *Request_FinalizeBlock) MarshalTo(dAtA []byte) (int, error) { } func (m *Request_FinalizeBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.FinalizeBlock != nil { { @@ -5566,6 +5614,9 @@ func (m *RequestEcho) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestEcho) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -5596,6 +5647,9 @@ func (m *RequestFlush) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestFlush) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -5619,6 +5673,9 @@ func (m *RequestInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -5666,6 +5723,9 @@ func (m *RequestInitChain) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestInitChain) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -5745,6 +5805,9 @@ func (m *RequestQuery) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -5797,6 +5860,9 @@ func (m *RequestCheckTx) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestCheckTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -5832,6 +5898,9 @@ func (m *RequestListSnapshots) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestListSnapshots) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -5855,6 +5924,9 @@ func (m *RequestOfferSnapshot) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestOfferSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -5897,6 +5969,9 @@ func (m *RequestLoadSnapshotChunk) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestLoadSnapshotChunk) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -5937,6 +6012,9 @@ func (m *RequestApplySnapshotChunk) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestApplySnapshotChunk) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -5981,6 +6059,9 @@ func (m *RequestPrepareProposal) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestPrepareProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -6103,6 +6184,9 @@ func (m *RequestProcessProposal) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestProcessProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -6239,6 +6323,9 @@ func (m *RequestExtendVote) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestExtendVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -6279,6 +6366,9 @@ func (m *RequestVerifyVoteExtension) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestVerifyVoteExtension) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -6340,6 +6430,9 @@ func (m *RequestFinalizeBlock) MarshalTo(dAtA []byte) (int, error) { } func (m *RequestFinalizeBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -6428,6 +6521,9 @@ func (m *Response) MarshalTo(dAtA []byte) (int, error) { } func (m *Response) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -6450,6 +6546,9 @@ func (m *Response_Exception) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_Exception) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Exception != nil { { @@ -6471,6 +6570,9 @@ func (m *Response_Echo) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_Echo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Echo != nil { { @@ -6492,6 +6594,9 @@ func (m *Response_Flush) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_Flush) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Flush != nil { { @@ -6513,6 +6618,9 @@ func (m *Response_Info) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_Info) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Info != nil { { @@ -6534,6 +6642,9 @@ func (m *Response_InitChain) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_InitChain) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.InitChain != nil { { @@ -6555,6 +6666,9 @@ func (m *Response_Query) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_Query) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Query != nil { { @@ -6576,6 +6690,9 @@ func (m *Response_CheckTx) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_CheckTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.CheckTx != nil { { @@ -6597,6 +6714,9 @@ func (m *Response_ListSnapshots) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_ListSnapshots) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ListSnapshots != nil { { @@ -6618,6 +6738,9 @@ func (m *Response_OfferSnapshot) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_OfferSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.OfferSnapshot != nil { { @@ -6639,6 +6762,9 @@ func (m *Response_LoadSnapshotChunk) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_LoadSnapshotChunk) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.LoadSnapshotChunk != nil { { @@ -6660,6 +6786,9 @@ func (m *Response_ApplySnapshotChunk) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_ApplySnapshotChunk) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ApplySnapshotChunk != nil { { @@ -6681,6 +6810,9 @@ func (m *Response_PrepareProposal) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_PrepareProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.PrepareProposal != nil { { @@ -6702,6 +6834,9 @@ func (m *Response_ProcessProposal) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_ProcessProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ProcessProposal != nil { { @@ -6723,6 +6858,9 @@ func (m *Response_ExtendVote) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_ExtendVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ExtendVote != nil { { @@ -6744,6 +6882,9 @@ func (m *Response_VerifyVoteExtension) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_VerifyVoteExtension) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.VerifyVoteExtension != nil { { @@ -6765,6 +6906,9 @@ func (m *Response_FinalizeBlock) MarshalTo(dAtA []byte) (int, error) { } func (m *Response_FinalizeBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.FinalizeBlock != nil { { @@ -6798,6 +6942,9 @@ func (m *ResponseException) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseException) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -6828,6 +6975,9 @@ func (m *ResponseEcho) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseEcho) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -6858,6 +7008,9 @@ func (m *ResponseFlush) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseFlush) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -6881,6 +7034,9 @@ func (m *ResponseInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -6935,6 +7091,9 @@ func (m *ResponseInitChain) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseInitChain) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7003,6 +7162,9 @@ func (m *ResponseInitChain_GenesisTime) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseInitChain_GenesisTime) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.GenesisTime != nil { n49, err49 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.GenesisTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.GenesisTime):]) @@ -7032,6 +7194,9 @@ func (m *ResponseQuery) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7117,6 +7282,9 @@ func (m *ResponseCheckTx) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseCheckTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7183,6 +7351,9 @@ func (m *ResponseListSnapshots) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseListSnapshots) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7220,6 +7391,9 @@ func (m *ResponseOfferSnapshot) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseOfferSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7248,6 +7422,9 @@ func (m *ResponseLoadSnapshotChunk) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseLoadSnapshotChunk) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7278,6 +7455,9 @@ func (m *ResponseApplySnapshotChunk) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseApplySnapshotChunk) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7333,6 +7513,9 @@ func (m *ResponsePrepareProposal) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponsePrepareProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7432,6 +7615,9 @@ func (m *ResponseProcessProposal) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseProcessProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7519,6 +7705,9 @@ func (m *ExtendVoteExtension) MarshalTo(dAtA []byte) (int, error) { } func (m *ExtendVoteExtension) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7553,6 +7742,9 @@ func (m *ExtendVoteExtension_SignRequestId) MarshalTo(dAtA []byte) (int, error) } func (m *ExtendVoteExtension_SignRequestId) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.SignRequestId != nil { i -= len(m.SignRequestId) @@ -7579,6 +7771,9 @@ func (m *ResponseExtendVote) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseExtendVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7616,6 +7811,9 @@ func (m *ResponseVerifyVoteExtension) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseVerifyVoteExtension) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7644,6 +7842,9 @@ func (m *ResponseFinalizeBlock) MarshalTo(dAtA []byte) (int, error) { } func (m *ResponseFinalizeBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7672,6 +7873,9 @@ func (m *CommitInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *CommitInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7728,6 +7932,9 @@ func (m *Event) MarshalTo(dAtA []byte) (int, error) { } func (m *Event) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7772,6 +7979,9 @@ func (m *EventAttribute) MarshalTo(dAtA []byte) (int, error) { } func (m *EventAttribute) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7819,6 +8029,9 @@ func (m *ExecTxResult) MarshalTo(dAtA []byte) (int, error) { } func (m *ExecTxResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7894,6 +8107,9 @@ func (m *TxResult) MarshalTo(dAtA []byte) (int, error) { } func (m *TxResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7944,6 +8160,9 @@ func (m *TxRecord) MarshalTo(dAtA []byte) (int, error) { } func (m *TxRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -7979,6 +8198,9 @@ func (m *Validator) MarshalTo(dAtA []byte) (int, error) { } func (m *Validator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -8014,6 +8236,9 @@ func (m *ValidatorUpdate) MarshalTo(dAtA []byte) (int, error) { } func (m *ValidatorUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -8068,6 +8293,9 @@ func (m *ValidatorSetUpdate) MarshalTo(dAtA []byte) (int, error) { } func (m *ValidatorSetUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -8122,6 +8350,9 @@ func (m *ThresholdPublicKeyUpdate) MarshalTo(dAtA []byte) (int, error) { } func (m *ThresholdPublicKeyUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -8155,6 +8386,9 @@ func (m *QuorumHashUpdate) MarshalTo(dAtA []byte) (int, error) { } func (m *QuorumHashUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -8185,6 +8419,9 @@ func (m *VoteInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *VoteInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -8228,6 +8465,9 @@ func (m *ExtendedVoteInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *ExtendedVoteInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -8278,6 +8518,9 @@ func (m *Misbehavior) MarshalTo(dAtA []byte) (int, error) { } func (m *Misbehavior) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -8334,6 +8577,9 @@ func (m *Snapshot) MarshalTo(dAtA []byte) (int, error) { } func (m *Snapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/internal/consensus/replay_test.go b/internal/consensus/replay_test.go index 4b9e9ef875..c075eee4e2 100644 --- a/internal/consensus/replay_test.go +++ b/internal/consensus/replay_test.go @@ -1282,6 +1282,7 @@ func TestHandshakeUpdatesValidators(t *testing.T) { btcjson.LLMQType_5_60, randQuorumHash, true, + nil, ) abciValidatorSetUpdates := types.TM2PB.ValidatorUpdates(vals) app := &initChainApp{vals: &abciValidatorSetUpdates} diff --git a/internal/consensus/replayer.go b/internal/consensus/replayer.go index d950de4b2c..d2a32c258c 100644 --- a/internal/consensus/replayer.go +++ b/internal/consensus/replayer.go @@ -342,9 +342,20 @@ func (r *BlockReplayer) execInitChain(ctx context.Context, rs *replayState, stat quorumType = r.genDoc.QuorumType } + var valParams *types.ValidatorParams + if res.ConsensusParams != nil && res.ConsensusParams.Validator != nil { + params := types.ValidatorParamsFromProto(res.ConsensusParams.Validator) + valParams = ¶ms + } else { + valParams = &r.genDoc.ConsensusParams.Validator + } + if len(res.ValidatorSetUpdate.ValidatorUpdates) != 0 { // we replace existing validator with the one from InitChain instead of applying it as a diff - state.Validators = types.NewValidatorSet(nil, nil, quorumType, nil, false) + state.Validators = types.NewValidatorSet(nil, nil, quorumType, nil, false, valParams) + // } else if valParams != nil && valParams.VotingPowerThreshold != nil { + // // we update the existing validator set with the new voting threshold + // state.Validators.VotingPowerThreshold = *valParams.VotingPowerThreshold } // we only update state when we are in initial state @@ -401,11 +412,18 @@ func validatorSetUpdateFromGenesis(genDoc *types.GenesisDoc) (*abci.ValidatorSet return nil, fmt.Errorf("blockReplayer blocks error when validating validator: %s", err) } } + + var validatorParams types.ValidatorParams + if genDoc.ConsensusParams != nil { + validatorParams = genDoc.ConsensusParams.Validator + } + validatorSet := types.NewValidatorSetCheckPublicKeys( validators, genDoc.ThresholdPublicKey, genDoc.QuorumType, genDoc.QuorumHash, + &validatorParams, ) err := validatorSet.ValidateBasic() if err != nil { diff --git a/internal/consensus/replayer_test.go b/internal/consensus/replayer_test.go index 14c952f41d..440c2719e4 100644 --- a/internal/consensus/replayer_test.go +++ b/internal/consensus/replayer_test.go @@ -198,6 +198,9 @@ func TestInitChainGenesisTime(t *testing.T) { QuorumHash: make([]byte, 32), GenesisTime: time.Date(1999, 1, 1, 0, 0, 0, 0, time.UTC), } + // We must synchronize genesis validator set voting threshold with the one from the validator set. + // In normal cicrumstances, the threshold is set in genesis or in ResponseInitChain. + genDoc.ConsensusParams.Validator.VotingPowerThreshold = &vset.VotingPowerThreshold err = genDoc.ValidateAndComplete() require.NoError(t, err) diff --git a/internal/consensus/versioned/selectproposer/height_proposer_test.go b/internal/consensus/versioned/selectproposer/height_proposer_test.go index 9e370078e4..248b651da2 100644 --- a/internal/consensus/versioned/selectproposer/height_proposer_test.go +++ b/internal/consensus/versioned/selectproposer/height_proposer_test.go @@ -28,7 +28,7 @@ func TestProposerSelection1(t *testing.T) { types.NewTestValidatorGeneratedFromProTxHash(fooProTxHash), types.NewTestValidatorGeneratedFromProTxHash(barProTxHash), types.NewTestValidatorGeneratedFromProTxHash(bazProTxHash), - }, bls12381.GenPrivKey().PubKey(), btcjson.LLMQType_5_60, crypto.RandQuorumHash(), true) + }, bls12381.GenPrivKey().PubKey(), btcjson.LLMQType_5_60, crypto.RandQuorumHash(), true, nil) var proposers []string vs, err := selectproposer.NewProposerSelector(types.ConsensusParams{}, vset, 0, 0, nil, log.NewTestingLogger(t)) diff --git a/internal/evidence/pool_test.go b/internal/evidence/pool_test.go index 34b7aed6df..92b08ade46 100644 --- a/internal/evidence/pool_test.go +++ b/internal/evidence/pool_test.go @@ -130,7 +130,7 @@ func TestAddExpiredEvidence(t *testing.T) { quorumHash = crypto.RandQuorumHash() privval = types.NewMockPVForQuorum(quorumHash) val = privval.ExtractIntoValidator(ctx, quorumHash) - valSet = types.NewValidatorSet([]*types.Validator{val}, val.PubKey, btcjson.LLMQType_5_60, quorumHash, true) + valSet = types.NewValidatorSet([]*types.Validator{val}, val.PubKey, btcjson.LLMQType_5_60, quorumHash, true, nil) height = int64(30) stateStore = initializeValidatorState(ctx, t, privval, height, btcjson.LLMQType_5_60, quorumHash) evidenceDB = dbm.NewMemDB() @@ -221,7 +221,7 @@ func TestReportConflictingVotes(t *testing.T) { state.LastBlockHeight++ state.LastBlockTime = ev.Time() state.LastValidators = types.NewValidatorSet([]*types.Validator{val}, val.PubKey, btcjson.LLMQType_5_60, - quorumHash, true) + quorumHash, true, nil) pool.Update(ctx, state, []types.Evidence{}) // should be able to retrieve evidence from pool diff --git a/internal/evidence/reactor_test.go b/internal/evidence/reactor_test.go index cec9c185ae..9446b8d55b 100644 --- a/internal/evidence/reactor_test.go +++ b/internal/evidence/reactor_test.go @@ -99,14 +99,14 @@ func setup(ctx context.Context, t *testing.T, stateStores []sm.Store) *reactorTe rts.network.Nodes[nodeID].PeerManager.Register(ctx, pu) rts.nodes = append(rts.nodes, rts.network.Nodes[nodeID]) - chCreator := func(ctx context.Context, chdesc *p2p.ChannelDescriptor) (p2p.Channel, error) { + chCreator := func(_ctx context.Context, _chDesc *p2p.ChannelDescriptor) (p2p.Channel, error) { return rts.evidenceChannels[nodeID], nil } rts.reactors[nodeID] = evidence.NewReactor( logger, chCreator, - func(ctx context.Context, _ string) *p2p.PeerUpdates { return pu }, + func(_ctx context.Context, _ string) *p2p.PeerUpdates { return pu }, rts.pools[nodeID]) require.NoError(t, rts.reactors[nodeID].Start(ctx)) @@ -550,6 +550,7 @@ func TestEvidenceListSerialization(t *testing.T) { btcjson.LLMQType_5_60, crypto.RandQuorumHash(), true, + nil, ) dupl, err := types.NewDuplicateVoteEvidence( diff --git a/internal/evidence/verify_test.go b/internal/evidence/verify_test.go index fde060ad30..df06a8f957 100644 --- a/internal/evidence/verify_test.go +++ b/internal/evidence/verify_test.go @@ -39,7 +39,7 @@ func TestVerifyDuplicateVoteEvidence(t *testing.T) { val := types.NewMockPVForQuorum(quorumHash) val2 := types.NewMockPVForQuorum(quorumHash) validator1 := val.ExtractIntoValidator(context.Background(), quorumHash) - valSet := types.NewValidatorSet([]*types.Validator{validator1}, validator1.PubKey, quorumType, quorumHash, true) + valSet := types.NewValidatorSet([]*types.Validator{validator1}, validator1.PubKey, quorumType, quorumHash, true, nil) stateID := types.RandStateID() blockID := makeBlockID([]byte("blockhash"), 1000, []byte("partshash"), stateID) blockID2 := makeBlockID([]byte("blockhash2"), 1000, []byte("partshash"), stateID) diff --git a/internal/state/current_round_state.go b/internal/state/current_round_state.go index a6848ccea5..6e328ebcc3 100644 --- a/internal/state/current_round_state.go +++ b/internal/state/current_round_state.go @@ -329,7 +329,7 @@ func valsetUpdate( } else { // if we don't have proTxHash, NewValidatorSetWithLocalNodeProTxHash behaves like NewValidatorSet nValSet = types.NewValidatorSetCheckPublicKeys(validatorUpdates, thresholdPubKey, - currentVals.QuorumType, quorumHash) + currentVals.QuorumType, quorumHash, ¶ms) } } else { // validators not changed, but we might have a new quorum hash or threshold public key @@ -340,7 +340,11 @@ func valsetUpdate( if thresholdPubKey != nil { nValSet.ThresholdPublicKey = thresholdPubKey } + + if params.VotingPowerThreshold != nil { + nValSet.VotingPowerThreshold = *params.VotingPowerThreshold + } } - return nValSet, nil + return nValSet, nValSet.ValidateBasic() } diff --git a/internal/state/state.go b/internal/state/state.go index 3b3605e393..b05b5730a6 100644 --- a/internal/state/state.go +++ b/internal/state/state.go @@ -382,8 +382,13 @@ func MakeGenesisState(genDoc *types.GenesisDoc) (State, error) { } var validatorSet *types.ValidatorSet + var valParams *types.ValidatorParams + if genDoc.ConsensusParams != nil { + valParams = &genDoc.ConsensusParams.Validator + } + if len(genDoc.Validators) == 0 { - validatorSet = types.NewValidatorSet(nil, nil, genDoc.QuorumType, nil, false) + validatorSet = types.NewValidatorSet(nil, nil, genDoc.QuorumType, nil, false, valParams) } else { validators := make([]*types.Validator, len(genDoc.Validators)) hasAllPublicKeys := true @@ -394,7 +399,7 @@ func MakeGenesisState(genDoc *types.GenesisDoc) (State, error) { } } validatorSet = types.NewValidatorSet( - validators, genDoc.ThresholdPublicKey, genDoc.QuorumType, genDoc.QuorumHash, hasAllPublicKeys, + validators, genDoc.ThresholdPublicKey, genDoc.QuorumType, genDoc.QuorumHash, hasAllPublicKeys, valParams, ) } diff --git a/internal/state/state_test.go b/internal/state/state_test.go index 6d297bec02..95cd2e0749 100644 --- a/internal/state/state_test.go +++ b/internal/state/state_test.go @@ -354,12 +354,14 @@ func TestEmptyValidatorUpdates(t *testing.T) { tearDown, _, state := setupTestCase(t) defer tearDown(t) + originalValidatorSet, _ := types.RandValidatorSet(2) + state.Validators = originalValidatorSet + firstNode := state.Validators.GetByIndex(0) require.NotZero(t, firstNode.ProTxHash) ctx := dash.ContextWithProTxHash(context.Background(), firstNode.ProTxHash) - newPrivKey := bls12381.GenPrivKeyFromSecret([]byte("test")) - newPubKey := newPrivKey.PubKey() + newPubKey := originalValidatorSet.ThresholdPublicKey newQuorumHash := crypto.RandQuorumHash() expectValidators := types.ValidatorListString(state.Validators.Validators) @@ -628,6 +630,7 @@ func TestConsensusParamsChangesSaveLoad(t *testing.T) { for i := 1; i < N+1; i++ { params[i] = *types.DefaultConsensusParams() params[i].Block.MaxBytes += int64(i) + params[i].Validator.PubKeyTypes = []string{"bls12381"} } cp := params[changeIndex] @@ -671,6 +674,7 @@ func TestConsensusParamsChangesSaveLoad(t *testing.T) { for _, testCase := range testCases { p, err := stateStore.LoadConsensusParams(testCase.height) + assert.EqualValues(t, []string{"bls12381"}, p.Validator.PubKeyTypes) assert.NoError(t, err, fmt.Sprintf("expected no err at height %d", testCase.height)) assert.EqualValues(t, testCase.params, p, fmt.Sprintf(`unexpected consensus params at height %d`, testCase.height)) diff --git a/internal/test/factory/validator_set.go b/internal/test/factory/validator_set.go index 45ccddcd63..de2d2e8f8a 100644 --- a/internal/test/factory/validator_set.go +++ b/internal/test/factory/validator_set.go @@ -44,5 +44,12 @@ func MockValidatorSet() (*types.ValidatorSet, []types.PrivValidator) { false, ) } - return types.NewValidatorSet(valz, thPubKey, btcjson.LLMQType_5_60, quorumHash, true), privVals + votingPowerThreshold := uint64(len(valz)) * uint64(types.DefaultDashVotingPower) + return types.NewValidatorSet(valz, + thPubKey, + btcjson.LLMQType_5_60, + quorumHash, + true, + &types.ValidatorParams{VotingPowerThreshold: &votingPowerThreshold}, + ), privVals } diff --git a/light/helpers_test.go b/light/helpers_test.go index 9ff02e0ca0..d9c0766fb3 100644 --- a/light/helpers_test.go +++ b/light/helpers_test.go @@ -51,6 +51,7 @@ func (pkz privKeys) ToValidators(thresholdPublicKey crypto.PubKey) *types.Valida btcjson.LLMQType_5_60, crypto.Checksum(thresholdPublicKey.Bytes()), true, + nil, ) } diff --git a/light/provider/http/http.go b/light/provider/http/http.go index 73451e6b44..2fdc7550b5 100644 --- a/light/provider/http/http.go +++ b/light/provider/http/http.go @@ -238,7 +238,7 @@ func (p *http) validatorSet(ctx context.Context, height *int64, proposer types.P break } } - valSet := types.NewValidatorSet(vals, thresholdPubKey, quorumType, quorumHash, false) + valSet := types.NewValidatorSet(vals, thresholdPubKey, quorumType, quorumHash, false, nil) if valSet == nil || valSet.IsNilOrEmpty() { return nil, provider.ErrBadLightBlock{Reason: fmt.Errorf("retrieved nil or empty validator set")} diff --git a/proto/tendermint/blocksync/types.pb.go b/proto/tendermint/blocksync/types.pb.go index ba8a002f3f..6e44307087 100644 --- a/proto/tendermint/blocksync/types.pb.go +++ b/proto/tendermint/blocksync/types.pb.go @@ -305,6 +305,9 @@ func (m *BlockRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *BlockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -333,6 +336,9 @@ func (m *NoBlockResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *NoBlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -361,6 +367,9 @@ func (m *BlockResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *BlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -408,6 +417,9 @@ func (m *StatusRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *StatusRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -431,6 +443,9 @@ func (m *StatusResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *StatusResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/consensus/types.pb.go b/proto/tendermint/consensus/types.pb.go index d8db55ed93..c1cfc32191 100644 --- a/proto/tendermint/consensus/types.pb.go +++ b/proto/tendermint/consensus/types.pb.go @@ -1007,6 +1007,9 @@ func (m *NewRoundStep) MarshalTo(dAtA []byte) (int, error) { } func (m *NewRoundStep) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1055,6 +1058,9 @@ func (m *NewValidBlock) MarshalTo(dAtA []byte) (int, error) { } func (m *NewValidBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1120,6 +1126,9 @@ func (m *Proposal) MarshalTo(dAtA []byte) (int, error) { } func (m *Proposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1153,6 +1162,9 @@ func (m *ProposalPOL) MarshalTo(dAtA []byte) (int, error) { } func (m *ProposalPOL) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1196,6 +1208,9 @@ func (m *BlockPart) MarshalTo(dAtA []byte) (int, error) { } func (m *BlockPart) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1239,6 +1254,9 @@ func (m *Vote) MarshalTo(dAtA []byte) (int, error) { } func (m *Vote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1274,6 +1292,9 @@ func (m *HasVote) MarshalTo(dAtA []byte) (int, error) { } func (m *HasVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1317,6 +1338,9 @@ func (m *Commit) MarshalTo(dAtA []byte) (int, error) { } func (m *Commit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1352,6 +1376,9 @@ func (m *HasCommit) MarshalTo(dAtA []byte) (int, error) { } func (m *HasCommit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1385,6 +1412,9 @@ func (m *VoteSetMaj23) MarshalTo(dAtA []byte) (int, error) { } func (m *VoteSetMaj23) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1433,6 +1463,9 @@ func (m *VoteSetBits) MarshalTo(dAtA []byte) (int, error) { } func (m *VoteSetBits) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1491,6 +1524,9 @@ func (m *Message) MarshalTo(dAtA []byte) (int, error) { } func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1513,6 +1549,9 @@ func (m *Message_NewRoundStep) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_NewRoundStep) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.NewRoundStep != nil { { @@ -1534,6 +1573,9 @@ func (m *Message_NewValidBlock) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_NewValidBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.NewValidBlock != nil { { @@ -1555,6 +1597,9 @@ func (m *Message_Proposal) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_Proposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Proposal != nil { { @@ -1576,6 +1621,9 @@ func (m *Message_ProposalPol) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_ProposalPol) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ProposalPol != nil { { @@ -1597,6 +1645,9 @@ func (m *Message_BlockPart) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_BlockPart) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.BlockPart != nil { { @@ -1618,6 +1669,9 @@ func (m *Message_Vote) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_Vote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Vote != nil { { @@ -1639,6 +1693,9 @@ func (m *Message_HasVote) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_HasVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.HasVote != nil { { @@ -1660,6 +1717,9 @@ func (m *Message_VoteSetMaj23) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_VoteSetMaj23) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.VoteSetMaj23 != nil { { @@ -1681,6 +1741,9 @@ func (m *Message_VoteSetBits) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_VoteSetBits) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.VoteSetBits != nil { { @@ -1702,6 +1765,9 @@ func (m *Message_Commit) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_Commit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Commit != nil { { @@ -1723,6 +1789,9 @@ func (m *Message_HasCommit) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_HasCommit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.HasCommit != nil { { diff --git a/proto/tendermint/consensus/wal.pb.go b/proto/tendermint/consensus/wal.pb.go index 52dac8deaf..eb86b9eae8 100644 --- a/proto/tendermint/consensus/wal.pb.go +++ b/proto/tendermint/consensus/wal.pb.go @@ -426,6 +426,9 @@ func (m *MsgInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *MsgInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -466,6 +469,9 @@ func (m *TimeoutInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *TimeoutInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -512,6 +518,9 @@ func (m *EndHeight) MarshalTo(dAtA []byte) (int, error) { } func (m *EndHeight) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -540,6 +549,9 @@ func (m *WALMessage) MarshalTo(dAtA []byte) (int, error) { } func (m *WALMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -562,6 +574,9 @@ func (m *WALMessage_EventDataRoundState) MarshalTo(dAtA []byte) (int, error) { } func (m *WALMessage_EventDataRoundState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.EventDataRoundState != nil { { @@ -583,6 +598,9 @@ func (m *WALMessage_MsgInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *WALMessage_MsgInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.MsgInfo != nil { { @@ -604,6 +622,9 @@ func (m *WALMessage_TimeoutInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *WALMessage_TimeoutInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.TimeoutInfo != nil { { @@ -625,6 +646,9 @@ func (m *WALMessage_EndHeight) MarshalTo(dAtA []byte) (int, error) { } func (m *WALMessage_EndHeight) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.EndHeight != nil { { @@ -656,6 +680,9 @@ func (m *TimedWALMessage) MarshalTo(dAtA []byte) (int, error) { } func (m *TimedWALMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/crypto/keys.pb.go b/proto/tendermint/crypto/keys.pb.go index 62b06df7ab..3341b70f99 100644 --- a/proto/tendermint/crypto/keys.pb.go +++ b/proto/tendermint/crypto/keys.pb.go @@ -425,6 +425,9 @@ func (m *PublicKey) MarshalTo(dAtA []byte) (int, error) { } func (m *PublicKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -447,6 +450,9 @@ func (m *PublicKey_Ed25519) MarshalTo(dAtA []byte) (int, error) { } func (m *PublicKey_Ed25519) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Ed25519 != nil { i -= len(m.Ed25519) @@ -463,6 +469,9 @@ func (m *PublicKey_Secp256K1) MarshalTo(dAtA []byte) (int, error) { } func (m *PublicKey_Secp256K1) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Secp256K1 != nil { i -= len(m.Secp256K1) @@ -479,6 +488,9 @@ func (m *PublicKey_Bls12381) MarshalTo(dAtA []byte) (int, error) { } func (m *PublicKey_Bls12381) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Bls12381 != nil { i -= len(m.Bls12381) diff --git a/proto/tendermint/crypto/proof.pb.go b/proto/tendermint/crypto/proof.pb.go index 1831de7236..0c8b39e5e5 100644 --- a/proto/tendermint/crypto/proof.pb.go +++ b/proto/tendermint/crypto/proof.pb.go @@ -366,6 +366,9 @@ func (m *Proof) MarshalTo(dAtA []byte) (int, error) { } func (m *Proof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -415,6 +418,9 @@ func (m *ValueOp) MarshalTo(dAtA []byte) (int, error) { } func (m *ValueOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -457,6 +463,9 @@ func (m *DominoOp) MarshalTo(dAtA []byte) (int, error) { } func (m *DominoOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -501,6 +510,9 @@ func (m *ProofOp) MarshalTo(dAtA []byte) (int, error) { } func (m *ProofOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -545,6 +557,9 @@ func (m *ProofOps) MarshalTo(dAtA []byte) (int, error) { } func (m *ProofOps) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/libs/bits/types.pb.go b/proto/tendermint/libs/bits/types.pb.go index 97445df26e..7803fdcd76 100644 --- a/proto/tendermint/libs/bits/types.pb.go +++ b/proto/tendermint/libs/bits/types.pb.go @@ -111,6 +111,9 @@ func (m *BitArray) MarshalTo(dAtA []byte) (int, error) { } func (m *BitArray) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/mempool/types.pb.go b/proto/tendermint/mempool/types.pb.go index b38e602520..e2bf10ded7 100644 --- a/proto/tendermint/mempool/types.pb.go +++ b/proto/tendermint/mempool/types.pb.go @@ -102,6 +102,9 @@ func (m *Txs) MarshalTo(dAtA []byte) (int, error) { } func (m *Txs) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/p2p/conn.pb.go b/proto/tendermint/p2p/conn.pb.go index 1b57bf3cc5..7500b78ef5 100644 --- a/proto/tendermint/p2p/conn.pb.go +++ b/proto/tendermint/p2p/conn.pb.go @@ -362,6 +362,9 @@ func (m *PacketPing) MarshalTo(dAtA []byte) (int, error) { } func (m *PacketPing) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -385,6 +388,9 @@ func (m *PacketPong) MarshalTo(dAtA []byte) (int, error) { } func (m *PacketPong) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -408,6 +414,9 @@ func (m *PacketMsg) MarshalTo(dAtA []byte) (int, error) { } func (m *PacketMsg) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -453,6 +462,9 @@ func (m *Packet) MarshalTo(dAtA []byte) (int, error) { } func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -475,6 +487,9 @@ func (m *Packet_PacketPing) MarshalTo(dAtA []byte) (int, error) { } func (m *Packet_PacketPing) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.PacketPing != nil { { @@ -496,6 +511,9 @@ func (m *Packet_PacketPong) MarshalTo(dAtA []byte) (int, error) { } func (m *Packet_PacketPong) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.PacketPong != nil { { @@ -517,6 +535,9 @@ func (m *Packet_PacketMsg) MarshalTo(dAtA []byte) (int, error) { } func (m *Packet_PacketMsg) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.PacketMsg != nil { { @@ -548,6 +569,9 @@ func (m *AuthSigMessage) MarshalTo(dAtA []byte) (int, error) { } func (m *AuthSigMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/p2p/pex.pb.go b/proto/tendermint/p2p/pex.pb.go index ff6f3fc496..e9dcc7573b 100644 --- a/proto/tendermint/p2p/pex.pb.go +++ b/proto/tendermint/p2p/pex.pb.go @@ -190,6 +190,9 @@ func (m *PexAddress) MarshalTo(dAtA []byte) (int, error) { } func (m *PexAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -220,6 +223,9 @@ func (m *PexRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *PexRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -243,6 +249,9 @@ func (m *PexResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *PexResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/p2p/types.pb.go b/proto/tendermint/p2p/types.pb.go index de977db334..782146c4d0 100644 --- a/proto/tendermint/p2p/types.pb.go +++ b/proto/tendermint/p2p/types.pb.go @@ -1008,6 +1008,9 @@ func (m *ProtocolVersion) MarshalTo(dAtA []byte) (int, error) { } func (m *ProtocolVersion) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1046,6 +1049,9 @@ func (m *NodeInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *NodeInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1149,6 +1155,9 @@ func (m *NodeInfoOther) MarshalTo(dAtA []byte) (int, error) { } func (m *NodeInfoOther) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1186,6 +1195,9 @@ func (m *PeerInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *PeerInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1257,6 +1269,9 @@ func (m *PeerAddressInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *PeerAddressInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1312,6 +1327,9 @@ func (m *Echo) MarshalTo(dAtA []byte) (int, error) { } func (m *Echo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1342,6 +1360,9 @@ func (m *Envelope) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1383,6 +1404,9 @@ func (m *Envelope_Echo) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_Echo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Echo != nil { { @@ -1404,6 +1428,9 @@ func (m *Envelope_PexRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_PexRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.PexRequest != nil { { @@ -1425,6 +1452,9 @@ func (m *Envelope_PexResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_PexResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.PexResponse != nil { { @@ -1446,6 +1476,9 @@ func (m *Envelope_Evidence) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_Evidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Evidence != nil { { @@ -1467,6 +1500,9 @@ func (m *Envelope_MempoolTxs) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_MempoolTxs) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.MempoolTxs != nil { { @@ -1488,6 +1524,9 @@ func (m *Envelope_BlockRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_BlockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.BlockRequest != nil { { @@ -1509,6 +1548,9 @@ func (m *Envelope_NoBlockResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_NoBlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.NoBlockResponse != nil { { @@ -1530,6 +1572,9 @@ func (m *Envelope_BlockResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_BlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.BlockResponse != nil { { @@ -1551,6 +1596,9 @@ func (m *Envelope_StatusRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_StatusRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.StatusRequest != nil { { @@ -1572,6 +1620,9 @@ func (m *Envelope_StatusResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_StatusResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.StatusResponse != nil { { @@ -1593,6 +1644,9 @@ func (m *Envelope_SnapshotsRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_SnapshotsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.SnapshotsRequest != nil { { @@ -1614,6 +1668,9 @@ func (m *Envelope_SnapshotsResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_SnapshotsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.SnapshotsResponse != nil { { @@ -1635,6 +1692,9 @@ func (m *Envelope_ChunkRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_ChunkRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ChunkRequest != nil { { @@ -1656,6 +1716,9 @@ func (m *Envelope_ChunkResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_ChunkResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ChunkResponse != nil { { @@ -1677,6 +1740,9 @@ func (m *Envelope_LightBlockRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_LightBlockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.LightBlockRequest != nil { { @@ -1700,6 +1766,9 @@ func (m *Envelope_LightBlockResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_LightBlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.LightBlockResponse != nil { { @@ -1723,6 +1792,9 @@ func (m *Envelope_ParamsRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_ParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ParamsRequest != nil { { @@ -1746,6 +1818,9 @@ func (m *Envelope_ParamsResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_ParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ParamsResponse != nil { { @@ -1769,6 +1844,9 @@ func (m *Envelope_NewRoundStep) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_NewRoundStep) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.NewRoundStep != nil { { @@ -1792,6 +1870,9 @@ func (m *Envelope_NewValidBlock) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_NewValidBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.NewValidBlock != nil { { @@ -1815,6 +1896,9 @@ func (m *Envelope_Proposal) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_Proposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Proposal != nil { { @@ -1838,6 +1922,9 @@ func (m *Envelope_ProposalPol) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_ProposalPol) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ProposalPol != nil { { @@ -1861,6 +1948,9 @@ func (m *Envelope_BlockPart) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_BlockPart) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.BlockPart != nil { { @@ -1884,6 +1974,9 @@ func (m *Envelope_Vote) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_Vote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Vote != nil { { @@ -1907,6 +2000,9 @@ func (m *Envelope_HasVote) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_HasVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.HasVote != nil { { @@ -1930,6 +2026,9 @@ func (m *Envelope_VoteSetMaj23) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_VoteSetMaj23) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.VoteSetMaj23 != nil { { @@ -1953,6 +2052,9 @@ func (m *Envelope_VoteSetBits) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_VoteSetBits) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.VoteSetBits != nil { { @@ -1976,6 +2078,9 @@ func (m *Envelope_Commit) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_Commit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.Commit != nil { { @@ -1999,6 +2104,9 @@ func (m *Envelope_HasCommit) MarshalTo(dAtA []byte) (int, error) { } func (m *Envelope_HasCommit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.HasCommit != nil { { diff --git a/proto/tendermint/privval/types.pb.go b/proto/tendermint/privval/types.pb.go index 4a2697fee1..6958b2e696 100644 --- a/proto/tendermint/privval/types.pb.go +++ b/proto/tendermint/privval/types.pb.go @@ -1114,6 +1114,9 @@ func (m *RemoteSignerError) MarshalTo(dAtA []byte) (int, error) { } func (m *RemoteSignerError) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1149,6 +1152,9 @@ func (m *PubKeyRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *PubKeyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1186,6 +1192,9 @@ func (m *ThresholdPubKeyRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *ThresholdPubKeyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1223,6 +1232,9 @@ func (m *ProTxHashRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *ProTxHashRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1253,6 +1265,9 @@ func (m *PubKeyResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *PubKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1298,6 +1313,9 @@ func (m *ThresholdPubKeyResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *ThresholdPubKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1343,6 +1361,9 @@ func (m *ProTxHashResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *ProTxHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1385,6 +1406,9 @@ func (m *SignVoteRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *SignVoteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1439,6 +1463,9 @@ func (m *SignedVoteResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *SignedVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1484,6 +1511,9 @@ func (m *SignProposalRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *SignProposalRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1538,6 +1568,9 @@ func (m *SignedProposalResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *SignedProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1583,6 +1616,9 @@ func (m *PingRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *PingRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1606,6 +1642,9 @@ func (m *PingResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *PingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1629,6 +1668,9 @@ func (m *Message) MarshalTo(dAtA []byte) (int, error) { } func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1651,6 +1693,9 @@ func (m *Message_PubKeyRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_PubKeyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.PubKeyRequest != nil { { @@ -1672,6 +1717,9 @@ func (m *Message_PubKeyResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_PubKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.PubKeyResponse != nil { { @@ -1693,6 +1741,9 @@ func (m *Message_SignVoteRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_SignVoteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.SignVoteRequest != nil { { @@ -1714,6 +1765,9 @@ func (m *Message_SignedVoteResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_SignedVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.SignedVoteResponse != nil { { @@ -1735,6 +1789,9 @@ func (m *Message_SignProposalRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_SignProposalRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.SignProposalRequest != nil { { @@ -1756,6 +1813,9 @@ func (m *Message_SignedProposalResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_SignedProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.SignedProposalResponse != nil { { @@ -1777,6 +1837,9 @@ func (m *Message_PingRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_PingRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.PingRequest != nil { { @@ -1798,6 +1861,9 @@ func (m *Message_PingResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_PingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.PingResponse != nil { { @@ -1819,6 +1885,9 @@ func (m *Message_ProTxHashRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_ProTxHashRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ProTxHashRequest != nil { { @@ -1840,6 +1909,9 @@ func (m *Message_ProTxHashResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_ProTxHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ProTxHashResponse != nil { { @@ -1861,6 +1933,9 @@ func (m *Message_ThresholdPubKeyRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_ThresholdPubKeyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ThresholdPubKeyRequest != nil { { @@ -1882,6 +1957,9 @@ func (m *Message_ThresholdPubKeyResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *Message_ThresholdPubKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.ThresholdPubKeyResponse != nil { { @@ -1913,6 +1991,9 @@ func (m *AuthSigMessage) MarshalTo(dAtA []byte) (int, error) { } func (m *AuthSigMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/state/types.pb.go b/proto/tendermint/state/types.pb.go index 792516f9c9..a62a666ba4 100644 --- a/proto/tendermint/state/types.pb.go +++ b/proto/tendermint/state/types.pb.go @@ -491,6 +491,9 @@ func (m *ABCIResponses) MarshalTo(dAtA []byte) (int, error) { } func (m *ABCIResponses) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -526,6 +529,9 @@ func (m *ValidatorsInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *ValidatorsInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -566,6 +572,9 @@ func (m *ConsensusParamsInfo) MarshalTo(dAtA []byte) (int, error) { } func (m *ConsensusParamsInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -604,6 +613,9 @@ func (m *Version) MarshalTo(dAtA []byte) (int, error) { } func (m *Version) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -644,6 +656,9 @@ func (m *State) MarshalTo(dAtA []byte) (int, error) { } func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/statesync/types.pb.go b/proto/tendermint/statesync/types.pb.go index 64ab0bb378..c844952e14 100644 --- a/proto/tendermint/statesync/types.pb.go +++ b/proto/tendermint/statesync/types.pb.go @@ -508,6 +508,9 @@ func (m *SnapshotsRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *SnapshotsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -531,6 +534,9 @@ func (m *SnapshotsResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *SnapshotsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -578,6 +584,9 @@ func (m *ChunkRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *ChunkRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -618,6 +627,9 @@ func (m *ChunkResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *ChunkResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -675,6 +687,9 @@ func (m *LightBlockRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *LightBlockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -703,6 +718,9 @@ func (m *LightBlockResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *LightBlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -738,6 +756,9 @@ func (m *ParamsRequest) MarshalTo(dAtA []byte) (int, error) { } func (m *ParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -766,6 +787,9 @@ func (m *ParamsResponse) MarshalTo(dAtA []byte) (int, error) { } func (m *ParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/types/block.pb.go b/proto/tendermint/types/block.pb.go index 1c37a498bc..a804a2bd45 100644 --- a/proto/tendermint/types/block.pb.go +++ b/proto/tendermint/types/block.pb.go @@ -145,6 +145,9 @@ func (m *Block) MarshalTo(dAtA []byte) (int, error) { } func (m *Block) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/types/canonical.pb.go b/proto/tendermint/types/canonical.pb.go index db9b751d3a..46e1060b2b 100644 --- a/proto/tendermint/types/canonical.pb.go +++ b/proto/tendermint/types/canonical.pb.go @@ -437,6 +437,9 @@ func (m *CanonicalBlockID) MarshalTo(dAtA []byte) (int, error) { } func (m *CanonicalBlockID) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -477,6 +480,9 @@ func (m *CanonicalPartSetHeader) MarshalTo(dAtA []byte) (int, error) { } func (m *CanonicalPartSetHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -512,6 +518,9 @@ func (m *CanonicalProposal) MarshalTo(dAtA []byte) (int, error) { } func (m *CanonicalProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -584,6 +593,9 @@ func (m *CanonicalVote) MarshalTo(dAtA []byte) (int, error) { } func (m *CanonicalVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -647,6 +659,9 @@ func (m *CanonicalVoteExtension) MarshalTo(dAtA []byte) (int, error) { } func (m *CanonicalVoteExtension) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/types/dash.pb.go b/proto/tendermint/types/dash.pb.go index 8e14ec95f0..b53ebbdc8c 100644 --- a/proto/tendermint/types/dash.pb.go +++ b/proto/tendermint/types/dash.pb.go @@ -306,6 +306,9 @@ func (m *CoreChainLock) MarshalTo(dAtA []byte) (int, error) { } func (m *CoreChainLock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -348,6 +351,9 @@ func (m *VoteExtension) MarshalTo(dAtA []byte) (int, error) { } func (m *VoteExtension) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -389,6 +395,9 @@ func (m *VoteExtension_SignRequestId) MarshalTo(dAtA []byte) (int, error) { } func (m *VoteExtension_SignRequestId) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.SignRequestId != nil { i -= len(m.SignRequestId) diff --git a/proto/tendermint/types/dash_test.go b/proto/tendermint/types/dash_test.go index 0191df6952..a620071eb2 100644 --- a/proto/tendermint/types/dash_test.go +++ b/proto/tendermint/types/dash_test.go @@ -3,14 +3,14 @@ package types_test import ( "testing" - "github.com/dashpay/tenderdash/proto/tendermint/types" "github.com/stretchr/testify/assert" + + "github.com/dashpay/tenderdash/proto/tendermint/types" ) func TestMarshalVoteExtension(t *testing.T) { testCases := []struct { - extension types.VoteExtension - expectPanic bool + extension types.VoteExtension }{ { extension: types.VoteExtension{ @@ -31,10 +31,8 @@ func TestMarshalVoteExtension(t *testing.T) { Extension: []byte("threshold"), XSignRequestId: &types.VoteExtension_SignRequestId{nil}, }}, - // Test below panics because of nil pointer dereference bug in gogoproto - // FIXME: remove expectPanic when we replace gogoproto + { - expectPanic: true, extension: types.VoteExtension{ Type: types.VoteExtensionType_THRESHOLD_RECOVER_RAW, Extension: []byte("threshold"), @@ -58,17 +56,10 @@ func TestMarshalVoteExtension(t *testing.T) { Type: types.PrecommitType, VoteExtensions: []*types.VoteExtension{&tc.extension}, } - f := func() { - marshaled, err := v.Marshal() - assert.NoError(t, err) - assert.NotEmpty(t, marshaled) - } - if tc.expectPanic { - assert.Panics(t, f) - } else { - assert.NotPanics(t, f) - } + marshaled, err := v.Marshal() + assert.NoError(t, err) + assert.NotEmpty(t, marshaled) }) } diff --git a/proto/tendermint/types/events.pb.go b/proto/tendermint/types/events.pb.go index ccd0cac04a..4ba7790ca4 100644 --- a/proto/tendermint/types/events.pb.go +++ b/proto/tendermint/types/events.pb.go @@ -121,6 +121,9 @@ func (m *EventDataRoundState) MarshalTo(dAtA []byte) (int, error) { } func (m *EventDataRoundState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/types/evidence.pb.go b/proto/tendermint/types/evidence.pb.go index 8fe8530e2f..3fa4dd8f47 100644 --- a/proto/tendermint/types/evidence.pb.go +++ b/proto/tendermint/types/evidence.pb.go @@ -274,6 +274,9 @@ func (m *Evidence) MarshalTo(dAtA []byte) (int, error) { } func (m *Evidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -296,6 +299,9 @@ func (m *Evidence_DuplicateVoteEvidence) MarshalTo(dAtA []byte) (int, error) { } func (m *Evidence_DuplicateVoteEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) if m.DuplicateVoteEvidence != nil { { @@ -327,6 +333,9 @@ func (m *DuplicateVoteEvidence) MarshalTo(dAtA []byte) (int, error) { } func (m *DuplicateVoteEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -392,6 +401,9 @@ func (m *EvidenceList) MarshalTo(dAtA []byte) (int, error) { } func (m *EvidenceList) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/types/params.pb.go b/proto/tendermint/types/params.pb.go index 910aecf9d0..375ef243c3 100644 --- a/proto/tendermint/types/params.pb.go +++ b/proto/tendermint/types/params.pb.go @@ -284,6 +284,9 @@ func (m *EvidenceParams) GetMaxBytes() int64 { // NOTE: uses ABCI pubkey naming, not Amino names. type ValidatorParams struct { PubKeyTypes []string `protobuf:"bytes,1,rep,name=pub_key_types,json=pubKeyTypes,proto3" json:"pub_key_types,omitempty"` + // Types that are valid to be assigned to XVotingPowerThreshold: + // *ValidatorParams_VotingPowerThreshold + XVotingPowerThreshold isValidatorParams_XVotingPowerThreshold `protobuf_oneof:"_voting_power_threshold"` } func (m *ValidatorParams) Reset() { *m = ValidatorParams{} } @@ -319,6 +322,26 @@ func (m *ValidatorParams) XXX_DiscardUnknown() { var xxx_messageInfo_ValidatorParams proto.InternalMessageInfo +type isValidatorParams_XVotingPowerThreshold interface { + isValidatorParams_XVotingPowerThreshold() + Equal(interface{}) bool + MarshalTo([]byte) (int, error) + Size() int +} + +type ValidatorParams_VotingPowerThreshold struct { + VotingPowerThreshold uint64 `protobuf:"varint,2,opt,name=voting_power_threshold,json=votingPowerThreshold,proto3,oneof" json:"voting_power_threshold,omitempty"` +} + +func (*ValidatorParams_VotingPowerThreshold) isValidatorParams_XVotingPowerThreshold() {} + +func (m *ValidatorParams) GetXVotingPowerThreshold() isValidatorParams_XVotingPowerThreshold { + if m != nil { + return m.XVotingPowerThreshold + } + return nil +} + func (m *ValidatorParams) GetPubKeyTypes() []string { if m != nil { return m.PubKeyTypes @@ -326,6 +349,20 @@ func (m *ValidatorParams) GetPubKeyTypes() []string { return nil } +func (m *ValidatorParams) GetVotingPowerThreshold() uint64 { + if x, ok := m.GetXVotingPowerThreshold().(*ValidatorParams_VotingPowerThreshold); ok { + return x.VotingPowerThreshold + } + return 0 +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*ValidatorParams) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*ValidatorParams_VotingPowerThreshold)(nil), + } +} + // VersionParams contains the ABCI application version. type VersionParams struct { AppVersion uint64 `protobuf:"varint,1,opt,name=app_version,json=appVersion,proto3" json:"app_version,omitempty"` @@ -659,57 +696,60 @@ func init() { func init() { proto.RegisterFile("tendermint/types/params.proto", fileDescriptor_e12598271a686f57) } var fileDescriptor_e12598271a686f57 = []byte{ - // 801 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0x4f, 0x8f, 0xdb, 0x44, - 0x14, 0x8f, 0x1b, 0x6f, 0x36, 0x79, 0xd9, 0x6c, 0xcc, 0x00, 0xaa, 0x29, 0xac, 0xb3, 0xf8, 0x80, - 0x2a, 0x55, 0xb2, 0x97, 0x2e, 0x1c, 0x90, 0xf8, 0xa3, 0x26, 0x59, 0x95, 0x16, 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, 0xc3, 0xc3, 0x57, 0xe5, 0x8f, 0xc8, 0xde, 0xfe, 0xb9, 0x79, - 0x0d, 0x11, 0x3f, 0xff, 0x37, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x7d, 0x36, 0x05, 0xf7, 0x06, 0x00, + // 849 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x95, 0x4d, 0x6f, 0x1b, 0x45, + 0x18, 0xc7, 0x3d, 0xf5, 0xc6, 0xb1, 0x1f, 0xc7, 0xb1, 0x19, 0x0a, 0x71, 0x0b, 0x71, 0xc2, 0x1e, + 0x50, 0xa5, 0x4a, 0xeb, 0xd0, 0x70, 0xa9, 0xc4, 0x8b, 0xea, 0x38, 0xea, 0x0b, 0x6a, 0x5a, 0xad, + 0x43, 0x0f, 0x48, 0x68, 0x35, 0xbb, 0x1e, 0xd6, 0xab, 0x78, 0x77, 0x56, 0x3b, 0xb3, 0xc6, 0xfb, + 0x09, 0x40, 0xe2, 0xc2, 0x09, 0xf1, 0x11, 0xe0, 0x82, 0xf8, 0x18, 0x3d, 0xf6, 0x82, 0xc4, 0x09, + 0x50, 0xf2, 0x45, 0xd0, 0xcc, 0xce, 0xc4, 0xd8, 0x71, 0x69, 0x4e, 0xf6, 0xcc, 0xf3, 0xff, 0xcd, + 0x33, 0x33, 0xcf, 0xff, 0x99, 0x85, 0x5d, 0x41, 0x93, 0x31, 0xcd, 0xe2, 0x28, 0x11, 0x7d, 0x51, + 0xa4, 0x94, 0xf7, 0x53, 0x92, 0x91, 0x98, 0x3b, 0x69, 0xc6, 0x04, 0xc3, 0x9d, 0x45, 0xd8, 0x51, + 0xe1, 0xdb, 0x37, 0x43, 0x16, 0x32, 0x15, 0xec, 0xcb, 0x7f, 0xa5, 0xee, 0x76, 0x2f, 0x64, 0x2c, + 0x9c, 0xd2, 0xbe, 0x1a, 0xf9, 0xf9, 0x37, 0xfd, 0x71, 0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, 0x86, 0x12, 0xc2, 0x87, 0x60, 0xcd, 0x98, 0xa0, + 0xfa, 0xc5, 0x7c, 0x23, 0xac, 0xc4, 0xf8, 0x33, 0x00, 0xf9, 0xab, 0xf3, 0x5a, 0xd7, 0xbc, 0x07, + 0x89, 0xa8, 0xa4, 0x4f, 0xac, 0xfa, 0x46, 0xa7, 0xf6, 0xc4, 0xaa, 0xd7, 0x3a, 0x9b, 0x6e, 0x2d, + 0x60, 0x71, 0x1c, 0x09, 0xf7, 0x1d, 0xbf, 0x48, 0x09, 0xe7, 0x5e, 0x39, 0xf4, 0xf4, 0xf3, 0x66, + 0xdf, 0x05, 0x58, 0x3c, 0x60, 0x78, 0x17, 0x20, 0xa3, 0xc1, 0x84, 0x06, 0x67, 0x9e, 0x98, 0xab, + 0x1b, 0xab, 0xbb, 0x0d, 0x3d, 0x73, 0x3a, 0x1f, 0xb8, 0xbf, 0x9c, 0xf7, 0xd0, 0xcb, 0xf3, 0x1e, + 0x7a, 0x75, 0xde, 0x43, 0xff, 0x9c, 0xf7, 0xd0, 0x8f, 0x17, 0xbd, 0xca, 0xab, 0x8b, 0x5e, 0xe5, + 0xcf, 0x8b, 0x5e, 0xe5, 0xab, 0x8f, 0xc3, 0x48, 0x4c, 0x72, 0xdf, 0x09, 0x58, 0xdc, 0x1f, 0x13, + 0x3e, 0x49, 0x49, 0xd1, 0x2f, 0x9b, 0x47, 0x8e, 0xca, 0xef, 0x5b, 0x7f, 0xf5, 0x9b, 0xe9, 0xd7, + 0xd4, 0xfc, 0xe1, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb2, 0xb1, 0x36, 0x07, 0x4e, 0x07, 0x00, 0x00, } @@ -839,6 +879,39 @@ func (this *ValidatorParams) Equal(that interface{}) bool { return false } } + if that1.XVotingPowerThreshold == nil { + if this.XVotingPowerThreshold != nil { + return false + } + } else if this.XVotingPowerThreshold == nil { + return false + } else if !this.XVotingPowerThreshold.Equal(that1.XVotingPowerThreshold) { + return false + } + return true +} +func (this *ValidatorParams_VotingPowerThreshold) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ValidatorParams_VotingPowerThreshold) + if !ok { + that2, ok := that.(ValidatorParams_VotingPowerThreshold) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.VotingPowerThreshold != that1.VotingPowerThreshold { + return false + } return true } func (this *VersionParams) Equal(that interface{}) bool { @@ -1034,6 +1107,9 @@ func (m *ConsensusParams) MarshalTo(dAtA []byte) (int, error) { } func (m *ConsensusParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1141,6 +1217,9 @@ func (m *BlockParams) MarshalTo(dAtA []byte) (int, error) { } func (m *BlockParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1174,6 +1253,9 @@ func (m *EvidenceParams) MarshalTo(dAtA []byte) (int, error) { } func (m *EvidenceParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1215,10 +1297,22 @@ func (m *ValidatorParams) MarshalTo(dAtA []byte) (int, error) { } func (m *ValidatorParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int _ = l + if m.XVotingPowerThreshold != nil { + { + size := m.XVotingPowerThreshold.Size() + i -= size + if _, err := m.XVotingPowerThreshold.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } if len(m.PubKeyTypes) > 0 { for iNdEx := len(m.PubKeyTypes) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.PubKeyTypes[iNdEx]) @@ -1231,6 +1325,21 @@ func (m *ValidatorParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ValidatorParams_VotingPowerThreshold) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorParams_VotingPowerThreshold) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + i = encodeVarintParams(dAtA, i, uint64(m.VotingPowerThreshold)) + i-- + dAtA[i] = 0x10 + return len(dAtA) - i, nil +} func (m *VersionParams) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1247,6 +1356,9 @@ func (m *VersionParams) MarshalTo(dAtA []byte) (int, error) { } func (m *VersionParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1280,6 +1392,9 @@ func (m *HashedParams) MarshalTo(dAtA []byte) (int, error) { } func (m *HashedParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1318,6 +1433,9 @@ func (m *SynchronyParams) MarshalTo(dAtA []byte) (int, error) { } func (m *SynchronyParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1361,6 +1479,9 @@ func (m *TimeoutParams) MarshalTo(dAtA []byte) (int, error) { } func (m *TimeoutParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1424,6 +1545,9 @@ func (m *ABCIParams) MarshalTo(dAtA []byte) (int, error) { } func (m *ABCIParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1533,9 +1657,21 @@ func (m *ValidatorParams) Size() (n int) { n += 1 + l + sovParams(uint64(l)) } } + if m.XVotingPowerThreshold != nil { + n += m.XVotingPowerThreshold.Size() + } return n } +func (m *ValidatorParams_VotingPowerThreshold) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 1 + sovParams(uint64(m.VotingPowerThreshold)) + return n +} func (m *VersionParams) Size() (n int) { if m == nil { return 0 @@ -2201,6 +2337,26 @@ func (m *ValidatorParams) Unmarshal(dAtA []byte) error { } m.PubKeyTypes = append(m.PubKeyTypes, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingPowerThreshold", wireType) + } + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.XVotingPowerThreshold = &ValidatorParams_VotingPowerThreshold{v} default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/proto/tendermint/types/params.proto b/proto/tendermint/types/params.proto index 3c4a7feec0..4ac45ab7b7 100644 --- a/proto/tendermint/types/params.proto +++ b/proto/tendermint/types/params.proto @@ -58,6 +58,25 @@ message EvidenceParams { // NOTE: uses ABCI pubkey naming, not Amino names. message ValidatorParams { repeated string pub_key_types = 1; + // Threshold defines the minimum voting power of validators that must vote for a proposal + // to be considered signed and added to the block. + // + // For Dash Platform, the voting power can be calculated by multiply of the number of validators + // and const `DefaultDashVotingPower == 100`. + // + // The following validation rules MUST be enforced: + // + // 1. For validator sets containing 1 or 2 validators, the threshold MUST be equal to the total voting power + // of these validators. + // 2. For validator set with 3 validators, the threshold MUST be equal or greater than 2/3 of the total voting power. + // 3. For validator sets containing more than 3 validators, the threshold MUST be greater than 2/3 of the + // total voting power. + // + // If set to 0, default value is determined based on LLMQ quorum type defined for the network, + // with a fall back to 2/3 + 1 of the total voting power. + // + // If absent, previous value is used. + optional uint64 voting_power_threshold = 2; //[(gogoproto.nullable) = true] } // VersionParams contains the ABCI application version. diff --git a/proto/tendermint/types/types.pb.go b/proto/tendermint/types/types.pb.go index 4897e23fca..1dd9d243db 100644 --- a/proto/tendermint/types/types.pb.go +++ b/proto/tendermint/types/types.pb.go @@ -1268,6 +1268,9 @@ func (m *PartSetHeader) MarshalTo(dAtA []byte) (int, error) { } func (m *PartSetHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1303,6 +1306,9 @@ func (m *Part) MarshalTo(dAtA []byte) (int, error) { } func (m *Part) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1348,6 +1354,9 @@ func (m *BlockID) MarshalTo(dAtA []byte) (int, error) { } func (m *BlockID) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1395,6 +1404,9 @@ func (m *StateID) MarshalTo(dAtA []byte) (int, error) { } func (m *StateID) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1449,6 +1461,9 @@ func (m *Header) MarshalTo(dAtA []byte) (int, error) { } func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1596,6 +1611,9 @@ func (m *Data) MarshalTo(dAtA []byte) (int, error) { } func (m *Data) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1628,6 +1646,9 @@ func (m *Vote) MarshalTo(dAtA []byte) (int, error) { } func (m *Vote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1709,6 +1730,9 @@ func (m *Commit) MarshalTo(dAtA []byte) (int, error) { } func (m *Commit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1780,6 +1804,9 @@ func (m *Proposal) MarshalTo(dAtA []byte) (int, error) { } func (m *Proposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1865,6 +1892,9 @@ func (m *SignedHeader) MarshalTo(dAtA []byte) (int, error) { } func (m *SignedHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1912,6 +1942,9 @@ func (m *LightBlock) MarshalTo(dAtA []byte) (int, error) { } func (m *LightBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -1959,6 +1992,9 @@ func (m *BlockMeta) MarshalTo(dAtA []byte) (int, error) { } func (m *BlockMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -2027,6 +2063,9 @@ func (m *TxProof) MarshalTo(dAtA []byte) (int, error) { } func (m *TxProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/proto/tendermint/types/validator.pb.go b/proto/tendermint/types/validator.pb.go index ee9206fc34..a2dcc14891 100644 --- a/proto/tendermint/types/validator.pb.go +++ b/proto/tendermint/types/validator.pb.go @@ -25,13 +25,14 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type ValidatorSet struct { - Validators []*Validator `protobuf:"bytes,1,rep,name=validators,proto3" json:"validators,omitempty"` - Proposer *Validator `protobuf:"bytes,2,opt,name=proposer,proto3" json:"proposer,omitempty"` - TotalVotingPower int64 `protobuf:"varint,3,opt,name=total_voting_power,json=totalVotingPower,proto3" json:"total_voting_power,omitempty"` - ThresholdPublicKey crypto.PublicKey `protobuf:"bytes,4,opt,name=threshold_public_key,json=thresholdPublicKey,proto3" json:"threshold_public_key"` - QuorumType int32 `protobuf:"varint,5,opt,name=quorum_type,json=quorumType,proto3" json:"quorum_type,omitempty"` - QuorumHash []byte `protobuf:"bytes,6,opt,name=quorum_hash,json=quorumHash,proto3" json:"quorum_hash,omitempty"` - HasPublicKeys bool `protobuf:"varint,7,opt,name=has_public_keys,json=hasPublicKeys,proto3" json:"has_public_keys,omitempty"` + Validators []*Validator `protobuf:"bytes,1,rep,name=validators,proto3" json:"validators,omitempty"` + Proposer *Validator `protobuf:"bytes,2,opt,name=proposer,proto3" json:"proposer,omitempty"` + TotalVotingPower int64 `protobuf:"varint,3,opt,name=total_voting_power,json=totalVotingPower,proto3" json:"total_voting_power,omitempty"` + ThresholdPublicKey crypto.PublicKey `protobuf:"bytes,4,opt,name=threshold_public_key,json=thresholdPublicKey,proto3" json:"threshold_public_key"` + QuorumType int32 `protobuf:"varint,5,opt,name=quorum_type,json=quorumType,proto3" json:"quorum_type,omitempty"` + QuorumHash []byte `protobuf:"bytes,6,opt,name=quorum_hash,json=quorumHash,proto3" json:"quorum_hash,omitempty"` + HasPublicKeys bool `protobuf:"varint,7,opt,name=has_public_keys,json=hasPublicKeys,proto3" json:"has_public_keys,omitempty"` + VotingPowerThreshold uint64 `protobuf:"varint,8,opt,name=voting_power_threshold,json=votingPowerThreshold,proto3" json:"voting_power_threshold,omitempty"` } func (m *ValidatorSet) Reset() { *m = ValidatorSet{} } @@ -116,6 +117,13 @@ func (m *ValidatorSet) GetHasPublicKeys() bool { return false } +func (m *ValidatorSet) GetVotingPowerThreshold() uint64 { + if m != nil { + return m.VotingPowerThreshold + } + return 0 +} + type Validator struct { PubKey *crypto.PublicKey `protobuf:"bytes,1,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` VotingPower int64 `protobuf:"varint,2,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` @@ -253,37 +261,38 @@ func init() { func init() { proto.RegisterFile("tendermint/types/validator.proto", fileDescriptor_4e92274df03d3088) } var fileDescriptor_4e92274df03d3088 = []byte{ - // 475 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 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0x56, 0x90, 0xb0, 0x88, 0x26, 0x89, 0x64, - 0x4a, 0x99, 0x96, 0x86, 0xa1, 0x55, 0x62, 0xef, 0x2b, 0x68, 0xbc, 0xc0, 0x87, 0x57, 0xe9, 0x52, - 0x64, 0xec, 0x3e, 0xe2, 0xdb, 0x9d, 0x22, 0xee, 0x10, 0xee, 0xf2, 0xd3, 0xed, 0xc6, 0x41, 0x77, - 0x1b, 0x07, 0xfd, 0xda, 0x38, 0xe8, 0xdb, 0xd6, 0xe9, 0xdc, 0x6d, 0x9d, 0xce, 0xf7, 0xad, 0xd3, - 0xf9, 0xfc, 0x66, 0x9e, 0x6a, 0x9e, 0xc7, 0xfe, 0x0c, 0x96, 0x41, 0x42, 0x15, 0x17, 0xb4, 0x08, - 0x2a, 0xd3, 0xf2, 0x2f, 0xa8, 0xee, 0xe4, 0xe1, 0x95, 0xc5, 0x03, 0x83, 0xbf, 0xfe, 0x13, 0x00, - 0x00, 0xff, 0xff, 0x84, 0xb2, 0x3f, 0xb9, 0x80, 0x03, 0x00, 0x00, + // 495 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x41, 0x6b, 0xdb, 0x30, + 0x18, 0x8d, 0x9a, 0x34, 0x4d, 0x94, 0x8c, 0x76, 0x22, 0x0c, 0xd3, 0x15, 0xd7, 0xcd, 0x61, 0x18, + 0x36, 0x6c, 0xd8, 0x3a, 0x76, 0xe8, 0x69, 0x3d, 0x0d, 0x06, 0x23, 0xb8, 0xa1, 0x87, 0x5d, 0x8c, + 0x1c, 0x8b, 0xc8, 0xc4, 0xc9, 0xa7, 0x49, 0x72, 0x56, 0xff, 0x8b, 0xfd, 0x8c, 0xfd, 0x94, 0x1e, + 0x7b, 0x1c, 0x0c, 0xc6, 0x48, 0xfe, 0xc8, 0xb0, 0x3c, 0x3b, 0x5e, 0x2f, 0x6b, 0x6f, 0xf6, 0x7b, + 0xef,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7, 0xee, 0xb6, 0x76, + 0xeb, 0xc7, 0xd6, 0x6e, 0x7d, 0x3e, 0x9f, 0x27, 0x9a, 0x67, 0x91, 0x37, 0x83, 0xa5, 0x1f, 0x53, + 0xc5, 0x05, 0xcd, 0xfd, 0xd2, 0xb4, 0xf8, 0xf3, 0xcb, 0xd7, 0x75, 0xff, 0x6d, 0x46, 0x5d, 0x83, + 0xbf, 0xf9, 0x13, 0x00, 0x00, 0xff, 0xff, 0x0f, 0xc1, 0xfd, 0x1a, 0xb6, 0x03, 0x00, 0x00, } func (m *ValidatorSet) Marshal() (dAtA []byte, err error) { @@ -302,10 +311,18 @@ func (m *ValidatorSet) MarshalTo(dAtA []byte) (int, error) { } func (m *ValidatorSet) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int _ = l + if m.VotingPowerThreshold != 0 { + i = encodeVarintValidator(dAtA, i, uint64(m.VotingPowerThreshold)) + i-- + dAtA[i] = 0x40 + } if m.HasPublicKeys { i-- if m.HasPublicKeys { @@ -388,6 +405,9 @@ func (m *Validator) MarshalTo(dAtA []byte) (int, error) { } func (m *Validator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -447,6 +467,9 @@ func (m *SimpleValidator) MarshalTo(dAtA []byte) (int, error) { } func (m *SimpleValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int @@ -513,6 +536,9 @@ func (m *ValidatorSet) Size() (n int) { if m.HasPublicKeys { n += 2 } + if m.VotingPowerThreshold != 0 { + n += 1 + sovValidator(uint64(m.VotingPowerThreshold)) + } return n } @@ -789,6 +815,25 @@ func (m *ValidatorSet) Unmarshal(dAtA []byte) error { } } m.HasPublicKeys = bool(v != 0) + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingPowerThreshold", wireType) + } + m.VotingPowerThreshold = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowValidator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VotingPowerThreshold |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipValidator(dAtA[iNdEx:]) diff --git a/proto/tendermint/types/validator.proto b/proto/tendermint/types/validator.proto index 9c0fe6ab17..23fb02d654 100644 --- a/proto/tendermint/types/validator.proto +++ b/proto/tendermint/types/validator.proto @@ -7,13 +7,14 @@ import "gogoproto/gogo.proto"; import "tendermint/crypto/keys.proto"; message ValidatorSet { - repeated Validator validators = 1; - Validator proposer = 2; - int64 total_voting_power = 3; - tendermint.crypto.PublicKey threshold_public_key = 4 [(gogoproto.nullable) = false]; - int32 quorum_type = 5; - bytes quorum_hash = 6; - bool has_public_keys = 7; + repeated Validator validators = 1; + Validator proposer = 2; + int64 total_voting_power = 3; + tendermint.crypto.PublicKey threshold_public_key = 4 [(gogoproto.nullable) = false]; + int32 quorum_type = 5; + bytes quorum_hash = 6; + bool has_public_keys = 7; + uint64 voting_power_threshold = 8; // must equal ValidatorParams.voting_power_threshold } message Validator { diff --git a/proto/tendermint/version/types.pb.go b/proto/tendermint/version/types.pb.go index 7ba940c46a..66b9174c07 100644 --- a/proto/tendermint/version/types.pb.go +++ b/proto/tendermint/version/types.pb.go @@ -143,6 +143,9 @@ func (m *Consensus) MarshalTo(dAtA []byte) (int, error) { } func (m *Consensus) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } i := len(dAtA) _ = i var l int diff --git a/rpc/client/evidence_test.go b/rpc/client/evidence_test.go index 5789e6a648..f15430df66 100644 --- a/rpc/client/evidence_test.go +++ b/rpc/client/evidence_test.go @@ -39,7 +39,7 @@ func newEvidence(t *testing.T, val *privval.FilePV, require.NoError(t, err) validator := types.NewValidator(privKey.PubKey(), types.DefaultDashVotingPower, val.Key.ProTxHash, "") - valSet := types.NewValidatorSet([]*types.Validator{validator}, validator.PubKey, quorumType, quorumHash, true) + valSet := types.NewValidatorSet([]*types.Validator{validator}, validator.PubKey, quorumType, quorumHash, true, nil) ev, err := types.NewDuplicateVoteEvidence(vote, vote2, timestamp, valSet) require.NoError(t, err) diff --git a/test/e2e/networks/single.toml b/test/e2e/networks/single.toml index 54c40b19e4..2e0aef1a89 100644 --- a/test/e2e/networks/single.toml +++ b/test/e2e/networks/single.toml @@ -1 +1,3 @@ +voting_power_threshold = 100 + [node.validator] diff --git a/test/e2e/pkg/manifest.go b/test/e2e/pkg/manifest.go index e44b714f5e..bcb776d551 100644 --- a/test/e2e/pkg/manifest.go +++ b/test/e2e/pkg/manifest.go @@ -17,6 +17,10 @@ type Manifest struct { // QuorumType represents the initial quorum type QuorumType uint32 `toml:"quorum_type"` + // VotingPowerThreshold represents how much voting power is needed to approve a block; + // typically it's set to `(2/3 * num of validators + 1) * 100` where 100 is the default voting power. + VotingPowerThreshold uint64 `toml:"voting_power_threshold"` + // InitialHeight specifies the initial block height, set in genesis. Defaults to 1. InitialHeight int64 `toml:"initial_height"` diff --git a/test/e2e/pkg/testnet.go b/test/e2e/pkg/testnet.go index a92b7816bd..26ea2d393d 100644 --- a/test/e2e/pkg/testnet.go +++ b/test/e2e/pkg/testnet.go @@ -100,6 +100,7 @@ type Testnet struct { ThresholdPublicKey crypto.PubKey ThresholdPublicKeyUpdates map[int64]crypto.PubKey QuorumType btcjson.LLMQType + VotingPowerThreshold uint64 QuorumHash crypto.QuorumHash QuorumHashUpdates map[int64]crypto.QuorumHash // ConsensusVersionUpdates maps height to new consensus version (ConsensusParams.Version.ConsensusVersion) @@ -216,6 +217,7 @@ func LoadTestnet(file string) (*Testnet, error) { ThresholdPublicKey: ld.ThresholdPubKey, ThresholdPublicKeyUpdates: map[int64]crypto.PubKey{}, QuorumType: btcjson.LLMQType(quorumType), + VotingPowerThreshold: manifest.VotingPowerThreshold, QuorumHash: quorumHash, QuorumHashUpdates: map[int64]crypto.QuorumHash{}, ConsensusVersionUpdates: map[int64]int32{}, diff --git a/test/e2e/runner/evidence.go b/test/e2e/runner/evidence.go index 0901990194..80d98ba351 100644 --- a/test/e2e/runner/evidence.go +++ b/test/e2e/runner/evidence.go @@ -71,7 +71,7 @@ func InjectEvidence(ctx context.Context, logger log.Logger, r *rand.Rand, testne valSet := types.NewValidatorSet(valRes.Validators, *valRes.ThresholdPublicKey, valRes.QuorumType, *valRes.QuorumHash, - false) + false, nil) if valSet == nil { return fmt.Errorf("could not create validator set from response") } diff --git a/test/e2e/runner/setup.go b/test/e2e/runner/setup.go index d149e042a1..ad14e43064 100644 --- a/test/e2e/runner/setup.go +++ b/test/e2e/runner/setup.go @@ -179,6 +179,10 @@ func MakeGenesis(testnet *e2e.Testnet, genesisTime time.Time) (types.GenesisDoc, if testnet.MaxBlockSize > 0 { genesis.ConsensusParams.Block.MaxBytes = testnet.MaxBlockSize } + if testnet.VotingPowerThreshold > 0 { + threshold := testnet.VotingPowerThreshold + genesis.ConsensusParams.Validator.VotingPowerThreshold = &threshold + } for validator, validatorUpdate := range testnet.Validators { if validatorUpdate.PubKey == nil { diff --git a/test/e2e/tests/validator_test.go b/test/e2e/tests/validator_test.go index 837980060e..db46577af7 100644 --- a/test/e2e/tests/validator_test.go +++ b/test/e2e/tests/validator_test.go @@ -186,7 +186,7 @@ func newValidatorSchedule(testnet e2e.Testnet) *validatorSchedule { } } - vs := types.NewValidatorSet(makeVals(valMap), thresholdPublicKey, quorumType, quorumHash, true) + vs := types.NewValidatorSet(makeVals(valMap), thresholdPublicKey, quorumType, quorumHash, true, nil) ps, err := selectproposer.NewProposerSelector(*types.DefaultConsensusParams(), vs, testnet.InitialHeight, 0, nil, nil) if err != nil { panic(err) @@ -257,7 +257,7 @@ func (s *validatorSchedule) Increment(heights int64) error { } } else { vs := types.NewValidatorSet(makeVals(update), thresholdPublicKeyUpdate, btcjson.LLMQType_5_60, - quorumHashUpdate, true) + quorumHashUpdate, true, &cp.Validator) ps, err := selectproposer.NewProposerSelector(cp, vs, s.height, 0, nil, nil) if err != nil { diff --git a/types/evidence.go b/types/evidence.go index 86e3f08631..42d058de2a 100644 --- a/types/evidence.go +++ b/types/evidence.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "strings" + "testing" "time" "github.com/dashpay/dashd-go/btcjson" @@ -490,6 +491,9 @@ func NewMockDuplicateVoteEvidenceWithValidator( quorumType btcjson.LLMQType, quorumHash crypto.QuorumHash, ) (*DuplicateVoteEvidence, error) { + if !testing.Testing() { + panic("NewMockDuplicateVoteEvidenceWithValidator should only be used in tests") + } pubKey, err := pv.GetPubKey(ctx, quorumHash) if err != nil { panic(err) @@ -510,7 +514,7 @@ func NewMockDuplicateVoteEvidenceWithValidator( voteA, voteB, time, - NewValidatorSet([]*Validator{val}, val.PubKey, quorumType, quorumHash, true), + NewValidatorSet([]*Validator{val}, val.PubKey, quorumType, quorumHash, true, nil), ) } diff --git a/types/evidence_test.go b/types/evidence_test.go index 19df99c4fe..e7ed069c9d 100644 --- a/types/evidence_test.go +++ b/types/evidence_test.go @@ -165,7 +165,8 @@ func TestDuplicateVoteEvidenceValidation(t *testing.T) { thresholdPublicKey, err := val.GetThresholdPublicKey(context.Background(), quorumHash) assert.NoError(t, err) valSet := NewValidatorSet( - []*Validator{val.ExtractIntoValidator(context.Background(), quorumHash)}, thresholdPublicKey, quorumType, quorumHash, true) + []*Validator{val.ExtractIntoValidator(context.Background(), quorumHash)}, + thresholdPublicKey, quorumType, quorumHash, true, nil) ev, err := NewDuplicateVoteEvidence(vote1, vote2, defaultVoteTime, valSet) require.NoError(t, err) tc.malleateEvidence(ev) diff --git a/types/generator.go b/types/generator.go index 75c8f034f4..115d1cac02 100644 --- a/types/generator.go +++ b/types/generator.go @@ -83,7 +83,7 @@ func GenerateValidatorSet(valParams []ValSetParam, opts ...ValSetOptionFunc) (*V valz = append(valz, NewValidator(qks.PubKey, opt.VotingPower, proTxHash, "")) } sort.Sort(PrivValidatorsByProTxHash(privValidators)) - return NewValidatorSet(valz, ld.ThresholdPubKey, crypto.SmallQuorumType(), quorumHash, true), privValidators + return NewValidatorSet(valz, ld.ThresholdPubKey, crypto.SmallQuorumType(), quorumHash, true, nil), privValidators } // MakeGenesisValsFromValidatorSet converts ValidatorSet data into a list of GenesisValidator diff --git a/types/params.go b/types/params.go index fa7243825f..acc4a1600a 100644 --- a/types/params.go +++ b/types/params.go @@ -69,7 +69,8 @@ type EvidenceParams struct { // ValidatorParams restrict the public key types validators can use. // NOTE: uses ABCI pubkey naming, not Amino names. type ValidatorParams struct { - PubKeyTypes []string `json:"pub_key_types"` + PubKeyTypes []string `json:"pub_key_types"` + VotingPowerThreshold *uint64 `json:"threshold,omitempty"` } type VersionParams struct { @@ -141,7 +142,8 @@ func DefaultEvidenceParams() EvidenceParams { // only bls12381 pubkeys. func DefaultValidatorParams() ValidatorParams { return ValidatorParams{ - PubKeyTypes: []string{ABCIPubKeyTypeBLS12381}, + PubKeyTypes: []string{ABCIPubKeyTypeBLS12381}, + VotingPowerThreshold: nil, } } @@ -239,6 +241,44 @@ func (val *ValidatorParams) IsValidPubkeyType(pubkeyType string) bool { return false } +func (val *ValidatorParams) ToProto() *tmproto.ValidatorParams { + if val == nil { + return nil + } + + params := tmproto.ValidatorParams{ + PubKeyTypes: val.PubKeyTypes, + } + + if val.VotingPowerThreshold != nil { + params.XVotingPowerThreshold = &tmproto.ValidatorParams_VotingPowerThreshold{ + VotingPowerThreshold: *val.VotingPowerThreshold, + } + } + + return ¶ms +} + +// ValidatorParamsFromProto returns a ValidatorParams from a protobuf representation. +// If pbValParams is nil, it returns a ValidatorParams with empty PubKeyTypes and 0 VotingPowerThreshold. +func ValidatorParamsFromProto(pbValParams *tmproto.ValidatorParams) ValidatorParams { + var params = ValidatorParams{ + PubKeyTypes: []string{}, + } + + if pbValParams != nil { + if pbValParams.XVotingPowerThreshold != nil { + val := pbValParams.GetVotingPowerThreshold() + params.VotingPowerThreshold = &val + } + // Copy Validator.PubkeyTypes, and set result's value to the copy. + // This avoids having to initialize the slice to 0 values, and then write to it again. + params.PubKeyTypes = append(params.PubKeyTypes, pbValParams.PubKeyTypes...) + } + + return params +} + func (params *ConsensusParams) Complete() { if params.Synchrony == (SynchronyParams{}) { params.Synchrony = DefaultSynchronyParams() @@ -392,9 +432,7 @@ func (params ConsensusParams) UpdateConsensusParams(params2 *tmproto.ConsensusPa res.Evidence.MaxBytes = params2.Evidence.MaxBytes } if params2.Validator != nil { - // Copy params2.Validator.PubkeyTypes, and set result's value to the copy. - // This avoids having to initialize the slice to 0 values, and then write to it again. - res.Validator.PubKeyTypes = append([]string{}, params2.Validator.PubKeyTypes...) + res.Validator = ValidatorParamsFromProto(params2.Validator) } if params2.Version != nil { res.Version.AppVersion = params2.Version.AppVersion @@ -439,9 +477,7 @@ func (params *ConsensusParams) ToProto() tmproto.ConsensusParams { MaxAgeDuration: params.Evidence.MaxAgeDuration, MaxBytes: params.Evidence.MaxBytes, }, - Validator: &tmproto.ValidatorParams{ - PubKeyTypes: params.Validator.PubKeyTypes, - }, + Validator: params.Validator.ToProto(), Version: &tmproto.VersionParams{ AppVersion: params.Version.AppVersion, ConsensusVersion: tmproto.VersionParams_ConsensusVersion(params.Version.ConsensusVersion), @@ -482,8 +518,13 @@ func ConsensusParamsFromProto(pbParams tmproto.ConsensusParams) ConsensusParams } if pbParams.Validator != nil { + var threshold *uint64 + if n, ok := pbParams.Validator.XVotingPowerThreshold.(*tmproto.ValidatorParams_VotingPowerThreshold); ok && n != nil { + threshold = &n.VotingPowerThreshold + } c.Validator = ValidatorParams{ - PubKeyTypes: pbParams.Validator.PubKeyTypes, + PubKeyTypes: append([]string{}, pbParams.Validator.PubKeyTypes...), + VotingPowerThreshold: threshold, } } diff --git a/types/params_test.go b/types/params_test.go index ccd18e8e71..781e9d7c60 100644 --- a/types/params_test.go +++ b/types/params_test.go @@ -218,7 +218,8 @@ func makeParams(args makeParamsArgs) ConsensusParams { MaxBytes: args.maxEvidenceBytes, }, Validator: ValidatorParams{ - PubKeyTypes: args.pubkeyTypes, + PubKeyTypes: args.pubkeyTypes, + VotingPowerThreshold: nil, }, Synchrony: SynchronyParams{ Precision: args.precision, diff --git a/types/protobuf.go b/types/protobuf.go index 671e21321c..979ac2fe46 100644 --- a/types/protobuf.go +++ b/types/protobuf.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "testing" "github.com/dashpay/dashd-go/btcjson" @@ -159,10 +160,16 @@ func (pb2tm) ValidatorUpdatesFromValidatorSet(valSetUpdate *abci.ValidatorSetUpd return tmVals, pub, valSetUpdate.QuorumHash, nil } +// ValidatorSetFromProtoUpdate creates validator set from validator update. +// +// Only use in tests. func (pb2tm) ValidatorSetFromProtoUpdate( quorumType btcjson.LLMQType, valSetUpdate *abci.ValidatorSetUpdate, ) (*ValidatorSet, error) { + if !testing.Testing() { + panic("ValidatorSetFromProtoUpdate should only be used in tests") + } hasPublicKeys := true for i, v := range valSetUpdate.ValidatorUpdates { if v.PubKey == nil { @@ -183,7 +190,7 @@ func (pb2tm) ValidatorSetFromProtoUpdate( if err != nil { return nil, err } - return NewValidatorSet(tmVals, pub, quorumType, quorumHash, hasPublicKeys), nil + return NewValidatorSet(tmVals, pub, quorumType, quorumHash, hasPublicKeys, nil), nil } func (pb2tm) ThresholdPublicKeyUpdate(thresholdPublicKey crypto2.PublicKey) (crypto.PubKey, error) { diff --git a/types/protobuf_test.go b/types/protobuf_test.go index d1530e134b..4774d40eb8 100644 --- a/types/protobuf_test.go +++ b/types/protobuf_test.go @@ -43,7 +43,7 @@ func TestABCIValidators(t *testing.T) { assert.NoError(t, err) assert.Equal(t, tmValExpected, tmVals[0]) - abciVals := TM2PB.ValidatorUpdates(NewValidatorSet(tmVals, tmVal.PubKey, btcjson.LLMQType_5_60, quorumHash, true)) + abciVals := TM2PB.ValidatorUpdates(NewValidatorSet(tmVals, tmVal.PubKey, btcjson.LLMQType_5_60, quorumHash, true, nil)) assert.Equal(t, abci.ValidatorSetUpdate{ ValidatorUpdates: []abci.ValidatorUpdate{abciVal}, ThresholdPublicKey: *abciVal.PubKey, diff --git a/types/validation_test.go b/types/validation_test.go index f518d1f7ed..59568dafb0 100644 --- a/types/validation_test.go +++ b/types/validation_test.go @@ -23,7 +23,7 @@ func TestValidatorSet_VerifyCommit_All(t *testing.T) { pubKey = privKey.PubKey() v1 = NewValidatorDefaultVotingPower(pubKey, proTxHash) quorumHash = crypto.RandQuorumHash() - vset = NewValidatorSet([]*Validator{v1}, v1.PubKey, btcjson.LLMQType_5_60, quorumHash, true) + vset = NewValidatorSet([]*Validator{v1}, v1.PubKey, btcjson.LLMQType_5_60, quorumHash, true, nil) chainID = "Lalande21185" ) diff --git a/types/validator_set.go b/types/validator_set.go index 37aff76e32..5d2d23c420 100644 --- a/types/validator_set.go +++ b/types/validator_set.go @@ -65,6 +65,8 @@ type ValidatorSet struct { QuorumHash crypto.QuorumHash `json:"quorum_hash"` QuorumType btcjson.LLMQType `json:"quorum_type"` HasPublicKeys bool `json:"has_public_keys"` + // Threshold power, must equal to ValidatorParams.voting_power_threshold + VotingPowerThreshold uint64 `json:"threshold_power"` } // NewValidatorSet initializes a ValidatorSet by copying over the values from @@ -78,12 +80,15 @@ type ValidatorSet struct { // MaxVotesCount - commits by a validator set larger than this will fail // validation. func NewValidatorSet(valz []*Validator, newThresholdPublicKey crypto.PubKey, quorumType btcjson.LLMQType, - quorumHash crypto.QuorumHash, hasPublicKeys bool) *ValidatorSet { + quorumHash crypto.QuorumHash, hasPublicKeys bool, validatorParams *ValidatorParams) *ValidatorSet { vals := &ValidatorSet{ QuorumHash: quorumHash, QuorumType: quorumType, HasPublicKeys: hasPublicKeys, } + if validatorParams != nil && validatorParams.VotingPowerThreshold != nil { + vals.VotingPowerThreshold = *validatorParams.VotingPowerThreshold + } err := vals.updateWithChangeSet(valz, false, newThresholdPublicKey, quorumHash) if err != nil { panic(fmt.Sprintf("Cannot create validator set: %v", err)) @@ -99,6 +104,7 @@ func NewValidatorSetCheckPublicKeys( newThresholdPublicKey crypto.PubKey, quorumType btcjson.LLMQType, quorumHash crypto.QuorumHash, + params *ValidatorParams, ) *ValidatorSet { hasPublicKeys := true for _, val := range valz { @@ -106,12 +112,12 @@ func NewValidatorSetCheckPublicKeys( hasPublicKeys = false } } - return NewValidatorSet(valz, newThresholdPublicKey, quorumType, quorumHash, hasPublicKeys) + return NewValidatorSet(valz, newThresholdPublicKey, quorumType, quorumHash, hasPublicKeys, params) } // NewEmptyValidatorSet initializes a ValidatorSet with no validators func NewEmptyValidatorSet() *ValidatorSet { - return NewValidatorSet(nil, nil, 0, nil, false) + return NewValidatorSet(nil, nil, 0, nil, false, nil) } func (vals *ValidatorSet) ValidateBasic() error { @@ -152,6 +158,33 @@ func (vals *ValidatorSet) ValidateBasic() error { return fmt.Errorf("proposer failed validate basic, error: %w", err) } + if vals.VotingPowerThreshold > math.MaxInt64 { + return fmt.Errorf("voting power threshold %d is too large", vals.VotingPowerThreshold) + } + + threshold := vals.QuorumVotingThresholdPower() + totalPower := vals.TotalVotingPower() + switch len(vals.Validators) { + case 1, 2: + // For validator sets containing 1 or 2 validators, the threshold MUST be equal to the total voting power. + if totalPower != threshold { + return fmt.Errorf("with 1 or 2 validators, quorum voting power %d must be equal to threshold %d", totalPower, threshold) + } + case 3: + // For validator set with 3 validators, the threshold MUST be equal or greater than 2/3 of the total voting power. + if threshold < totalPower*2/3 { + return fmt.Errorf("%d-members quorum voting power %d is less than threshold %d", + len(vals.Validators), totalPower, vals.VotingPowerThreshold) + } + default: + // For validator sets containing more than 3 validators, the threshold MUST be at least 2/3 + 1 of the total voting power. + if threshold < (totalPower*2/3)+1 { + return fmt.Errorf("voting threshold %d of quorum with power %d MUST be at least 2/3*%d+1 = %d", + threshold, totalPower, totalPower, (totalPower*2/3)+1) + + } + } + return nil } @@ -397,6 +430,14 @@ func (vals *ValidatorSet) QuorumVotingPower() int64 { // QuorumVotingThresholdPower returns the threshold power of the voting power of the quorum if all the members existed. // Voting is considered successful when voting power is at or above this threshold. func (vals *ValidatorSet) QuorumVotingThresholdPower() int64 { + if thresholdPower := vals.VotingPowerThreshold; thresholdPower > 0 { + if thresholdPower > math.MaxInt64 { + // this should never happen + panic(fmt.Sprintf("threshold power %d is too large", thresholdPower)) + } + return int64(thresholdPower) + } + return int64(vals.QuorumTypeThresholdCount()) * DefaultDashVotingPower } @@ -902,6 +943,8 @@ func (vals *ValidatorSet) ToProto() (*tmproto.ValidatorSet, error) { // be consistent with cached data vp.TotalVotingPower = 0 + vp.VotingPowerThreshold = vals.VotingPowerThreshold + if vals.ThresholdPublicKey == nil { return nil, fmt.Errorf("thresholdPublicKey is not set") } @@ -956,6 +999,8 @@ func ValidatorSetFromProto(vp *tmproto.ValidatorSet) (*ValidatorSet, error) { } } + vals.VotingPowerThreshold = vp.GetVotingPowerThreshold() + // NOTE: We can't trust the total voting power given to us by other peers. If someone were to // inject a non-zeo value that wasn't the correct voting power we could assume a wrong total // power hence we need to recompute it. diff --git a/types/validator_set_test.go b/types/validator_set_test.go index c423ff7710..ee0b38fc26 100644 --- a/types/validator_set_test.go +++ b/types/validator_set_test.go @@ -24,7 +24,7 @@ import ( func TestValidatorSetBasic(t *testing.T) { // empty or nil validator lists are allowed, - vset := NewValidatorSet([]*Validator{}, nil, btcjson.LLMQType_5_60, nil, true) + vset := NewValidatorSet([]*Validator{}, nil, btcjson.LLMQType_5_60, nil, true, nil) assert.EqualValues(t, vset, vset.Copy()) assert.False(t, vset.HasProTxHash([]byte("some val"))) @@ -233,7 +233,7 @@ func TestCopy(t *testing.T) { func BenchmarkValidatorSetCopy(b *testing.B) { b.StopTimer() - vset := NewValidatorSet([]*Validator{}, nil, btcjson.LLMQType_5_60, nil, true) + vset := NewValidatorSet([]*Validator{}, nil, btcjson.LLMQType_5_60, nil, true, nil) for i := 0; i < 1000; i++ { privKey := bls12381.GenPrivKey() pubKey := privKey.PubKey() @@ -279,7 +279,7 @@ func randValidatorInQuorum(ctx context.Context, t *testing.T, quorumHash crypto. func TestEmptySet(t *testing.T) { var valList []*Validator - valSet := NewValidatorSet(valList, bls12381.PubKey{}, btcjson.LLMQType_5_60, crypto.QuorumHash{}, true) + valSet := NewValidatorSet(valList, bls12381.PubKey{}, btcjson.LLMQType_5_60, crypto.QuorumHash{}, true, nil) // Add to empty set proTxHashes := []crypto.ProTxHash{crypto.Checksum([]byte("v1")), crypto.Checksum([]byte("v2"))} @@ -310,14 +310,18 @@ func TestUpdatesForNewValidatorSet(t *testing.T) { v112 := NewTestValidatorGeneratedFromProTxHash(crypto.Checksum([]byte("v1"))) v113 := NewTestValidatorGeneratedFromProTxHash(crypto.Checksum([]byte("v1"))) valList := []*Validator{v111, v112, v113} - assert.Panics(t, func() { NewValidatorSet(valList, bls12381.PubKey{}, btcjson.LLMQType_5_60, crypto.QuorumHash{}, true) }) + assert.Panics(t, func() { + NewValidatorSet(valList, bls12381.PubKey{}, btcjson.LLMQType_5_60, crypto.QuorumHash{}, true, nil) + }) // Verify set including validator with voting power 0 cannot be created v1 := NewTestRemoveValidatorGeneratedFromProTxHash(crypto.Checksum([]byte("v1"))) v2 := NewTestValidatorGeneratedFromProTxHash(crypto.Checksum([]byte("v2"))) v3 := NewTestValidatorGeneratedFromProTxHash(crypto.Checksum([]byte("v3"))) valList = []*Validator{v1, v2, v3} - assert.Panics(t, func() { NewValidatorSet(valList, bls12381.PubKey{}, btcjson.LLMQType_5_60, crypto.QuorumHash{}, true) }) + assert.Panics(t, func() { + NewValidatorSet(valList, bls12381.PubKey{}, btcjson.LLMQType_5_60, crypto.QuorumHash{}, true, nil) + }) // Verify set including validator with negative voting power cannot be created v1 = NewTestValidatorGeneratedFromProTxHash(crypto.Checksum([]byte("v1"))) @@ -327,7 +331,9 @@ func TestUpdatesForNewValidatorSet(t *testing.T) { } v3 = NewTestValidatorGeneratedFromProTxHash(crypto.Checksum([]byte("v3"))) valList = []*Validator{v1, v2, v3} - assert.Panics(t, func() { NewValidatorSet(valList, bls12381.PubKey{}, btcjson.LLMQType_5_60, crypto.QuorumHash{}, true) }) + assert.Panics(t, func() { + NewValidatorSet(valList, bls12381.PubKey{}, btcjson.LLMQType_5_60, crypto.QuorumHash{}, true, nil) + }) } diff --git a/types/vote_set_test.go b/types/vote_set_test.go index f3a47aaa54..dd3f95f016 100644 --- a/types/vote_set_test.go +++ b/types/vote_set_test.go @@ -513,6 +513,7 @@ func TestVoteSet_LLMQType_50_60(t *testing.T) { tt.numValidators, tt.llmqType, tt.threshold, + nil, ) assert.EqualValues(t, tt.threshold, valSet.QuorumTypeThresholdCount()) assert.GreaterOrEqual(t, len(privValidators), tt.threshold+3, @@ -548,6 +549,103 @@ func TestVoteSet_LLMQType_50_60(t *testing.T) { } } +// Given a set of validators and a threshold defined in ValidatorParams, +// when votes are cast, +// then the threshold from ValidatorParams is respected. +func TestVoteSet_ValidatorParams_Threshold(t *testing.T) { + const ( + height = int64(1) + round = int32(0) + ) + testCases := []struct { + llmqType btcjson.LLMQType + numValidators int + threshold int + }{ + { // single node network + llmqType: btcjson.LLMQType_100_67, + numValidators: 1, + threshold: 1, + }, + { // two node network + llmqType: btcjson.LLMQType_100_67, + numValidators: 2, + threshold: 2, + }, + { // full network but threshold 2 + llmqType: btcjson.LLMQType_100_67, + numValidators: 100, + threshold: 2, + }, + { // full network but threshold 3 + llmqType: btcjson.LLMQType_100_67, + numValidators: 100, + threshold: 3, + }, + { // normal network + llmqType: btcjson.LLMQType_100_67, + numValidators: 100, + threshold: 67, + }, + { // network below threshold + llmqType: btcjson.LLMQType_100_67, + numValidators: 67, + threshold: 67, + }, + } + + for ti, tt := range testCases { + name := strconv.Itoa(ti) + t.Run(name, func(t *testing.T) { + threshold := uint64(int64(tt.threshold) * DefaultDashVotingPower) + params := ValidatorParams{ + VotingPowerThreshold: &threshold, + } + voteSet, _, privValidators := randVoteSetWithLLMQType( + height, + round, + tmproto.PrevoteType, + tt.numValidators, + tt.llmqType, + tt.threshold, + ¶ms, + ) + blockHash := crypto.CRandBytes(32) + stateID := RandStateID() + blockPartSetHeader := PartSetHeader{uint32(123), crypto.CRandBytes(32)} + votedBlock := BlockID{blockHash, blockPartSetHeader, stateID.Hash()} + + // below threshold + for i := 0; i < tt.threshold-1; i++ { + blockMaj, anyMaj := castVote(t, votedBlock, height, round, privValidators, int32(i), voteSet) + assert.False(t, blockMaj, "no block majority expected here: i=%d, threshold=%d", i, tt.threshold) + assert.False(t, anyMaj, "no 'any' majority expected here: i=%d, threshold=%d", i, tt.threshold) + } + + // we add null vote + if tt.numValidators > tt.threshold { + // we add null vote + blockMaj, anyMaj := castVote(t, BlockID{}, height, round, privValidators, int32(tt.threshold), voteSet) + assert.False(t, blockMaj, "no block majority expected after nil vote") + assert.True(t, anyMaj, "'any' majority expected after nil vote at threshold") + + } + if tt.numValidators > tt.threshold+1 { + // at threshold + blockMaj, anyMaj := castVote(t, votedBlock, height, round, privValidators, int32(tt.threshold+1), voteSet) + assert.True(t, blockMaj, "block majority expected") + assert.True(t, anyMaj, "'any' majority expected") + } + // above threshold + if tt.numValidators > tt.threshold+2 { + blockMaj, anyMaj := castVote(t, votedBlock, height, round, privValidators, int32(tt.threshold+2), voteSet) + assert.True(t, blockMaj, "block majority expected") + assert.True(t, anyMaj, "'any' majority expected") + } + }) + } +} + func TestVoteSet_json_marshal_nil(t *testing.T) { var vset *VoteSet jsonBytes, err := json.Marshal(vset) @@ -619,6 +717,7 @@ func randVoteSetWithLLMQType( numValidators int, llmqType btcjson.LLMQType, threshold int, + params *ValidatorParams, ) (*VoteSet, *ValidatorSet, []PrivValidator) { valz := make([]*Validator, 0, numValidators) privValidators := make([]PrivValidator, 0, numValidators) @@ -640,7 +739,7 @@ func randVoteSetWithLLMQType( sort.Sort(PrivValidatorsByProTxHash(privValidators)) - valSet := NewValidatorSet(valz, ld.ThresholdPubKey, llmqType, quorumHash, true) + valSet := NewValidatorSet(valz, ld.ThresholdPubKey, llmqType, quorumHash, true, params) voteSet := NewVoteSet("test_chain_id", height, round, signedMsgType, valSet) return voteSet, valSet, privValidators diff --git a/version/version.go b/version/version.go index e2db669794..df7d4822e8 100644 --- a/version/version.go +++ b/version/version.go @@ -11,7 +11,7 @@ const ( // when not using git describe. It is formatted with semantic versioning. TMVersionDefault = "1.4.0" // ABCISemVer is the semantic version of the ABCI library - ABCISemVer = "1.2.0" + ABCISemVer = "1.3.0" ABCIVersion = ABCISemVer )