From 71a34adfe58e654e36583a5db3b0ad4d78e3c0b3 Mon Sep 17 00:00:00 2001 From: Joon Date: Sat, 29 Sep 2018 09:03:19 +0900 Subject: [PATCH] General Merkle Proof (#2298) * first commit finalize rebase add protoc_merkle to Makefile * in progress * fix kvstore * fix tests * remove iavl dependency * fix tx_test * fix test_abci_cli fix test_apps * fix test_apps * fix test_cover * rm rebase residue * address comment in progress * finalize rebase --- Makefile | 4 +- abci/cmd/abci-cli/abci-cli.go | 5 +- abci/example/code/code.go | 1 + abci/example/kvstore/kvstore.go | 3 +- abci/tests/test_cli/ex1.abci.out | 4 + abci/types/types.pb.go | 817 +++++++++++---------------- abci/types/types.proto | 3 +- abci/types/typespb_test.go | 1 + crypto/merkle/compile.sh | 6 + crypto/merkle/merkle.pb.go | 792 ++++++++++++++++++++++++++ crypto/merkle/merkle.proto | 30 + crypto/merkle/proof.go | 132 +++++ crypto/merkle/proof_key_path.go | 107 ++++ crypto/merkle/proof_key_path_test.go | 41 ++ crypto/merkle/proof_simple_value.go | 91 +++ crypto/merkle/simple_proof.go | 53 +- crypto/merkle/simple_tree_test.go | 59 +- crypto/merkle/wire.go | 12 + docs/app-dev/app-development.md | 68 ++- lite/errors/errors.go | 21 + lite/proxy/proof.go | 14 + lite/proxy/query.go | 128 ++--- lite/proxy/query_test.go | 98 ++-- lite/proxy/wrapper.go | 7 +- rpc/client/httpclient.go | 2 +- rpc/client/localclient.go | 2 +- rpc/client/mock/abci.go | 23 +- rpc/client/mock/abci_test.go | 16 +- rpc/client/mock/client.go | 5 +- rpc/client/rpc_test.go | 14 +- rpc/client/types.go | 9 +- rpc/core/abci.go | 16 +- test/app/kvstore_test.sh | 2 +- types/block.go | 1 - types/part_set.go | 2 +- types/results_test.go | 4 +- types/tx.go | 17 +- types/tx_test.go | 6 +- 38 files changed, 1867 insertions(+), 749 deletions(-) create mode 100644 crypto/merkle/compile.sh create mode 100644 crypto/merkle/merkle.pb.go create mode 100644 crypto/merkle/merkle.proto create mode 100644 crypto/merkle/proof.go create mode 100644 crypto/merkle/proof_key_path.go create mode 100644 crypto/merkle/proof_key_path_test.go create mode 100644 crypto/merkle/proof_simple_value.go create mode 100644 crypto/merkle/wire.go create mode 100644 lite/proxy/proof.go diff --git a/Makefile b/Makefile index ffc72c46..73bd67b0 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ install: ######################################## ### Protobuf -protoc_all: protoc_libs protoc_abci protoc_grpc +protoc_all: protoc_libs protoc_merkle protoc_abci protoc_grpc %.pb.go: %.proto ## If you get the following error, @@ -137,6 +137,8 @@ grpc_dbserver: protoc_grpc: rpc/grpc/types.pb.go +protoc_merkle: crypto/merkle/merkle.pb.go + ######################################## ### Testing diff --git a/abci/cmd/abci-cli/abci-cli.go b/abci/cmd/abci-cli/abci-cli.go index b7b8e7d7..50972ec3 100644 --- a/abci/cmd/abci-cli/abci-cli.go +++ b/abci/cmd/abci-cli/abci-cli.go @@ -22,6 +22,7 @@ import ( servertest "github.com/tendermint/tendermint/abci/tests/server" "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/abci/version" + "github.com/tendermint/tendermint/crypto/merkle" ) // client is a global variable so it can be reused by the console @@ -100,7 +101,7 @@ type queryResponse struct { Key []byte Value []byte Height int64 - Proof []byte + Proof *merkle.Proof } func Execute() error { @@ -748,7 +749,7 @@ func printResponse(cmd *cobra.Command, args []string, rsp response) { fmt.Printf("-> value.hex: %X\n", rsp.Query.Value) } if rsp.Query.Proof != nil { - fmt.Printf("-> proof: %X\n", rsp.Query.Proof) + fmt.Printf("-> proof: %#v\n", rsp.Query.Proof) } } } diff --git a/abci/example/code/code.go b/abci/example/code/code.go index 94e9d015..988b2a93 100644 --- a/abci/example/code/code.go +++ b/abci/example/code/code.go @@ -6,4 +6,5 @@ const ( CodeTypeEncodingError uint32 = 1 CodeTypeBadNonce uint32 = 2 CodeTypeUnauthorized uint32 = 3 + CodeTypeUnknownError uint32 = 4 ) diff --git a/abci/example/kvstore/kvstore.go b/abci/example/kvstore/kvstore.go index c1554cc5..9523bf74 100644 --- a/abci/example/kvstore/kvstore.go +++ b/abci/example/kvstore/kvstore.go @@ -81,7 +81,7 @@ func (app *KVStoreApplication) DeliverTx(tx []byte) types.ResponseDeliverTx { app.state.Size += 1 tags := []cmn.KVPair{ - {Key: []byte("app.creator"), Value: []byte("jae")}, + {Key: []byte("app.creator"), Value: []byte("Cosmoshi Netowoko")}, {Key: []byte("app.key"), Value: key}, } return types.ResponseDeliverTx{Code: code.CodeTypeOK, Tags: tags} @@ -114,6 +114,7 @@ func (app *KVStoreApplication) Query(reqQuery types.RequestQuery) (resQuery type } return } else { + resQuery.Key = reqQuery.Data value := app.state.db.Get(prefixKey(reqQuery.Data)) resQuery.Value = value if value != nil { diff --git a/abci/tests/test_cli/ex1.abci.out b/abci/tests/test_cli/ex1.abci.out index 5d4c196d..0cdd43df 100644 --- a/abci/tests/test_cli/ex1.abci.out +++ b/abci/tests/test_cli/ex1.abci.out @@ -28,6 +28,8 @@ -> code: OK -> log: exists -> height: 0 +-> key: abc +-> key.hex: 616263 -> value: abc -> value.hex: 616263 @@ -42,6 +44,8 @@ -> code: OK -> log: exists -> height: 0 +-> key: def +-> key.hex: 646566 -> value: xyz -> value.hex: 78797A diff --git a/abci/types/types.pb.go b/abci/types/types.pb.go index 3c7f81ab..427315df 100644 --- a/abci/types/types.pb.go +++ b/abci/types/types.pb.go @@ -9,6 +9,7 @@ import fmt "fmt" import math "math" import _ "github.com/gogo/protobuf/gogoproto" import _ "github.com/golang/protobuf/ptypes/timestamp" +import merkle "github.com/tendermint/tendermint/crypto/merkle" import common "github.com/tendermint/tendermint/libs/common" import time "time" @@ -60,7 +61,7 @@ func (m *Request) Reset() { *m = Request{} } func (m *Request) String() string { return proto.CompactTextString(m) } func (*Request) ProtoMessage() {} func (*Request) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{0} + return fileDescriptor_types_03c41ca87033c976, []int{0} } func (m *Request) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -482,7 +483,7 @@ func (m *RequestEcho) Reset() { *m = RequestEcho{} } func (m *RequestEcho) String() string { return proto.CompactTextString(m) } func (*RequestEcho) ProtoMessage() {} func (*RequestEcho) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{1} + return fileDescriptor_types_03c41ca87033c976, []int{1} } func (m *RequestEcho) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -528,7 +529,7 @@ func (m *RequestFlush) Reset() { *m = RequestFlush{} } func (m *RequestFlush) String() string { return proto.CompactTextString(m) } func (*RequestFlush) ProtoMessage() {} func (*RequestFlush) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{2} + return fileDescriptor_types_03c41ca87033c976, []int{2} } func (m *RequestFlush) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -568,7 +569,7 @@ func (m *RequestInfo) Reset() { *m = RequestInfo{} } func (m *RequestInfo) String() string { return proto.CompactTextString(m) } func (*RequestInfo) ProtoMessage() {} func (*RequestInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{3} + return fileDescriptor_types_03c41ca87033c976, []int{3} } func (m *RequestInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -617,7 +618,7 @@ func (m *RequestSetOption) Reset() { *m = RequestSetOption{} } func (m *RequestSetOption) String() string { return proto.CompactTextString(m) } func (*RequestSetOption) ProtoMessage() {} func (*RequestSetOption) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{4} + return fileDescriptor_types_03c41ca87033c976, []int{4} } func (m *RequestSetOption) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -675,7 +676,7 @@ func (m *RequestInitChain) Reset() { *m = RequestInitChain{} } func (m *RequestInitChain) String() string { return proto.CompactTextString(m) } func (*RequestInitChain) ProtoMessage() {} func (*RequestInitChain) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{5} + return fileDescriptor_types_03c41ca87033c976, []int{5} } func (m *RequestInitChain) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -753,7 +754,7 @@ func (m *RequestQuery) Reset() { *m = RequestQuery{} } func (m *RequestQuery) String() string { return proto.CompactTextString(m) } func (*RequestQuery) ProtoMessage() {} func (*RequestQuery) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{6} + return fileDescriptor_types_03c41ca87033c976, []int{6} } func (m *RequestQuery) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -825,7 +826,7 @@ func (m *RequestBeginBlock) Reset() { *m = RequestBeginBlock{} } func (m *RequestBeginBlock) String() string { return proto.CompactTextString(m) } func (*RequestBeginBlock) ProtoMessage() {} func (*RequestBeginBlock) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{7} + return fileDescriptor_types_03c41ca87033c976, []int{7} } func (m *RequestBeginBlock) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -893,7 +894,7 @@ func (m *RequestCheckTx) Reset() { *m = RequestCheckTx{} } func (m *RequestCheckTx) String() string { return proto.CompactTextString(m) } func (*RequestCheckTx) ProtoMessage() {} func (*RequestCheckTx) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{8} + return fileDescriptor_types_03c41ca87033c976, []int{8} } func (m *RequestCheckTx) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -940,7 +941,7 @@ func (m *RequestDeliverTx) Reset() { *m = RequestDeliverTx{} } func (m *RequestDeliverTx) String() string { return proto.CompactTextString(m) } func (*RequestDeliverTx) ProtoMessage() {} func (*RequestDeliverTx) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{9} + return fileDescriptor_types_03c41ca87033c976, []int{9} } func (m *RequestDeliverTx) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -987,7 +988,7 @@ func (m *RequestEndBlock) Reset() { *m = RequestEndBlock{} } func (m *RequestEndBlock) String() string { return proto.CompactTextString(m) } func (*RequestEndBlock) ProtoMessage() {} func (*RequestEndBlock) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{10} + return fileDescriptor_types_03c41ca87033c976, []int{10} } func (m *RequestEndBlock) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1033,7 +1034,7 @@ func (m *RequestCommit) Reset() { *m = RequestCommit{} } func (m *RequestCommit) String() string { return proto.CompactTextString(m) } func (*RequestCommit) ProtoMessage() {} func (*RequestCommit) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{11} + return fileDescriptor_types_03c41ca87033c976, []int{11} } func (m *RequestCommit) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1086,7 +1087,7 @@ func (m *Response) Reset() { *m = Response{} } func (m *Response) String() string { return proto.CompactTextString(m) } func (*Response) ProtoMessage() {} func (*Response) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{12} + return fileDescriptor_types_03c41ca87033c976, []int{12} } func (m *Response) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1539,7 +1540,7 @@ func (m *ResponseException) Reset() { *m = ResponseException{} } func (m *ResponseException) String() string { return proto.CompactTextString(m) } func (*ResponseException) ProtoMessage() {} func (*ResponseException) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{13} + return fileDescriptor_types_03c41ca87033c976, []int{13} } func (m *ResponseException) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1586,7 +1587,7 @@ func (m *ResponseEcho) Reset() { *m = ResponseEcho{} } func (m *ResponseEcho) String() string { return proto.CompactTextString(m) } func (*ResponseEcho) ProtoMessage() {} func (*ResponseEcho) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{14} + return fileDescriptor_types_03c41ca87033c976, []int{14} } func (m *ResponseEcho) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1632,7 +1633,7 @@ func (m *ResponseFlush) Reset() { *m = ResponseFlush{} } func (m *ResponseFlush) String() string { return proto.CompactTextString(m) } func (*ResponseFlush) ProtoMessage() {} func (*ResponseFlush) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{15} + return fileDescriptor_types_03c41ca87033c976, []int{15} } func (m *ResponseFlush) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1675,7 +1676,7 @@ func (m *ResponseInfo) Reset() { *m = ResponseInfo{} } func (m *ResponseInfo) String() string { return proto.CompactTextString(m) } func (*ResponseInfo) ProtoMessage() {} func (*ResponseInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{16} + return fileDescriptor_types_03c41ca87033c976, []int{16} } func (m *ResponseInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1747,7 +1748,7 @@ func (m *ResponseSetOption) Reset() { *m = ResponseSetOption{} } func (m *ResponseSetOption) String() string { return proto.CompactTextString(m) } func (*ResponseSetOption) ProtoMessage() {} func (*ResponseSetOption) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{17} + return fileDescriptor_types_03c41ca87033c976, []int{17} } func (m *ResponseSetOption) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1809,7 +1810,7 @@ func (m *ResponseInitChain) Reset() { *m = ResponseInitChain{} } func (m *ResponseInitChain) String() string { return proto.CompactTextString(m) } func (*ResponseInitChain) ProtoMessage() {} func (*ResponseInitChain) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{18} + return fileDescriptor_types_03c41ca87033c976, []int{18} } func (m *ResponseInitChain) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1855,23 +1856,23 @@ func (m *ResponseInitChain) GetValidators() []ValidatorUpdate { type ResponseQuery struct { Code uint32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` // bytes data = 2; // use "value" instead. - Log string `protobuf:"bytes,3,opt,name=log,proto3" json:"log,omitempty"` - Info string `protobuf:"bytes,4,opt,name=info,proto3" json:"info,omitempty"` - Index int64 `protobuf:"varint,5,opt,name=index,proto3" json:"index,omitempty"` - Key []byte `protobuf:"bytes,6,opt,name=key,proto3" json:"key,omitempty"` - Value []byte `protobuf:"bytes,7,opt,name=value,proto3" json:"value,omitempty"` - Proof []byte `protobuf:"bytes,8,opt,name=proof,proto3" json:"proof,omitempty"` - Height int64 `protobuf:"varint,9,opt,name=height,proto3" json:"height,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Log string `protobuf:"bytes,3,opt,name=log,proto3" json:"log,omitempty"` + Info string `protobuf:"bytes,4,opt,name=info,proto3" json:"info,omitempty"` + Index int64 `protobuf:"varint,5,opt,name=index,proto3" json:"index,omitempty"` + Key []byte `protobuf:"bytes,6,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,7,opt,name=value,proto3" json:"value,omitempty"` + Proof *merkle.Proof `protobuf:"bytes,8,opt,name=proof" json:"proof,omitempty"` + Height int64 `protobuf:"varint,9,opt,name=height,proto3" json:"height,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *ResponseQuery) Reset() { *m = ResponseQuery{} } func (m *ResponseQuery) String() string { return proto.CompactTextString(m) } func (*ResponseQuery) ProtoMessage() {} func (*ResponseQuery) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{19} + return fileDescriptor_types_03c41ca87033c976, []int{19} } func (m *ResponseQuery) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1942,7 +1943,7 @@ func (m *ResponseQuery) GetValue() []byte { return nil } -func (m *ResponseQuery) GetProof() []byte { +func (m *ResponseQuery) GetProof() *merkle.Proof { if m != nil { return m.Proof } @@ -1967,7 +1968,7 @@ func (m *ResponseBeginBlock) Reset() { *m = ResponseBeginBlock{} } func (m *ResponseBeginBlock) String() string { return proto.CompactTextString(m) } func (*ResponseBeginBlock) ProtoMessage() {} func (*ResponseBeginBlock) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{20} + return fileDescriptor_types_03c41ca87033c976, []int{20} } func (m *ResponseBeginBlock) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2020,7 +2021,7 @@ func (m *ResponseCheckTx) Reset() { *m = ResponseCheckTx{} } func (m *ResponseCheckTx) String() string { return proto.CompactTextString(m) } func (*ResponseCheckTx) ProtoMessage() {} func (*ResponseCheckTx) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{21} + return fileDescriptor_types_03c41ca87033c976, []int{21} } func (m *ResponseCheckTx) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2115,7 +2116,7 @@ func (m *ResponseDeliverTx) Reset() { *m = ResponseDeliverTx{} } func (m *ResponseDeliverTx) String() string { return proto.CompactTextString(m) } func (*ResponseDeliverTx) ProtoMessage() {} func (*ResponseDeliverTx) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{22} + return fileDescriptor_types_03c41ca87033c976, []int{22} } func (m *ResponseDeliverTx) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2206,7 +2207,7 @@ func (m *ResponseEndBlock) Reset() { *m = ResponseEndBlock{} } func (m *ResponseEndBlock) String() string { return proto.CompactTextString(m) } func (*ResponseEndBlock) ProtoMessage() {} func (*ResponseEndBlock) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{23} + return fileDescriptor_types_03c41ca87033c976, []int{23} } func (m *ResponseEndBlock) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2268,7 +2269,7 @@ func (m *ResponseCommit) Reset() { *m = ResponseCommit{} } func (m *ResponseCommit) String() string { return proto.CompactTextString(m) } func (*ResponseCommit) ProtoMessage() {} func (*ResponseCommit) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{24} + return fileDescriptor_types_03c41ca87033c976, []int{24} } func (m *ResponseCommit) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2318,7 +2319,7 @@ func (m *ConsensusParams) Reset() { *m = ConsensusParams{} } func (m *ConsensusParams) String() string { return proto.CompactTextString(m) } func (*ConsensusParams) ProtoMessage() {} func (*ConsensusParams) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{25} + return fileDescriptor_types_03c41ca87033c976, []int{25} } func (m *ConsensusParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2376,7 +2377,7 @@ func (m *BlockSize) Reset() { *m = BlockSize{} } func (m *BlockSize) String() string { return proto.CompactTextString(m) } func (*BlockSize) ProtoMessage() {} func (*BlockSize) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{26} + return fileDescriptor_types_03c41ca87033c976, []int{26} } func (m *BlockSize) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2432,7 +2433,7 @@ func (m *EvidenceParams) Reset() { *m = EvidenceParams{} } func (m *EvidenceParams) String() string { return proto.CompactTextString(m) } func (*EvidenceParams) ProtoMessage() {} func (*EvidenceParams) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{27} + return fileDescriptor_types_03c41ca87033c976, []int{27} } func (m *EvidenceParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2480,7 +2481,7 @@ func (m *LastCommitInfo) Reset() { *m = LastCommitInfo{} } func (m *LastCommitInfo) String() string { return proto.CompactTextString(m) } func (*LastCommitInfo) ProtoMessage() {} func (*LastCommitInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{28} + return fileDescriptor_types_03c41ca87033c976, []int{28} } func (m *LastCommitInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2553,7 +2554,7 @@ func (m *Header) Reset() { *m = Header{} } func (m *Header) String() string { return proto.CompactTextString(m) } func (*Header) ProtoMessage() {} func (*Header) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{29} + return fileDescriptor_types_03c41ca87033c976, []int{29} } func (m *Header) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2699,7 +2700,7 @@ func (m *BlockID) Reset() { *m = BlockID{} } func (m *BlockID) String() string { return proto.CompactTextString(m) } func (*BlockID) ProtoMessage() {} func (*BlockID) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{30} + return fileDescriptor_types_03c41ca87033c976, []int{30} } func (m *BlockID) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2754,7 +2755,7 @@ func (m *PartSetHeader) Reset() { *m = PartSetHeader{} } func (m *PartSetHeader) String() string { return proto.CompactTextString(m) } func (*PartSetHeader) ProtoMessage() {} func (*PartSetHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{31} + return fileDescriptor_types_03c41ca87033c976, []int{31} } func (m *PartSetHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2811,7 +2812,7 @@ func (m *Validator) Reset() { *m = Validator{} } func (m *Validator) String() string { return proto.CompactTextString(m) } func (*Validator) ProtoMessage() {} func (*Validator) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{32} + return fileDescriptor_types_03c41ca87033c976, []int{32} } func (m *Validator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2867,7 +2868,7 @@ func (m *ValidatorUpdate) Reset() { *m = ValidatorUpdate{} } func (m *ValidatorUpdate) String() string { return proto.CompactTextString(m) } func (*ValidatorUpdate) ProtoMessage() {} func (*ValidatorUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{33} + return fileDescriptor_types_03c41ca87033c976, []int{33} } func (m *ValidatorUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2923,7 +2924,7 @@ func (m *VoteInfo) Reset() { *m = VoteInfo{} } func (m *VoteInfo) String() string { return proto.CompactTextString(m) } func (*VoteInfo) ProtoMessage() {} func (*VoteInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{34} + return fileDescriptor_types_03c41ca87033c976, []int{34} } func (m *VoteInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2978,7 +2979,7 @@ func (m *PubKey) Reset() { *m = PubKey{} } func (m *PubKey) String() string { return proto.CompactTextString(m) } func (*PubKey) ProtoMessage() {} func (*PubKey) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{35} + return fileDescriptor_types_03c41ca87033c976, []int{35} } func (m *PubKey) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3036,7 +3037,7 @@ func (m *Evidence) Reset() { *m = Evidence{} } func (m *Evidence) String() string { return proto.CompactTextString(m) } func (*Evidence) ProtoMessage() {} func (*Evidence) Descriptor() ([]byte, []int) { - return fileDescriptor_types_8495fed925debe52, []int{36} + return fileDescriptor_types_03c41ca87033c976, []int{36} } func (m *Evidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -4347,7 +4348,7 @@ func (this *ResponseQuery) Equal(that interface{}) bool { if !bytes.Equal(this.Value, that1.Value) { return false } - if !bytes.Equal(this.Proof, that1.Proof) { + if !this.Proof.Equal(that1.Proof) { return false } if this.Height != that1.Height { @@ -6377,11 +6378,15 @@ func (m *ResponseQuery) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintTypes(dAtA, i, uint64(len(m.Value))) i += copy(dAtA[i:], m.Value) } - if len(m.Proof) > 0 { + if m.Proof != nil { dAtA[i] = 0x42 i++ - i = encodeVarintTypes(dAtA, i, uint64(len(m.Proof))) - i += copy(dAtA[i:], m.Proof) + i = encodeVarintTypes(dAtA, i, uint64(m.Proof.Size())) + n31, err := m.Proof.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n31 } if m.Height != 0 { dAtA[i] = 0x48 @@ -6590,11 +6595,11 @@ func (m *ResponseEndBlock) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintTypes(dAtA, i, uint64(m.ConsensusParamUpdates.Size())) - n31, err := m.ConsensusParamUpdates.MarshalTo(dAtA[i:]) + n32, err := m.ConsensusParamUpdates.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n31 + i += n32 } if len(m.Tags) > 0 { for _, msg := range m.Tags { @@ -6660,21 +6665,21 @@ func (m *ConsensusParams) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintTypes(dAtA, i, uint64(m.BlockSize.Size())) - n32, err := m.BlockSize.MarshalTo(dAtA[i:]) + n33, err := m.BlockSize.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n32 + i += n33 } if m.EvidenceParams != nil { dAtA[i] = 0x12 i++ i = encodeVarintTypes(dAtA, i, uint64(m.EvidenceParams.Size())) - n33, err := m.EvidenceParams.MarshalTo(dAtA[i:]) + n34, err := m.EvidenceParams.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n33 + i += n34 } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) @@ -6806,11 +6811,11 @@ func (m *Header) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintTypes(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.Time))) - n34, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i:]) + n35, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i:]) if err != nil { return 0, err } - i += n34 + i += n35 if m.NumTxs != 0 { dAtA[i] = 0x20 i++ @@ -6824,11 +6829,11 @@ func (m *Header) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x32 i++ i = encodeVarintTypes(dAtA, i, uint64(m.LastBlockId.Size())) - n35, err := m.LastBlockId.MarshalTo(dAtA[i:]) + n36, err := m.LastBlockId.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n35 + i += n36 if len(m.LastCommitHash) > 0 { dAtA[i] = 0x3a i++ @@ -6913,11 +6918,11 @@ func (m *BlockID) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintTypes(dAtA, i, uint64(m.PartsHeader.Size())) - n36, err := m.PartsHeader.MarshalTo(dAtA[i:]) + n37, err := m.PartsHeader.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n36 + i += n37 if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) } @@ -7006,11 +7011,11 @@ func (m *ValidatorUpdate) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintTypes(dAtA, i, uint64(m.PubKey.Size())) - n37, err := m.PubKey.MarshalTo(dAtA[i:]) + n38, err := m.PubKey.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n37 + i += n38 if m.Power != 0 { dAtA[i] = 0x10 i++ @@ -7040,11 +7045,11 @@ func (m *VoteInfo) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintTypes(dAtA, i, uint64(m.Validator.Size())) - n38, err := m.Validator.MarshalTo(dAtA[i:]) + n39, err := m.Validator.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n38 + i += n39 if m.SignedLastBlock { dAtA[i] = 0x10 i++ @@ -7118,11 +7123,11 @@ func (m *Evidence) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintTypes(dAtA, i, uint64(m.Validator.Size())) - n39, err := m.Validator.MarshalTo(dAtA[i:]) + n40, err := m.Validator.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n39 + i += n40 if m.Height != 0 { dAtA[i] = 0x18 i++ @@ -7131,11 +7136,11 @@ func (m *Evidence) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x22 i++ i = encodeVarintTypes(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.Time))) - n40, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i:]) + n41, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i:]) if err != nil { return 0, err } - i += n40 + i += n41 if m.TotalVotingPower != 0 { dAtA[i] = 0x28 i++ @@ -7586,10 +7591,8 @@ func NewPopulatedResponseQuery(r randyTypes, easy bool) *ResponseQuery { for i := 0; i < v17; i++ { this.Value[i] = byte(r.Intn(256)) } - v18 := r.Intn(100) - this.Proof = make([]byte, v18) - for i := 0; i < v18; i++ { - this.Proof[i] = byte(r.Intn(256)) + if r.Intn(10) != 0 { + this.Proof = merkle.NewPopulatedProof(r, easy) } this.Height = int64(r.Int63()) if r.Intn(2) == 0 { @@ -7604,11 +7607,11 @@ func NewPopulatedResponseQuery(r randyTypes, easy bool) *ResponseQuery { func NewPopulatedResponseBeginBlock(r randyTypes, easy bool) *ResponseBeginBlock { this := &ResponseBeginBlock{} if r.Intn(10) != 0 { - v19 := r.Intn(5) - this.Tags = make([]common.KVPair, v19) - for i := 0; i < v19; i++ { - v20 := common.NewPopulatedKVPair(r, easy) - this.Tags[i] = *v20 + v18 := r.Intn(5) + this.Tags = make([]common.KVPair, v18) + for i := 0; i < v18; i++ { + v19 := common.NewPopulatedKVPair(r, easy) + this.Tags[i] = *v19 } } if !easy && r.Intn(10) != 0 { @@ -7620,9 +7623,9 @@ func NewPopulatedResponseBeginBlock(r randyTypes, easy bool) *ResponseBeginBlock func NewPopulatedResponseCheckTx(r randyTypes, easy bool) *ResponseCheckTx { this := &ResponseCheckTx{} this.Code = uint32(r.Uint32()) - v21 := r.Intn(100) - this.Data = make([]byte, v21) - for i := 0; i < v21; i++ { + v20 := r.Intn(100) + this.Data = make([]byte, v20) + for i := 0; i < v20; i++ { this.Data[i] = byte(r.Intn(256)) } this.Log = string(randStringTypes(r)) @@ -7636,11 +7639,11 @@ func NewPopulatedResponseCheckTx(r randyTypes, easy bool) *ResponseCheckTx { this.GasUsed *= -1 } if r.Intn(10) != 0 { - v22 := r.Intn(5) - this.Tags = make([]common.KVPair, v22) - for i := 0; i < v22; i++ { - v23 := common.NewPopulatedKVPair(r, easy) - this.Tags[i] = *v23 + v21 := r.Intn(5) + this.Tags = make([]common.KVPair, v21) + for i := 0; i < v21; i++ { + v22 := common.NewPopulatedKVPair(r, easy) + this.Tags[i] = *v22 } } if !easy && r.Intn(10) != 0 { @@ -7652,9 +7655,9 @@ func NewPopulatedResponseCheckTx(r randyTypes, easy bool) *ResponseCheckTx { func NewPopulatedResponseDeliverTx(r randyTypes, easy bool) *ResponseDeliverTx { this := &ResponseDeliverTx{} this.Code = uint32(r.Uint32()) - v24 := r.Intn(100) - this.Data = make([]byte, v24) - for i := 0; i < v24; i++ { + v23 := r.Intn(100) + this.Data = make([]byte, v23) + for i := 0; i < v23; i++ { this.Data[i] = byte(r.Intn(256)) } this.Log = string(randStringTypes(r)) @@ -7668,11 +7671,11 @@ func NewPopulatedResponseDeliverTx(r randyTypes, easy bool) *ResponseDeliverTx { this.GasUsed *= -1 } if r.Intn(10) != 0 { - v25 := r.Intn(5) - this.Tags = make([]common.KVPair, v25) - for i := 0; i < v25; i++ { - v26 := common.NewPopulatedKVPair(r, easy) - this.Tags[i] = *v26 + v24 := r.Intn(5) + this.Tags = make([]common.KVPair, v24) + for i := 0; i < v24; i++ { + v25 := common.NewPopulatedKVPair(r, easy) + this.Tags[i] = *v25 } } if !easy && r.Intn(10) != 0 { @@ -7684,22 +7687,22 @@ func NewPopulatedResponseDeliverTx(r randyTypes, easy bool) *ResponseDeliverTx { func NewPopulatedResponseEndBlock(r randyTypes, easy bool) *ResponseEndBlock { this := &ResponseEndBlock{} if r.Intn(10) != 0 { - v27 := r.Intn(5) - this.ValidatorUpdates = make([]ValidatorUpdate, v27) - for i := 0; i < v27; i++ { - v28 := NewPopulatedValidatorUpdate(r, easy) - this.ValidatorUpdates[i] = *v28 + v26 := r.Intn(5) + this.ValidatorUpdates = make([]ValidatorUpdate, v26) + for i := 0; i < v26; i++ { + v27 := NewPopulatedValidatorUpdate(r, easy) + this.ValidatorUpdates[i] = *v27 } } if r.Intn(10) != 0 { this.ConsensusParamUpdates = NewPopulatedConsensusParams(r, easy) } if r.Intn(10) != 0 { - v29 := r.Intn(5) - this.Tags = make([]common.KVPair, v29) - for i := 0; i < v29; i++ { - v30 := common.NewPopulatedKVPair(r, easy) - this.Tags[i] = *v30 + v28 := r.Intn(5) + this.Tags = make([]common.KVPair, v28) + for i := 0; i < v28; i++ { + v29 := common.NewPopulatedKVPair(r, easy) + this.Tags[i] = *v29 } } if !easy && r.Intn(10) != 0 { @@ -7710,9 +7713,9 @@ func NewPopulatedResponseEndBlock(r randyTypes, easy bool) *ResponseEndBlock { func NewPopulatedResponseCommit(r randyTypes, easy bool) *ResponseCommit { this := &ResponseCommit{} - v31 := r.Intn(100) - this.Data = make([]byte, v31) - for i := 0; i < v31; i++ { + v30 := r.Intn(100) + this.Data = make([]byte, v30) + for i := 0; i < v30; i++ { this.Data[i] = byte(r.Intn(256)) } if !easy && r.Intn(10) != 0 { @@ -7770,11 +7773,11 @@ func NewPopulatedLastCommitInfo(r randyTypes, easy bool) *LastCommitInfo { this.Round *= -1 } if r.Intn(10) != 0 { - v32 := r.Intn(5) - this.Votes = make([]VoteInfo, v32) - for i := 0; i < v32; i++ { - v33 := NewPopulatedVoteInfo(r, easy) - this.Votes[i] = *v33 + v31 := r.Intn(5) + this.Votes = make([]VoteInfo, v31) + for i := 0; i < v31; i++ { + v32 := NewPopulatedVoteInfo(r, easy) + this.Votes[i] = *v32 } } if !easy && r.Intn(10) != 0 { @@ -7790,8 +7793,8 @@ func NewPopulatedHeader(r randyTypes, easy bool) *Header { if r.Intn(2) == 0 { this.Height *= -1 } - v34 := github_com_gogo_protobuf_types.NewPopulatedStdTime(r, easy) - this.Time = *v34 + v33 := github_com_gogo_protobuf_types.NewPopulatedStdTime(r, easy) + this.Time = *v33 this.NumTxs = int64(r.Int63()) if r.Intn(2) == 0 { this.NumTxs *= -1 @@ -7800,51 +7803,51 @@ func NewPopulatedHeader(r randyTypes, easy bool) *Header { if r.Intn(2) == 0 { this.TotalTxs *= -1 } - v35 := NewPopulatedBlockID(r, easy) - this.LastBlockId = *v35 - v36 := r.Intn(100) - this.LastCommitHash = make([]byte, v36) - for i := 0; i < v36; i++ { + v34 := NewPopulatedBlockID(r, easy) + this.LastBlockId = *v34 + v35 := r.Intn(100) + this.LastCommitHash = make([]byte, v35) + for i := 0; i < v35; i++ { this.LastCommitHash[i] = byte(r.Intn(256)) } - v37 := r.Intn(100) - this.DataHash = make([]byte, v37) - for i := 0; i < v37; i++ { + v36 := r.Intn(100) + this.DataHash = make([]byte, v36) + for i := 0; i < v36; i++ { this.DataHash[i] = byte(r.Intn(256)) } - v38 := r.Intn(100) - this.ValidatorsHash = make([]byte, v38) - for i := 0; i < v38; i++ { + v37 := r.Intn(100) + this.ValidatorsHash = make([]byte, v37) + for i := 0; i < v37; i++ { this.ValidatorsHash[i] = byte(r.Intn(256)) } - v39 := r.Intn(100) - this.NextValidatorsHash = make([]byte, v39) - for i := 0; i < v39; i++ { + v38 := r.Intn(100) + this.NextValidatorsHash = make([]byte, v38) + for i := 0; i < v38; i++ { this.NextValidatorsHash[i] = byte(r.Intn(256)) } - v40 := r.Intn(100) - this.ConsensusHash = make([]byte, v40) - for i := 0; i < v40; i++ { + v39 := r.Intn(100) + this.ConsensusHash = make([]byte, v39) + for i := 0; i < v39; i++ { this.ConsensusHash[i] = byte(r.Intn(256)) } - v41 := r.Intn(100) - this.AppHash = make([]byte, v41) - for i := 0; i < v41; i++ { + v40 := r.Intn(100) + this.AppHash = make([]byte, v40) + for i := 0; i < v40; i++ { this.AppHash[i] = byte(r.Intn(256)) } - v42 := r.Intn(100) - this.LastResultsHash = make([]byte, v42) - for i := 0; i < v42; i++ { + v41 := r.Intn(100) + this.LastResultsHash = make([]byte, v41) + for i := 0; i < v41; i++ { this.LastResultsHash[i] = byte(r.Intn(256)) } - v43 := r.Intn(100) - this.EvidenceHash = make([]byte, v43) - for i := 0; i < v43; i++ { + v42 := r.Intn(100) + this.EvidenceHash = make([]byte, v42) + for i := 0; i < v42; i++ { this.EvidenceHash[i] = byte(r.Intn(256)) } - v44 := r.Intn(100) - this.ProposerAddress = make([]byte, v44) - for i := 0; i < v44; i++ { + v43 := r.Intn(100) + this.ProposerAddress = make([]byte, v43) + for i := 0; i < v43; i++ { this.ProposerAddress[i] = byte(r.Intn(256)) } if !easy && r.Intn(10) != 0 { @@ -7855,13 +7858,13 @@ func NewPopulatedHeader(r randyTypes, easy bool) *Header { func NewPopulatedBlockID(r randyTypes, easy bool) *BlockID { this := &BlockID{} - v45 := r.Intn(100) - this.Hash = make([]byte, v45) - for i := 0; i < v45; i++ { + v44 := r.Intn(100) + this.Hash = make([]byte, v44) + for i := 0; i < v44; i++ { this.Hash[i] = byte(r.Intn(256)) } - v46 := NewPopulatedPartSetHeader(r, easy) - this.PartsHeader = *v46 + v45 := NewPopulatedPartSetHeader(r, easy) + this.PartsHeader = *v45 if !easy && r.Intn(10) != 0 { this.XXX_unrecognized = randUnrecognizedTypes(r, 3) } @@ -7874,9 +7877,9 @@ func NewPopulatedPartSetHeader(r randyTypes, easy bool) *PartSetHeader { if r.Intn(2) == 0 { this.Total *= -1 } - v47 := r.Intn(100) - this.Hash = make([]byte, v47) - for i := 0; i < v47; i++ { + v46 := r.Intn(100) + this.Hash = make([]byte, v46) + for i := 0; i < v46; i++ { this.Hash[i] = byte(r.Intn(256)) } if !easy && r.Intn(10) != 0 { @@ -7887,9 +7890,9 @@ func NewPopulatedPartSetHeader(r randyTypes, easy bool) *PartSetHeader { func NewPopulatedValidator(r randyTypes, easy bool) *Validator { this := &Validator{} - v48 := r.Intn(100) - this.Address = make([]byte, v48) - for i := 0; i < v48; i++ { + v47 := r.Intn(100) + this.Address = make([]byte, v47) + for i := 0; i < v47; i++ { this.Address[i] = byte(r.Intn(256)) } this.Power = int64(r.Int63()) @@ -7904,8 +7907,8 @@ func NewPopulatedValidator(r randyTypes, easy bool) *Validator { func NewPopulatedValidatorUpdate(r randyTypes, easy bool) *ValidatorUpdate { this := &ValidatorUpdate{} - v49 := NewPopulatedPubKey(r, easy) - this.PubKey = *v49 + v48 := NewPopulatedPubKey(r, easy) + this.PubKey = *v48 this.Power = int64(r.Int63()) if r.Intn(2) == 0 { this.Power *= -1 @@ -7918,8 +7921,8 @@ func NewPopulatedValidatorUpdate(r randyTypes, easy bool) *ValidatorUpdate { func NewPopulatedVoteInfo(r randyTypes, easy bool) *VoteInfo { this := &VoteInfo{} - v50 := NewPopulatedValidator(r, easy) - this.Validator = *v50 + v49 := NewPopulatedValidator(r, easy) + this.Validator = *v49 this.SignedLastBlock = bool(bool(r.Intn(2) == 0)) if !easy && r.Intn(10) != 0 { this.XXX_unrecognized = randUnrecognizedTypes(r, 3) @@ -7930,9 +7933,9 @@ func NewPopulatedVoteInfo(r randyTypes, easy bool) *VoteInfo { func NewPopulatedPubKey(r randyTypes, easy bool) *PubKey { this := &PubKey{} this.Type = string(randStringTypes(r)) - v51 := r.Intn(100) - this.Data = make([]byte, v51) - for i := 0; i < v51; i++ { + v50 := r.Intn(100) + this.Data = make([]byte, v50) + for i := 0; i < v50; i++ { this.Data[i] = byte(r.Intn(256)) } if !easy && r.Intn(10) != 0 { @@ -7944,14 +7947,14 @@ func NewPopulatedPubKey(r randyTypes, easy bool) *PubKey { func NewPopulatedEvidence(r randyTypes, easy bool) *Evidence { this := &Evidence{} this.Type = string(randStringTypes(r)) - v52 := NewPopulatedValidator(r, easy) - this.Validator = *v52 + v51 := NewPopulatedValidator(r, easy) + this.Validator = *v51 this.Height = int64(r.Int63()) if r.Intn(2) == 0 { this.Height *= -1 } - v53 := github_com_gogo_protobuf_types.NewPopulatedStdTime(r, easy) - this.Time = *v53 + v52 := github_com_gogo_protobuf_types.NewPopulatedStdTime(r, easy) + this.Time = *v52 this.TotalVotingPower = int64(r.Int63()) if r.Intn(2) == 0 { this.TotalVotingPower *= -1 @@ -7981,9 +7984,9 @@ func randUTF8RuneTypes(r randyTypes) rune { return rune(ru + 61) } func randStringTypes(r randyTypes) string { - v54 := r.Intn(100) - tmps := make([]rune, v54) - for i := 0; i < v54; i++ { + v53 := r.Intn(100) + tmps := make([]rune, v53) + for i := 0; i < v53; i++ { tmps[i] = randUTF8RuneTypes(r) } return string(tmps) @@ -8005,11 +8008,11 @@ func randFieldTypes(dAtA []byte, r randyTypes, fieldNumber int, wire int) []byte switch wire { case 0: dAtA = encodeVarintPopulateTypes(dAtA, uint64(key)) - v55 := r.Int63() + v54 := r.Int63() if r.Intn(2) == 0 { - v55 *= -1 + v54 *= -1 } - dAtA = encodeVarintPopulateTypes(dAtA, uint64(v55)) + dAtA = encodeVarintPopulateTypes(dAtA, uint64(v54)) case 1: dAtA = encodeVarintPopulateTypes(dAtA, uint64(key)) dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) @@ -8035,9 +8038,6 @@ func encodeVarintPopulateTypes(dAtA []byte, v uint64) []byte { return dAtA } func (m *Request) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Value != nil { @@ -8050,9 +8050,6 @@ func (m *Request) Size() (n int) { } func (m *Request_Echo) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Echo != nil { @@ -8062,9 +8059,6 @@ func (m *Request_Echo) Size() (n int) { return n } func (m *Request_Flush) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Flush != nil { @@ -8074,9 +8068,6 @@ func (m *Request_Flush) Size() (n int) { return n } func (m *Request_Info) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Info != nil { @@ -8086,9 +8077,6 @@ func (m *Request_Info) Size() (n int) { return n } func (m *Request_SetOption) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.SetOption != nil { @@ -8098,9 +8086,6 @@ func (m *Request_SetOption) Size() (n int) { return n } func (m *Request_InitChain) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.InitChain != nil { @@ -8110,9 +8095,6 @@ func (m *Request_InitChain) Size() (n int) { return n } func (m *Request_Query) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Query != nil { @@ -8122,9 +8104,6 @@ func (m *Request_Query) Size() (n int) { return n } func (m *Request_BeginBlock) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.BeginBlock != nil { @@ -8134,9 +8113,6 @@ func (m *Request_BeginBlock) Size() (n int) { return n } func (m *Request_CheckTx) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.CheckTx != nil { @@ -8146,9 +8122,6 @@ func (m *Request_CheckTx) Size() (n int) { return n } func (m *Request_EndBlock) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.EndBlock != nil { @@ -8158,9 +8131,6 @@ func (m *Request_EndBlock) Size() (n int) { return n } func (m *Request_Commit) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Commit != nil { @@ -8170,9 +8140,6 @@ func (m *Request_Commit) Size() (n int) { return n } func (m *Request_DeliverTx) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.DeliverTx != nil { @@ -8182,9 +8149,6 @@ func (m *Request_DeliverTx) Size() (n int) { return n } func (m *RequestEcho) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Message) @@ -8198,9 +8162,6 @@ func (m *RequestEcho) Size() (n int) { } func (m *RequestFlush) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.XXX_unrecognized != nil { @@ -8210,9 +8171,6 @@ func (m *RequestFlush) Size() (n int) { } func (m *RequestInfo) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Version) @@ -8226,9 +8184,6 @@ func (m *RequestInfo) Size() (n int) { } func (m *RequestSetOption) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Key) @@ -8246,9 +8201,6 @@ func (m *RequestSetOption) Size() (n int) { } func (m *RequestInitChain) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Time) @@ -8278,9 +8230,6 @@ func (m *RequestInitChain) Size() (n int) { } func (m *RequestQuery) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Data) @@ -8304,9 +8253,6 @@ func (m *RequestQuery) Size() (n int) { } func (m *RequestBeginBlock) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Hash) @@ -8330,9 +8276,6 @@ func (m *RequestBeginBlock) Size() (n int) { } func (m *RequestCheckTx) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Tx) @@ -8346,9 +8289,6 @@ func (m *RequestCheckTx) Size() (n int) { } func (m *RequestDeliverTx) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Tx) @@ -8362,9 +8302,6 @@ func (m *RequestDeliverTx) Size() (n int) { } func (m *RequestEndBlock) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Height != 0 { @@ -8377,9 +8314,6 @@ func (m *RequestEndBlock) Size() (n int) { } func (m *RequestCommit) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.XXX_unrecognized != nil { @@ -8389,9 +8323,6 @@ func (m *RequestCommit) Size() (n int) { } func (m *Response) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Value != nil { @@ -8404,9 +8335,6 @@ func (m *Response) Size() (n int) { } func (m *Response_Exception) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Exception != nil { @@ -8416,9 +8344,6 @@ func (m *Response_Exception) Size() (n int) { return n } func (m *Response_Echo) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Echo != nil { @@ -8428,9 +8353,6 @@ func (m *Response_Echo) Size() (n int) { return n } func (m *Response_Flush) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Flush != nil { @@ -8440,9 +8362,6 @@ func (m *Response_Flush) Size() (n int) { return n } func (m *Response_Info) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Info != nil { @@ -8452,9 +8371,6 @@ func (m *Response_Info) Size() (n int) { return n } func (m *Response_SetOption) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.SetOption != nil { @@ -8464,9 +8380,6 @@ func (m *Response_SetOption) Size() (n int) { return n } func (m *Response_InitChain) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.InitChain != nil { @@ -8476,9 +8389,6 @@ func (m *Response_InitChain) Size() (n int) { return n } func (m *Response_Query) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Query != nil { @@ -8488,9 +8398,6 @@ func (m *Response_Query) Size() (n int) { return n } func (m *Response_BeginBlock) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.BeginBlock != nil { @@ -8500,9 +8407,6 @@ func (m *Response_BeginBlock) Size() (n int) { return n } func (m *Response_CheckTx) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.CheckTx != nil { @@ -8512,9 +8416,6 @@ func (m *Response_CheckTx) Size() (n int) { return n } func (m *Response_DeliverTx) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.DeliverTx != nil { @@ -8524,9 +8425,6 @@ func (m *Response_DeliverTx) Size() (n int) { return n } func (m *Response_EndBlock) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.EndBlock != nil { @@ -8536,9 +8434,6 @@ func (m *Response_EndBlock) Size() (n int) { return n } func (m *Response_Commit) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Commit != nil { @@ -8548,9 +8443,6 @@ func (m *Response_Commit) Size() (n int) { return n } func (m *ResponseException) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Error) @@ -8564,9 +8456,6 @@ func (m *ResponseException) Size() (n int) { } func (m *ResponseEcho) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Message) @@ -8580,9 +8469,6 @@ func (m *ResponseEcho) Size() (n int) { } func (m *ResponseFlush) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.XXX_unrecognized != nil { @@ -8592,9 +8478,6 @@ func (m *ResponseFlush) Size() (n int) { } func (m *ResponseInfo) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Data) @@ -8619,9 +8502,6 @@ func (m *ResponseInfo) Size() (n int) { } func (m *ResponseSetOption) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Code != 0 { @@ -8642,9 +8522,6 @@ func (m *ResponseSetOption) Size() (n int) { } func (m *ResponseInitChain) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.ConsensusParams != nil { @@ -8664,9 +8541,6 @@ func (m *ResponseInitChain) Size() (n int) { } func (m *ResponseQuery) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Code != 0 { @@ -8691,8 +8565,8 @@ func (m *ResponseQuery) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } - l = len(m.Proof) - if l > 0 { + if m.Proof != nil { + l = m.Proof.Size() n += 1 + l + sovTypes(uint64(l)) } if m.Height != 0 { @@ -8705,9 +8579,6 @@ func (m *ResponseQuery) Size() (n int) { } func (m *ResponseBeginBlock) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if len(m.Tags) > 0 { @@ -8723,9 +8594,6 @@ func (m *ResponseBeginBlock) Size() (n int) { } func (m *ResponseCheckTx) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Code != 0 { @@ -8762,9 +8630,6 @@ func (m *ResponseCheckTx) Size() (n int) { } func (m *ResponseDeliverTx) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Code != 0 { @@ -8801,9 +8666,6 @@ func (m *ResponseDeliverTx) Size() (n int) { } func (m *ResponseEndBlock) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if len(m.ValidatorUpdates) > 0 { @@ -8829,9 +8691,6 @@ func (m *ResponseEndBlock) Size() (n int) { } func (m *ResponseCommit) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Data) @@ -8845,9 +8704,6 @@ func (m *ResponseCommit) Size() (n int) { } func (m *ConsensusParams) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.BlockSize != nil { @@ -8865,9 +8721,6 @@ func (m *ConsensusParams) Size() (n int) { } func (m *BlockSize) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.MaxBytes != 0 { @@ -8883,9 +8736,6 @@ func (m *BlockSize) Size() (n int) { } func (m *EvidenceParams) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.MaxAge != 0 { @@ -8898,9 +8748,6 @@ func (m *EvidenceParams) Size() (n int) { } func (m *LastCommitInfo) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Round != 0 { @@ -8919,9 +8766,6 @@ func (m *LastCommitInfo) Size() (n int) { } func (m *Header) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.ChainID) @@ -8984,9 +8828,6 @@ func (m *Header) Size() (n int) { } func (m *BlockID) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Hash) @@ -9002,9 +8843,6 @@ func (m *BlockID) Size() (n int) { } func (m *PartSetHeader) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l if m.Total != 0 { @@ -9021,9 +8859,6 @@ func (m *PartSetHeader) Size() (n int) { } func (m *Validator) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Address) @@ -9040,9 +8875,6 @@ func (m *Validator) Size() (n int) { } func (m *ValidatorUpdate) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = m.PubKey.Size() @@ -9057,9 +8889,6 @@ func (m *ValidatorUpdate) Size() (n int) { } func (m *VoteInfo) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = m.Validator.Size() @@ -9074,9 +8903,6 @@ func (m *VoteInfo) Size() (n int) { } func (m *PubKey) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Type) @@ -9094,9 +8920,6 @@ func (m *PubKey) Size() (n int) { } func (m *Evidence) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Type) @@ -11907,7 +11730,7 @@ func (m *ResponseQuery) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -11917,21 +11740,23 @@ func (m *ResponseQuery) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= (int(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex > l { return io.ErrUnexpectedEOF } - m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) if m.Proof == nil { - m.Proof = []byte{} + m.Proof = &merkle.Proof{} + } + if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 9: @@ -14503,140 +14328,142 @@ var ( ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("abci/types/types.proto", fileDescriptor_types_8495fed925debe52) } +func init() { proto.RegisterFile("abci/types/types.proto", fileDescriptor_types_03c41ca87033c976) } func init() { - golang_proto.RegisterFile("abci/types/types.proto", fileDescriptor_types_8495fed925debe52) + golang_proto.RegisterFile("abci/types/types.proto", fileDescriptor_types_03c41ca87033c976) } -var fileDescriptor_types_8495fed925debe52 = []byte{ - // 2062 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0x4f, 0x6f, 0x23, 0x49, - 0x15, 0x4f, 0xdb, 0x8e, 0xed, 0x7e, 0x49, 0xec, 0x4c, 0x25, 0x93, 0x78, 0x0c, 0x24, 0xa3, 0x06, - 0x76, 0x13, 0x36, 0x9b, 0xac, 0xb2, 0x2c, 0xca, 0xec, 0x2c, 0x2b, 0xc5, 0x33, 0x03, 0x89, 0x76, - 0x81, 0xd0, 0x33, 0x13, 0x2e, 0x48, 0xad, 0xb2, 0xbb, 0x62, 0xb7, 0xc6, 0xee, 0xee, 0xed, 0x2e, - 0x67, 0x9d, 0x39, 0x72, 0xde, 0xc3, 0x1e, 0x90, 0xf8, 0x0a, 0x7c, 0x01, 0x24, 0x8e, 0x9c, 0xd0, - 0x1e, 0x11, 0x02, 0x71, 0x1b, 0x20, 0x88, 0x03, 0x7c, 0x02, 0x8e, 0xa8, 0x5e, 0x55, 0xf5, 0xbf, - 0xb4, 0x47, 0x33, 0xc3, 0x8d, 0x4b, 0xab, 0xab, 0xde, 0x7b, 0x55, 0xf5, 0x5e, 0xbd, 0xf7, 0x7e, - 0xef, 0x15, 0x6c, 0xd0, 0xfe, 0xc0, 0x3b, 0xe0, 0x57, 0x21, 0x8b, 0xe5, 0x77, 0x3f, 0x8c, 0x02, - 0x1e, 0x90, 0x45, 0x1c, 0x74, 0xdf, 0x1d, 0x7a, 0x7c, 0x34, 0xed, 0xef, 0x0f, 0x82, 0xc9, 0xc1, - 0x30, 0x18, 0x06, 0x07, 0x48, 0xed, 0x4f, 0x2f, 0x70, 0x84, 0x03, 0xfc, 0x93, 0x52, 0xdd, 0xed, - 0x61, 0x10, 0x0c, 0xc7, 0x2c, 0xe5, 0xe2, 0xde, 0x84, 0xc5, 0x9c, 0x4e, 0x42, 0xc5, 0x70, 0x94, - 0x59, 0x8f, 0x33, 0xdf, 0x65, 0xd1, 0xc4, 0xf3, 0x79, 0xf6, 0x77, 0xec, 0xf5, 0xe3, 0x83, 0x41, - 0x30, 0x99, 0x04, 0x7e, 0xf6, 0x40, 0xd6, 0xef, 0x6b, 0xd0, 0xb0, 0xd9, 0x67, 0x53, 0x16, 0x73, - 0xb2, 0x03, 0x35, 0x36, 0x18, 0x05, 0x9d, 0xca, 0x5d, 0x63, 0x67, 0xe9, 0x90, 0xec, 0x4b, 0x3e, - 0x45, 0x7d, 0x34, 0x18, 0x05, 0x27, 0x0b, 0x36, 0x72, 0x90, 0x77, 0x60, 0xf1, 0x62, 0x3c, 0x8d, - 0x47, 0x9d, 0x2a, 0xb2, 0xae, 0xe5, 0x59, 0x7f, 0x20, 0x48, 0x27, 0x0b, 0xb6, 0xe4, 0x11, 0xcb, - 0x7a, 0xfe, 0x45, 0xd0, 0xa9, 0x95, 0x2d, 0x7b, 0xea, 0x5f, 0xe0, 0xb2, 0x82, 0x83, 0x1c, 0x01, - 0xc4, 0x8c, 0x3b, 0x41, 0xc8, 0xbd, 0xc0, 0xef, 0x2c, 0x22, 0xff, 0x66, 0x9e, 0xff, 0x31, 0xe3, - 0x3f, 0x41, 0xf2, 0xc9, 0x82, 0x6d, 0xc6, 0x7a, 0x20, 0x24, 0x3d, 0xdf, 0xe3, 0xce, 0x60, 0x44, - 0x3d, 0xbf, 0x53, 0x2f, 0x93, 0x3c, 0xf5, 0x3d, 0xfe, 0x40, 0x90, 0x85, 0xa4, 0xa7, 0x07, 0x42, - 0x95, 0xcf, 0xa6, 0x2c, 0xba, 0xea, 0x34, 0xca, 0x54, 0xf9, 0xa9, 0x20, 0x09, 0x55, 0x90, 0x87, - 0xdc, 0x87, 0xa5, 0x3e, 0x1b, 0x7a, 0xbe, 0xd3, 0x1f, 0x07, 0x83, 0x67, 0x9d, 0x26, 0x8a, 0x74, - 0xf2, 0x22, 0x3d, 0xc1, 0xd0, 0x13, 0xf4, 0x93, 0x05, 0x1b, 0xfa, 0xc9, 0x88, 0x1c, 0x42, 0x73, - 0x30, 0x62, 0x83, 0x67, 0x0e, 0x9f, 0x75, 0x4c, 0x94, 0xbc, 0x9d, 0x97, 0x7c, 0x20, 0xa8, 0x4f, - 0x66, 0x27, 0x0b, 0x76, 0x63, 0x20, 0x7f, 0xc9, 0x07, 0x60, 0x32, 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0xd5, 0x41, 0xe0, 0xc7, 0xcc, 0x8f, 0xa7, 0xb1, 0x13, 0xd2, 0x88, 0x4e, 0x62, 0x15, 0x25, - 0xfa, 0xe2, 0x1e, 0x68, 0xf2, 0x19, 0x52, 0xed, 0xf6, 0x20, 0x3f, 0x41, 0x3e, 0x02, 0xb8, 0xa4, - 0x63, 0xcf, 0xa5, 0x3c, 0x88, 0xe2, 0x4e, 0xed, 0x6e, 0x35, 0x23, 0x7c, 0xae, 0x09, 0x4f, 0x43, - 0x97, 0x72, 0xd6, 0xab, 0x89, 0x93, 0xd9, 0x19, 0x7e, 0xf2, 0x16, 0xb4, 0x69, 0x18, 0x3a, 0x31, - 0xa7, 0x9c, 0x39, 0xfd, 0x2b, 0xce, 0x62, 0x8c, 0xa4, 0x65, 0x7b, 0x85, 0x86, 0xe1, 0x63, 0x31, - 0xdb, 0x13, 0x93, 0x96, 0x9b, 0xdc, 0x03, 0x3a, 0x39, 0x21, 0x50, 0x73, 0x29, 0xa7, 0x68, 0x8d, - 0x65, 0x1b, 0xff, 0xc5, 0x5c, 0x48, 0xf9, 0x48, 0xe9, 0x88, 0xff, 0x64, 0x03, 0xea, 0x23, 0xe6, - 0x0d, 0x47, 0x1c, 0xd5, 0xaa, 0xda, 0x6a, 0x24, 0x0c, 0x1f, 0x46, 0xc1, 0x25, 0xc3, 0x38, 0x6f, - 0xda, 0x72, 0x60, 0xfd, 0xd3, 0x80, 0x5b, 0x37, 0x02, 0x43, 0xac, 0x3b, 0xa2, 0xf1, 0x48, 0xef, - 0x25, 0xfe, 0xc9, 0x3b, 0x62, 0x5d, 0xea, 0xb2, 0x48, 0xe5, 0x9f, 0x15, 0xa5, 0xf1, 0x09, 0x4e, - 0x2a, 0x45, 0x15, 0x0b, 0x79, 0x04, 0xab, 0x63, 0x1a, 0x73, 0x47, 0xfa, 0xaf, 0x83, 0xf9, 0xa5, - 0x9a, 0x8b, 0xa9, 0x4f, 0xa9, 0xf6, 0x73, 0xe1, 0x56, 0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- 0x37, 0x71, 0x64, 0xb3, 0x78, 0xb5, 0x65, 0x40, 0x72, 0x50, 0x00, 0x92, 0xdb, 0xc5, 0x53, 0x16, - 0x90, 0x24, 0xc5, 0x83, 0x5d, 0x11, 0xf7, 0x05, 0x4f, 0x13, 0x39, 0x82, 0x45, 0x51, 0x10, 0xa9, - 0x84, 0x2d, 0x07, 0xd6, 0x8e, 0xc8, 0x44, 0xa9, 0x7f, 0xbd, 0x04, 0x3b, 0xd0, 0xe9, 0x33, 0xde, - 0x65, 0xfd, 0xca, 0x48, 0x65, 0x31, 0xa2, 0xb3, 0x59, 0xcc, 0x54, 0x59, 0x2c, 0x03, 0x29, 0x95, - 0x1c, 0xa4, 0x90, 0xef, 0xc0, 0x2d, 0x4c, 0x23, 0x68, 0x17, 0x27, 0x97, 0xd6, 0xda, 0x82, 0x20, - 0x0d, 0x22, 0xf3, 0xdb, 0xbb, 0xb0, 0x96, 0xe1, 0x15, 0x29, 0x16, 0x53, 0x58, 0x0d, 0x83, 0x77, - 0x35, 0xe1, 0x3e, 0x0e, 0xc3, 0x13, 0x1a, 0x8f, 0xac, 0x1f, 0xa5, 0xfa, 0xa7, 0x70, 0x45, 0xa0, - 0x36, 0x08, 0x5c, 0xa9, 0xd6, 0x8a, 0x8d, 0xff, 0x02, 0xc2, 0xc6, 0xc1, 0x10, 0x77, 0x35, 0x6d, - 0xf1, 0x2b, 0xb8, 0x92, 0x48, 0x31, 0x65, 0x48, 0x58, 0xbf, 0x34, 0xd2, 0xf5, 0x52, 0x04, 0x2b, - 0x03, 0x1b, 0xe3, 0x7f, 0x01, 0x9b, 0xca, 0xeb, 0x81, 0x8d, 0xf5, 0x1b, 0x23, 0xbd, 0x91, 0x04, - 0x46, 0xde, 0x4c, 0x45, 0xe1, 0x1c, 0x9e, 0xef, 0xb2, 0x19, 0x06, 0x7c, 0xd5, 0x96, 0x03, 0x8d, - 0xf0, 0x75, 0x34, 0x73, 0x1e, 0xe1, 0x1b, 0x38, 0x27, 0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 0xeb, 0xfe, 0x74, 0xf2, 0x64, 0x16, 0x0b, 0x9b, 0xf2, 0x80, - 0xd3, 0x31, 0x92, 0x64, 0xb0, 0x35, 0x71, 0x42, 0x10, 0x8f, 0x60, 0x25, 0x83, 0x72, 0x9e, 0xab, - 0x4a, 0xa8, 0x56, 0xf6, 0xc6, 0x4f, 0x1f, 0x2a, 0x75, 0x97, 0x12, 0xd4, 0x3b, 0x75, 0xc9, 0x4e, - 0xbe, 0x24, 0x47, 0x70, 0x94, 0x19, 0x3a, 0x53, 0x75, 0x0b, 0x68, 0x14, 0x07, 0x10, 0xee, 0x26, - 0x59, 0x64, 0xba, 0x6e, 0x8a, 0x09, 0x24, 0xbe, 0x0d, 0xed, 0x14, 0x5f, 0x24, 0x8b, 0x29, 0x57, - 0x49, 0xa7, 0x91, 0xf1, 0x3d, 0x58, 0xf7, 0xd9, 0x8c, 0x3b, 0x45, 0x6e, 0x40, 0x6e, 0x22, 0x68, - 0xe7, 0x79, 0x89, 0x6f, 0x43, 0x2b, 0x0d, 0x48, 0xe4, 0x5d, 0x92, 0x8d, 0x51, 0x32, 0x8b, 0x6c, - 0x77, 0xa0, 0x99, 0xa0, 0xfb, 0x32, 0x32, 0x34, 0xa8, 0x04, 0xf5, 0xa4, 0x5e, 0x88, 0x58, 0x3c, - 0x1d, 0x73, 0xb5, 0xc8, 0x0a, 0xf2, 0x60, 0xbd, 0x60, 0xcb, 0x79, 0xe4, 0xfd, 0x26, 0xac, 0x24, - 0x71, 0x80, 0x7c, 0x2d, 0xe4, 0x5b, 0xd6, 0x93, 0xc8, 0xb4, 0x0b, 0xab, 0x61, 0x14, 0x84, 0x41, - 0xcc, 0x22, 0x87, 0xba, 0x6e, 0xc4, 0xe2, 0xb8, 0xd3, 0x96, 0xeb, 0xe9, 0xf9, 0x63, 0x39, 0x6d, - 0xfd, 0x1c, 0x1a, 0xca, 0xfa, 0xa5, 0xed, 0xd3, 0xf7, 0x61, 0x39, 0xa4, 0x91, 0x38, 0x53, 0xb6, - 0x89, 0xd2, 0x45, 0xec, 0x19, 0x8d, 0x44, 0xd7, 0x9c, 0xeb, 0xa5, 0x96, 0x90, 0x5f, 0x4e, 0x59, - 0xf7, 0x60, 0x25, 0xc7, 0x23, 0xc2, 0x00, 0x9d, 0x42, 0x87, 0x01, 0x0e, 0x92, 0x9d, 0x2b, 0xe9, - 0xce, 0xd6, 0x7d, 0x30, 0x13, 0x43, 0x8b, 0x5a, 0x4b, 0xeb, 0x61, 0x28, 0xdb, 0xc9, 0x21, 0x02, - 0x74, 0xf0, 0x39, 0x8b, 0x54, 0x7d, 0x25, 0x07, 0xd6, 0x53, 0x68, 0x17, 0xf2, 0x29, 0xd9, 0x83, - 0x46, 0x38, 0xed, 0x3b, 0xba, 0xaf, 0x4f, 0x3b, 0xc1, 0xb3, 0x69, 0xff, 0x13, 0x76, 0xa5, 0x3b, - 0xc1, 0x10, 0x47, 0xe9, 0xb2, 0x95, 0xec, 0xb2, 0x63, 0x68, 0xea, 0xd0, 0x24, 0xdf, 0x05, 0x33, - 0xf1, 0x91, 0x42, 0x02, 0x4b, 0xb6, 0x56, 0x8b, 0xa6, 0x8c, 0xe2, 0xaa, 0x63, 0x6f, 0xe8, 0x33, - 0xd7, 0x49, 0xe3, 0x01, 0xf7, 0x68, 0xda, 0x6d, 0x49, 0xf8, 0x54, 0x3b, 0xbf, 0xf5, 0x1e, 0xd4, - 0xe5, 0xd9, 0x84, 0x7d, 0xc4, 0xca, 0xba, 0xfc, 0x14, 0xff, 0xa5, 0x99, 0xf6, 0x4f, 0x06, 0x34, - 0x75, 0x8a, 0x2a, 0x15, 0xca, 0x1d, 0xba, 0xf2, 0xaa, 0x87, 0x9e, 0xd7, 0x9b, 0xeb, 0x2c, 0x52, - 0x7b, 0xed, 0x2c, 0xb2, 0x07, 0x44, 0x26, 0x8b, 0xcb, 0x80, 0x7b, 0xfe, 0xd0, 0x91, 0xb6, 0x96, - 0x59, 0x63, 0x15, 0x29, 0xe7, 0x48, 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8e, 0xee, 0xff, 0xfe, - 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xef, 0x95, 0x6c, 0x08, 0xac, 0x17, 0x00, 0x00, +var fileDescriptor_types_03c41ca87033c976 = []byte{ + // 2089 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0x4f, 0x73, 0x1b, 0x49, + 0x15, 0xf7, 0x48, 0xb2, 0xa4, 0x79, 0xb6, 0x25, 0xa7, 0x93, 0xd8, 0x8a, 0x00, 0x3b, 0x35, 0x0b, + 0xbb, 0x36, 0xeb, 0x95, 0xb7, 0xbc, 0x2c, 0xe5, 0x6c, 0x96, 0xad, 0xb2, 0x92, 0x80, 0x5d, 0xbb, + 0x80, 0x99, 0x24, 0xe6, 0x42, 0xd5, 0x54, 0x4b, 0xd3, 0x96, 0xa6, 0x22, 0xcd, 0xcc, 0xce, 0xb4, + 0xbc, 0x72, 0x8e, 0x9c, 0xf7, 0xb0, 0x07, 0xaa, 0xf8, 0x0a, 0x7c, 0x04, 0x8e, 0x1c, 0x28, 0x6a, + 0x8f, 0x14, 0x05, 0xc5, 0x2d, 0x80, 0x29, 0x0e, 0xf0, 0x09, 0x38, 0x52, 0xfd, 0xba, 0x7b, 0xfe, + 0x79, 0x14, 0x36, 0xe1, 0xc6, 0x45, 0xea, 0xee, 0xf7, 0x5e, 0x77, 0xbf, 0x37, 0xef, 0xbd, 0xdf, + 0x7b, 0x0d, 0x1b, 0x74, 0x30, 0xf4, 0xf6, 0xf9, 0x65, 0xc8, 0x62, 0xf9, 0xdb, 0x0b, 0xa3, 0x80, + 0x07, 0x64, 0x19, 0x27, 0xdd, 0x77, 0x46, 0x1e, 0x1f, 0xcf, 0x06, 0xbd, 0x61, 0x30, 0xdd, 0x1f, + 0x05, 0xa3, 0x60, 0x1f, 0xa9, 0x83, 0xd9, 0x39, 0xce, 0x70, 0x82, 0x23, 0x29, 0xd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0x42, 0x59, 0x14, 0xd8, 0xcb, 0xa3, 0xc0, 0xad, 0x02, + 0x6f, 0x01, 0x06, 0x76, 0x73, 0x30, 0x50, 0xdc, 0x38, 0x87, 0x03, 0xf7, 0x4a, 0x70, 0xa0, 0x78, + 0xfd, 0x05, 0x40, 0x70, 0xaf, 0x04, 0x08, 0x3a, 0xd7, 0xce, 0x2a, 0x45, 0x82, 0xbd, 0x3c, 0x12, + 0x14, 0xd5, 0x29, 0x40, 0xc1, 0x87, 0x65, 0x50, 0x70, 0xa7, 0x20, 0xb3, 0x10, 0x0b, 0xde, 0xbb, + 0x86, 0x05, 0x1b, 0x05, 0xd1, 0x12, 0x30, 0xb8, 0x97, 0xcb, 0xd2, 0x50, 0xaa, 0x5b, 0x79, 0x9a, + 0x26, 0xdf, 0xbd, 0x8e, 0x23, 0x9b, 0xc5, 0x4f, 0x5b, 0x06, 0x24, 0xfb, 0x05, 0x20, 0xb9, 0x5d, + 0xbc, 0x65, 0x01, 0x49, 0x52, 0x3c, 0xd8, 0x15, 0x71, 0x5f, 0xf0, 0x34, 0x91, 0x23, 0x58, 0x14, + 0x05, 0x91, 0x4a, 0xd8, 0x72, 0x62, 0xed, 0x88, 0x4c, 0x94, 0xfa, 0xd7, 0x4b, 0xb0, 0x03, 0x9d, + 0x3e, 0xe3, 0x5d, 0xd6, 0x2f, 0x8d, 0x54, 0x16, 0x23, 0x3a, 0x9b, 0xc5, 0x4c, 0x95, 0xc5, 0x32, + 0x90, 0x52, 0xc9, 0x41, 0x0a, 0xf9, 0x36, 0xdc, 0xc0, 0x34, 0x82, 0x76, 0x71, 0x72, 0x69, 0xad, + 0x2d, 0x08, 0xd2, 0x20, 0x32, 0xbf, 0xbd, 0x03, 0x37, 0x33, 0xbc, 0x22, 0xc5, 0x62, 0x0a, 0xab, + 0x61, 0xf0, 0xae, 0x27, 0xdc, 0x47, 0x61, 0x78, 0x4c, 0xe3, 0xb1, 0xf5, 0xc3, 0x54, 0xff, 0x14, + 0xae, 0x08, 0xd4, 0x86, 0x81, 0x2b, 0xd5, 0x5a, 0xb3, 0x71, 0x2c, 0x20, 0x6c, 0x12, 0x8c, 0xf0, + 0x54, 0xd3, 0x16, 0x43, 0xc1, 0x95, 0x44, 0x8a, 0x29, 0x43, 0xc2, 0xfa, 0x85, 0x91, 0xee, 0x97, + 0x22, 0x58, 0x19, 0xd8, 0x18, 0xff, 0x0b, 0xd8, 0x54, 0x5e, 0x0d, 0x6c, 0xac, 0xdf, 0x1a, 0xe9, + 0x17, 0x49, 0x60, 0xe4, 0xf5, 0x54, 0x14, 0xce, 0xe1, 0xf9, 0x2e, 0x9b, 0x63, 0xc0, 0x57, 0x6d, + 0x39, 0xd1, 0x08, 0x5f, 0x47, 0x33, 0xe7, 0x11, 0xbe, 0x81, 0x6b, 0x72, 0x42, 0xde, 0x40, 0xf8, + 0x09, 0xce, 0x55, 0x24, 0xae, 0xf5, 0x54, 0x99, 0x7b, 0x2a, 0x16, 0x6d, 0x49, 0xcb, 0x24, 0x53, + 0x33, 0x97, 0x4c, 0x4f, 0x81, 0x5c, 0x0f, 0x59, 0xf2, 0x01, 0xd4, 0x38, 0x1d, 0x09, 0x8b, 0x0a, + 0xa3, 0xb4, 0x7a, 0xb2, 0xf6, 0xee, 0x7d, 0x7c, 0x76, 0x4a, 0xbd, 0xa8, 0xbf, 0x21, 0x8c, 0xf1, + 0xaf, 0x17, 0xdb, 0x2d, 0xc1, 0xb3, 0x17, 0x4c, 0x3d, 0xce, 0xa6, 0x21, 0xbf, 0xb4, 0x51, 0xc6, + 0xfa, 0x93, 0x21, 0x52, 0x79, 0x2e, 0x94, 0x4b, 0x4d, 0xa3, 0xfd, 0xb5, 0x92, 0x41, 0xdd, 0xaf, + 0x66, 0xae, 0x6f, 0x00, 0x8c, 0x68, 0xec, 0x7c, 0x46, 0x7d, 0xce, 0x5c, 0x65, 0x33, 0x73, 0x44, + 0xe3, 0x9f, 0xe2, 0x82, 0x28, 0x51, 0x04, 0x79, 0x16, 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9f, 0x94, 0xac, 0x22, 0xdb, 0x1d, 0x68, 0x26, 0x60, 0xbf, + 0x8a, 0x0c, 0x0d, 0x2a, 0x31, 0x3e, 0x29, 0x1f, 0x22, 0x16, 0xcf, 0x26, 0x5c, 0x6d, 0xb2, 0x86, + 0x3c, 0x58, 0x3e, 0xd8, 0x72, 0x1d, 0x79, 0xdf, 0x80, 0xb5, 0x24, 0x0e, 0x90, 0xaf, 0x85, 0x7c, + 0xab, 0x7a, 0x11, 0x99, 0x76, 0x61, 0x3d, 0x8c, 0x82, 0x30, 0x88, 0x59, 0xe4, 0x50, 0xd7, 0x8d, + 0x58, 0x1c, 0x77, 0xda, 0x72, 0x3f, 0xbd, 0x7e, 0x24, 0x97, 0xad, 0x9f, 0x41, 0x43, 0x59, 0xbf, + 0xb4, 0x9b, 0xfa, 0x1e, 0xac, 0x86, 0x34, 0x12, 0x77, 0xca, 0xf6, 0x54, 0xba, 0xa6, 0x3d, 0xa5, + 0x91, 0x68, 0xa2, 0x73, 0xad, 0xd5, 0x0a, 0xf2, 0xcb, 0x25, 0xeb, 0x1e, 0xac, 0xe5, 0x78, 0x44, + 0x18, 0xa0, 0x53, 0xe8, 0x30, 0xc0, 0x49, 0x72, 0x72, 0x25, 0x3d, 0xd9, 0xba, 0x0f, 0x66, 0x62, + 0x68, 0x51, 0x7a, 0x69, 0x3d, 0x0c, 0x65, 0x3b, 0x39, 0xc5, 0x76, 0x31, 0xf8, 0x8c, 0x45, 0xaa, + 0xdc, 0x92, 0x13, 0xeb, 0x29, 0xb4, 0x0b, 0xf9, 0x94, 0xec, 0x41, 0x23, 0x9c, 0x0d, 0x1c, 0xdd, + 0xe6, 0xa7, 0x8d, 0xe1, 0xe9, 0x6c, 0xf0, 0x31, 0xbb, 0xd4, 0x8d, 0x61, 0x88, 0xb3, 0x74, 0xdb, + 0x4a, 0x76, 0xdb, 0x09, 0x34, 0x75, 0x68, 0x92, 0xef, 0x80, 0x99, 0xf8, 0x48, 0x21, 0x81, 0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b1, 0xe4, 0x7d, 0xa8, 0x2b, 0xd8, 0x2f, 0x7d, 0x18, 0xec, 0x96, + 0x77, 0x79, 0x42, 0xc9, 0xb4, 0xf5, 0x58, 0xf4, 0xba, 0xda, 0x5d, 0xd8, 0x6d, 0x93, 0x23, 0x80, + 0x4c, 0x75, 0xbd, 0xf0, 0xd9, 0xb4, 0xbb, 0xb8, 0x8b, 0x26, 0xf7, 0xa1, 0x99, 0xbe, 0x8c, 0x94, + 0x3f, 0x84, 0x76, 0x17, 0x35, 0xb6, 0xfd, 0xaf, 0xff, 0xfb, 0x6f, 0x5b, 0xc6, 0xaf, 0xae, 0xb6, + 0x8c, 0x5f, 0x5f, 0x6d, 0x19, 0x5f, 0x5e, 0x6d, 0x19, 0xbf, 0xbf, 0xda, 0x32, 0xfe, 0x7a, 0xb5, + 0x65, 0xfc, 0xe6, 0xef, 0x5b, 0xc6, 0xa0, 0x8e, 0xee, 0xff, 0xde, 0x7f, 0x02, 0x00, 0x00, 0xff, + 0xff, 0x51, 0x4f, 0x34, 0x66, 0xf8, 0x17, 0x00, 0x00, } diff --git a/abci/types/types.proto b/abci/types/types.proto index d23ac513..b62162c4 100644 --- a/abci/types/types.proto +++ b/abci/types/types.proto @@ -6,6 +6,7 @@ package types; import "github.com/gogo/protobuf/gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; import "github.com/tendermint/tendermint/libs/common/types.proto"; +import "github.com/tendermint/tendermint/crypto/merkle/merkle.proto"; // This file is copied from http://github.com/tendermint/abci // NOTE: When using custom types, mind the warnings. @@ -154,7 +155,7 @@ message ResponseQuery { int64 index = 5; bytes key = 6; bytes value = 7; - bytes proof = 8; + merkle.Proof proof = 8; int64 height = 9; } diff --git a/abci/types/typespb_test.go b/abci/types/typespb_test.go index 5da925e1..0ae0fea0 100644 --- a/abci/types/typespb_test.go +++ b/abci/types/typespb_test.go @@ -14,6 +14,7 @@ import fmt "fmt" import math "math" import _ "github.com/gogo/protobuf/gogoproto" import _ "github.com/golang/protobuf/ptypes/timestamp" +import _ "github.com/tendermint/tendermint/crypto/merkle" import _ "github.com/tendermint/tendermint/libs/common" // Reference imports to suppress errors if they are not otherwise used. diff --git a/crypto/merkle/compile.sh b/crypto/merkle/compile.sh new file mode 100644 index 00000000..8e4c739f --- /dev/null +++ b/crypto/merkle/compile.sh @@ -0,0 +1,6 @@ +#! /bin/bash + +protoc --gogo_out=. -I $GOPATH/src/ -I . -I $GOPATH/src/github.com/gogo/protobuf/protobuf merkle.proto +echo "--> adding nolint declarations to protobuf generated files" +awk '/package merkle/ { print "//nolint: gas"; print; next }1' merkle.pb.go > merkle.pb.go.new +mv merkle.pb.go.new merkle.pb.go diff --git a/crypto/merkle/merkle.pb.go b/crypto/merkle/merkle.pb.go new file mode 100644 index 00000000..75e1b08c --- /dev/null +++ b/crypto/merkle/merkle.pb.go @@ -0,0 +1,792 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: crypto/merkle/merkle.proto + +package merkle + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" +import _ "github.com/gogo/protobuf/gogoproto" + +import bytes "bytes" + +import io "io" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +// ProofOp defines an operation used for calculating Merkle root +// The data could be arbitrary format, providing nessecary data +// for example neighbouring node hash +type ProofOp struct { + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ProofOp) Reset() { *m = ProofOp{} } +func (m *ProofOp) String() string { return proto.CompactTextString(m) } +func (*ProofOp) ProtoMessage() {} +func (*ProofOp) Descriptor() ([]byte, []int) { + return fileDescriptor_merkle_5d3f6051907285da, []int{0} +} +func (m *ProofOp) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProofOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProofOp.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *ProofOp) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProofOp.Merge(dst, src) +} +func (m *ProofOp) XXX_Size() int { + return m.Size() +} +func (m *ProofOp) XXX_DiscardUnknown() { + xxx_messageInfo_ProofOp.DiscardUnknown(m) +} + +var xxx_messageInfo_ProofOp proto.InternalMessageInfo + +func (m *ProofOp) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *ProofOp) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *ProofOp) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +// Proof is Merkle proof defined by the list of ProofOps +type Proof struct { + Ops []ProofOp `protobuf:"bytes,1,rep,name=ops" json:"ops"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Proof) Reset() { *m = Proof{} } +func (m *Proof) String() string { return proto.CompactTextString(m) } +func (*Proof) ProtoMessage() {} +func (*Proof) Descriptor() ([]byte, []int) { + return fileDescriptor_merkle_5d3f6051907285da, []int{1} +} +func (m *Proof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Proof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Proof.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Proof) XXX_Merge(src proto.Message) { + xxx_messageInfo_Proof.Merge(dst, src) +} +func (m *Proof) XXX_Size() int { + return m.Size() +} +func (m *Proof) XXX_DiscardUnknown() { + xxx_messageInfo_Proof.DiscardUnknown(m) +} + +var xxx_messageInfo_Proof proto.InternalMessageInfo + +func (m *Proof) GetOps() []ProofOp { + if m != nil { + return m.Ops + } + return nil +} + +func init() { + proto.RegisterType((*ProofOp)(nil), "merkle.ProofOp") + proto.RegisterType((*Proof)(nil), "merkle.Proof") +} +func (this *ProofOp) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ProofOp) + if !ok { + that2, ok := that.(ProofOp) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Type != that1.Type { + return false + } + if !bytes.Equal(this.Key, that1.Key) { + return false + } + if !bytes.Equal(this.Data, that1.Data) { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Proof) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Proof) + if !ok { + that2, ok := that.(Proof) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Ops) != len(that1.Ops) { + return false + } + for i := range this.Ops { + if !this.Ops[i].Equal(&that1.Ops[i]) { + return false + } + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (m *ProofOp) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ProofOp) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Type) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintMerkle(dAtA, i, uint64(len(m.Type))) + i += copy(dAtA[i:], m.Type) + } + if len(m.Key) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintMerkle(dAtA, i, uint64(len(m.Key))) + i += copy(dAtA[i:], m.Key) + } + if len(m.Data) > 0 { + dAtA[i] = 0x1a + i++ + i = encodeVarintMerkle(dAtA, i, uint64(len(m.Data))) + i += copy(dAtA[i:], m.Data) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *Proof) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Proof) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Ops) > 0 { + for _, msg := range m.Ops { + dAtA[i] = 0xa + i++ + i = encodeVarintMerkle(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func encodeVarintMerkle(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func NewPopulatedProofOp(r randyMerkle, easy bool) *ProofOp { + this := &ProofOp{} + this.Type = string(randStringMerkle(r)) + v1 := r.Intn(100) + this.Key = make([]byte, v1) + for i := 0; i < v1; i++ { + this.Key[i] = byte(r.Intn(256)) + } + v2 := r.Intn(100) + this.Data = make([]byte, v2) + for i := 0; i < v2; i++ { + this.Data[i] = byte(r.Intn(256)) + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedMerkle(r, 4) + } + return this +} + +func NewPopulatedProof(r randyMerkle, easy bool) *Proof { + this := &Proof{} + if r.Intn(10) != 0 { + v3 := r.Intn(5) + this.Ops = make([]ProofOp, v3) + for i := 0; i < v3; i++ { + v4 := NewPopulatedProofOp(r, easy) + this.Ops[i] = *v4 + } + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedMerkle(r, 2) + } + return this +} + +type randyMerkle interface { + Float32() float32 + Float64() float64 + Int63() int64 + Int31() int32 + Uint32() uint32 + Intn(n int) int +} + +func randUTF8RuneMerkle(r randyMerkle) rune { + ru := r.Intn(62) + if ru < 10 { + return rune(ru + 48) + } else if ru < 36 { + return rune(ru + 55) + } + return rune(ru + 61) +} +func randStringMerkle(r randyMerkle) string { + v5 := r.Intn(100) + tmps := make([]rune, v5) + for i := 0; i < v5; i++ { + tmps[i] = randUTF8RuneMerkle(r) + } + return string(tmps) +} +func randUnrecognizedMerkle(r randyMerkle, maxFieldNumber int) (dAtA []byte) { + l := r.Intn(5) + for i := 0; i < l; i++ { + wire := r.Intn(4) + if wire == 3 { + wire = 5 + } + fieldNumber := maxFieldNumber + r.Intn(100) + dAtA = randFieldMerkle(dAtA, r, fieldNumber, wire) + } + return dAtA +} +func randFieldMerkle(dAtA []byte, r randyMerkle, fieldNumber int, wire int) []byte { + key := uint32(fieldNumber)<<3 | uint32(wire) + switch wire { + case 0: + dAtA = encodeVarintPopulateMerkle(dAtA, uint64(key)) + v6 := r.Int63() + if r.Intn(2) == 0 { + v6 *= -1 + } + dAtA = encodeVarintPopulateMerkle(dAtA, uint64(v6)) + case 1: + dAtA = encodeVarintPopulateMerkle(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + case 2: + dAtA = encodeVarintPopulateMerkle(dAtA, uint64(key)) + ll := r.Intn(100) + dAtA = encodeVarintPopulateMerkle(dAtA, uint64(ll)) + for j := 0; j < ll; j++ { + dAtA = append(dAtA, byte(r.Intn(256))) + } + default: + dAtA = encodeVarintPopulateMerkle(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + } + return dAtA +} +func encodeVarintPopulateMerkle(dAtA []byte, v uint64) []byte { + for v >= 1<<7 { + dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) + v >>= 7 + } + dAtA = append(dAtA, uint8(v)) + return dAtA +} +func (m *ProofOp) Size() (n int) { + var l int + _ = l + l = len(m.Type) + if l > 0 { + n += 1 + l + sovMerkle(uint64(l)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovMerkle(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovMerkle(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *Proof) Size() (n int) { + var l int + _ = l + if len(m.Ops) > 0 { + for _, e := range m.Ops { + l = e.Size() + n += 1 + l + sovMerkle(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovMerkle(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozMerkle(x uint64) (n int) { + return sovMerkle(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ProofOp) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMerkle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ProofOp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProofOp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMerkle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMerkle + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Type = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMerkle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthMerkle + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMerkle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthMerkle + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMerkle(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthMerkle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Proof) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMerkle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Proof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Proof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ops", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMerkle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMerkle + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ops = append(m.Ops, ProofOp{}) + if err := m.Ops[len(m.Ops)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMerkle(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthMerkle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMerkle(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMerkle + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMerkle + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMerkle + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthMerkle + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMerkle + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipMerkle(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthMerkle = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMerkle = fmt.Errorf("proto: integer overflow") +) + +func init() { proto.RegisterFile("crypto/merkle/merkle.proto", fileDescriptor_merkle_5d3f6051907285da) } + +var fileDescriptor_merkle_5d3f6051907285da = []byte{ + // 200 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0x2e, 0xaa, 0x2c, + 0x28, 0xc9, 0xd7, 0xcf, 0x4d, 0x2d, 0xca, 0xce, 0x49, 0x85, 0x52, 0x7a, 0x05, 0x45, 0xf9, 0x25, + 0xf9, 0x42, 0x6c, 0x10, 0x9e, 0x94, 0x6e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, + 0xae, 0x7e, 0x7a, 0x7e, 0x7a, 0xbe, 0x3e, 0x58, 0x3a, 0xa9, 0x34, 0x0d, 0xcc, 0x03, 0x73, 0xc0, + 0x2c, 0x88, 0x36, 0x25, 0x67, 0x2e, 0xf6, 0x80, 0xa2, 0xfc, 0xfc, 0x34, 0xff, 0x02, 0x21, 0x21, + 0x2e, 0x96, 0x92, 0xca, 0x82, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x30, 0x5b, 0x48, + 0x80, 0x8b, 0x39, 0x3b, 0xb5, 0x52, 0x82, 0x49, 0x81, 0x51, 0x83, 0x27, 0x08, 0xc4, 0x04, 0xa9, + 0x4a, 0x49, 0x2c, 0x49, 0x94, 0x60, 0x06, 0x0b, 0x81, 0xd9, 0x4a, 0x06, 0x5c, 0xac, 0x60, 0x43, + 0x84, 0xd4, 0xb9, 0x98, 0xf3, 0x0b, 0x8a, 0x25, 0x18, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0xf8, 0xf5, + 0xa0, 0x0e, 0x84, 0x5a, 0xe0, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x48, 0x85, 0x93, 0xc8, + 0x8f, 0x87, 0x72, 0x8c, 0x2b, 0x1e, 0xc9, 0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, + 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x49, 0x6c, 0x60, 0x37, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, + 0xb9, 0x2b, 0x0f, 0xd1, 0xe8, 0x00, 0x00, 0x00, +} diff --git a/crypto/merkle/merkle.proto b/crypto/merkle/merkle.proto new file mode 100644 index 00000000..8a6c467d --- /dev/null +++ b/crypto/merkle/merkle.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; +package merkle; + +// For more information on gogo.proto, see: +// https://github.com/gogo/protobuf/blob/master/extensions.md +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; + +option (gogoproto.marshaler_all) = true; +option (gogoproto.unmarshaler_all) = true; +option (gogoproto.sizer_all) = true; + +option (gogoproto.populate_all) = true; +option (gogoproto.equal_all) = true; + +//---------------------------------------- +// Message types + +// ProofOp defines an operation used for calculating Merkle root +// The data could be arbitrary format, providing nessecary data +// for example neighbouring node hash +message ProofOp { + string type = 1; + bytes key = 2; + bytes data = 3; +} + +// Proof is Merkle proof defined by the list of ProofOps +message Proof { + repeated ProofOp ops = 1 [(gogoproto.nullable)=false]; +} diff --git a/crypto/merkle/proof.go b/crypto/merkle/proof.go new file mode 100644 index 00000000..7da89495 --- /dev/null +++ b/crypto/merkle/proof.go @@ -0,0 +1,132 @@ +package merkle + +import ( + "bytes" + + cmn "github.com/tendermint/tmlibs/common" +) + +//---------------------------------------- +// ProofOp gets converted to an instance of ProofOperator: + +// ProofOperator is a layer for calculating intermediate Merkle root +// Run() takes a list of bytes because it can be more than one +// for example in range proofs +// ProofOp() defines custom encoding which can be decoded later with +// OpDecoder +type ProofOperator interface { + Run([][]byte) ([][]byte, error) + GetKey() []byte + ProofOp() ProofOp +} + +//---------------------------------------- +// Operations on a list of ProofOperators + +// ProofOperators is a slice of ProofOperator(s) +// Each operator will be applied to the input value sequencially +// and the last Merkle root will be verified with already known data +type ProofOperators []ProofOperator + +func (poz ProofOperators) VerifyValue(root []byte, keypath string, value []byte) (err error) { + return poz.Verify(root, keypath, [][]byte{value}) +} + +func (poz ProofOperators) Verify(root []byte, keypath string, args [][]byte) (err error) { + keys, err := KeyPathToKeys(keypath) + if err != nil { + return + } + + for i, op := range poz { + key := op.GetKey() + if len(key) != 0 { + if !bytes.Equal(keys[0], key) { + return cmn.NewError("Key mismatch on operation #%d: expected %+v but %+v", i, []byte(keys[0]), []byte(key)) + } + keys = keys[1:] + } + args, err = op.Run(args) + if err != nil { + return + } + } + if !bytes.Equal(root, args[0]) { + return cmn.NewError("Calculated root hash is invalid: expected %+v but %+v", root, args[0]) + } + if len(keys) != 0 { + return cmn.NewError("Keypath not consumed all") + } + return nil +} + +//---------------------------------------- +// ProofRuntime - main entrypoint + +type OpDecoder func(ProofOp) (ProofOperator, error) + +type ProofRuntime struct { + decoders map[string]OpDecoder +} + +func NewProofRuntime() *ProofRuntime { + return &ProofRuntime{ + decoders: make(map[string]OpDecoder), + } +} + +func (prt *ProofRuntime) RegisterOpDecoder(typ string, dec OpDecoder) { + _, ok := prt.decoders[typ] + if ok { + panic("already registered for type " + typ) + } + prt.decoders[typ] = dec +} + +func (prt *ProofRuntime) Decode(pop ProofOp) (ProofOperator, error) { + decoder := prt.decoders[pop.Type] + if decoder == nil { + return nil, cmn.NewError("unrecognized proof type %v", pop.Type) + } + return decoder(pop) +} + +func (prt *ProofRuntime) DecodeProof(proof *Proof) (poz ProofOperators, err error) { + poz = ProofOperators(nil) + for _, pop := range proof.Ops { + operator, err := prt.Decode(pop) + if err != nil { + return nil, cmn.ErrorWrap(err, "decoding a proof operator") + } + poz = append(poz, operator) + } + return +} + +func (prt *ProofRuntime) VerifyValue(proof *Proof, root []byte, keypath string, value []byte) (err error) { + return prt.Verify(proof, root, keypath, [][]byte{value}) +} + +// TODO In the long run we'll need a method of classifcation of ops, +// whether existence or absence or perhaps a third? +func (prt *ProofRuntime) VerifyAbsence(proof *Proof, root []byte, keypath string) (err error) { + return prt.Verify(proof, root, keypath, nil) +} + +func (prt *ProofRuntime) Verify(proof *Proof, root []byte, keypath string, args [][]byte) (err error) { + poz, err := prt.DecodeProof(proof) + if err != nil { + return cmn.ErrorWrap(err, "decoding proof") + } + return poz.Verify(root, keypath, args) +} + +// DefaultProofRuntime only knows about Simple value +// proofs. +// To use e.g. IAVL proofs, register op-decoders as +// defined in the IAVL package. +func DefaultProofRuntime() (prt *ProofRuntime) { + prt = NewProofRuntime() + prt.RegisterOpDecoder(ProofOpSimpleValue, SimpleValueOpDecoder) + return +} diff --git a/crypto/merkle/proof_key_path.go b/crypto/merkle/proof_key_path.go new file mode 100644 index 00000000..d74dac51 --- /dev/null +++ b/crypto/merkle/proof_key_path.go @@ -0,0 +1,107 @@ +package merkle + +import ( + "encoding/hex" + "fmt" + "net/url" + "strings" + + cmn "github.com/tendermint/tendermint/libs/common" +) + +/* + + For generalized Merkle proofs, each layer of the proof may require an + optional key. The key may be encoded either by URL-encoding or + (upper-case) hex-encoding. + TODO: In the future, more encodings may be supported, like base32 (e.g. + /32:) + + For example, for a Cosmos-SDK application where the first two proof layers + are SimpleValueOps, and the third proof layer is an IAVLValueOp, the keys + might look like: + + 0: []byte("App") + 1: []byte("IBC") + 2: []byte{0x01, 0x02, 0x03} + + Assuming that we know that the first two layers are always ASCII texts, we + probably want to use URLEncoding for those, whereas the third layer will + require HEX encoding for efficient representation. + + kp := new(KeyPath) + kp.AppendKey([]byte("App"), KeyEncodingURL) + kp.AppendKey([]byte("IBC"), KeyEncodingURL) + kp.AppendKey([]byte{0x01, 0x02, 0x03}, KeyEncodingURL) + kp.String() // Should return "/App/IBC/x:010203" + + NOTE: All encodings *MUST* work compatibly, such that you can choose to use + whatever encoding, and the decoded keys will always be the same. In other + words, it's just as good to encode all three keys using URL encoding or HEX + encoding... it just wouldn't be optimal in terms of readability or space + efficiency. + + NOTE: Punycode will never be supported here, because not all values can be + decoded. For example, no string decodes to the string "xn--blah" in + Punycode. + +*/ + +type keyEncoding int + +const ( + KeyEncodingURL keyEncoding = iota + KeyEncodingHex + KeyEncodingMax +) + +type Key struct { + name []byte + enc keyEncoding +} + +type KeyPath []Key + +func (pth KeyPath) AppendKey(key []byte, enc keyEncoding) KeyPath { + return append(pth, Key{key, enc}) +} + +func (pth KeyPath) String() string { + res := "" + for _, key := range pth { + switch key.enc { + case KeyEncodingURL: + res += "/" + url.PathEscape(string(key.name)) + case KeyEncodingHex: + res += "/x:" + fmt.Sprintf("%X", key.name) + default: + panic("unexpected key encoding type") + } + } + return res +} + +func KeyPathToKeys(path string) (keys [][]byte, err error) { + if path == "" || path[0] != '/' { + return nil, cmn.NewError("key path string must start with a forward slash '/'") + } + parts := strings.Split(path[1:], "/") + keys = make([][]byte, len(parts)) + for i, part := range parts { + if strings.HasPrefix(part, "x:") { + hexPart := part[2:] + key, err := hex.DecodeString(hexPart) + if err != nil { + return nil, cmn.ErrorWrap(err, "decoding hex-encoded part #%d: /%s", i, part) + } + keys[i] = key + } else { + key, err := url.PathUnescape(part) + if err != nil { + return nil, cmn.ErrorWrap(err, "decoding url-encoded part #%d: /%s", i, part) + } + keys[i] = []byte(key) // TODO Test this with random bytes, I'm not sure that it works for arbitrary bytes... + } + } + return keys, nil +} diff --git a/crypto/merkle/proof_key_path_test.go b/crypto/merkle/proof_key_path_test.go new file mode 100644 index 00000000..48fda303 --- /dev/null +++ b/crypto/merkle/proof_key_path_test.go @@ -0,0 +1,41 @@ +package merkle + +import ( + "math/rand" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestKeyPath(t *testing.T) { + var path KeyPath + keys := make([][]byte, 10) + alphanum := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + + for d := 0; d < 1e4; d++ { + path = nil + + for i := range keys { + enc := keyEncoding(rand.Intn(int(KeyEncodingMax))) + keys[i] = make([]byte, rand.Uint32()%20) + switch enc { + case KeyEncodingURL: + for j := range keys[i] { + keys[i][j] = alphanum[rand.Intn(len(alphanum))] + } + case KeyEncodingHex: + rand.Read(keys[i]) + default: + panic("Unexpected encoding") + } + path = path.AppendKey(keys[i], enc) + } + + res, err := KeyPathToKeys(path.String()) + require.Nil(t, err) + + for i, key := range keys { + require.Equal(t, key, res[i]) + } + } +} diff --git a/crypto/merkle/proof_simple_value.go b/crypto/merkle/proof_simple_value.go new file mode 100644 index 00000000..28935e2c --- /dev/null +++ b/crypto/merkle/proof_simple_value.go @@ -0,0 +1,91 @@ +package merkle + +import ( + "bytes" + "fmt" + + "github.com/tendermint/tendermint/crypto/tmhash" + cmn "github.com/tendermint/tendermint/libs/common" +) + +const ProofOpSimpleValue = "simple:v" + +// SimpleValueOp takes a key and a single value as argument and +// produces the root hash. The corresponding tree structure is +// the SimpleMap tree. SimpleMap takes a Hasher, and currently +// Tendermint uses aminoHasher. SimpleValueOp should support +// the hash function as used in aminoHasher. TODO support +// additional hash functions here as options/args to this +// operator. +// +// If the produced root hash matches the expected hash, the +// proof is good. +type SimpleValueOp struct { + // Encoded in ProofOp.Key. + key []byte + + // To encode in ProofOp.Data + Proof *SimpleProof `json:"simple-proof"` +} + +var _ ProofOperator = SimpleValueOp{} + +func NewSimpleValueOp(key []byte, proof *SimpleProof) SimpleValueOp { + return SimpleValueOp{ + key: key, + Proof: proof, + } +} + +func SimpleValueOpDecoder(pop ProofOp) (ProofOperator, error) { + if pop.Type != ProofOpSimpleValue { + return nil, cmn.NewError("unexpected ProofOp.Type; got %v, want %v", pop.Type, ProofOpSimpleValue) + } + var op SimpleValueOp // a bit strange as we'll discard this, but it works. + err := cdc.UnmarshalBinary(pop.Data, &op) + if err != nil { + return nil, cmn.ErrorWrap(err, "decoding ProofOp.Data into SimpleValueOp") + } + return NewSimpleValueOp(pop.Key, op.Proof), nil +} + +func (op SimpleValueOp) ProofOp() ProofOp { + bz := cdc.MustMarshalBinary(op) + return ProofOp{ + Type: ProofOpSimpleValue, + Key: op.key, + Data: bz, + } +} + +func (op SimpleValueOp) String() string { + return fmt.Sprintf("SimpleValueOp{%v}", op.GetKey()) +} + +func (op SimpleValueOp) Run(args [][]byte) ([][]byte, error) { + if len(args) != 1 { + return nil, cmn.NewError("expected 1 arg, got %v", len(args)) + } + value := args[0] + hasher := tmhash.New() + hasher.Write(value) // does not error + vhash := hasher.Sum(nil) + + // Wrap to hash the KVPair. + hasher = tmhash.New() + encodeByteSlice(hasher, []byte(op.key)) // does not error + encodeByteSlice(hasher, []byte(vhash)) // does not error + kvhash := hasher.Sum(nil) + + if !bytes.Equal(kvhash, op.Proof.LeafHash) { + return nil, cmn.NewError("leaf hash mismatch: want %X got %X", op.Proof.LeafHash, kvhash) + } + + return [][]byte{ + op.Proof.ComputeRootHash(), + }, nil +} + +func (op SimpleValueOp) GetKey() []byte { + return op.key +} diff --git a/crypto/merkle/simple_proof.go b/crypto/merkle/simple_proof.go index 2541b6d3..306505fc 100644 --- a/crypto/merkle/simple_proof.go +++ b/crypto/merkle/simple_proof.go @@ -2,12 +2,24 @@ package merkle import ( "bytes" + "errors" "fmt" + + cmn "github.com/tendermint/tendermint/libs/common" ) -// SimpleProof represents a simple merkle proof. +// SimpleProof represents a simple Merkle proof. +// NOTE: The convention for proofs is to include leaf hashes but to +// exclude the root hash. +// This convention is implemented across IAVL range proofs as well. +// Keep this consistent unless there's a very good reason to change +// everything. This also affects the generalized proof system as +// well. type SimpleProof struct { - Aunts [][]byte `json:"aunts"` // Hashes from leaf's sibling to a root's child. + Total int `json:"total"` // Total number of items. + Index int `json:"index"` // Index of item to prove. + LeafHash []byte `json:"leaf_hash"` // Hash of item value. + Aunts [][]byte `json:"aunts"` // Hashes from leaf's sibling to a root's child. } // SimpleProofsFromHashers computes inclusion proof for given items. @@ -18,7 +30,10 @@ func SimpleProofsFromHashers(items []Hasher) (rootHash []byte, proofs []*SimpleP proofs = make([]*SimpleProof, len(items)) for i, trail := range trails { proofs[i] = &SimpleProof{ - Aunts: trail.FlattenAunts(), + Total: len(items), + Index: i, + LeafHash: trail.Hash, + Aunts: trail.FlattenAunts(), } } return @@ -49,11 +64,33 @@ func SimpleProofsFromMap(m map[string]Hasher) (rootHash []byte, proofs map[strin return } -// Verify that leafHash is a leaf hash of the simple-merkle-tree -// which hashes to rootHash. -func (sp *SimpleProof) Verify(index int, total int, leafHash []byte, rootHash []byte) bool { - computedHash := computeHashFromAunts(index, total, leafHash, sp.Aunts) - return computedHash != nil && bytes.Equal(computedHash, rootHash) +// Verify that the SimpleProof proves the root hash. +// Check sp.Index/sp.Total manually if needed +func (sp *SimpleProof) Verify(rootHash []byte, leafHash []byte) error { + if sp.Total < 0 { + return errors.New("Proof total must be positive") + } + if sp.Index < 0 { + return errors.New("Proof index cannot be negative") + } + if !bytes.Equal(sp.LeafHash, leafHash) { + return cmn.NewError("invalid leaf hash: wanted %X got %X", leafHash, sp.LeafHash) + } + computedHash := sp.ComputeRootHash() + if !bytes.Equal(computedHash, rootHash) { + return cmn.NewError("invalid root hash: wanted %X got %X", rootHash, computedHash) + } + return nil +} + +// Compute the root hash given a leaf hash. Does not verify the result. +func (sp *SimpleProof) ComputeRootHash() []byte { + return computeHashFromAunts( + sp.Index, + sp.Total, + sp.LeafHash, + sp.Aunts, + ) } // String implements the stringer interface for SimpleProof. diff --git a/crypto/merkle/simple_tree_test.go b/crypto/merkle/simple_tree_test.go index e2dccd3b..b299aba7 100644 --- a/crypto/merkle/simple_tree_test.go +++ b/crypto/merkle/simple_tree_test.go @@ -1,13 +1,13 @@ package merkle import ( - "bytes" + "testing" + + "github.com/stretchr/testify/require" cmn "github.com/tendermint/tendermint/libs/common" . "github.com/tendermint/tendermint/libs/test" - "testing" - "github.com/tendermint/tendermint/crypto/tmhash" ) @@ -30,60 +30,43 @@ func TestSimpleProof(t *testing.T) { rootHash2, proofs := SimpleProofsFromHashers(items) - if !bytes.Equal(rootHash, rootHash2) { - t.Errorf("Unmatched root hashes: %X vs %X", rootHash, rootHash2) - } + require.Equal(t, rootHash, rootHash2, "Unmatched root hashes: %X vs %X", rootHash, rootHash2) // For each item, check the trail. for i, item := range items { itemHash := item.Hash() proof := proofs[i] - // Verify success - ok := proof.Verify(i, total, itemHash, rootHash) - if !ok { - t.Errorf("Verification failed for index %v.", i) - } + // Check total/index + require.Equal(t, proof.Index, i, "Unmatched indicies: %d vs %d", proof.Index, i) - // Wrong item index should make it fail - { - ok = proof.Verify((i+1)%total, total, itemHash, rootHash) - if ok { - t.Errorf("Expected verification to fail for wrong index %v.", i) - } - } + require.Equal(t, proof.Total, total, "Unmatched totals: %d vs %d", proof.Total, total) + + // Verify success + err := proof.Verify(rootHash, itemHash) + require.NoError(t, err, "Verificatior failed: %v.", err) // Trail too long should make it fail origAunts := proof.Aunts proof.Aunts = append(proof.Aunts, cmn.RandBytes(32)) - { - ok = proof.Verify(i, total, itemHash, rootHash) - if ok { - t.Errorf("Expected verification to fail for wrong trail length.") - } - } + err = proof.Verify(rootHash, itemHash) + require.Error(t, err, "Expected verification to fail for wrong trail length") + proof.Aunts = origAunts // Trail too short should make it fail proof.Aunts = proof.Aunts[0 : len(proof.Aunts)-1] - { - ok = proof.Verify(i, total, itemHash, rootHash) - if ok { - t.Errorf("Expected verification to fail for wrong trail length.") - } - } + err = proof.Verify(rootHash, itemHash) + require.Error(t, err, "Expected verification to fail for wrong trail length") + proof.Aunts = origAunts // Mutating the itemHash should make it fail. - ok = proof.Verify(i, total, MutateByteSlice(itemHash), rootHash) - if ok { - t.Errorf("Expected verification to fail for mutated leaf hash") - } + err = proof.Verify(rootHash, MutateByteSlice(itemHash)) + require.Error(t, err, "Expected verification to fail for mutated leaf hash") // Mutating the rootHash should make it fail. - ok = proof.Verify(i, total, itemHash, MutateByteSlice(rootHash)) - if ok { - t.Errorf("Expected verification to fail for mutated root hash") - } + err = proof.Verify(MutateByteSlice(rootHash), itemHash) + require.Error(t, err, "Expected verification to fail for mutated root hash") } } diff --git a/crypto/merkle/wire.go b/crypto/merkle/wire.go new file mode 100644 index 00000000..c20ec9aa --- /dev/null +++ b/crypto/merkle/wire.go @@ -0,0 +1,12 @@ +package merkle + +import ( + "github.com/tendermint/go-amino" +) + +var cdc *amino.Codec + +func init() { + cdc = amino.NewCodec() + cdc.Seal() +} diff --git a/docs/app-dev/app-development.md b/docs/app-dev/app-development.md index 3aaebb23..2618bb1e 100644 --- a/docs/app-dev/app-development.md +++ b/docs/app-dev/app-development.md @@ -431,17 +431,30 @@ Note: these query formats are subject to change! In go: ``` -func (app *KVStoreApplication) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery) { - if reqQuery.Prove { - value, proof, exists := app.state.Proof(reqQuery.Data) - resQuery.Index = -1 // TODO make Proof return index - resQuery.Key = reqQuery.Data - resQuery.Value = value - resQuery.Proof = proof - if exists { - resQuery.Log = "exists" - } else { - resQuery.Log = "does not exist" + func (app *KVStoreApplication) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery) { + if reqQuery.Prove { + value, proof, exists := app.state.GetWithProof(reqQuery.Data) + resQuery.Index = -1 // TODO make Proof return index + resQuery.Key = reqQuery.Data + resQuery.Value = value + resQuery.Proof = proof + if exists { + resQuery.Log = "exists" + } else { + resQuery.Log = "does not exist" + } + return + } else { + index, value, exists := app.state.Get(reqQuery.Data) + resQuery.Index = int64(index) + resQuery.Value = value + if exists { + resQuery.Log = "exists" + } else { + resQuery.Log = "does not exist" + } + return + } } return } else { @@ -461,22 +474,25 @@ func (app *KVStoreApplication) Query(reqQuery types.RequestQuery) (resQuery type In Java: ``` -ResponseQuery requestQuery(RequestQuery req) { - final boolean isProveQuery = req.getProve(); - final ResponseQuery.Builder responseBuilder = ResponseQuery.newBuilder(); + ResponseQuery requestQuery(RequestQuery req) { + final boolean isProveQuery = req.getProve(); + final ResponseQuery.Builder responseBuilder = ResponseQuery.newBuilder(); + byte[] queryData = req.getData().toByteArray(); - if (isProveQuery) { - com.app.example.ProofResult proofResult = generateProof(req.getData().toByteArray()); - final byte[] proofAsByteArray = proofResult.getAsByteArray(); - - responseBuilder.setProof(ByteString.copyFrom(proofAsByteArray)); - responseBuilder.setKey(req.getData()); - responseBuilder.setValue(ByteString.copyFrom(proofResult.getData())); - responseBuilder.setLog(result.getLogValue()); - } else { - byte[] queryData = req.getData().toByteArray(); - - final com.app.example.QueryResult result = generateQueryResult(queryData); + if (isProveQuery) { + com.app.example.QueryResultWithProof result = generateQueryResultWithProof(queryData); + responseBuilder.setIndex(result.getLeftIndex()); + responseBuilder.setKey(req.getData()); + responseBuilder.setValue(result.getValueOrNull(0)); + responseBuilder.setHeight(result.getHeight()); + responseBuilder.setProof(result.getProof()); + responseBuilder.setLog(result.getLogValue()); + } else { + com.app.example.QueryResult result = generateQueryResult(queryData); + responseBuilder.setIndex(result.getIndex()); + responseBuilder.setValue(result.getValue()); + responseBuilder.setLog(result.getLogValue()); + } responseBuilder.setIndex(result.getIndex()); responseBuilder.setValue(ByteString.copyFrom(result.getValue())); diff --git a/lite/errors/errors.go b/lite/errors/errors.go index 61426b23..59b6380d 100644 --- a/lite/errors/errors.go +++ b/lite/errors/errors.go @@ -41,6 +41,12 @@ func (e errUnknownValidators) Error() string { e.chainID, e.height) } +type errEmptyTree struct{} + +func (e errEmptyTree) Error() string { + return "Tree is empty" +} + //---------------------------------------- // Methods for above error types @@ -110,3 +116,18 @@ func IsErrUnknownValidators(err error) bool { } return false } + +//----------------- +// ErrEmptyTree + +func ErrEmptyTree() error { + return cmn.ErrorWrap(errEmptyTree{}, "") +} + +func IsErrEmptyTree(err error) bool { + if err_, ok := err.(cmn.Error); ok { + _, ok := err_.Data().(errEmptyTree) + return ok + } + return false +} diff --git a/lite/proxy/proof.go b/lite/proxy/proof.go new file mode 100644 index 00000000..452dee27 --- /dev/null +++ b/lite/proxy/proof.go @@ -0,0 +1,14 @@ +package proxy + +import ( + "github.com/tendermint/tendermint/crypto/merkle" +) + +func defaultProofRuntime() *merkle.ProofRuntime { + prt := merkle.NewProofRuntime() + prt.RegisterOpDecoder( + merkle.ProofOpSimpleValue, + merkle.SimpleValueOpDecoder, + ) + return prt +} diff --git a/lite/proxy/query.go b/lite/proxy/query.go index 84ff98b4..3acf826b 100644 --- a/lite/proxy/query.go +++ b/lite/proxy/query.go @@ -3,127 +3,95 @@ package proxy import ( "fmt" - "github.com/pkg/errors" - cmn "github.com/tendermint/tendermint/libs/common" + "github.com/tendermint/tendermint/crypto/merkle" "github.com/tendermint/tendermint/lite" + lerr "github.com/tendermint/tendermint/lite/errors" rpcclient "github.com/tendermint/tendermint/rpc/client" ctypes "github.com/tendermint/tendermint/rpc/core/types" "github.com/tendermint/tendermint/types" ) -// KeyProof represents a proof of existence or absence of a single key. -// Copied from iavl repo. TODO -type KeyProof interface { - // Verify verfies the proof is valid. To verify absence, - // the value should be nil. - Verify(key, value, root []byte) error - - // Root returns the root hash of the proof. - Root() []byte - - // Serialize itself - Bytes() []byte -} - // GetWithProof will query the key on the given node, and verify it has // a valid proof, as defined by the Verifier. // // If there is any error in checking, returns an error. -// If val is non-empty, proof should be KeyExistsProof -// If val is empty, proof should be KeyMissingProof -func GetWithProof(key []byte, reqHeight int64, node rpcclient.Client, +func GetWithProof(prt *merkle.ProofRuntime, key []byte, reqHeight int64, node rpcclient.Client, cert lite.Verifier) ( - val cmn.HexBytes, height int64, proof KeyProof, err error) { + val cmn.HexBytes, height int64, proof *merkle.Proof, err error) { if reqHeight < 0 { - err = errors.Errorf("Height cannot be negative") + err = cmn.NewError("Height cannot be negative") return } - _resp, proof, err := GetWithProofOptions("/key", key, - rpcclient.ABCIQueryOptions{Height: int64(reqHeight)}, + res, err := GetWithProofOptions(prt, "/key", key, + rpcclient.ABCIQueryOptions{Height: int64(reqHeight), Prove: true}, node, cert) - if _resp != nil { - resp := _resp.Response - val, height = resp.Value, resp.Height + if err != nil { + return } + + resp := res.Response + val, height = resp.Value, resp.Height return val, height, proof, err } -// GetWithProofOptions is useful if you want full access to the ABCIQueryOptions -func GetWithProofOptions(path string, key []byte, opts rpcclient.ABCIQueryOptions, +// GetWithProofOptions is useful if you want full access to the ABCIQueryOptions. +// XXX Usage of path? It's not used, and sometimes it's /, sometimes /key, sometimes /store. +func GetWithProofOptions(prt *merkle.ProofRuntime, path string, key []byte, opts rpcclient.ABCIQueryOptions, node rpcclient.Client, cert lite.Verifier) ( - *ctypes.ResultABCIQuery, KeyProof, error) { + *ctypes.ResultABCIQuery, error) { - _resp, err := node.ABCIQueryWithOptions(path, key, opts) + if !opts.Prove { + return nil, cmn.NewError("require ABCIQueryOptions.Prove to be true") + } + + res, err := node.ABCIQueryWithOptions(path, key, opts) if err != nil { - return nil, nil, err + return nil, err } - resp := _resp.Response + resp := res.Response - // make sure the proof is the proper height + // Validate the response, e.g. height. if resp.IsErr() { - err = errors.Errorf("Query error for key %d: %d", key, resp.Code) - return nil, nil, err + err = cmn.NewError("Query error for key %d: %d", key, resp.Code) + return nil, err } - if len(resp.Key) == 0 || len(resp.Proof) == 0 { - return nil, nil, ErrNoData() + + if len(resp.Key) == 0 || resp.Proof == nil { + return nil, lerr.ErrEmptyTree() } if resp.Height == 0 { - return nil, nil, errors.New("Height returned is zero") + return nil, cmn.NewError("Height returned is zero") } // AppHash for height H is in header H+1 signedHeader, err := GetCertifiedCommit(resp.Height+1, node, cert) if err != nil { - return nil, nil, err - } - - _ = signedHeader - return &ctypes.ResultABCIQuery{Response: resp}, nil, nil - - /* // TODO refactor so iavl stuff is not in tendermint core - // https://github.com/tendermint/tendermint/issues/1183 - if len(resp.Value) > 0 { - // The key was found, construct a proof of existence. - proof, err := iavl.ReadKeyProof(resp.Proof) - if err != nil { - return nil, nil, errors.Wrap(err, "Error reading proof") - } - - eproof, ok := proof.(*iavl.KeyExistsProof) - if !ok { - return nil, nil, errors.New("Expected KeyExistsProof for non-empty value") - } - - // Validate the proof against the certified header to ensure data integrity. - err = eproof.Verify(resp.Key, resp.Value, signedHeader.AppHash) - if err != nil { - return nil, nil, errors.Wrap(err, "Couldn't verify proof") - } - return &ctypes.ResultABCIQuery{Response: resp}, eproof, nil - } - - // The key wasn't found, construct a proof of non-existence. - proof, err := iavl.ReadKeyProof(resp.Proof) - if err != nil { - return nil, nil, errors.Wrap(err, "Error reading proof") - } - - aproof, ok := proof.(*iavl.KeyAbsentProof) - if !ok { - return nil, nil, errors.New("Expected KeyAbsentProof for empty Value") + return nil, err } // Validate the proof against the certified header to ensure data integrity. - err = aproof.Verify(resp.Key, nil, signedHeader.AppHash) - if err != nil { - return nil, nil, errors.Wrap(err, "Couldn't verify proof") + if resp.Value != nil { + // Value exists + // XXX How do we encode the key into a string... + err = prt.VerifyValue(resp.Proof, signedHeader.AppHash, string(resp.Key), resp.Value) + if err != nil { + return nil, cmn.ErrorWrap(err, "Couldn't verify value proof") + } + return &ctypes.ResultABCIQuery{Response: resp}, nil + } else { + // Value absent + // Validate the proof against the certified header to ensure data integrity. + // XXX How do we encode the key into a string... + err = prt.VerifyAbsence(resp.Proof, signedHeader.AppHash, string(resp.Key)) + if err != nil { + return nil, cmn.ErrorWrap(err, "Couldn't verify absence proof") + } + return &ctypes.ResultABCIQuery{Response: resp}, nil } - return &ctypes.ResultABCIQuery{Response: resp}, aproof, ErrNoData() - */ } // GetCertifiedCommit gets the signed header for a given height and certifies diff --git a/lite/proxy/query_test.go b/lite/proxy/query_test.go index 7f759cc6..0e30d755 100644 --- a/lite/proxy/query_test.go +++ b/lite/proxy/query_test.go @@ -4,12 +4,12 @@ import ( "fmt" "os" "testing" + "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/abci/example/kvstore" - "github.com/tendermint/tendermint/lite" certclient "github.com/tendermint/tendermint/lite/client" nm "github.com/tendermint/tendermint/node" @@ -20,6 +20,7 @@ import ( var node *nm.Node var chainID = "tendermint_test" // TODO use from config. +var waitForEventTimeout = 5 * time.Second // TODO fix tests!! @@ -38,70 +39,87 @@ func kvstoreTx(k, v []byte) []byte { return []byte(fmt.Sprintf("%s=%s", k, v)) } +// TODO: enable it after general proof format has been adapted +// in abci/examples/kvstore.go func _TestAppProofs(t *testing.T) { assert, require := assert.New(t), require.New(t) + prt := defaultProofRuntime() cl := client.NewLocal(node) client.WaitForHeight(cl, 1, nil) + // This sets up our trust on the node based on some past point. + source := certclient.NewProvider(chainID, cl) + seed, err := source.LatestFullCommit(chainID, 1, 1) + require.NoError(err, "%#v", err) + cert := lite.NewBaseVerifier(chainID, seed.Height(), seed.Validators) + + // Wait for tx confirmation. + done := make(chan int64) + go func() { + evtTyp := types.EventTx + _, err = client.WaitForOneEvent(cl, evtTyp, waitForEventTimeout) + require.Nil(err, "%#v", err) + close(done) + }() + + // Submit a transaction. k := []byte("my-key") v := []byte("my-value") - tx := kvstoreTx(k, v) br, err := cl.BroadcastTxCommit(tx) - require.NoError(err, "%+v", err) + require.NoError(err, "%#v", err) require.EqualValues(0, br.CheckTx.Code, "%#v", br.CheckTx) require.EqualValues(0, br.DeliverTx.Code) brh := br.Height - // This sets up our trust on the node based on some past point. - source := certclient.NewProvider(chainID, cl) - seed, err := source.LatestFullCommit(chainID, brh-2, brh-2) - require.NoError(err, "%+v", err) - cert := lite.NewBaseVerifier("my-chain", seed.Height(), seed.Validators) - - client.WaitForHeight(cl, 3, nil) + // Fetch latest after tx commit. + <-done latest, err := source.LatestFullCommit(chainID, 1, 1<<63-1) - require.NoError(err, "%+v", err) + require.NoError(err, "%#v", err) rootHash := latest.SignedHeader.AppHash + if rootHash == nil { + // Fetch one block later, AppHash hasn't been committed yet. + // TODO find a way to avoid doing this. + client.WaitForHeight(cl, latest.SignedHeader.Height+1, nil) + latest, err = source.LatestFullCommit(chainID, latest.SignedHeader.Height+1, 1<<63-1) + require.NoError(err, "%#v", err) + rootHash = latest.SignedHeader.AppHash + } + require.NotNil(rootHash) // verify a query before the tx block has no data (and valid non-exist proof) - bs, height, proof, err := GetWithProof(k, brh-1, cl, cert) - fmt.Println(bs, height, proof, err) - require.NotNil(err) - require.True(IsErrNoData(err), err.Error()) + bs, height, proof, err := GetWithProof(prt, k, brh-1, cl, cert) + require.NoError(err, "%#v", err) + // require.NotNil(proof) + // TODO: Ensure that *some* keys will be there, ensuring that proof is nil, + // (currently there's a race condition) + // and ensure that proof proves absence of k. require.Nil(bs) // but given that block it is good - bs, height, proof, err = GetWithProof(k, brh, cl, cert) - require.NoError(err, "%+v", err) + bs, height, proof, err = GetWithProof(prt, k, brh, cl, cert) + require.NoError(err, "%#v", err) require.NotNil(proof) - require.True(height >= int64(latest.Height())) + require.Equal(height, brh) - // Alexis there is a bug here, somehow the above code gives us rootHash = nil - // and proof.Verify doesn't care, while proofNotExists.Verify fails. - // I am hacking this in to make it pass, but please investigate further. - rootHash = proof.Root() - - //err = wire.ReadBinaryBytes(bs, &data) - //require.NoError(err, "%+v", err) assert.EqualValues(v, bs) - err = proof.Verify(k, bs, rootHash) - assert.NoError(err, "%+v", err) + err = prt.VerifyValue(proof, rootHash, string(k), bs) // XXX key encoding + assert.NoError(err, "%#v", err) // Test non-existing key. missing := []byte("my-missing-key") - bs, _, proof, err = GetWithProof(missing, 0, cl, cert) - require.True(IsErrNoData(err)) + bs, _, proof, err = GetWithProof(prt, missing, 0, cl, cert) + require.NoError(err) require.Nil(bs) require.NotNil(proof) - err = proof.Verify(missing, nil, rootHash) - assert.NoError(err, "%+v", err) - err = proof.Verify(k, nil, rootHash) - assert.Error(err) + err = prt.VerifyAbsence(proof, rootHash, string(missing)) // XXX VerifyAbsence(), keyencoding + assert.NoError(err, "%#v", err) + err = prt.VerifyAbsence(proof, rootHash, string(k)) // XXX VerifyAbsence(), keyencoding + assert.Error(err, "%#v", err) } -func _TestTxProofs(t *testing.T) { +func TestTxProofs(t *testing.T) { assert, require := assert.New(t), require.New(t) cl := client.NewLocal(node) @@ -109,15 +127,15 @@ func _TestTxProofs(t *testing.T) { tx := kvstoreTx([]byte("key-a"), []byte("value-a")) br, err := cl.BroadcastTxCommit(tx) - require.NoError(err, "%+v", err) + require.NoError(err, "%#v", err) require.EqualValues(0, br.CheckTx.Code, "%#v", br.CheckTx) require.EqualValues(0, br.DeliverTx.Code) brh := br.Height source := certclient.NewProvider(chainID, cl) seed, err := source.LatestFullCommit(chainID, brh-2, brh-2) - require.NoError(err, "%+v", err) - cert := lite.NewBaseVerifier("my-chain", seed.Height(), seed.Validators) + require.NoError(err, "%#v", err) + cert := lite.NewBaseVerifier(chainID, seed.Height(), seed.Validators) // First let's make sure a bogus transaction hash returns a valid non-existence proof. key := types.Tx([]byte("bogus")).Hash() @@ -128,12 +146,12 @@ func _TestTxProofs(t *testing.T) { // Now let's check with the real tx hash. key = types.Tx(tx).Hash() res, err = cl.Tx(key, true) - require.NoError(err, "%+v", err) + require.NoError(err, "%#v", err) require.NotNil(res) err = res.Proof.Validate(key) - assert.NoError(err, "%+v", err) + assert.NoError(err, "%#v", err) commit, err := GetCertifiedCommit(br.Height, cl, cert) - require.Nil(err, "%+v", err) + require.Nil(err, "%#v", err) require.Equal(res.Proof.RootHash, commit.Header.DataHash) } diff --git a/lite/proxy/wrapper.go b/lite/proxy/wrapper.go index 4c0df022..7ddb3b8a 100644 --- a/lite/proxy/wrapper.go +++ b/lite/proxy/wrapper.go @@ -3,6 +3,7 @@ package proxy import ( cmn "github.com/tendermint/tendermint/libs/common" + "github.com/tendermint/tendermint/crypto/merkle" "github.com/tendermint/tendermint/lite" rpcclient "github.com/tendermint/tendermint/rpc/client" ctypes "github.com/tendermint/tendermint/rpc/core/types" @@ -15,6 +16,7 @@ var _ rpcclient.Client = Wrapper{} type Wrapper struct { rpcclient.Client cert *lite.DynamicVerifier + prt *merkle.ProofRuntime } // SecureClient uses a given Verifier to wrap an connection to an untrusted @@ -22,7 +24,8 @@ type Wrapper struct { // // If it is wrapping an HTTP rpcclient, it will also wrap the websocket interface func SecureClient(c rpcclient.Client, cert *lite.DynamicVerifier) Wrapper { - wrap := Wrapper{c, cert} + prt := defaultProofRuntime() + wrap := Wrapper{c, cert, prt} // TODO: no longer possible as no more such interface exposed.... // if we wrap http client, then we can swap out the event switch to filter // if hc, ok := c.(*rpcclient.HTTP); ok { @@ -36,7 +39,7 @@ func SecureClient(c rpcclient.Client, cert *lite.DynamicVerifier) Wrapper { func (w Wrapper) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts rpcclient.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { - res, _, err := GetWithProofOptions(path, data, opts, w.Client, w.cert) + res, err := GetWithProofOptions(w.prt, path, data, opts, w.Client, w.cert) return res, err } diff --git a/rpc/client/httpclient.go b/rpc/client/httpclient.go index a9c64f5d..a1b59ffa 100644 --- a/rpc/client/httpclient.go +++ b/rpc/client/httpclient.go @@ -75,7 +75,7 @@ func (c *HTTP) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuer func (c *HTTP) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { result := new(ctypes.ResultABCIQuery) _, err := c.rpc.Call("abci_query", - map[string]interface{}{"path": path, "data": data, "height": opts.Height, "trusted": opts.Trusted}, + map[string]interface{}{"path": path, "data": data, "height": opts.Height, "prove": opts.Prove}, result) if err != nil { return nil, errors.Wrap(err, "ABCIQuery") diff --git a/rpc/client/localclient.go b/rpc/client/localclient.go index b3c5e309..8d89b715 100644 --- a/rpc/client/localclient.go +++ b/rpc/client/localclient.go @@ -61,7 +61,7 @@ func (c *Local) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQue } func (Local) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { - return core.ABCIQuery(path, data, opts.Height, opts.Trusted) + return core.ABCIQuery(path, data, opts.Height, opts.Prove) } func (Local) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) { diff --git a/rpc/client/mock/abci.go b/rpc/client/mock/abci.go index 022e4f36..3a0ed79c 100644 --- a/rpc/client/mock/abci.go +++ b/rpc/client/mock/abci.go @@ -31,10 +31,18 @@ func (a ABCIApp) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQu } func (a ABCIApp) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { - q := a.App.Query(abci.RequestQuery{Data: data, Path: path, Height: opts.Height, Prove: opts.Trusted}) + q := a.App.Query(abci.RequestQuery{ + Data: data, + Path: path, + Height: opts.Height, + Prove: opts.Prove, + }) return &ctypes.ResultABCIQuery{q}, nil } +// NOTE: Caller should call a.App.Commit() separately, +// this function does not actually wait for a commit. +// TODO: Make it wait for a commit and set res.Height appropriately. func (a ABCIApp) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) { res := ctypes.ResultBroadcastTxCommit{} res.CheckTx = a.App.CheckTx(tx) @@ -42,6 +50,7 @@ func (a ABCIApp) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit return &res, nil } res.DeliverTx = a.App.DeliverTx(tx) + res.Height = -1 // TODO return &res, nil } @@ -86,7 +95,7 @@ func (m ABCIMock) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQ } func (m ABCIMock) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { - res, err := m.Query.GetResponse(QueryArgs{path, data, opts.Height, opts.Trusted}) + res, err := m.Query.GetResponse(QueryArgs{path, data, opts.Height, opts.Prove}) if err != nil { return nil, err } @@ -133,10 +142,10 @@ func NewABCIRecorder(client client.ABCIClient) *ABCIRecorder { } type QueryArgs struct { - Path string - Data cmn.HexBytes - Height int64 - Trusted bool + Path string + Data cmn.HexBytes + Height int64 + Prove bool } func (r *ABCIRecorder) addCall(call Call) { @@ -161,7 +170,7 @@ func (r *ABCIRecorder) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts res, err := r.Client.ABCIQueryWithOptions(path, data, opts) r.addCall(Call{ Name: "abci_query", - Args: QueryArgs{path, data, opts.Height, opts.Trusted}, + Args: QueryArgs{path, data, opts.Height, opts.Prove}, Response: res, Error: err, }) diff --git a/rpc/client/mock/abci_test.go b/rpc/client/mock/abci_test.go index 327ec9e7..ca220c84 100644 --- a/rpc/client/mock/abci_test.go +++ b/rpc/client/mock/abci_test.go @@ -51,7 +51,7 @@ func TestABCIMock(t *testing.T) { assert.Equal("foobar", err.Error()) // query always returns the response - _query, err := m.ABCIQueryWithOptions("/", nil, client.ABCIQueryOptions{Trusted: true}) + _query, err := m.ABCIQueryWithOptions("/", nil, client.ABCIQueryOptions{Prove: false}) query := _query.Response require.Nil(err) require.NotNil(query) @@ -98,7 +98,7 @@ func TestABCIRecorder(t *testing.T) { _, err := r.ABCIInfo() assert.Nil(err, "expected no err on info") - _, err = r.ABCIQueryWithOptions("path", cmn.HexBytes("data"), client.ABCIQueryOptions{Trusted: false}) + _, err = r.ABCIQueryWithOptions("path", cmn.HexBytes("data"), client.ABCIQueryOptions{Prove: false}) assert.NotNil(err, "expected error on query") require.Equal(2, len(r.Calls)) @@ -122,7 +122,7 @@ func TestABCIRecorder(t *testing.T) { require.True(ok) assert.Equal("path", qa.Path) assert.EqualValues("data", qa.Data) - assert.False(qa.Trusted) + assert.False(qa.Prove) // now add some broadcasts (should all err) txs := []types.Tx{{1}, {2}, {3}} @@ -173,9 +173,17 @@ func TestABCIApp(t *testing.T) { require.NotNil(res.DeliverTx) assert.True(res.DeliverTx.IsOK()) + // commit + // TODO: This may not be necessary in the future + if res.Height == -1 { + m.App.Commit() + } + // check the key - _qres, err := m.ABCIQueryWithOptions("/key", cmn.HexBytes(key), client.ABCIQueryOptions{Trusted: true}) + _qres, err := m.ABCIQueryWithOptions("/key", cmn.HexBytes(key), client.ABCIQueryOptions{Prove: true}) qres := _qres.Response require.Nil(err) assert.EqualValues(value, qres.Value) + + // XXX Check proof } diff --git a/rpc/client/mock/client.go b/rpc/client/mock/client.go index c5787849..ef2d4f19 100644 --- a/rpc/client/mock/client.go +++ b/rpc/client/mock/client.go @@ -1,3 +1,5 @@ +package mock + /* package mock returns a Client implementation that accepts various (mock) implementations of the various methods. @@ -11,7 +13,6 @@ For real clients, you probably want the "http" package. If you want to directly call a tendermint node in process, you can use the "local" package. */ -package mock import ( "reflect" @@ -87,7 +88,7 @@ func (c Client) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQue } func (c Client) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { - return core.ABCIQuery(path, data, opts.Height, opts.Trusted) + return core.ABCIQuery(path, data, opts.Height, opts.Prove) } func (c Client) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) { diff --git a/rpc/client/rpc_test.go b/rpc/client/rpc_test.go index 767ae684..602525b5 100644 --- a/rpc/client/rpc_test.go +++ b/rpc/client/rpc_test.go @@ -166,10 +166,10 @@ func TestAppCalls(t *testing.T) { if err := client.WaitForHeight(c, apph, nil); err != nil { t.Error(err) } - _qres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Trusted: true}) + _qres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Prove: false}) qres := _qres.Response if assert.Nil(err) && assert.True(qres.IsOK()) { - // assert.Equal(k, data.GetKey()) // only returned for proofs + assert.Equal(k, qres.Key) assert.EqualValues(v, qres.Value) } @@ -221,10 +221,12 @@ func TestAppCalls(t *testing.T) { assert.Equal(block.Block.LastCommit, commit2.Commit) // and we got a proof that works! - _pres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Trusted: false}) + _pres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Prove: true}) pres := _pres.Response assert.Nil(err) assert.True(pres.IsOK()) + + // XXX Test proof } } @@ -310,7 +312,7 @@ func TestTx(t *testing.T) { // time to verify the proof proof := ptx.Proof if tc.prove && assert.EqualValues(t, tx, proof.Data) { - assert.True(t, proof.Proof.Verify(proof.Index, proof.Total, txHash, proof.RootHash)) + assert.NoError(t, proof.Proof.Verify(proof.RootHash, txHash)) } } } @@ -348,7 +350,7 @@ func TestTxSearch(t *testing.T) { // time to verify the proof proof := ptx.Proof if assert.EqualValues(t, tx, proof.Data) { - assert.True(t, proof.Proof.Verify(proof.Index, proof.Total, txHash, proof.RootHash)) + assert.NoError(t, proof.Proof.Verify(proof.RootHash, txHash)) } // query by height @@ -362,7 +364,7 @@ func TestTxSearch(t *testing.T) { require.Len(t, result.Txs, 0) // we query using a tag (see kvstore application) - result, err = c.TxSearch("app.creator='jae'", false, 1, 30) + result, err = c.TxSearch("app.creator='Cosmoshi Netowoko'", false, 1, 30) require.Nil(t, err, "%+v", err) if len(result.Txs) == 0 { t.Fatal("expected a lot of transactions") diff --git a/rpc/client/types.go b/rpc/client/types.go index 89bd2f98..6a23fa45 100644 --- a/rpc/client/types.go +++ b/rpc/client/types.go @@ -3,10 +3,9 @@ package client // ABCIQueryOptions can be used to provide options for ABCIQuery call other // than the DefaultABCIQueryOptions. type ABCIQueryOptions struct { - Height int64 - Trusted bool + Height int64 + Prove bool } -// DefaultABCIQueryOptions are latest height (0) and trusted equal to false -// (which will result in a proof being returned). -var DefaultABCIQueryOptions = ABCIQueryOptions{Height: 0, Trusted: false} +// DefaultABCIQueryOptions are latest height (0) and prove false. +var DefaultABCIQueryOptions = ABCIQueryOptions{Height: 0, Prove: false} diff --git a/rpc/core/abci.go b/rpc/core/abci.go index 9c7af92c..47219563 100644 --- a/rpc/core/abci.go +++ b/rpc/core/abci.go @@ -1,8 +1,6 @@ package core import ( - "fmt" - abci "github.com/tendermint/tendermint/abci/types" cmn "github.com/tendermint/tendermint/libs/common" ctypes "github.com/tendermint/tendermint/rpc/core/types" @@ -12,7 +10,7 @@ import ( // Query the application for some information. // // ```shell -// curl 'localhost:26657/abci_query?path=""&data="abcd"&trusted=false' +// curl 'localhost:26657/abci_query?path=""&data="abcd"&prove=false' // ``` // // ```go @@ -47,18 +45,14 @@ import ( // |-----------+--------+---------+----------+------------------------------------------------| // | path | string | false | false | Path to the data ("/a/b/c") | // | data | []byte | false | true | Data | -// | height | int64 | 0 | false | Height (0 means latest) | -// | trusted | bool | false | false | Does not include a proof of the data inclusion | -func ABCIQuery(path string, data cmn.HexBytes, height int64, trusted bool) (*ctypes.ResultABCIQuery, error) { - if height < 0 { - return nil, fmt.Errorf("height must be non-negative") - } - +// | height | int64 | 0 | false | Height (0 means latest) | +// | prove | bool | false | false | Includes proof if true | +func ABCIQuery(path string, data cmn.HexBytes, height int64, prove bool) (*ctypes.ResultABCIQuery, error) { resQuery, err := proxyAppQuery.QuerySync(abci.RequestQuery{ Path: path, Data: data, Height: height, - Prove: !trusted, + Prove: prove, }) if err != nil { return nil, err diff --git a/test/app/kvstore_test.sh b/test/app/kvstore_test.sh index 67f6b583..034e2887 100755 --- a/test/app/kvstore_test.sh +++ b/test/app/kvstore_test.sh @@ -41,7 +41,7 @@ set -e # we should not be able to look up the value RESPONSE=`abci-cli query \"$VALUE\"` set +e -A=`echo $RESPONSE | grep $VALUE` +A=`echo $RESPONSE | grep \"value: $VALUE\"` if [[ $? == 0 ]]; then echo "Found '$VALUE' for $VALUE when we should not have. Response:" echo "$RESPONSE" diff --git a/types/block.go b/types/block.go index 14f97548..5610cc79 100644 --- a/types/block.go +++ b/types/block.go @@ -709,7 +709,6 @@ func (h hasher) Hash() []byte { } } return hasher.Sum(nil) - } func aminoHash(item interface{}) []byte { diff --git a/types/part_set.go b/types/part_set.go index f6d7f6b6..8c8151ba 100644 --- a/types/part_set.go +++ b/types/part_set.go @@ -190,7 +190,7 @@ func (ps *PartSet) AddPart(part *Part) (bool, error) { } // Check hash proof - if !part.Proof.Verify(part.Index, ps.total, part.Hash(), ps.Hash()) { + if part.Proof.Verify(ps.Hash(), part.Hash()) != nil { return false, ErrPartSetInvalidProof } diff --git a/types/results_test.go b/types/results_test.go index 8cbe319f..80803385 100644 --- a/types/results_test.go +++ b/types/results_test.go @@ -38,8 +38,8 @@ func TestABCIResults(t *testing.T) { for i, res := range results { proof := results.ProveResult(i) - valid := proof.Verify(i, len(results), res.Hash(), root) - assert.True(t, valid, "%d", i) + valid := proof.Verify(root, res.Hash()) + assert.NoError(t, valid, "%d", i) } } diff --git a/types/tx.go b/types/tx.go index 489f0b23..41fc310f 100644 --- a/types/tx.go +++ b/types/tx.go @@ -77,8 +77,6 @@ func (txs Txs) Proof(i int) TxProof { root, proofs := merkle.SimpleProofsFromHashers(hashers) return TxProof{ - Index: i, - Total: l, RootHash: root, Data: txs[i], Proof: *proofs[i], @@ -87,10 +85,9 @@ func (txs Txs) Proof(i int) TxProof { // TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree. type TxProof struct { - Index, Total int - RootHash cmn.HexBytes - Data Tx - Proof merkle.SimpleProof + RootHash cmn.HexBytes + Data Tx + Proof merkle.SimpleProof } // LeadHash returns the hash of the this proof refers to. @@ -104,14 +101,14 @@ func (tp TxProof) Validate(dataHash []byte) error { if !bytes.Equal(dataHash, tp.RootHash) { return errors.New("Proof matches different data hash") } - if tp.Index < 0 { + if tp.Proof.Index < 0 { return errors.New("Proof index cannot be negative") } - if tp.Total <= 0 { + if tp.Proof.Total <= 0 { return errors.New("Proof total must be positive") } - valid := tp.Proof.Verify(tp.Index, tp.Total, tp.LeafHash(), tp.RootHash) - if !valid { + valid := tp.Proof.Verify(tp.RootHash, tp.LeafHash()) + if valid != nil { return errors.New("Proof is not internally consistent") } return nil diff --git a/types/tx_test.go b/types/tx_test.go index df7a7449..9fb8ff34 100644 --- a/types/tx_test.go +++ b/types/tx_test.go @@ -69,8 +69,8 @@ func TestValidTxProof(t *testing.T) { leaf := txs[i] leafHash := leaf.Hash() proof := txs.Proof(i) - assert.Equal(t, i, proof.Index, "%d: %d", h, i) - assert.Equal(t, len(txs), proof.Total, "%d: %d", h, i) + assert.Equal(t, i, proof.Proof.Index, "%d: %d", h, i) + assert.Equal(t, len(txs), proof.Proof.Total, "%d: %d", h, i) assert.EqualValues(t, root, proof.RootHash, "%d: %d", h, i) assert.EqualValues(t, leaf, proof.Data, "%d: %d", h, i) assert.EqualValues(t, leafHash, proof.LeafHash(), "%d: %d", h, i) @@ -128,7 +128,7 @@ func assertBadProof(t *testing.T, root []byte, bad []byte, good TxProof) { // This can happen if we have a slightly different total (where the // path ends up the same). If it is something else, we have a real // problem. - assert.NotEqual(t, proof.Total, good.Total, "bad: %#v\ngood: %#v", proof, good) + assert.NotEqual(t, proof.Proof.Total, good.Proof.Total, "bad: %#v\ngood: %#v", proof, good) } } }