From 74cae49c3b1eadb1355a0a23ae6bb81545fb08ea Mon Sep 17 00:00:00 2001 From: Marko Date: Mon, 15 Jun 2020 11:14:36 +0200 Subject: [PATCH] proto: leftover amino (#4986) --- config/toml.go | 2 +- crypto/ed25519/ed25519.go | 8 +- crypto/ed25519/encoding.go | 18 - crypto/encoding/amino/amino.go | 18 +- crypto/encoding/amino/encode_test.go | 12 +- crypto/merkle/codec.go | 12 - crypto/merkle/compile.sh | 6 - crypto/merkle/proof.go | 1 + crypto/merkle/proof_test.go | 50 ++- crypto/merkle/proof_value.go | 24 +- crypto/merkle/types.go | 12 +- crypto/secp256k1/encoding.go | 21 +- crypto/secp256k1/secp256k1.go | 2 +- crypto/sr25519/encoding.go | 19 +- crypto/sr25519/privkey.go | 2 +- crypto/sr25519/pubkey.go | 2 +- node/node_test.go | 1 - proto/crypto/merkle/types.pb.go | 561 +++++++++++++++++++++++++-- proto/crypto/merkle/types.proto | 14 + proto/types/evidence.pb.go | 429 +++++++++++++++++--- proto/types/evidence.proto | 10 +- proto/types/types.pb.go | 454 ++++++++++++++++++---- proto/types/types.proto | 7 + proto/types/validator.pb.go | 271 +++++++++++-- proto/types/validator.proto | 5 + state/main_test.go | 3 - types/block.go | 73 ++-- types/block_meta.go | 28 -- types/block_test.go | 53 ++- types/codec.go | 28 -- types/encoding_helper.go | 41 +- types/events.go | 15 - types/evidence.go | 439 ++++++++++++++------- types/evidence_test.go | 9 +- types/params.go | 2 +- types/protobuf.go | 8 +- types/protobuf_test.go | 61 --- types/tx.go | 29 ++ types/tx_test.go | 46 ++- types/validator.go | 22 +- types/validator_set_test.go | 33 +- 41 files changed, 2170 insertions(+), 681 deletions(-) delete mode 100644 crypto/ed25519/encoding.go delete mode 100644 crypto/merkle/codec.go delete mode 100644 crypto/merkle/compile.sh delete mode 100644 types/codec.go diff --git a/config/toml.go b/config/toml.go index a6f699620..f4c7b489b 100644 --- a/config/toml.go +++ b/config/toml.go @@ -323,7 +323,7 @@ max_txs_bytes = {{ .Mempool.MaxTxsBytes }} cache_size = {{ .Mempool.CacheSize }} # Maximum size of a single transaction. -# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes} + {amino overhead}. +# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. max_tx_bytes = {{ .Mempool.MaxTxBytes }} ####################################################### diff --git a/crypto/ed25519/ed25519.go b/crypto/ed25519/ed25519.go index 8d86083b1..19bb3f062 100644 --- a/crypto/ed25519/ed25519.go +++ b/crypto/ed25519/ed25519.go @@ -18,8 +18,8 @@ import ( var _ crypto.PrivKey = PrivKey{} const ( - PrivKeyAminoName = "tendermint/PrivKeyEd25519" - PubKeyAminoName = "tendermint/PubKeyEd25519" + PrivKeyName = "tendermint/PrivKeyEd25519" + PubKeyName = "tendermint/PubKeyEd25519" // PubKeySize is is the size, in bytes, of public keys as used in this package. PubKeySize = 32 // PrivateKeySize is the size, in bytes, of private keys as used in this package. @@ -35,8 +35,8 @@ const ( ) func init() { - tmjson.RegisterType(PubKey{}, PubKeyAminoName) - tmjson.RegisterType(PrivKey{}, PrivKeyAminoName) + tmjson.RegisterType(PubKey{}, PubKeyName) + tmjson.RegisterType(PrivKey{}, PrivKeyName) } // PrivKey implements crypto.PrivKey. diff --git a/crypto/ed25519/encoding.go b/crypto/ed25519/encoding.go deleted file mode 100644 index e53931e7c..000000000 --- a/crypto/ed25519/encoding.go +++ /dev/null @@ -1,18 +0,0 @@ -package ed25519 - -import ( - amino "github.com/tendermint/go-amino" - "github.com/tendermint/tendermint/crypto" -) - -var cdc = amino.NewCodec() - -func init() { - cdc.RegisterInterface((*crypto.PubKey)(nil), nil) - cdc.RegisterConcrete(PubKey{}, - PubKeyAminoName, nil) - - cdc.RegisterInterface((*crypto.PrivKey)(nil), nil) - cdc.RegisterConcrete(PrivKey{}, - PrivKeyAminoName, nil) -} diff --git a/crypto/encoding/amino/amino.go b/crypto/encoding/amino/amino.go index a2e60e7ca..a0e71cdc4 100644 --- a/crypto/encoding/amino/amino.go +++ b/crypto/encoding/amino/amino.go @@ -30,9 +30,9 @@ func init() { // TODO: Have amino provide a way to go from concrete struct to route directly. // Its currently a private API - nameTable[reflect.TypeOf(ed25519.PubKey{})] = ed25519.PubKeyAminoName - nameTable[reflect.TypeOf(sr25519.PubKey{})] = sr25519.PubKeyAminoName - nameTable[reflect.TypeOf(secp256k1.PubKey{})] = secp256k1.PubKeyAminoName + nameTable[reflect.TypeOf(ed25519.PubKey{})] = ed25519.PubKeyName + nameTable[reflect.TypeOf(sr25519.PubKey{})] = sr25519.PubKeyName + nameTable[reflect.TypeOf(secp256k1.PubKey{})] = secp256k1.PubKeyName } // PubkeyAminoName returns the amino route of a pubkey @@ -48,19 +48,19 @@ func RegisterAmino(cdc *amino.Codec) { // These are all written here instead of cdc.RegisterInterface((*crypto.PubKey)(nil), nil) cdc.RegisterConcrete(ed25519.PubKey{}, - ed25519.PubKeyAminoName, nil) + ed25519.PubKeyName, nil) cdc.RegisterConcrete(sr25519.PubKey{}, - sr25519.PubKeyAminoName, nil) + sr25519.PubKeyName, nil) cdc.RegisterConcrete(secp256k1.PubKey{}, - secp256k1.PubKeyAminoName, nil) + secp256k1.PubKeyName, nil) cdc.RegisterInterface((*crypto.PrivKey)(nil), nil) cdc.RegisterConcrete(ed25519.PrivKey{}, - ed25519.PrivKeyAminoName, nil) + ed25519.PrivKeyName, nil) cdc.RegisterConcrete(sr25519.PrivKey{}, - sr25519.PrivKeyAminoName, nil) + sr25519.PrivKeyName, nil) cdc.RegisterConcrete(secp256k1.PrivKey{}, - secp256k1.PrivKeyAminoName, nil) + secp256k1.PrivKeyName, nil) } // RegisterKeyType registers an external key type to allow decoding it from bytes diff --git a/crypto/encoding/amino/encode_test.go b/crypto/encoding/amino/encode_test.go index 509ffa279..511c47e9d 100644 --- a/crypto/encoding/amino/encode_test.go +++ b/crypto/encoding/amino/encode_test.go @@ -135,9 +135,9 @@ func TestPubkeyAminoName(t *testing.T) { want string found bool }{ - {ed25519.PubKey{}, ed25519.PubKeyAminoName, true}, - {sr25519.PubKey{}, sr25519.PubKeyAminoName, true}, - {secp256k1.PubKey{}, secp256k1.PubKeyAminoName, true}, + {ed25519.PubKey{}, ed25519.PubKeyName, true}, + {sr25519.PubKey{}, sr25519.PubKeyName, true}, + {secp256k1.PubKey{}, secp256k1.PubKeyName, true}, } for i, tc := range tests { got, found := PubkeyAminoName(cdc, tc.key) @@ -218,7 +218,7 @@ func TestRegisterKeyType(t *testing.T) { cdc = amino.NewCodec() nameTable = make(map[reflect.Type]string, 3) RegisterAmino(cdc) - nameTable[reflect.TypeOf(ed25519.PubKey{})] = ed25519.PubKeyAminoName - nameTable[reflect.TypeOf(sr25519.PubKey{})] = sr25519.PubKeyAminoName - nameTable[reflect.TypeOf(secp256k1.PubKey{})] = secp256k1.PubKeyAminoName + nameTable[reflect.TypeOf(ed25519.PubKey{})] = ed25519.PubKeyName + nameTable[reflect.TypeOf(sr25519.PubKey{})] = sr25519.PubKeyName + nameTable[reflect.TypeOf(secp256k1.PubKey{})] = secp256k1.PubKeyName } diff --git a/crypto/merkle/codec.go b/crypto/merkle/codec.go deleted file mode 100644 index 2b6ee350b..000000000 --- a/crypto/merkle/codec.go +++ /dev/null @@ -1,12 +0,0 @@ -package merkle - -import ( - amino "github.com/tendermint/go-amino" -) - -var cdc *amino.Codec - -func init() { - cdc = amino.NewCodec() - cdc.Seal() -} diff --git a/crypto/merkle/compile.sh b/crypto/merkle/compile.sh deleted file mode 100644 index 8e4c739f4..000000000 --- a/crypto/merkle/compile.sh +++ /dev/null @@ -1,6 +0,0 @@ -#! /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/proof.go b/crypto/merkle/proof.go index ae463e83c..5f869a2a6 100644 --- a/crypto/merkle/proof.go +++ b/crypto/merkle/proof.go @@ -134,6 +134,7 @@ func ProofFromProto(pb *tmmerkle.Proof) (*Proof, error) { if pb == nil { return nil, errors.New("nil proof") } + sp := new(Proof) sp.Total = pb.Total diff --git a/crypto/merkle/proof_test.go b/crypto/merkle/proof_test.go index 398cb3e29..b07673072 100644 --- a/crypto/merkle/proof_test.go +++ b/crypto/merkle/proof_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - amino "github.com/tendermint/go-amino" + "github.com/stretchr/testify/require" tmmerkle "github.com/tendermint/tendermint/proto/crypto/merkle" ) @@ -28,21 +28,17 @@ func NewDominoOp(key, input, output string) DominoOp { } } -//nolint:unused -func DominoOpDecoder(pop tmmerkle.ProofOp) (ProofOperator, error) { - if pop.Type != ProofOpDomino { - panic("unexpected proof op type") +func (dop DominoOp) ProofOp() tmmerkle.ProofOp { + dopb := tmmerkle.DominoOp{ + Key: dop.key, + Input: dop.Input, + Output: dop.Output, } - var op DominoOp // a bit strange as we'll discard this, but it works. - err := amino.UnmarshalBinaryLengthPrefixed(pop.Data, &op) + bz, err := dopb.Marshal() if err != nil { - return nil, fmt.Errorf("decoding ProofOp.Data into ValueOp: %w", err) + panic(err) } - return NewDominoOp(string(pop.Key), op.Input, op.Output), nil -} -func (dop DominoOp) ProofOp() tmmerkle.ProofOp { - bz := amino.MustMarshalBinaryLengthPrefixed(dop) return tmmerkle.ProofOp{ Type: ProofOpDomino, Key: []byte(dop.key), @@ -72,8 +68,6 @@ func TestProofOperators(t *testing.T) { // ProofRuntime setup // TODO test this somehow. - // prt := NewProofRuntime() - // prt.RegisterOpDecoder(ProofOpDomino, DominoOpDecoder) // ProofOperators setup op1 := NewDominoOp("KEY1", "INPUT1", "INPUT2") @@ -175,3 +169,31 @@ func TestProofValidateBasic(t *testing.T) { }) } } +func TestVoteProtobuf(t *testing.T) { + + _, proofs := ProofsFromByteSlices([][]byte{ + []byte("apple"), + []byte("watermelon"), + []byte("kiwi"), + }) + testCases := []struct { + testName string + v1 *Proof + expPass bool + }{ + {"empty proof", &Proof{}, false}, + {"failure nil", nil, false}, + {"success", proofs[0], true}, + } + for _, tc := range testCases { + pb := tc.v1.ToProto() + + v, err := ProofFromProto(pb) + if tc.expPass { + require.NoError(t, err) + require.Equal(t, tc.v1, v, tc.testName) + } else { + require.Error(t, err) + } + } +} diff --git a/crypto/merkle/proof_value.go b/crypto/merkle/proof_value.go index b9be68ca7..9d92d6992 100644 --- a/crypto/merkle/proof_value.go +++ b/crypto/merkle/proof_value.go @@ -13,8 +13,8 @@ const ProofOpValue = "simple:v" // ValueOp 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. ValueOp should support -// the hash function as used in aminoHasher. TODO support +// Tendermint uses tmhash. SimpleValueOp should support +// the hash function as used in tmhash. TODO support // additional hash functions here as options/args to this // operator. // @@ -41,16 +41,28 @@ func ValueOpDecoder(pop tmmerkle.ProofOp) (ProofOperator, error) { if pop.Type != ProofOpValue { return nil, fmt.Errorf("unexpected ProofOp.Type; got %v, want %v", pop.Type, ProofOpValue) } - var op ValueOp // a bit strange as we'll discard this, but it works. - err := cdc.UnmarshalBinaryLengthPrefixed(pop.Data, &op) + var pbop tmmerkle.ValueOp // a bit strange as we'll discard this, but it works. + err := pbop.Unmarshal(pop.Data) if err != nil { return nil, fmt.Errorf("decoding ProofOp.Data into ValueOp: %w", err) } - return NewValueOp(pop.Key, op.Proof), nil + + sp, err := ProofFromProto(pbop.Proof) + if err != nil { + return nil, err + } + return NewValueOp(pop.Key, sp), nil } func (op ValueOp) ProofOp() tmmerkle.ProofOp { - bz := cdc.MustMarshalBinaryLengthPrefixed(op) + pbval := tmmerkle.ValueOp{ + Key: op.key, + Proof: op.Proof.ToProto(), + } + bz, err := pbval.Marshal() + if err != nil { + panic(err) + } return tmmerkle.ProofOp{ Type: ProofOpValue, Key: op.key, diff --git a/crypto/merkle/types.go b/crypto/merkle/types.go index 97a47879b..6a5c7e6a3 100644 --- a/crypto/merkle/types.go +++ b/crypto/merkle/types.go @@ -1,9 +1,8 @@ package merkle import ( + "encoding/binary" "io" - - amino "github.com/tendermint/go-amino" ) // Tree is a Merkle tree interface. @@ -29,5 +28,12 @@ type Tree interface { // Uvarint length prefixed byteslice func encodeByteSlice(w io.Writer, bz []byte) (err error) { - return amino.EncodeByteSlice(w, bz) + var buf [binary.MaxVarintLen64]byte + n := binary.PutUvarint(buf[:], uint64(len(bz))) + _, err = w.Write(buf[0:n]) + if err != nil { + return + } + _, err = w.Write(bz) + return } diff --git a/crypto/secp256k1/encoding.go b/crypto/secp256k1/encoding.go index 3ea0b7947..d60d513dd 100644 --- a/crypto/secp256k1/encoding.go +++ b/crypto/secp256k1/encoding.go @@ -1,28 +1,15 @@ package secp256k1 import ( - amino "github.com/tendermint/go-amino" - - "github.com/tendermint/tendermint/crypto" tmjson "github.com/tendermint/tendermint/libs/json" ) const ( - PrivKeyAminoName = "tendermint/PrivKeySecp256k1" - PubKeyAminoName = "tendermint/PubKeySecp256k1" + PrivKeyName = "tendermint/PrivKeySecp256k1" + PubKeyName = "tendermint/PubKeySecp256k1" ) -var cdc = amino.NewCodec() - func init() { - cdc.RegisterInterface((*crypto.PubKey)(nil), nil) - cdc.RegisterConcrete(PubKey{}, - PubKeyAminoName, nil) - - cdc.RegisterInterface((*crypto.PrivKey)(nil), nil) - cdc.RegisterConcrete(PrivKey{}, - PrivKeyAminoName, nil) - - tmjson.RegisterType(PubKey{}, PubKeyAminoName) - tmjson.RegisterType(PrivKey{}, PrivKeyAminoName) + tmjson.RegisterType(PubKey{}, PubKeyName) + tmjson.RegisterType(PrivKey{}, PrivKeyName) } diff --git a/crypto/secp256k1/secp256k1.go b/crypto/secp256k1/secp256k1.go index c223510dd..ec57c1648 100644 --- a/crypto/secp256k1/secp256k1.go +++ b/crypto/secp256k1/secp256k1.go @@ -24,7 +24,7 @@ const ( // PrivKey implements PrivKey. type PrivKey []byte -// Bytes marshalls the private key using amino encoding. +// Bytes returns the byte representation of the Private Key. func (privKey PrivKey) Bytes() []byte { return []byte(privKey) } diff --git a/crypto/sr25519/encoding.go b/crypto/sr25519/encoding.go index a914e1b7d..41570b5d0 100644 --- a/crypto/sr25519/encoding.go +++ b/crypto/sr25519/encoding.go @@ -1,8 +1,6 @@ package sr25519 import ( - "github.com/tendermint/go-amino" - "github.com/tendermint/tendermint/crypto" tmjson "github.com/tendermint/tendermint/libs/json" ) @@ -10,25 +8,16 @@ import ( var _ crypto.PrivKey = PrivKey{} const ( - PrivKeyAminoName = "tendermint/PrivKeySr25519" - PubKeyAminoName = "tendermint/PubKeySr25519" + PrivKeyName = "tendermint/PrivKeySr25519" + PubKeyName = "tendermint/PubKeySr25519" // SignatureSize is the size of an Edwards25519 signature. Namely the size of a compressed // Sr25519 point, and a field element. Both of which are 32 bytes. SignatureSize = 64 ) -var cdc = amino.NewCodec() - func init() { - cdc.RegisterInterface((*crypto.PubKey)(nil), nil) - cdc.RegisterConcrete(PubKey{}, - PubKeyAminoName, nil) - - cdc.RegisterInterface((*crypto.PrivKey)(nil), nil) - cdc.RegisterConcrete(PrivKey{}, - PrivKeyAminoName, nil) - tmjson.RegisterType(PubKey{}, PubKeyAminoName) - tmjson.RegisterType(PrivKey{}, PrivKeyAminoName) + tmjson.RegisterType(PubKey{}, PubKeyName) + tmjson.RegisterType(PrivKey{}, PrivKeyName) } diff --git a/crypto/sr25519/privkey.go b/crypto/sr25519/privkey.go index 215a50173..e77ca375c 100644 --- a/crypto/sr25519/privkey.go +++ b/crypto/sr25519/privkey.go @@ -16,7 +16,7 @@ const PrivKeySize = 32 // PrivKeySr25519 implements crypto.PrivKey. type PrivKey []byte -// Bytes marshals the privkey using amino encoding. +// Bytes returns the byte representation of the PrivKey. func (privKey PrivKey) Bytes() []byte { return []byte(privKey) } diff --git a/crypto/sr25519/pubkey.go b/crypto/sr25519/pubkey.go index 1256136d3..89b9cdcc7 100644 --- a/crypto/sr25519/pubkey.go +++ b/crypto/sr25519/pubkey.go @@ -26,7 +26,7 @@ func (pubKey PubKey) Address() crypto.Address { return crypto.Address(tmhash.SumTruncated(pubKey[:])) } -// Bytes marshals the PubKey using amino encoding. +// Bytes returns the byte representation of the PubKey. func (pubKey PubKey) Bytes() []byte { return []byte(pubKey) } diff --git a/node/node_test.go b/node/node_test.go index e7f3bfe89..82463dba8 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -251,7 +251,6 @@ func TestCreateProposalBlock(t *testing.T) { mempool.SetLogger(logger) // Make EvidencePool - types.RegisterMockEvidencesGlobal() // XXX! evidenceDB := dbm.NewMemDB() blockStore := store.NewBlockStore(dbm.NewMemDB()) evidencePool, err := evidence.NewPool(stateDB, evidenceDB, blockStore) diff --git a/proto/crypto/merkle/types.pb.go b/proto/crypto/merkle/types.pb.go index 41e452962..bdbccb3a3 100644 --- a/proto/crypto/merkle/types.pb.go +++ b/proto/crypto/merkle/types.pb.go @@ -91,6 +91,120 @@ func (m *Proof) GetAunts() [][]byte { return nil } +type ValueOp struct { + // Encoded in ProofOp.Key. + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // To encode in ProofOp.Data + Proof *Proof `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` +} + +func (m *ValueOp) Reset() { *m = ValueOp{} } +func (m *ValueOp) String() string { return proto.CompactTextString(m) } +func (*ValueOp) ProtoMessage() {} +func (*ValueOp) Descriptor() ([]byte, []int) { + return fileDescriptor_57e39eefdaf7ae96, []int{1} +} +func (m *ValueOp) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValueOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValueOp.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ValueOp) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValueOp.Merge(m, src) +} +func (m *ValueOp) XXX_Size() int { + return m.Size() +} +func (m *ValueOp) XXX_DiscardUnknown() { + xxx_messageInfo_ValueOp.DiscardUnknown(m) +} + +var xxx_messageInfo_ValueOp proto.InternalMessageInfo + +func (m *ValueOp) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *ValueOp) GetProof() *Proof { + if m != nil { + return m.Proof + } + return nil +} + +type DominoOp struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Input string `protobuf:"bytes,2,opt,name=input,proto3" json:"input,omitempty"` + Output string `protobuf:"bytes,3,opt,name=output,proto3" json:"output,omitempty"` +} + +func (m *DominoOp) Reset() { *m = DominoOp{} } +func (m *DominoOp) String() string { return proto.CompactTextString(m) } +func (*DominoOp) ProtoMessage() {} +func (*DominoOp) Descriptor() ([]byte, []int) { + return fileDescriptor_57e39eefdaf7ae96, []int{2} +} +func (m *DominoOp) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DominoOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DominoOp.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DominoOp) XXX_Merge(src proto.Message) { + xxx_messageInfo_DominoOp.Merge(m, src) +} +func (m *DominoOp) XXX_Size() int { + return m.Size() +} +func (m *DominoOp) XXX_DiscardUnknown() { + xxx_messageInfo_DominoOp.DiscardUnknown(m) +} + +var xxx_messageInfo_DominoOp proto.InternalMessageInfo + +func (m *DominoOp) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *DominoOp) GetInput() string { + if m != nil { + return m.Input + } + return "" +} + +func (m *DominoOp) GetOutput() string { + if m != nil { + return m.Output + } + return "" +} + // ProofOp defines an operation used for calculating Merkle root // The data could be arbitrary format, providing nessecary data // for example neighbouring node hash @@ -104,7 +218,7 @@ 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_57e39eefdaf7ae96, []int{1} + return fileDescriptor_57e39eefdaf7ae96, []int{3} } func (m *ProofOp) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -163,7 +277,7 @@ func (m *ProofOps) Reset() { *m = ProofOps{} } func (m *ProofOps) String() string { return proto.CompactTextString(m) } func (*ProofOps) ProtoMessage() {} func (*ProofOps) Descriptor() ([]byte, []int) { - return fileDescriptor_57e39eefdaf7ae96, []int{2} + return fileDescriptor_57e39eefdaf7ae96, []int{4} } func (m *ProofOps) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -201,6 +315,8 @@ func (m *ProofOps) GetOps() []ProofOp { func init() { proto.RegisterType((*Proof)(nil), "tendermint.proto.crypto.merkle.Proof") + proto.RegisterType((*ValueOp)(nil), "tendermint.proto.crypto.merkle.ValueOp") + proto.RegisterType((*DominoOp)(nil), "tendermint.proto.crypto.merkle.DominoOp") proto.RegisterType((*ProofOp)(nil), "tendermint.proto.crypto.merkle.ProofOp") proto.RegisterType((*ProofOps)(nil), "tendermint.proto.crypto.merkle.ProofOps") } @@ -208,26 +324,31 @@ func init() { func init() { proto.RegisterFile("proto/crypto/merkle/types.proto", fileDescriptor_57e39eefdaf7ae96) } var fileDescriptor_57e39eefdaf7ae96 = []byte{ - // 303 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x51, 0x3f, 0x4b, 0x03, 0x31, - 0x1c, 0xbd, 0x78, 0xad, 0xb6, 0xb1, 0x83, 0x04, 0x87, 0x43, 0x21, 0x3d, 0x3a, 0xe8, 0x4d, 0x39, - 0x50, 0x77, 0xa1, 0x2e, 0x82, 0xa0, 0x92, 0xd1, 0xa5, 0xa4, 0xbd, 0xb4, 0x77, 0xb4, 0xbd, 0x84, - 0xe4, 0x57, 0xf0, 0xbe, 0x85, 0x1f, 0xab, 0x63, 0x47, 0x27, 0x91, 0xf6, 0x8b, 0x48, 0x92, 0x42, - 0x1d, 0xc4, 0xed, 0xbd, 0x97, 0xf7, 0x87, 0x24, 0xb8, 0xaf, 0x8d, 0x02, 0x95, 0x4f, 0x4c, 0xa3, - 0x41, 0xe5, 0x4b, 0x69, 0xe6, 0x0b, 0x99, 0x43, 0xa3, 0xa5, 0x65, 0xfe, 0x84, 0x50, 0x90, 0x75, - 0x21, 0xcd, 0xb2, 0xaa, 0x21, 0x28, 0x2c, 0x78, 0x59, 0xf0, 0x5e, 0x5c, 0x41, 0x59, 0x99, 0x62, - 0xa4, 0x85, 0x81, 0x26, 0x0f, 0x65, 0x33, 0x35, 0x53, 0x07, 0x14, 0x52, 0x83, 0x29, 0x6e, 0xbf, - 0x1a, 0xa5, 0xa6, 0xe4, 0x1c, 0xb7, 0x41, 0x81, 0x58, 0x24, 0x28, 0x45, 0x59, 0xcc, 0x03, 0x71, - 0x6a, 0x55, 0x17, 0xf2, 0x3d, 0x39, 0x0a, 0xaa, 0x27, 0xe4, 0x12, 0x77, 0x17, 0x52, 0x4c, 0x47, - 0xa5, 0xb0, 0x65, 0x12, 0xa7, 0x28, 0xeb, 0xf1, 0x8e, 0x13, 0x1e, 0x85, 0x2d, 0x5d, 0x44, 0xac, - 0x6a, 0xb0, 0x49, 0x2b, 0x8d, 0xb3, 0x1e, 0x0f, 0x64, 0xf0, 0x80, 0x4f, 0xfc, 0xce, 0x8b, 0x26, - 0x04, 0xb7, 0xdc, 0x4d, 0xfc, 0x50, 0x97, 0x7b, 0x4c, 0xce, 0x70, 0x3c, 0x97, 0x8d, 0x5f, 0xe9, - 0x71, 0x07, 0x9d, 0xab, 0x10, 0x20, 0xf6, 0xf5, 0x1e, 0x0f, 0x9e, 0x70, 0x67, 0x5f, 0x62, 0xc9, - 0x3d, 0x8e, 0x95, 0xb6, 0x09, 0x4a, 0xe3, 0xec, 0xf4, 0xe6, 0x9a, 0xfd, 0xff, 0x1c, 0x6c, 0x1f, - 0x1b, 0xb6, 0xd6, 0x5f, 0xfd, 0x88, 0xbb, 0xe4, 0xf0, 0x79, 0xbd, 0xa5, 0x68, 0xb3, 0xa5, 0xe8, - 0x7b, 0x4b, 0xd1, 0xc7, 0x8e, 0x46, 0x9b, 0x1d, 0x8d, 0x3e, 0x77, 0x34, 0x7a, 0xbb, 0x9b, 0x55, - 0x50, 0xae, 0xc6, 0x6c, 0xa2, 0x96, 0xf9, 0xa1, 0xf7, 0x37, 0xfc, 0xe3, 0x77, 0xc6, 0xc7, 0x5e, - 0xbc, 0xfd, 0x09, 0x00, 0x00, 0xff, 0xff, 0x3b, 0x62, 0x4b, 0x7e, 0xbb, 0x01, 0x00, 0x00, + // 372 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x4f, 0x4b, 0xc3, 0x30, + 0x18, 0xc6, 0xdb, 0xb5, 0xfb, 0x97, 0xed, 0x20, 0x41, 0xa4, 0x28, 0x74, 0xa5, 0xa0, 0xf6, 0xd4, + 0xc2, 0xf4, 0xe6, 0x41, 0x98, 0x1e, 0x44, 0xc1, 0x49, 0x0f, 0x22, 0x5e, 0x46, 0xb6, 0x66, 0x6b, + 0x59, 0xdb, 0x84, 0x34, 0x05, 0xfb, 0x2d, 0xfc, 0x58, 0x3b, 0xee, 0xe8, 0x49, 0x64, 0xfb, 0x22, + 0x92, 0xa4, 0x32, 0x05, 0x11, 0x6f, 0xcf, 0xf3, 0x34, 0xcf, 0x2f, 0xef, 0x1b, 0x0a, 0x06, 0x94, + 0x11, 0x4e, 0x82, 0x19, 0xab, 0x28, 0x27, 0x41, 0x86, 0xd9, 0x32, 0xc5, 0x01, 0xaf, 0x28, 0x2e, + 0x7c, 0xf9, 0x05, 0xda, 0x1c, 0xe7, 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90, 0xda, 0xbd, + 0x03, 0x9d, 0x1a, 0x52, 0xc0, 0x4b, 0x60, 0x10, 0x5a, 0x58, 0xba, 0x63, 0x78, 0xbd, 0xe1, 0xe9, + 0xbf, 0xf6, 0x1a, 0xd3, 0x91, 0xb9, 0x7a, 0x1f, 0x68, 0xa1, 0x68, 0x8e, 0xee, 0x57, 0x1b, 0x5b, + 0x5f, 0x6f, 0x6c, 0xfd, 0x63, 0x63, 0xeb, 0xaf, 0x5b, 0x5b, 0x5b, 0x6f, 0x6d, 0xed, 0x6d, 0x6b, + 0x6b, 0xcf, 0xe7, 0x8b, 0x84, 0xc7, 0xe5, 0xd4, 0x9f, 0x91, 0x2c, 0xd8, 0x71, 0xbf, 0xcb, 0x5f, + 0xfe, 0xa1, 0x69, 0x4b, 0x86, 0x67, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xee, 0x66, 0x38, 0xd7, + 0x61, 0x02, 0x00, 0x00, } func (m *Proof) Marshal() (dAtA []byte, err error) { @@ -279,6 +400,92 @@ func (m *Proof) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ValueOp) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ValueOp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValueOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Proof != nil { + { + size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DominoOp) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DominoOp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DominoOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Output) > 0 { + i -= len(m.Output) + copy(dAtA[i:], m.Output) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Output))) + i-- + dAtA[i] = 0x1a + } + if len(m.Input) > 0 { + i -= len(m.Input) + copy(dAtA[i:], m.Input) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Input))) + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *ProofOp) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -396,6 +603,44 @@ func (m *Proof) Size() (n int) { return n } +func (m *ValueOp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.Proof != nil { + l = m.Proof.Size() + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *DominoOp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Input) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Output) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + func (m *ProofOp) Size() (n int) { if m == nil { return 0 @@ -595,6 +840,278 @@ func (m *Proof) Unmarshal(dAtA []byte) error { } return nil } +func (m *ValueOp) 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 ErrIntOverflowTypes + } + 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: ValueOp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValueOp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Proof == nil { + m.Proof = &Proof{} + } + if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DominoOp) 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 ErrIntOverflowTypes + } + 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: DominoOp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DominoOp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Input", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Input = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Output", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Output = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ProofOp) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/proto/crypto/merkle/types.proto b/proto/crypto/merkle/types.proto index 905ef80c8..e81215416 100644 --- a/proto/crypto/merkle/types.proto +++ b/proto/crypto/merkle/types.proto @@ -12,6 +12,20 @@ message Proof { repeated bytes aunts = 4; } +message ValueOp { + // Encoded in ProofOp.Key. + bytes key = 1; + + // To encode in ProofOp.Data + Proof proof = 2; +} + +message DominoOp { + string key = 1; + string input = 2; + string output = 3; +} + // ProofOp defines an operation used for calculating Merkle root // The data could be arbitrary format, providing nessecary data // for example neighbouring node hash diff --git a/proto/types/evidence.pb.go b/proto/types/evidence.pb.go index 391075d90..cd5ca0c4b 100644 --- a/proto/types/evidence.pb.go +++ b/proto/types/evidence.pb.go @@ -435,6 +435,58 @@ func (m *LunaticValidatorEvidence) GetInvalidHeaderField() string { return "" } +type PhantomValidatorEvidence struct { + Vote *Vote `protobuf:"bytes,1,opt,name=vote,proto3" json:"vote,omitempty"` + LastHeightValidatorWasInSet int64 `protobuf:"varint,2,opt,name=last_height_validator_was_in_set,json=lastHeightValidatorWasInSet,proto3" json:"last_height_validator_was_in_set,omitempty"` +} + +func (m *PhantomValidatorEvidence) Reset() { *m = PhantomValidatorEvidence{} } +func (m *PhantomValidatorEvidence) String() string { return proto.CompactTextString(m) } +func (*PhantomValidatorEvidence) ProtoMessage() {} +func (*PhantomValidatorEvidence) Descriptor() ([]byte, []int) { + return fileDescriptor_86495eef24aeacc0, []int{7} +} +func (m *PhantomValidatorEvidence) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PhantomValidatorEvidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PhantomValidatorEvidence.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PhantomValidatorEvidence) XXX_Merge(src proto.Message) { + xxx_messageInfo_PhantomValidatorEvidence.Merge(m, src) +} +func (m *PhantomValidatorEvidence) XXX_Size() int { + return m.Size() +} +func (m *PhantomValidatorEvidence) XXX_DiscardUnknown() { + xxx_messageInfo_PhantomValidatorEvidence.DiscardUnknown(m) +} + +var xxx_messageInfo_PhantomValidatorEvidence proto.InternalMessageInfo + +func (m *PhantomValidatorEvidence) GetVote() *Vote { + if m != nil { + return m.Vote + } + return nil +} + +func (m *PhantomValidatorEvidence) GetLastHeightValidatorWasInSet() int64 { + if m != nil { + return m.LastHeightValidatorWasInSet + } + return 0 +} + type Evidence struct { // Types that are valid to be assigned to Sum: // *Evidence_DuplicateVoteEvidence @@ -442,6 +494,7 @@ type Evidence struct { // *Evidence_LunaticValidatorEvidence // *Evidence_PotentialAmnesiaEvidence // *Evidence_AmnesiaEvidence + // *Evidence_PhantomValidatorEvidence // *Evidence_MockEvidence // *Evidence_MockRandomEvidence Sum isEvidence_Sum `protobuf_oneof:"sum"` @@ -451,7 +504,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_86495eef24aeacc0, []int{7} + return fileDescriptor_86495eef24aeacc0, []int{8} } func (m *Evidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -501,11 +554,14 @@ type Evidence_PotentialAmnesiaEvidence struct { type Evidence_AmnesiaEvidence struct { AmnesiaEvidence *AmnesiaEvidence `protobuf:"bytes,5,opt,name=amnesia_evidence,json=amnesiaEvidence,proto3,oneof" json:"amnesia_evidence,omitempty"` } +type Evidence_PhantomValidatorEvidence struct { + PhantomValidatorEvidence *PhantomValidatorEvidence `protobuf:"bytes,6,opt,name=phantom_validator_evidence,json=phantomValidatorEvidence,proto3,oneof" json:"phantom_validator_evidence,omitempty"` +} type Evidence_MockEvidence struct { - MockEvidence *MockEvidence `protobuf:"bytes,6,opt,name=mock_evidence,json=mockEvidence,proto3,oneof" json:"mock_evidence,omitempty"` + MockEvidence *MockEvidence `protobuf:"bytes,7,opt,name=mock_evidence,json=mockEvidence,proto3,oneof" json:"mock_evidence,omitempty"` } type Evidence_MockRandomEvidence struct { - MockRandomEvidence *MockRandomEvidence `protobuf:"bytes,7,opt,name=mock_random_evidence,json=mockRandomEvidence,proto3,oneof" json:"mock_random_evidence,omitempty"` + MockRandomEvidence *MockRandomEvidence `protobuf:"bytes,8,opt,name=mock_random_evidence,json=mockRandomEvidence,proto3,oneof" json:"mock_random_evidence,omitempty"` } func (*Evidence_DuplicateVoteEvidence) isEvidence_Sum() {} @@ -513,6 +569,7 @@ func (*Evidence_ConflictingHeadersEvidence) isEvidence_Sum() {} func (*Evidence_LunaticValidatorEvidence) isEvidence_Sum() {} func (*Evidence_PotentialAmnesiaEvidence) isEvidence_Sum() {} func (*Evidence_AmnesiaEvidence) isEvidence_Sum() {} +func (*Evidence_PhantomValidatorEvidence) isEvidence_Sum() {} func (*Evidence_MockEvidence) isEvidence_Sum() {} func (*Evidence_MockRandomEvidence) isEvidence_Sum() {} @@ -558,6 +615,13 @@ func (m *Evidence) GetAmnesiaEvidence() *AmnesiaEvidence { return nil } +func (m *Evidence) GetPhantomValidatorEvidence() *PhantomValidatorEvidence { + if x, ok := m.GetSum().(*Evidence_PhantomValidatorEvidence); ok { + return x.PhantomValidatorEvidence + } + return nil +} + func (m *Evidence) GetMockEvidence() *MockEvidence { if x, ok := m.GetSum().(*Evidence_MockEvidence); ok { return x.MockEvidence @@ -580,6 +644,7 @@ func (*Evidence) XXX_OneofWrappers() []interface{} { (*Evidence_LunaticValidatorEvidence)(nil), (*Evidence_PotentialAmnesiaEvidence)(nil), (*Evidence_AmnesiaEvidence)(nil), + (*Evidence_PhantomValidatorEvidence)(nil), (*Evidence_MockEvidence)(nil), (*Evidence_MockRandomEvidence)(nil), } @@ -595,7 +660,7 @@ func (m *EvidenceData) Reset() { *m = EvidenceData{} } func (m *EvidenceData) String() string { return proto.CompactTextString(m) } func (*EvidenceData) ProtoMessage() {} func (*EvidenceData) Descriptor() ([]byte, []int) { - return fileDescriptor_86495eef24aeacc0, []int{8} + return fileDescriptor_86495eef24aeacc0, []int{9} } func (m *EvidenceData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -647,7 +712,7 @@ func (m *ProofOfLockChange) Reset() { *m = ProofOfLockChange{} } func (m *ProofOfLockChange) String() string { return proto.CompactTextString(m) } func (*ProofOfLockChange) ProtoMessage() {} func (*ProofOfLockChange) Descriptor() ([]byte, []int) { - return fileDescriptor_86495eef24aeacc0, []int{9} + return fileDescriptor_86495eef24aeacc0, []int{10} } func (m *ProofOfLockChange) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -698,6 +763,7 @@ func init() { proto.RegisterType((*MockRandomEvidence)(nil), "tendermint.proto.types.MockRandomEvidence") proto.RegisterType((*ConflictingHeadersEvidence)(nil), "tendermint.proto.types.ConflictingHeadersEvidence") proto.RegisterType((*LunaticValidatorEvidence)(nil), "tendermint.proto.types.LunaticValidatorEvidence") + proto.RegisterType((*PhantomValidatorEvidence)(nil), "tendermint.proto.types.PhantomValidatorEvidence") proto.RegisterType((*Evidence)(nil), "tendermint.proto.types.Evidence") proto.RegisterType((*EvidenceData)(nil), "tendermint.proto.types.EvidenceData") proto.RegisterType((*ProofOfLockChange)(nil), "tendermint.proto.types.ProofOfLockChange") @@ -706,61 +772,66 @@ func init() { func init() { proto.RegisterFile("proto/types/evidence.proto", fileDescriptor_86495eef24aeacc0) } var fileDescriptor_86495eef24aeacc0 = []byte{ - // 858 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcf, 0x6f, 0xdc, 0x44, - 0x14, 0xb6, 0xb3, 0x9b, 0x6d, 0xfa, 0xb2, 0x25, 0x65, 0xd4, 0x52, 0xcb, 0x6a, 0x37, 0xc1, 0x42, - 0x34, 0x45, 0xe0, 0x4d, 0xb7, 0x88, 0x1b, 0x12, 0xd9, 0x96, 0x6a, 0x51, 0x8a, 0xa8, 0xa6, 0x55, - 0x0f, 0x1c, 0xb0, 0xc6, 0xf6, 0xac, 0x3d, 0x5a, 0xdb, 0x63, 0xd9, 0xe3, 0x95, 0x7c, 0xe4, 0x06, - 0xb7, 0xfe, 0x17, 0x9c, 0xb8, 0x72, 0xe6, 0x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 0xcd, 0xf1, 0x48, 0x7f, 0x7b, 0x3c, 0xd2, 0xff, 0x3e, 0x1e, 0xe9, 0xaf, 0x4f, 0x46, 0xda, 0xdb, - 0x93, 0x91, 0xf6, 0xfb, 0xc9, 0x48, 0xfb, 0xf6, 0xe3, 0x80, 0x89, 0xb0, 0x70, 0x6d, 0x8f, 0xc7, - 0xe3, 0x15, 0xe9, 0xfa, 0xe3, 0xda, 0xd7, 0x91, 0x3b, 0x90, 0x7f, 0x1e, 0xfd, 0x13, 0x00, 0x00, - 0xff, 0xff, 0xa6, 0x62, 0x87, 0x20, 0x8f, 0x09, 0x00, 0x00, + // 930 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcf, 0x8f, 0xdb, 0x44, + 0x14, 0xb6, 0x37, 0xd9, 0x74, 0xfb, 0x36, 0x65, 0x8b, 0xd5, 0xd2, 0x28, 0xb4, 0xd9, 0xc5, 0x42, + 0x74, 0x8b, 0xc0, 0xd9, 0xa6, 0x88, 0x1b, 0x12, 0x9b, 0xfe, 0x50, 0xaa, 0x2d, 0xa2, 0x9a, 0xad, + 0x8a, 0xc4, 0x01, 0x6b, 0x62, 0x4f, 0xec, 0x51, 0x6c, 0x8f, 0x65, 0x4f, 0x82, 0x72, 0xe4, 0x06, + 0xb7, 0x4a, 0xfc, 0x11, 0x9c, 0xb8, 0x72, 0xe6, 0x58, 0x89, 0x4b, 0xc5, 0x89, 0x13, 0xa0, 0xdd, + 0x7f, 0x04, 0xcd, 0x8c, 0xed, 0xa4, 0x9b, 0x4c, 0x88, 0x38, 0x20, 0xf5, 0x12, 0x39, 0x6f, 0xde, + 0xfb, 0xde, 0xf7, 0xc6, 0xdf, 0x7c, 0x1e, 0x68, 0xa7, 0x19, 0xe3, 0xac, 0xcb, 0x67, 0x29, 0xc9, + 0xbb, 0x64, 0x4a, 0x7d, 0x92, 0x78, 0xc4, 0x91, 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0x73, 0xc4, 0x5d, 0xcc, 0x79, 0x3a, 0x19, 0x46, 0xd4, 0x3b, 0x21, 0x33, 0xd4, + 0x48, 0x27, 0xc3, 0x13, 0x32, 0xeb, 0x3f, 0x7a, 0x79, 0xd6, 0x31, 0x5f, 0x9d, 0x75, 0xcc, 0xbf, + 0xcf, 0x3a, 0xe6, 0x8b, 0xf3, 0x8e, 0xf1, 0xea, 0xbc, 0x63, 0xfc, 0x71, 0xde, 0x31, 0xbe, 0xfe, + 0x28, 0xa0, 0x3c, 0x9c, 0x0c, 0x1d, 0x8f, 0xc5, 0xdd, 0x39, 0xe8, 0xe2, 0xe3, 0xc2, 0x2d, 0x71, + 0xd8, 0x90, 0x7f, 0xee, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0x7c, 0xcb, 0x14, 0xa7, 0x97, 0x0a, + 0x00, 0x00, } func (m *DuplicateVoteEvidence) Marshal() (dAtA []byte, err error) { @@ -1103,6 +1174,46 @@ func (m *LunaticValidatorEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *PhantomValidatorEvidence) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PhantomValidatorEvidence) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PhantomValidatorEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.LastHeightValidatorWasInSet != 0 { + i = encodeVarintEvidence(dAtA, i, uint64(m.LastHeightValidatorWasInSet)) + i-- + dAtA[i] = 0x10 + } + if m.Vote != nil { + { + size, err := m.Vote.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvidence(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *Evidence) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1240,6 +1351,27 @@ func (m *Evidence_AmnesiaEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error } return len(dAtA) - i, nil } +func (m *Evidence_PhantomValidatorEvidence) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Evidence_PhantomValidatorEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.PhantomValidatorEvidence != nil { + { + size, err := m.PhantomValidatorEvidence.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvidence(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + return len(dAtA) - i, nil +} func (m *Evidence_MockEvidence) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) @@ -1257,7 +1389,7 @@ func (m *Evidence_MockEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintEvidence(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } return len(dAtA) - i, nil } @@ -1278,7 +1410,7 @@ func (m *Evidence_MockRandomEvidence) MarshalToSizedBuffer(dAtA []byte) (int, er i = encodeVarintEvidence(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x42 } return len(dAtA) - i, nil } @@ -1518,6 +1650,22 @@ func (m *LunaticValidatorEvidence) Size() (n int) { return n } +func (m *PhantomValidatorEvidence) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Vote != nil { + l = m.Vote.Size() + n += 1 + l + sovEvidence(uint64(l)) + } + if m.LastHeightValidatorWasInSet != 0 { + n += 1 + sovEvidence(uint64(m.LastHeightValidatorWasInSet)) + } + return n +} + func (m *Evidence) Size() (n int) { if m == nil { return 0 @@ -1590,6 +1738,18 @@ func (m *Evidence_AmnesiaEvidence) Size() (n int) { } return n } +func (m *Evidence_PhantomValidatorEvidence) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PhantomValidatorEvidence != nil { + l = m.PhantomValidatorEvidence.Size() + n += 1 + l + sovEvidence(uint64(l)) + } + return n +} func (m *Evidence_MockEvidence) Size() (n int) { if m == nil { return 0 @@ -2646,6 +2806,114 @@ func (m *LunaticValidatorEvidence) Unmarshal(dAtA []byte) error { } return nil } +func (m *PhantomValidatorEvidence) 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 ErrIntOverflowEvidence + } + 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: PhantomValidatorEvidence: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PhantomValidatorEvidence: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Vote", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidence + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvidence + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvidence + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Vote == nil { + m.Vote = &Vote{} + } + if err := m.Vote.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastHeightValidatorWasInSet", wireType) + } + m.LastHeightValidatorWasInSet = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidence + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastHeightValidatorWasInSet |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvidence(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthEvidence + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthEvidence + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Evidence) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2851,6 +3119,41 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { m.Sum = &Evidence_AmnesiaEvidence{v} iNdEx = postIndex case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PhantomValidatorEvidence", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidence + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvidence + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvidence + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &PhantomValidatorEvidence{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &Evidence_PhantomValidatorEvidence{v} + iNdEx = postIndex + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MockEvidence", wireType) } @@ -2885,7 +3188,7 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { } m.Sum = &Evidence_MockEvidence{v} iNdEx = postIndex - case 7: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MockRandomEvidence", wireType) } diff --git a/proto/types/evidence.proto b/proto/types/evidence.proto index 749e010ca..45e469751 100644 --- a/proto/types/evidence.proto +++ b/proto/types/evidence.proto @@ -53,6 +53,11 @@ message LunaticValidatorEvidence { string invalid_header_field = 3; } +message PhantomValidatorEvidence { + Vote vote = 1; + int64 last_height_validator_was_in_set = 2; +} + message Evidence { oneof sum { DuplicateVoteEvidence duplicate_vote_evidence = 1; @@ -60,9 +65,10 @@ message Evidence { LunaticValidatorEvidence lunatic_validator_evidence = 3; PotentialAmnesiaEvidence potential_amnesia_evidence = 4; AmnesiaEvidence amnesia_evidence = 5; + PhantomValidatorEvidence phantom_validator_evidence = 6; - MockEvidence mock_evidence = 6; - MockRandomEvidence mock_random_evidence = 7; + MockEvidence mock_evidence = 7; + MockRandomEvidence mock_random_evidence = 8; } } diff --git a/proto/types/types.pb.go b/proto/types/types.pb.go index be75cbcb8..77fc97a2d 100644 --- a/proto/types/types.pb.go +++ b/proto/types/types.pb.go @@ -939,6 +939,67 @@ func (m *BlockMeta) GetNumTxs() int64 { return 0 } +// TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree. +type TxProof struct { + RootHash []byte `protobuf:"bytes,1,opt,name=root_hash,json=rootHash,proto3" json:"root_hash,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + Proof *merkle.Proof `protobuf:"bytes,3,opt,name=Proof,proto3" json:"Proof,omitempty"` +} + +func (m *TxProof) Reset() { *m = TxProof{} } +func (m *TxProof) String() string { return proto.CompactTextString(m) } +func (*TxProof) ProtoMessage() {} +func (*TxProof) Descriptor() ([]byte, []int) { + return fileDescriptor_ff06f8095857fb18, []int{11} +} +func (m *TxProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TxProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TxProof.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TxProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_TxProof.Merge(m, src) +} +func (m *TxProof) XXX_Size() int { + return m.Size() +} +func (m *TxProof) XXX_DiscardUnknown() { + xxx_messageInfo_TxProof.DiscardUnknown(m) +} + +var xxx_messageInfo_TxProof proto.InternalMessageInfo + +func (m *TxProof) GetRootHash() []byte { + if m != nil { + return m.RootHash + } + return nil +} + +func (m *TxProof) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +func (m *TxProof) GetProof() *merkle.Proof { + if m != nil { + return m.Proof + } + return nil +} + func init() { proto.RegisterEnum("tendermint.proto.types.BlockIDFlag", BlockIDFlag_name, BlockIDFlag_value) proto.RegisterEnum("tendermint.proto.types.SignedMsgType", SignedMsgType_name, SignedMsgType_value) @@ -953,92 +1014,96 @@ func init() { proto.RegisterType((*Proposal)(nil), "tendermint.proto.types.Proposal") proto.RegisterType((*SignedHeader)(nil), "tendermint.proto.types.SignedHeader") proto.RegisterType((*BlockMeta)(nil), "tendermint.proto.types.BlockMeta") + proto.RegisterType((*TxProof)(nil), "tendermint.proto.types.TxProof") } func init() { proto.RegisterFile("proto/types/types.proto", fileDescriptor_ff06f8095857fb18) } var fileDescriptor_ff06f8095857fb18 = []byte{ - // 1274 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x4d, 0x6f, 0x1a, 0x47, - 0x18, 0xf6, 0xc2, 0x62, 0xe0, 0x05, 0x6c, 0xbc, 0x72, 0x13, 0x8a, 0x5b, 0x4c, 0x70, 0x93, 0x3a, - 0x69, 0x04, 0x95, 0x2b, 0x55, 0x8d, 0xd4, 0x0b, 0x5f, 0x71, 0x50, 0x6c, 0x40, 0x0b, 0x4d, 0xd5, - 0x5e, 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f, 0x9c, - 0xcc, 0x56, 0x90, 0x2f, 0x73, 0xef, 0x94, 0x03, 0xef, 0x94, 0xfb, 0x81, 0x77, 0x6a, 0x09, 0x3a, - 0xf1, 0xb3, 0xdf, 0x77, 0x25, 0x95, 0x31, 0x94, 0x16, 0x64, 0x2c, 0xe4, 0x13, 0x6d, 0x40, 0xd5, - 0xa3, 0xd3, 0xc7, 0x58, 0x89, 0xdd, 0x55, 0xd2, 0x08, 0x95, 0x03, 0x51, 0x28, 0x97, 0x87, 0x74, - 0x65, 0x1f, 0xb2, 0xac, 0xd4, 0xd0, 0x19, 0x8f, 0x4d, 0xa2, 0xb1, 0x4d, 0x58, 0x67, 0x9b, 0xb0, - 0x41, 0xe3, 0x75, 0x16, 0x7e, 0x40, 0xb7, 0x63, 0x07, 0x92, 0x3a, 0x22, 0x88, 0x43, 0xe2, 0x0c, - 0x92, 0xa0, 0x01, 0x96, 0xfc, 0x18, 0x36, 0x4f, 0x90, 0x65, 0xea, 0x88, 0x38, 0x9e, 0xcf, 0x21, - 0x09, 0x5e, 0x65, 0x16, 0x66, 0xc0, 0x4f, 0x61, 0xdb, 0xc6, 0xa7, 0x44, 0x7b, 0x1d, 0x9d, 0x64, - 0x68, 0x85, 0xe6, 0x1e, 0x2d, 0x32, 0x6e, 0xc2, 0xc6, 0x30, 0xd8, 0x02, 0x8e, 0x05, 0x86, 0xcd, - 0x84, 0x51, 0x06, 0x7b, 0x1f, 0x12, 0xc8, 0x75, 0x39, 0x20, 0xc5, 0x00, 0x71, 0xe4, 0xba, 0x2c, - 0x75, 0x07, 0xb6, 0x58, 0x8f, 0x1e, 0xf6, 0x27, 0x16, 0x11, 0x45, 0xd2, 0x0c, 0xb3, 0x49, 0x13, - 0x2a, 0x8f, 0x33, 0xec, 0x1e, 0x64, 0xf0, 0x89, 0xa9, 0x63, 0x7b, 0x88, 0x39, 0x2e, 0xc3, 0x70, - 0xe9, 0x20, 0xc8, 0x40, 0xb7, 0x21, 0xeb, 0x7a, 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, 0x55, 0x9b, 0x8f, 0x3a, 0xfd, 0x26, 0xcb, - 0x64, 0xa5, 0xfc, 0xe6, 0xd9, 0x79, 0x31, 0xd5, 0xf5, 0xf0, 0x89, 0x43, 0x30, 0xe3, 0xdf, 0x84, - 0x8d, 0xae, 0xda, 0xe4, 0x8b, 0xe5, 0xa0, 0x48, 0x7e, 0xeb, 0xec, 0xbc, 0x98, 0xe9, 0x7a, 0x98, - 0x1b, 0x81, 0xc1, 0xf6, 0x20, 0xd3, 0x55, 0x3b, 0xdd, 0x4e, 0xaf, 0x7a, 0xc4, 0x51, 0xd1, 0x7c, - 0xf6, 0xec, 0xbc, 0x98, 0x0e, 0x8e, 0x38, 0x05, 0xcd, 0xd6, 0x59, 0xbb, 0xff, 0xe2, 0xa2, 0x20, - 0xbd, 0xbc, 0x28, 0x48, 0x7f, 0x5c, 0x14, 0xa4, 0x67, 0x97, 0x85, 0xb5, 0x97, 0x97, 0x85, 0xb5, - 0xdf, 0x2e, 0x0b, 0x6b, 0xdf, 0xde, 0x35, 0x4c, 0x32, 0x9a, 0x0c, 0xca, 0x43, 0x67, 0x5c, 0x99, - 0xed, 0xea, 0xfc, 0xe7, 0xdc, 0x8f, 0x8a, 0xc1, 0x3a, 0x1b, 0x7c, 0xf6, 0x77, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x94, 0x73, 0x22, 0x3b, 0x6a, 0x0c, 0x00, 0x00, + // 1317 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x41, 0x6f, 0x1b, 0xc5, + 0x17, 0xcf, 0xda, 0xeb, 0xd8, 0x7e, 0xb6, 0x13, 0x67, 0x95, 0x7f, 0xeb, 0xbf, 0x03, 0x8e, 0xeb, + 0xd0, 0x92, 0x96, 0xca, 0x46, 0x41, 0x42, 0x54, 0x70, 0xb1, 0x93, 0x34, 0xb5, 0x9a, 0x38, 0xd6, + 0xda, 0x14, 0xc1, 0x65, 0xb5, 0xf6, 0x4e, 0xed, 0x55, 0xd7, 0x3b, 0xab, 0xdd, 0x71, 0x48, 0x7a, + 0xe0, 0x8c, 0x72, 0xea, 0x17, 0xc8, 0xa9, 0x20, 0xf1, 0x2d, 0xe0, 0xd8, 0x13, 0xea, 0x91, 0x53, + 0x41, 0xc9, 0x37, 0x40, 0x7c, 0x00, 0x34, 0x6f, 0x66, 0xd7, 0x76, 0x93, 0x40, 0xa0, 0x15, 0x97, + 0x64, 0xe6, 0xbd, 0xdf, 0x7b, 0x33, 0xef, 0x37, 0xbf, 0x99, 0xb7, 0x86, 0xeb, 0x9e, 0x4f, 0x19, + 0xad, 0xb1, 0x23, 0x8f, 0x04, 0xe2, 0x6f, 0x15, 0x2d, 0xda, 0x35, 0x46, 0x5c, 0x8b, 0xf8, 0x23, + 0xdb, 0x65, 0xc2, 0x52, 0x45, 0x6f, 0xf1, 0x16, 0x1b, 0xda, 0xbe, 0x65, 0x78, 0xa6, 0xcf, 0x8e, + 0x6a, 0x22, 0x78, 0x40, 0x07, 0x74, 0x32, 0x12, 0xe8, 0xe2, 0xea, 0x80, 0xd2, 0x81, 0x43, 0x04, + 0xa4, 0x37, 0x7e, 0x5c, 0x63, 0xf6, 0x88, 0x04, 0xcc, 0x1c, 0x79, 0x12, 0xb0, 0x22, 0x42, 0x1c, + 0xbb, 0x17, 0xd4, 0x7a, 0x36, 0x9b, 0x59, 0xbd, 0xb8, 0x2a, 0x9c, 0x7d, 0xff, 0xc8, 0x63, 0xb4, + 0x36, 0x22, 0xfe, 0x13, 0x87, 0xcc, 0x00, 0x64, 0xf4, 0x01, 0xf1, 0x03, 0x9b, 0xba, 0xe1, 0x7f, + 0xe1, 0xac, 0xdc, 0x83, 0x5c, 0xdb, 0xf4, 0x59, 0x87, 0xb0, 0x07, 0xc4, 0xb4, 0x88, 0xaf, 0x2d, + 0x43, 0x82, 0x51, 0x66, 0x3a, 0x05, 0xa5, 0xac, 0xac, 0xe7, 0x74, 0x31, 0xd1, 0x34, 0x50, 0x87, + 0x66, 0x30, 0x2c, 0xc4, 0xca, 0xca, 0x7a, 0x56, 0xc7, 0x71, 0x65, 0x0c, 0x2a, 0x0f, 0xe5, 0x11, + 0xb6, 0x6b, 0x91, 0xc3, 0x30, 0x02, 0x27, 0xdc, 0xda, 0x3b, 0x62, 0x24, 0x90, 0x21, 0x62, 0xa2, + 0xd5, 0x21, 0xe1, 0xf9, 0x94, 0x3e, 0x2e, 0xc4, 0xcb, 0xca, 0x7a, 0x66, 0xe3, 0x66, 0xf5, 0x1c, + 0x75, 0xa2, 0x8e, 0xaa, 0xa8, 0xa3, 0xda, 0xe6, 0xe0, 0x86, 0xfa, 0xe2, 0xd5, 0xea, 0x9c, 0x2e, + 0x22, 0x2b, 0x23, 0x48, 0x36, 0x1c, 0xda, 0x7f, 0xd2, 0xdc, 0x8a, 0x76, 0xa5, 0x4c, 0x76, 0xa5, + 0xb5, 0x20, 0xcb, 0x09, 0x0f, 0x8c, 0x21, 0xd6, 0x83, 0xcb, 0x5f, 0xb8, 0x90, 0xa0, 0x68, 0xa6, + 0x78, 0xb9, 0x50, 0x06, 0x13, 0x08, 0x53, 0xe5, 0x77, 0x15, 0xe6, 0x25, 0x35, 0x9b, 0x90, 0x94, + 0xe4, 0xe1, 0x8a, 0x99, 0x8d, 0xb5, 0xf3, 0x59, 0x43, 0x76, 0x37, 0xa9, 0x1b, 0x10, 0x37, 0x18, + 0x07, 0x32, 0x67, 0x18, 0xa9, 0xdd, 0x82, 0x54, 0x7f, 0x68, 0xda, 0xae, 0x61, 0x5b, 0xb8, 0xb7, + 0x74, 0x23, 0x73, 0xfa, 0x6a, 0x35, 0xb9, 0xc9, 0x6d, 0xcd, 0x2d, 0x3d, 0x89, 0xce, 0xa6, 0xa5, + 0x5d, 0x83, 0xf9, 0x21, 0xb1, 0x07, 0x43, 0x86, 0x54, 0xc5, 0x75, 0x39, 0xd3, 0x3e, 0x01, 0x95, + 0xcb, 0xa3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x2d, 0xdb, 0x29, 0xa6, 0xbe, 0x7d, + 0x5e, 0x9a, 0xfb, 0xe1, 0xbb, 0x92, 0x72, 0xe7, 0x7b, 0x05, 0x72, 0x33, 0xd7, 0x53, 0x5b, 0x81, + 0xeb, 0x9d, 0xe6, 0x4e, 0x6b, 0x7b, 0xcb, 0xd8, 0xeb, 0xec, 0x18, 0xdd, 0x2f, 0xdb, 0xdb, 0x53, + 0x55, 0xdc, 0x80, 0x6c, 0x5b, 0xdf, 0x7e, 0xb4, 0xdf, 0xdd, 0x46, 0x4f, 0x5e, 0x29, 0x2e, 0x1e, + 0x9f, 0x94, 0x33, 0x6d, 0x9f, 0x1c, 0x50, 0x46, 0x30, 0xfe, 0x26, 0x2c, 0xb4, 0xf5, 0x6d, 0xb1, + 0x59, 0x01, 0x8a, 0x15, 0x97, 0x8e, 0x4f, 0xca, 0xb9, 0xb6, 0x4f, 0x84, 0x02, 0x11, 0xb6, 0x06, + 0xb9, 0xb6, 0xbe, 0xdf, 0xde, 0xef, 0xd4, 0x77, 0x05, 0x2a, 0x5e, 0xcc, 0x1f, 0x9f, 0x94, 0xb3, + 0xe1, 0xdb, 0xc2, 0x41, 0x93, 0x7d, 0x36, 0xee, 0xbf, 0x38, 0x2d, 0x29, 0x2f, 0x4f, 0x4b, 0xca, + 0x6f, 0xa7, 0x25, 0xe5, 0xd9, 0x59, 0x69, 0xee, 0xe5, 0x59, 0x69, 0xee, 0x97, 0xb3, 0xd2, 0xdc, + 0x57, 0x77, 0x07, 0x36, 0x1b, 0x8e, 0x7b, 0xd5, 0x3e, 0x1d, 0xd5, 0x26, 0x87, 0x37, 0x3d, 0x9c, + 0xfa, 0x35, 0xd3, 0x9b, 0xc7, 0xc9, 0x47, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0x21, 0xb8, 0xcf, + 0x26, 0xe3, 0x0c, 0x00, 0x00, } func (m *PartSetHeader) Marshal() (dAtA []byte, err error) { @@ -1695,6 +1760,55 @@ func (m *BlockMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TxProof) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TxProof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TxProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Proof != nil { + { + size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if len(m.RootHash) > 0 { + i -= len(m.RootHash) + copy(dAtA[i:], m.RootHash) + i = encodeVarintTypes(dAtA, i, uint64(len(m.RootHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { offset -= sovTypes(v) base := offset @@ -1983,6 +2097,27 @@ func (m *BlockMeta) Size() (n int) { return n } +func (m *TxProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RootHash) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.Proof != nil { + l = m.Proof.Size() + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -4157,6 +4292,163 @@ func (m *BlockMeta) Unmarshal(dAtA []byte) error { } return nil } +func (m *TxProof) 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 ErrIntOverflowTypes + } + 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: TxProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TxProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RootHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RootHash = append(m.RootHash[:0], dAtA[iNdEx:postIndex]...) + if m.RootHash == nil { + m.RootHash = []byte{} + } + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Proof == nil { + m.Proof = &merkle.Proof{} + } + if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/proto/types/types.proto b/proto/types/types.proto index 1a16d1a67..1323ca2dd 100644 --- a/proto/types/types.proto +++ b/proto/types/types.proto @@ -144,3 +144,10 @@ message BlockMeta { Header header = 3 [(gogoproto.nullable) = false]; int64 num_txs = 4; } + +// TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree. +message TxProof { + bytes root_hash = 1; + bytes data = 2; + tendermint.proto.crypto.merkle.Proof Proof = 3; +} diff --git a/proto/types/validator.pb.go b/proto/types/validator.pb.go index 8a3dac774..e850ca01f 100644 --- a/proto/types/validator.pb.go +++ b/proto/types/validator.pb.go @@ -154,41 +154,98 @@ func (m *Validator) GetProposerPriority() int64 { return 0 } +type SimpleValidator struct { + PubKey *keys.PublicKey `protobuf:"bytes,1,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` + VotingPower int64 `protobuf:"varint,2,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` +} + +func (m *SimpleValidator) Reset() { *m = SimpleValidator{} } +func (m *SimpleValidator) String() string { return proto.CompactTextString(m) } +func (*SimpleValidator) ProtoMessage() {} +func (*SimpleValidator) Descriptor() ([]byte, []int) { + return fileDescriptor_2e7c6b38c20e5406, []int{2} +} +func (m *SimpleValidator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SimpleValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SimpleValidator.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SimpleValidator) XXX_Merge(src proto.Message) { + xxx_messageInfo_SimpleValidator.Merge(m, src) +} +func (m *SimpleValidator) XXX_Size() int { + return m.Size() +} +func (m *SimpleValidator) XXX_DiscardUnknown() { + xxx_messageInfo_SimpleValidator.DiscardUnknown(m) +} + +var xxx_messageInfo_SimpleValidator proto.InternalMessageInfo + +func (m *SimpleValidator) GetPubKey() *keys.PublicKey { + if m != nil { + return m.PubKey + } + return nil +} + +func (m *SimpleValidator) GetVotingPower() int64 { + if m != nil { + return m.VotingPower + } + return 0 +} + func init() { proto.RegisterType((*ValidatorSet)(nil), "tendermint.proto.types.ValidatorSet") golang_proto.RegisterType((*ValidatorSet)(nil), "tendermint.proto.types.ValidatorSet") proto.RegisterType((*Validator)(nil), "tendermint.proto.types.Validator") golang_proto.RegisterType((*Validator)(nil), "tendermint.proto.types.Validator") + proto.RegisterType((*SimpleValidator)(nil), "tendermint.proto.types.SimpleValidator") + golang_proto.RegisterType((*SimpleValidator)(nil), "tendermint.proto.types.SimpleValidator") } func init() { proto.RegisterFile("proto/types/validator.proto", fileDescriptor_2e7c6b38c20e5406) } -func init() { golang_proto.RegisterFile("proto/types/validator.proto", fileDescriptor_2e7c6b38c20e5406) } +func init() { + golang_proto.RegisterFile("proto/types/validator.proto", fileDescriptor_2e7c6b38c20e5406) +} var fileDescriptor_2e7c6b38c20e5406 = []byte{ - // 358 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x3f, 0x4f, 0xfa, 0x40, - 0x18, 0xc7, 0x7b, 0x3f, 0x08, 0xfc, 0x3c, 0x18, 0xf4, 0x06, 0xd3, 0x60, 0xac, 0xc0, 0xa0, 0x24, - 0x92, 0x36, 0xd1, 0xd9, 0x41, 0x06, 0x07, 0x59, 0x48, 0x4d, 0x18, 0x5c, 0x9a, 0x96, 0x5e, 0xca, - 0x85, 0x3f, 0x77, 0xb9, 0x3e, 0xc5, 0xdc, 0xbb, 0xf0, 0x0d, 0x69, 0x1c, 0x19, 0x19, 0x9d, 0x8c, - 0xa1, 0x6f, 0xc4, 0xd0, 0xa3, 0x85, 0x44, 0x06, 0xb7, 0xe7, 0xf9, 0x7e, 0x9f, 0x3f, 0x9f, 0x7b, - 0x72, 0xf8, 0x4c, 0x48, 0x0e, 0xdc, 0x01, 0x25, 0x68, 0xec, 0x2c, 0xfc, 0x29, 0x0b, 0x7d, 0xe0, - 0xd2, 0xce, 0x54, 0x72, 0x0a, 0x74, 0x1e, 0x52, 0x39, 0x63, 0x73, 0xd0, 0x8a, 0x9d, 0xd5, 0x35, - 0x2e, 0x61, 0xcc, 0x64, 0xe8, 0x09, 0x5f, 0x82, 0x72, 0xf4, 0x80, 0x88, 0x47, 0x7c, 0x17, 0xe9, - 0xea, 0xc6, 0xb9, 0x56, 0x46, 0x52, 0x09, 0xe0, 0xce, 0x84, 0xaa, 0x58, 0x2f, 0xd2, 0x76, 0xfb, - 0x1d, 0xe1, 0xfa, 0x30, 0x5f, 0xf9, 0x44, 0x81, 0xdc, 0x63, 0x5c, 0x20, 0xc4, 0x26, 0x6a, 0x96, - 0x3a, 0xb5, 0x9b, 0x96, 0x7d, 0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00, 0xff, 0xff, 0xbb, 0xf6, - 0x8f, 0xab, 0x51, 0x02, 0x00, 0x00, + // 383 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x4f, 0x6b, 0xe2, 0x40, + 0x18, 0xc6, 0x33, 0x2a, 0xba, 0x3b, 0x0a, 0xbb, 0x3b, 0x87, 0x25, 0xb8, 0x6c, 0x56, 0x3d, 0xec, + 0x0a, 0x2b, 0x09, 0xb4, 0xe7, 0x42, 0xeb, 0xa1, 0x87, 0x7a, 0x91, 0x08, 0x1e, 0x7a, 0x09, 0x89, + 0x19, 0xe2, 0x60, 0x74, 0x86, 0xc9, 0x24, 0x65, 0xbe, 0x45, 0xbf, 0x50, 0x4b, 0x8f, 0x1e, 0x3d, + 0xf6, 0x54, 0x8a, 0xf9, 0x22, 0xc5, 0x8c, 0x49, 0x04, 0x2d, 0xb4, 0xb7, 0x79, 0x9f, 0xe7, 0xfd, + 0xf3, 0x7b, 0x5f, 0x06, 0xfe, 0x62, 0x9c, 0x0a, 0x6a, 0x09, 0xc9, 0x70, 0x64, 0x25, 0x6e, 0x48, + 0x7c, 0x57, 0x50, 0x6e, 0x66, 0x2a, 0xfa, 0x29, 0xf0, 0xca, 0xc7, 0x7c, 0x49, 0x56, 0x42, 0x29, + 0x66, 0x96, 0xd7, 0xfe, 0x2b, 0xe6, 0x84, 0xfb, 0x0e, 0x73, 0xb9, 0x90, 0x96, 0x6a, 0x10, 0xd0, + 0x80, 0x96, 0x2f, 0x95, 0xdd, 0xfe, 0xad, 0x94, 0x19, 0x97, 0x4c, 0x50, 0x6b, 0x81, 0x65, 0xa4, + 0x06, 0x29, 0xbb, 0xf7, 0x08, 0x60, 0x6b, 0x9a, 0x8f, 0x9c, 0x60, 0x81, 0xae, 0x20, 0x2c, 0x10, + 0x22, 0x1d, 0x74, 0xaa, 0xfd, 0xe6, 0x59, 0xd7, 0x3c, 0x0d, 0x61, 0x16, 0x95, 0xf6, 0x41, 0x11, + 0xba, 0x80, 0x5f, 0x18, 0xa7, 0x8c, 0x46, 0x98, 0xeb, 0x95, 0x0e, 0xf8, 0x58, 0x83, 0xa2, 0x04, + 0x0d, 0x20, 0x12, 0x54, 0xb8, 0xa1, 0x93, 0x50, 0x41, 0x56, 0x81, 0xc3, 0xe8, 0x1d, 0xe6, 0x7a, + 0xb5, 0x03, 0xfa, 0x55, 0xfb, 0x7b, 0xe6, 0x4c, 0x33, 0x63, 0xbc, 0xd3, 0x7b, 0x0f, 0x00, 0x7e, + 0x2d, 0xba, 0x20, 0x1d, 0x36, 0x5c, 0xdf, 0xe7, 0x38, 0xda, 0xa1, 0x83, 0x7e, 0xcb, 0xce, 0x43, + 0x74, 0x0d, 0x1b, 0x2c, 0xf6, 0x9c, 0x05, 0x96, 0x7b, 0xa6, 0x7f, 0xc7, 0x4c, 0xea, 0x48, 0xe6, + 0xee, 0x48, 0xe6, 0x38, 0xf6, 0x42, 0x32, 0x1b, 0x61, 0x39, 0xac, 0xad, 0x5f, 0xfe, 0x68, 0x76, + 0x9d, 0xc5, 0xde, 0x08, 0x4b, 0xd4, 0x85, 0xad, 0x13, 0x5c, 0xcd, 0xa4, 0x44, 0x42, 0xff, 0xe1, + 0x8f, 0x7c, 0x19, 0x87, 0x71, 0x42, 0x39, 0x11, 0x52, 0xaf, 0x29, 0xfe, 0xdc, 0x18, 0xef, 0xf5, + 0x5e, 0x02, 0xbf, 0x4d, 0xc8, 0x92, 0x85, 0xb8, 0x5c, 0xe2, 0xb2, 0x44, 0x05, 0x9f, 0x42, 0x7d, + 0x17, 0xb2, 0x72, 0x04, 0x39, 0xbc, 0x59, 0x6f, 0x0d, 0xb0, 0xd9, 0x1a, 0xe0, 0x75, 0x6b, 0x80, + 0xfb, 0xd4, 0xd0, 0x9e, 0x52, 0x03, 0x6c, 0x52, 0x43, 0x7b, 0x4e, 0x0d, 0xed, 0x76, 0x10, 0x10, + 0x31, 0x8f, 0x3d, 0x73, 0x46, 0x97, 0x56, 0x39, 0xfb, 0xf0, 0x79, 0xf0, 0x67, 0xbd, 0x7a, 0x16, + 0x9c, 0xbf, 0x05, 0x00, 0x00, 0xff, 0xff, 0xbd, 0x74, 0x56, 0xec, 0xc9, 0x02, 0x00, 0x00, } func (m *ValidatorSet) Marshal() (dAtA []byte, err error) { @@ -295,6 +352,46 @@ func (m *Validator) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *SimpleValidator) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SimpleValidator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SimpleValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.VotingPower != 0 { + i = encodeVarintValidator(dAtA, i, uint64(m.VotingPower)) + i-- + dAtA[i] = 0x10 + } + if m.PubKey != nil { + { + size, err := m.PubKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintValidator(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintValidator(dAtA []byte, offset int, v uint64) int { offset -= sovValidator(v) base := offset @@ -349,6 +446,22 @@ func (m *Validator) Size() (n int) { return n } +func (m *SimpleValidator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PubKey != nil { + l = m.PubKey.Size() + n += 1 + l + sovValidator(uint64(l)) + } + if m.VotingPower != 0 { + n += 1 + sovValidator(uint64(m.VotingPower)) + } + return n +} + func sovValidator(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -655,6 +768,114 @@ func (m *Validator) Unmarshal(dAtA []byte) error { } return nil } +func (m *SimpleValidator) 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 ErrIntOverflowValidator + } + 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: SimpleValidator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SimpleValidator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowValidator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthValidator + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthValidator + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PubKey == nil { + m.PubKey = &keys.PublicKey{} + } + if err := m.PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) + } + m.VotingPower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowValidator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VotingPower |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipValidator(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthValidator + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthValidator + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipValidator(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/proto/types/validator.proto b/proto/types/validator.proto index 2c3e73ec5..c4dfd20e8 100644 --- a/proto/types/validator.proto +++ b/proto/types/validator.proto @@ -23,3 +23,8 @@ message Validator { int64 voting_power = 3; int64 proposer_priority = 4; } + +message SimpleValidator { + tendermint.proto.crypto.keys.PublicKey pub_key = 1; + int64 voting_power = 2; +} diff --git a/state/main_test.go b/state/main_test.go index 00ecf2686..864c96dd7 100644 --- a/state/main_test.go +++ b/state/main_test.go @@ -3,11 +3,8 @@ package state_test import ( "os" "testing" - - "github.com/tendermint/tendermint/types" ) func TestMain(m *testing.M) { - types.RegisterMockEvidencesGlobal() os.Exit(m.Run()) } diff --git a/types/block.go b/types/block.go index 78b0e1c94..9af3ee614 100644 --- a/types/block.go +++ b/types/block.go @@ -9,6 +9,7 @@ import ( "time" "github.com/gogo/protobuf/proto" + gogotypes "github.com/gogo/protobuf/types" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/merkle" @@ -21,10 +22,10 @@ import ( ) const ( - // MaxHeaderBytes is a maximum header size (including amino overhead). - MaxHeaderBytes int64 = 628 + // MaxHeaderBytes is a maximum header size. + MaxHeaderBytes int64 = 626 - // MaxAminoOverheadForBlock - maximum amino overhead to encode a block (up to + // MaxOverheadForBlock - maximum overhead to encode a block (up to // MaxBlockSizeBytes in size) not including it's parts except Data. // This means it also excludes the overhead for individual transactions. // @@ -32,7 +33,7 @@ const ( // 2 fields (2 embedded): 2 bytes // Uvarint length of Data.Txs: 4 bytes // Data.Txs field: 1 byte - MaxAminoOverheadForBlock int64 = 11 + MaxOverheadForBlock int64 = 11 ) // Block defines the atomic unit of a Tendermint blockchain. @@ -167,11 +168,12 @@ func (b *Block) HashesTo(hash []byte) bool { // Size returns size of the block in bytes. func (b *Block) Size() int { - bz, err := cdc.MarshalBinaryBare(b) + pbb, err := b.ToProto() if err != nil { return 0 } - return len(bz) + + return pbb.Size() } // String returns a string representation of the block @@ -257,28 +259,6 @@ func BlockFromProto(bp *tmproto.Block) (*Block, error) { return b, b.ValidateBasic() } -//----------------------------------------------------------- -// These methods are for Protobuf Compatibility - -// Marshal returns the amino encoding. -func (b *Block) Marshal() ([]byte, error) { - return cdc.MarshalBinaryBare(b) -} - -// MarshalTo calls Marshal and copies to the given buffer. -func (b *Block) MarshalTo(data []byte) (int, error) { - bs, err := b.Marshal() - if err != nil { - return -1, err - } - return copy(data, bs), nil -} - -// Unmarshal deserializes from amino encoded form. -func (b *Block) Unmarshal(bs []byte) error { - return cdc.UnmarshalBinaryBare(bs, b) -} - //----------------------------------------------------------------------------- // MaxDataBytes returns the maximum size of block's data. @@ -286,7 +266,7 @@ func (b *Block) Unmarshal(bs []byte) error { // XXX: Panics on negative result. func MaxDataBytes(maxBytes int64, valsCount, evidenceCount int) int64 { maxDataBytes := maxBytes - - MaxAminoOverheadForBlock - + MaxOverheadForBlock - MaxHeaderBytes - int64(valsCount)*MaxVoteBytes - int64(evidenceCount)*MaxEvidenceBytes @@ -311,7 +291,7 @@ func MaxDataBytes(maxBytes int64, valsCount, evidenceCount int) int64 { func MaxDataBytesUnknownEvidence(maxBytes int64, valsCount int, maxNumEvidence uint32) int64 { maxEvidenceBytes := int64(maxNumEvidence) * MaxEvidenceBytes maxDataBytes := maxBytes - - MaxAminoOverheadForBlock - + MaxOverheadForBlock - MaxHeaderBytes - int64(valsCount)*MaxVoteBytes - maxEvidenceBytes @@ -449,12 +429,27 @@ func (h *Header) Hash() tmbytes.HexBytes { if h == nil || len(h.ValidatorsHash) == 0 { return nil } + hbz, err := h.Version.Marshal() + if err != nil { + return nil + } + + pbt, err := gogotypes.StdTimeMarshal(h.Time) + if err != nil { + return nil + } + + pbbi := h.LastBlockID.ToProto() + bzbi, err := pbbi.Marshal() + if err != nil { + return nil + } return merkle.HashFromByteSlices([][]byte{ - cdcEncode(h.Version), + hbz, cdcEncode(h.ChainID), cdcEncode(h.Height), - cdcEncode(h.Time), - cdcEncode(h.LastBlockID), + pbt, + bzbi, cdcEncode(h.LastCommitHash), cdcEncode(h.DataHash), cdcEncode(h.ValidatorsHash), @@ -866,7 +861,13 @@ func (commit *Commit) Hash() tmbytes.HexBytes { if commit.hash == nil { bs := make([][]byte, len(commit.Signatures)) for i, commitSig := range commit.Signatures { - bs[i] = cdcEncode(commitSig) + pbcs := commitSig.ToProto() + bz, err := pbcs.Marshal() + if err != nil { + panic(err) + } + + bs[i] = bz } commit.hash = merkle.HashFromByteSlices(bs) } @@ -1248,10 +1249,12 @@ func (blockID BlockID) Equals(other BlockID) bool { // Key returns a machine-readable string representation of the BlockID func (blockID BlockID) Key() string { - bz, err := cdc.MarshalBinaryBare(blockID.PartsHeader) + pbph := blockID.PartsHeader.ToProto() + bz, err := pbph.Marshal() if err != nil { panic(err) } + return string(blockID.Hash) + string(bz) } diff --git a/types/block_meta.go b/types/block_meta.go index 3591a1847..a16176cd2 100644 --- a/types/block_meta.go +++ b/types/block_meta.go @@ -65,34 +65,6 @@ func BlockMetaFromProto(pb *tmproto.BlockMeta) (*BlockMeta, error) { return bm, bm.ValidateBasic() } -//----------------------------------------------------------- -// These methods are for Protobuf Compatibility - -// Size returns the size of the amino encoding, in bytes. -func (bm *BlockMeta) Size() int { - bs, _ := bm.Marshal() - return len(bs) -} - -// Marshal returns the amino encoding. -func (bm *BlockMeta) Marshal() ([]byte, error) { - return cdc.MarshalBinaryBare(bm) -} - -// MarshalTo calls Marshal and copies to the given buffer. -func (bm *BlockMeta) MarshalTo(data []byte) (int, error) { - bs, err := bm.Marshal() - if err != nil { - return -1, err - } - return copy(data, bs), nil -} - -// Unmarshal deserializes from amino encoded form. -func (bm *BlockMeta) Unmarshal(bs []byte) error { - return cdc.UnmarshalBinaryBare(bs, bm) -} - // ValidateBasic performs basic validation. func (bm *BlockMeta) ValidateBasic() error { if err := bm.BlockID.ValidateBasic(); err != nil { diff --git a/types/block_test.go b/types/block_test.go index 1e4e56b80..860aa3f0b 100644 --- a/types/block_test.go +++ b/types/block_test.go @@ -11,6 +11,7 @@ import ( "testing" "time" + gogotypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -26,8 +27,6 @@ import ( ) func TestMain(m *testing.M) { - RegisterMockEvidences(cdc) - code := m.Run() os.Exit(code) } @@ -270,7 +269,7 @@ func TestHeaderHash(t *testing.T) { LastResultsHash: tmhash.Sum([]byte("last_results_hash")), EvidenceHash: tmhash.Sum([]byte("evidence_hash")), ProposerAddress: crypto.AddressHash([]byte("proposer_address")), - }, hexBytesFromString("ABDC78921B18A47EE6BEF5E31637BADB0F3E587E3C0F4DB2D1E93E9FF0533862")}, + }, hexBytesFromString("F740121F553B5418C3EFBD343C2DBFE9E007BB67B0D020A0741374BAB65242A4")}, {"nil header yields nil", nil, nil}, {"nil ValidatorsHash yields nil", &Header{ Version: version.Consensus{Block: 1, App: 2}, @@ -298,12 +297,33 @@ func TestHeaderHash(t *testing.T) { // fields in the test struct are non-zero. if tc.header != nil && tc.expectHash != nil { byteSlices := [][]byte{} + s := reflect.ValueOf(*tc.header) for i := 0; i < s.NumField(); i++ { f := s.Field(i) + assert.False(t, f.IsZero(), "Found zero-valued field %v", s.Type().Field(i).Name) - byteSlices = append(byteSlices, cdcEncode(f.Interface())) + + switch f := f.Interface().(type) { + case int64, bytes.HexBytes, string: + byteSlices = append(byteSlices, cdcEncode(f)) + case time.Time: + bz, err := gogotypes.StdTimeMarshal(f) + require.NoError(t, err) + byteSlices = append(byteSlices, bz) + case version.Consensus: + bz, err := f.Marshal() + require.NoError(t, err) + byteSlices = append(byteSlices, bz) + case BlockID: + pbbi := f.ToProto() + bz, err := pbbi.Marshal() + require.NoError(t, err) + byteSlices = append(byteSlices, bz) + default: + t.Errorf("unknown type %T", f) + } } assert.Equal(t, bytes.HexBytes(merkle.HashFromByteSlices(byteSlices)), tc.header.Hash()) @@ -343,7 +363,7 @@ func TestMaxHeaderBytes(t *testing.T) { ProposerAddress: crypto.AddressHash([]byte("proposer_address")), } - bz, err := cdc.MarshalBinaryLengthPrefixed(h) + bz, err := h.ToProto().Marshal() require.NoError(t, err) assert.EqualValues(t, MaxHeaderBytes, int64(len(bz))) @@ -378,9 +398,9 @@ func TestBlockMaxDataBytes(t *testing.T) { }{ 0: {-10, 1, 0, true, 0}, 1: {10, 1, 0, true, 0}, - 2: {846, 1, 0, true, 0}, - 3: {848, 1, 0, false, 0}, - 4: {849, 1, 0, false, 1}, + 2: {844, 1, 0, true, 0}, + 3: {846, 1, 0, false, 0}, + 4: {847, 1, 0, false, 1}, } for i, tc := range testCases { @@ -408,10 +428,10 @@ func TestBlockMaxDataBytesUnknownEvidence(t *testing.T) { }{ 0: {-10, 0, 1, true, 0}, 1: {10, 0, 1, true, 0}, - 2: {847, 0, 1, true, 0}, - 3: {848, 0, 1, false, 0}, - 4: {1292, 1, 1, false, 0}, - 5: {1293, 1, 1, false, 1}, + 2: {845, 0, 1, true, 0}, + 3: {846, 0, 1, false, 0}, + 4: {1290, 1, 1, false, 0}, + 5: {1291, 1, 1, false, 1}, } for i, tc := range testCases { @@ -445,9 +465,12 @@ func TestCommitToVoteSet(t *testing.T) { vote2 := voteSet2.GetByIndex(i) vote3 := commit.GetVote(i) - vote1bz := cdc.MustMarshalBinaryBare(vote1) - vote2bz := cdc.MustMarshalBinaryBare(vote2) - vote3bz := cdc.MustMarshalBinaryBare(vote3) + vote1bz, err := vote1.ToProto().Marshal() + require.NoError(t, err) + vote2bz, err := vote2.ToProto().Marshal() + require.NoError(t, err) + vote3bz, err := vote3.ToProto().Marshal() + require.NoError(t, err) assert.Equal(t, vote1bz, vote2bz) assert.Equal(t, vote1bz, vote3bz) } diff --git a/types/codec.go b/types/codec.go deleted file mode 100644 index b4989d267..000000000 --- a/types/codec.go +++ /dev/null @@ -1,28 +0,0 @@ -package types - -import ( - amino "github.com/tendermint/go-amino" - - cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino" -) - -var cdc = amino.NewCodec() - -func init() { - RegisterBlockAmino(cdc) -} - -func RegisterBlockAmino(cdc *amino.Codec) { - cryptoamino.RegisterAmino(cdc) - RegisterEvidences(cdc) -} - -// GetCodec returns a codec used by the package. For testing purposes only. -func GetCodec() *amino.Codec { - return cdc -} - -// For testing purposes only -func RegisterMockEvidencesGlobal() { - RegisterMockEvidences(cdc) -} diff --git a/types/encoding_helper.go b/types/encoding_helper.go index a5c278938..630b088ce 100644 --- a/types/encoding_helper.go +++ b/types/encoding_helper.go @@ -1,10 +1,47 @@ package types +import ( + gogotypes "github.com/gogo/protobuf/types" + + "github.com/tendermint/tendermint/libs/bytes" +) + // cdcEncode returns nil if the input is nil, otherwise returns -// cdc.MustMarshalBinaryBare(item) +// proto.Marshal(Value{Value: item}) func cdcEncode(item interface{}) []byte { if item != nil && !isTypedNil(item) && !isEmpty(item) { - return cdc.MustMarshalBinaryBare(item) + switch item := item.(type) { + case string: + i := gogotypes.StringValue{ + Value: item, + } + bz, err := i.Marshal() + if err != nil { + return nil + } + return bz + case int64: + i := gogotypes.Int64Value{ + Value: item, + } + bz, err := i.Marshal() + if err != nil { + return nil + } + return bz + case bytes.HexBytes: + i := gogotypes.BytesValue{ + Value: item, + } + bz, err := i.Marshal() + if err != nil { + return nil + } + return bz + default: + return nil + } } + return nil } diff --git a/types/events.go b/types/events.go index 9fcd7aa27..378486546 100644 --- a/types/events.go +++ b/types/events.go @@ -3,8 +3,6 @@ package types import ( "fmt" - amino "github.com/tendermint/go-amino" - abci "github.com/tendermint/tendermint/abci/types" tmjson "github.com/tendermint/tendermint/libs/json" tmpubsub "github.com/tendermint/tendermint/libs/pubsub" @@ -48,19 +46,6 @@ type TMEventData interface { // empty interface } -func RegisterEventDatas(cdc *amino.Codec) { - cdc.RegisterInterface((*TMEventData)(nil), nil) - cdc.RegisterConcrete(EventDataNewBlock{}, "tendermint/event/NewBlock", nil) - cdc.RegisterConcrete(EventDataNewBlockHeader{}, "tendermint/event/NewBlockHeader", nil) - cdc.RegisterConcrete(EventDataTx{}, "tendermint/event/Tx", nil) - cdc.RegisterConcrete(EventDataRoundState{}, "tendermint/event/RoundState", nil) - cdc.RegisterConcrete(EventDataNewRound{}, "tendermint/event/NewRound", nil) - cdc.RegisterConcrete(EventDataCompleteProposal{}, "tendermint/event/CompleteProposal", nil) - cdc.RegisterConcrete(EventDataVote{}, "tendermint/event/Vote", nil) - cdc.RegisterConcrete(EventDataValidatorSetUpdates{}, "tendermint/event/ValidatorSetUpdates", nil) - cdc.RegisterConcrete(EventDataString(""), "tendermint/event/ProposalString", nil) -} - func init() { tmjson.RegisterType(EventDataNewBlock{}, "tendermint/event/NewBlock") tmjson.RegisterType(EventDataNewBlockHeader{}, "tendermint/event/NewBlockHeader") diff --git a/types/evidence.go b/types/evidence.go index 7e8adb084..5164b3428 100644 --- a/types/evidence.go +++ b/types/evidence.go @@ -7,8 +7,6 @@ import ( "strings" "time" - amino "github.com/tendermint/go-amino" - "github.com/tendermint/tendermint/crypto" cryptoenc "github.com/tendermint/tendermint/crypto/encoding" "github.com/tendermint/tendermint/crypto/merkle" @@ -91,99 +89,89 @@ func EvidenceToProto(evidence Evidence) (*tmproto.Evidence, error) { switch evi := evidence.(type) { case *DuplicateVoteEvidence: - voteB := evi.VoteB.ToProto() - voteA := evi.VoteA.ToProto() + pbevi := evi.ToProto() tp := &tmproto.Evidence{ Sum: &tmproto.Evidence_DuplicateVoteEvidence{ - DuplicateVoteEvidence: &tmproto.DuplicateVoteEvidence{ - VoteA: voteA, - VoteB: voteB, - }, + DuplicateVoteEvidence: &pbevi, }, } return tp, nil case ConflictingHeadersEvidence: - pbh1 := evi.H1.ToProto() - pbh2 := evi.H2.ToProto() + pbevi := evi.ToProto() tp := &tmproto.Evidence{ Sum: &tmproto.Evidence_ConflictingHeadersEvidence{ - ConflictingHeadersEvidence: &tmproto.ConflictingHeadersEvidence{ - H1: pbh1, - H2: pbh2, - }, + ConflictingHeadersEvidence: &pbevi, }, } return tp, nil case *ConflictingHeadersEvidence: - pbh1 := evi.H1.ToProto() - pbh2 := evi.H2.ToProto() + pbevi := evi.ToProto() tp := &tmproto.Evidence{ Sum: &tmproto.Evidence_ConflictingHeadersEvidence{ - ConflictingHeadersEvidence: &tmproto.ConflictingHeadersEvidence{ - H1: pbh1, - H2: pbh2, - }, + ConflictingHeadersEvidence: &pbevi, }, } return tp, nil case *LunaticValidatorEvidence: - h := evi.Header.ToProto() - v := evi.Vote.ToProto() + pbevi := evi.ToProto() tp := &tmproto.Evidence{ Sum: &tmproto.Evidence_LunaticValidatorEvidence{ - LunaticValidatorEvidence: &tmproto.LunaticValidatorEvidence{ - Header: h, - Vote: v, - InvalidHeaderField: evi.InvalidHeaderField, - }, + LunaticValidatorEvidence: &pbevi, }, } + return tp, nil case LunaticValidatorEvidence: - h := evi.Header.ToProto() - v := evi.Vote.ToProto() + pbevi := evi.ToProto() tp := &tmproto.Evidence{ Sum: &tmproto.Evidence_LunaticValidatorEvidence{ - LunaticValidatorEvidence: &tmproto.LunaticValidatorEvidence{ - Header: h, - Vote: v, - InvalidHeaderField: evi.InvalidHeaderField, - }, + LunaticValidatorEvidence: &pbevi, }, } + + return tp, nil + case *PhantomValidatorEvidence: + pbevi := evi.ToProto() + + tp := &tmproto.Evidence{ + Sum: &tmproto.Evidence_PhantomValidatorEvidence{ + PhantomValidatorEvidence: &pbevi, + }, + } + + return tp, nil + case PhantomValidatorEvidence: + pbevi := evi.ToProto() + + tp := &tmproto.Evidence{ + Sum: &tmproto.Evidence_PhantomValidatorEvidence{ + PhantomValidatorEvidence: &pbevi, + }, + } + return tp, nil case *PotentialAmnesiaEvidence: - voteB := evi.VoteB.ToProto() - voteA := evi.VoteA.ToProto() + pbevi := evi.ToProto() tp := &tmproto.Evidence{ Sum: &tmproto.Evidence_PotentialAmnesiaEvidence{ - PotentialAmnesiaEvidence: &tmproto.PotentialAmnesiaEvidence{ - VoteA: voteA, - VoteB: voteB, - HeightStamp: evi.HeightStamp, - }, + PotentialAmnesiaEvidence: &pbevi, }, } return tp, nil case PotentialAmnesiaEvidence: - voteB := evi.VoteB.ToProto() - voteA := evi.VoteA.ToProto() + pbevi := evi.ToProto() tp := &tmproto.Evidence{ Sum: &tmproto.Evidence_PotentialAmnesiaEvidence{ - PotentialAmnesiaEvidence: &tmproto.PotentialAmnesiaEvidence{ - VoteA: voteA, - VoteB: voteB, - HeightStamp: evi.HeightStamp, - }, + PotentialAmnesiaEvidence: &pbevi, }, } return tp, nil @@ -238,78 +226,17 @@ func EvidenceFromProto(evidence *tmproto.Evidence) (Evidence, error) { switch evi := evidence.Sum.(type) { case *tmproto.Evidence_DuplicateVoteEvidence: - - vA, err := VoteFromProto(evi.DuplicateVoteEvidence.VoteA) - if err != nil { - return nil, err - } - - vB, err := VoteFromProto(evi.DuplicateVoteEvidence.VoteB) - if err != nil { - return nil, err - } - - dve := DuplicateVoteEvidence{ - VoteA: vA, - VoteB: vB, - } - - return &dve, dve.ValidateBasic() + return DuplicateVoteEvidenceFromProto(evi.DuplicateVoteEvidence) case *tmproto.Evidence_ConflictingHeadersEvidence: - - h1, err := SignedHeaderFromProto(evi.ConflictingHeadersEvidence.H1) - if err != nil { - return nil, fmt.Errorf("from proto err: %w", err) - } - h2, err := SignedHeaderFromProto(evi.ConflictingHeadersEvidence.H2) - if err != nil { - return nil, fmt.Errorf("from proto err: %w", err) - } - - tp := ConflictingHeadersEvidence{ - H1: h1, - H2: h2, - } - - return tp, tp.ValidateBasic() + return ConflictingHeadersEvidenceFromProto(evi.ConflictingHeadersEvidence) case *tmproto.Evidence_LunaticValidatorEvidence: - - h, err := HeaderFromProto(evi.LunaticValidatorEvidence.GetHeader()) - if err != nil { - return nil, err - } - - v, err := VoteFromProto(evi.LunaticValidatorEvidence.GetVote()) - if err != nil { - return nil, err - } - - tp := LunaticValidatorEvidence{ - Header: &h, - Vote: v, - InvalidHeaderField: evi.LunaticValidatorEvidence.InvalidHeaderField, - } - - return &tp, tp.ValidateBasic() + return LunaticValidatorEvidenceFromProto(evi.LunaticValidatorEvidence) case *tmproto.Evidence_PotentialAmnesiaEvidence: return PotentialAmnesiaEvidenceFromProto(evi.PotentialAmnesiaEvidence) - case *tmproto.Evidence_AmnesiaEvidence: - pae, err := PotentialAmnesiaEvidenceFromProto(evi.AmnesiaEvidence.PotentialAmnesiaEvidence) - if err != nil { - return nil, err - } - polc, err := ProofOfLockChangeFromProto(evi.AmnesiaEvidence.Polc) - if err != nil { - return nil, err - } - - tp := AmnesiaEvidence{ - PotentialAmnesiaEvidence: *pae, - Polc: *polc, - } - - return tp, tp.ValidateBasic() + return AmensiaEvidenceFromProto(evi.AmnesiaEvidence) + case *tmproto.Evidence_PhantomValidatorEvidence: + return PhantomValidatorEvidenceFromProto(evi.PhantomValidatorEvidence) case *tmproto.Evidence_MockEvidence: me := MockEvidence{ EvidenceHeight: evi.MockEvidence.GetEvidenceHeight(), @@ -332,16 +259,6 @@ func EvidenceFromProto(evidence *tmproto.Evidence) (Evidence, error) { } } -func RegisterEvidences(cdc *amino.Codec) { - cdc.RegisterInterface((*Evidence)(nil), nil) - cdc.RegisterConcrete(&DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence", nil) - cdc.RegisterConcrete(&ConflictingHeadersEvidence{}, "tendermint/ConflictingHeadersEvidence", nil) - cdc.RegisterConcrete(&PhantomValidatorEvidence{}, "tendermint/PhantomValidatorEvidence", nil) - cdc.RegisterConcrete(&LunaticValidatorEvidence{}, "tendermint/LunaticValidatorEvidence", nil) - cdc.RegisterConcrete(&PotentialAmnesiaEvidence{}, "tendermint/PotentialAmnesiaEvidence", nil) - cdc.RegisterConcrete(&AmnesiaEvidence{}, "tendermint/AmnesiaEvidence", nil) -} - func init() { tmjson.RegisterType(&DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence") tmjson.RegisterType(&ConflictingHeadersEvidence{}, "tendermint/ConflictingHeadersEvidence") @@ -351,11 +268,6 @@ func init() { tmjson.RegisterType(&AmnesiaEvidence{}, "tendermint/AmnesiaEvidence") } -func RegisterMockEvidences(cdc *amino.Codec) { - cdc.RegisterConcrete(MockEvidence{}, "tendermint/MockEvidence", nil) - cdc.RegisterConcrete(MockRandomEvidence{}, "tendermint/MockRandomEvidence", nil) -} - //------------------------------------------- // DuplicateVoteEvidence contains evidence a validator signed two conflicting @@ -410,12 +322,24 @@ func (dve *DuplicateVoteEvidence) Address() []byte { // Hash returns the hash of the evidence. func (dve *DuplicateVoteEvidence) Bytes() []byte { - return cdcEncode(dve) + pbe := dve.ToProto() + bz, err := pbe.Marshal() + if err != nil { + panic(err) + } + + return bz } // Hash returns the hash of the evidence. func (dve *DuplicateVoteEvidence) Hash() []byte { - return tmhash.Sum(cdcEncode(dve)) + pbe := dve.ToProto() + bz, err := pbe.Marshal() + if err != nil { + panic(err) + } + + return tmhash.Sum(bz) } // Verify returns an error if the two votes aren't conflicting. @@ -481,11 +405,24 @@ func (dve *DuplicateVoteEvidence) Equal(ev Evidence) bool { if _, ok := ev.(*DuplicateVoteEvidence); !ok { return false } + pbdev := dve.ToProto() + bz, err := pbdev.Marshal() + if err != nil { + panic(err) + } + + var evbz []byte + if ev, ok := ev.(*DuplicateVoteEvidence); ok { + evpb := ev.ToProto() + evbz, err = evpb.Marshal() + if err != nil { + panic(err) + } + } // just check their hashes - dveHash := tmhash.Sum(cdcEncode(dve)) - evHash := tmhash.Sum(cdcEncode(ev)) - fmt.Println(dveHash, evHash) + dveHash := tmhash.Sum(bz) + evHash := tmhash.Sum(evbz) return bytes.Equal(dveHash, evHash) } @@ -507,6 +444,39 @@ func (dve *DuplicateVoteEvidence) ValidateBasic() error { return nil } +func (dve DuplicateVoteEvidence) ToProto() tmproto.DuplicateVoteEvidence { + voteB := dve.VoteB.ToProto() + voteA := dve.VoteA.ToProto() + tp := tmproto.DuplicateVoteEvidence{ + VoteA: voteA, + VoteB: voteB, + } + return tp +} + +func DuplicateVoteEvidenceFromProto(pb *tmproto.DuplicateVoteEvidence) (*DuplicateVoteEvidence, error) { + if pb == nil { + return nil, errors.New("nil duplicate vote evidence") + } + + vA, err := VoteFromProto(pb.VoteA) + if err != nil { + return nil, err + } + + vB, err := VoteFromProto(pb.VoteB) + if err != nil { + return nil, err + } + + dve := new(DuplicateVoteEvidence) + + dve.VoteA = vA + dve.VoteB = vB + + return dve, dve.ValidateBasic() +} + //------------------------------------------- // EvidenceList is a list of Evidence. Evidences is not a word. @@ -715,7 +685,14 @@ func (ev ConflictingHeadersEvidence) Address() []byte { } func (ev ConflictingHeadersEvidence) Bytes() []byte { - return cdcEncode(ev) + pbe := ev.ToProto() + + bz, err := pbe.Marshal() + if err != nil { + panic(err) + } + + return bz } func (ev ConflictingHeadersEvidence) Hash() []byte { @@ -811,6 +788,38 @@ func (ev ConflictingHeadersEvidence) String() string { ev.H2.Height, ev.H2.Hash()) } +func (ev ConflictingHeadersEvidence) ToProto() tmproto.ConflictingHeadersEvidence { + pbh1 := ev.H1.ToProto() + pbh2 := ev.H2.ToProto() + + tp := tmproto.ConflictingHeadersEvidence{ + H1: pbh1, + H2: pbh2, + } + return tp +} + +func ConflictingHeadersEvidenceFromProto(pb *tmproto.ConflictingHeadersEvidence) (ConflictingHeadersEvidence, error) { + if pb == nil { + return ConflictingHeadersEvidence{}, errors.New("nil ConflictingHeadersEvidence") + } + h1, err := SignedHeaderFromProto(pb.H1) + if err != nil { + return ConflictingHeadersEvidence{}, fmt.Errorf("from proto err: %w", err) + } + h2, err := SignedHeaderFromProto(pb.H2) + if err != nil { + return ConflictingHeadersEvidence{}, fmt.Errorf("from proto err: %w", err) + } + + tp := ConflictingHeadersEvidence{ + H1: h1, + H2: h2, + } + + return tp, tp.ValidateBasic() +} + //------------------------------------------- type PhantomValidatorEvidence struct { @@ -833,11 +842,24 @@ func (e PhantomValidatorEvidence) Address() []byte { } func (e PhantomValidatorEvidence) Hash() []byte { - return tmhash.Sum(cdcEncode(e)) + pbe := e.ToProto() + + bz, err := pbe.Marshal() + if err != nil { + panic(err) + } + return tmhash.Sum(bz) } func (e PhantomValidatorEvidence) Bytes() []byte { - return cdcEncode(e) + pbe := e.ToProto() + + bz, err := pbe.Marshal() + if err != nil { + panic(err) + } + + return bz } func (e PhantomValidatorEvidence) Verify(chainID string, pubKey crypto.PubKey) error { @@ -889,6 +911,35 @@ func (e PhantomValidatorEvidence) String() string { e.Vote.ValidatorAddress, e.Vote.Height) } +func (e PhantomValidatorEvidence) ToProto() tmproto.PhantomValidatorEvidence { + vpb := e.Vote.ToProto() + + tp := tmproto.PhantomValidatorEvidence{ + Vote: vpb, + LastHeightValidatorWasInSet: e.LastHeightValidatorWasInSet, + } + + return tp +} + +func PhantomValidatorEvidenceFromProto(pb *tmproto.PhantomValidatorEvidence) (PhantomValidatorEvidence, error) { + if pb == nil { + return PhantomValidatorEvidence{}, errors.New("nil PhantomValidatorEvidence") + } + + vpb, err := VoteFromProto(pb.Vote) + if err != nil { + return PhantomValidatorEvidence{}, err + } + + tp := PhantomValidatorEvidence{ + Vote: vpb, + LastHeightValidatorWasInSet: pb.LastHeightValidatorWasInSet, + } + + return tp, tp.ValidateBasic() +} + //------------------------------------------- type LunaticValidatorEvidence struct { @@ -919,7 +970,14 @@ func (e LunaticValidatorEvidence) Hash() []byte { } func (e LunaticValidatorEvidence) Bytes() []byte { - return cdcEncode(e) + pbe := e.ToProto() + + bz, err := pbe.Marshal() + if err != nil { + panic(err) + } + + return bz } func (e LunaticValidatorEvidence) Verify(chainID string, pubKey crypto.PubKey) error { @@ -1030,6 +1088,43 @@ func (e LunaticValidatorEvidence) VerifyHeader(committedHeader *Header) error { return nil } +func (e LunaticValidatorEvidence) ToProto() tmproto.LunaticValidatorEvidence { + h := e.Header.ToProto() + v := e.Vote.ToProto() + + tp := tmproto.LunaticValidatorEvidence{ + Header: h, + Vote: v, + InvalidHeaderField: e.InvalidHeaderField, + } + + return tp +} + +func LunaticValidatorEvidenceFromProto(pb *tmproto.LunaticValidatorEvidence) (*LunaticValidatorEvidence, error) { + if pb == nil { + return nil, errors.New("nil LunaticValidatorEvidence") + } + + h, err := HeaderFromProto(pb.GetHeader()) + if err != nil { + return nil, err + } + + v, err := VoteFromProto(pb.GetVote()) + if err != nil { + return nil, err + } + + tp := LunaticValidatorEvidence{ + Header: &h, + Vote: v, + InvalidHeaderField: pb.InvalidHeaderField, + } + + return &tp, tp.ValidateBasic() +} + //------------------------------------------- // PotentialAmnesiaEvidence is constructed when a validator votes on two different blocks at different rounds @@ -1059,11 +1154,25 @@ func (e PotentialAmnesiaEvidence) Address() []byte { } func (e PotentialAmnesiaEvidence) Hash() []byte { - return tmhash.Sum(cdcEncode(e)) + pbe := e.ToProto() + + bz, err := pbe.Marshal() + if err != nil { + panic(err) + } + + return tmhash.Sum(bz) } func (e PotentialAmnesiaEvidence) Bytes() []byte { - return cdcEncode(e) + pbe := e.ToProto() + + bz, err := pbe.Marshal() + if err != nil { + panic(err) + } + + return bz } func (e PotentialAmnesiaEvidence) Verify(chainID string, pubKey crypto.PubKey) error { @@ -1173,6 +1282,21 @@ func (e PotentialAmnesiaEvidence) Primed(trialPeriod, currentHeight int64) bool return false } +func (e PotentialAmnesiaEvidence) ToProto() tmproto.PotentialAmnesiaEvidence { + voteB := e.VoteB.ToProto() + voteA := e.VoteA.ToProto() + + tp := tmproto.PotentialAmnesiaEvidence{ + VoteA: voteA, + VoteB: voteB, + HeightStamp: e.HeightStamp, + } + + return tp +} + +// ------------------ + // ProofOfLockChange (POLC) proves that a node followed the consensus protocol and voted for a precommit in two // different rounds because the node received a majority of votes for a different block in the latter round. In cases of // amnesia evidence, a suspected node will need ProofOfLockChange to prove that the node did not break protocol. @@ -1522,15 +1646,7 @@ func PotentialAmnesiaEvidenceFromProto(pb *tmproto.PotentialAmnesiaEvidence) (*P } func AmnesiaEvidenceToProto(evi AmnesiaEvidence) (*tmproto.Evidence, error) { - ev, err := EvidenceToProto(evi.PotentialAmnesiaEvidence) - if err != nil { - return nil, err - } - - paepb := ev.GetPotentialAmnesiaEvidence() - if paepb == nil { - return nil, errors.New("provided evidence is not potential amnesia evidence") - } + paepb := evi.PotentialAmnesiaEvidence.ToProto() polc, err := evi.Polc.ToProto() if err != nil { @@ -1540,14 +1656,35 @@ func AmnesiaEvidenceToProto(evi AmnesiaEvidence) (*tmproto.Evidence, error) { tp := &tmproto.Evidence{ Sum: &tmproto.Evidence_AmnesiaEvidence{ AmnesiaEvidence: &tmproto.AmnesiaEvidence{ - PotentialAmnesiaEvidence: paepb, + PotentialAmnesiaEvidence: &paepb, Polc: polc, }, }, } return tp, nil +} + +func AmensiaEvidenceFromProto(pb *tmproto.AmnesiaEvidence) (AmnesiaEvidence, error) { + if pb == nil { + return AmnesiaEvidence{}, errors.New("nil duplicate vote evidence") + } + + pae, err := PotentialAmnesiaEvidenceFromProto(pb.PotentialAmnesiaEvidence) + if err != nil { + return AmnesiaEvidence{}, err + } + polc, err := ProofOfLockChangeFromProto(pb.Polc) + if err != nil { + return AmnesiaEvidence{}, err + } + + tp := AmnesiaEvidence{ + PotentialAmnesiaEvidence: *pae, + Polc: *polc, + } + return tp, tp.ValidateBasic() } //----------------------------------------------------------------- diff --git a/types/evidence_test.go b/types/evidence_test.go index d0aa4a193..336ba96c2 100644 --- a/types/evidence_test.go +++ b/types/evidence_test.go @@ -135,7 +135,9 @@ func TestMaxEvidenceBytes(t *testing.T) { } for _, tt := range testCases { - bz, err := cdc.MarshalBinaryLengthPrefixed(tt.evidence) + pb, err := EvidenceToProto(tt.evidence) + require.NoError(t, err, tt.testName) + bz, err := pb.Marshal() require.NoError(t, err, tt.testName) assert.LessOrEqual(t, int64(len(bz)), MaxEvidenceBytes, tt.testName) @@ -664,6 +666,11 @@ func TestEvidenceProto(t *testing.T) { {"&PotentialAmnesiaEvidence nil VoteB", &PotentialAmnesiaEvidence{VoteA: v, VoteB: nil}, false, true}, {"&PotentialAmnesiaEvidence nil VoteA", &PotentialAmnesiaEvidence{VoteA: nil, VoteB: v2}, false, true}, {"&PotentialAmnesiaEvidence success", &PotentialAmnesiaEvidence{VoteA: v2, VoteB: v}, false, false}, + {"&PhantomValidatorEvidence empty fail", &PhantomValidatorEvidence{}, false, true}, + {"&PhantomValidatorEvidence nil LastHeightValidatorWasInSet", &PhantomValidatorEvidence{Vote: v}, false, true}, + {"&PhantomValidatorEvidence nil Vote", &PhantomValidatorEvidence{LastHeightValidatorWasInSet: 2}, false, true}, + {"PhantomValidatorEvidence success", PhantomValidatorEvidence{Vote: v2, LastHeightValidatorWasInSet: 2}, + false, false}, } for _, tt := range tests { tt := tt diff --git a/types/params.go b/types/params.go index 022fd9561..0dd4d9a83 100644 --- a/types/params.go +++ b/types/params.go @@ -128,7 +128,7 @@ func ValidateConsensusParams(params tmproto.ConsensusParams) error { // Check if keyType is a known ABCIPubKeyType for i := 0; i < len(params.Validator.PubKeyTypes); i++ { keyType := params.Validator.PubKeyTypes[i] - if _, ok := ABCIPubKeyTypesToAminoNames[keyType]; !ok { + if _, ok := ABCIPubKeyTypesToNames[keyType]; !ok { return fmt.Errorf("params.Validator.PubKeyTypes[%d], %s, is an unknown pubkey type", i, keyType) } diff --git a/types/protobuf.go b/types/protobuf.go index f3a40ff3e..70876c7d8 100644 --- a/types/protobuf.go +++ b/types/protobuf.go @@ -30,10 +30,10 @@ const ( // TODO: Make non-global by allowing for registration of more pubkey types -var ABCIPubKeyTypesToAminoNames = map[string]string{ - ABCIPubKeyTypeEd25519: ed25519.PubKeyAminoName, - ABCIPubKeyTypeSr25519: sr25519.PubKeyAminoName, - ABCIPubKeyTypeSecp256k1: secp256k1.PubKeyAminoName, +var ABCIPubKeyTypesToNames = map[string]string{ + ABCIPubKeyTypeEd25519: ed25519.PubKeyName, + ABCIPubKeyTypeSr25519: sr25519.PubKeyName, + ABCIPubKeyTypeSecp256k1: secp256k1.PubKeyName, } //------------------------------------------------------- diff --git a/types/protobuf_test.go b/types/protobuf_test.go index 213b1f303..b0e73ac29 100644 --- a/types/protobuf_test.go +++ b/types/protobuf_test.go @@ -4,17 +4,13 @@ import ( "testing" "time" - "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - amino "github.com/tendermint/go-amino" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" cryptoenc "github.com/tendermint/tendermint/crypto/encoding" - "github.com/tendermint/tendermint/proto/version" ) func TestABCIPubKey(t *testing.T) { @@ -65,63 +61,6 @@ func TestABCIConsensusParams(t *testing.T) { assert.Equal(t, *cp, cp2) } -func newHeader( - height int64, commitHash, dataHash, evidenceHash []byte, -) *Header { - return &Header{ - Height: height, - LastCommitHash: commitHash, - DataHash: dataHash, - EvidenceHash: evidenceHash, - } -} - -func TestABCIHeader(t *testing.T) { - // build a full header - var height int64 = 5 - header := newHeader(height, []byte("lastCommitHash"), []byte("dataHash"), []byte("evidenceHash")) - protocolVersion := version.Consensus{Block: 7, App: 8} - timestamp := time.Now() - lastBlockID := BlockID{ - Hash: []byte("hash"), - PartsHeader: PartSetHeader{ - Total: 10, - Hash: []byte("hash"), - }, - } - header.Populate( - protocolVersion, "chainID", timestamp, lastBlockID, - []byte("valHash"), []byte("nextValHash"), - []byte("consHash"), []byte("appHash"), []byte("lastResultsHash"), - []byte("proposerAddress"), - ) - - cdc := amino.NewCodec() - headerBz := cdc.MustMarshalBinaryBare(header) - - pbHeader := header.ToProto() - pbHeaderBz, err := proto.Marshal(pbHeader) - assert.NoError(t, err) - - // assert some fields match - assert.EqualValues(t, protocolVersion.Block, pbHeader.Version.Block) - assert.EqualValues(t, protocolVersion.App, pbHeader.Version.App) - assert.EqualValues(t, "chainID", pbHeader.ChainID) - assert.EqualValues(t, height, pbHeader.Height) - assert.EqualValues(t, timestamp, pbHeader.Time) - assert.EqualValues(t, lastBlockID.Hash, pbHeader.LastBlockId.Hash) - assert.EqualValues(t, []byte("lastCommitHash"), pbHeader.LastCommitHash) - assert.Equal(t, []byte("proposerAddress"), pbHeader.ProposerAddress) - - // assert the encodings match - // NOTE: they don't yet because Amino encodes - // int64 as zig-zag and we're using non-zigzag in the protobuf. - // See https://github.com/tendermint/tendermint/issues/2682 - _, _ = headerBz, pbHeaderBz - // assert.EqualValues(t, headerBz, pbHeaderBz) - -} - func TestABCIEvidence(t *testing.T) { val := NewMockPV() blockID := makeBlockID([]byte("blockhash"), 1000, []byte("partshash")) diff --git a/types/tx.go b/types/tx.go index 402a376b6..689a1aadd 100644 --- a/types/tx.go +++ b/types/tx.go @@ -8,6 +8,7 @@ import ( "github.com/tendermint/tendermint/crypto/merkle" "github.com/tendermint/tendermint/crypto/tmhash" tmbytes "github.com/tendermint/tendermint/libs/bytes" + tmproto "github.com/tendermint/tendermint/proto/types" ) // Tx is an arbitrary byte array. @@ -108,3 +109,31 @@ func (tp TxProof) Validate(dataHash []byte) error { } return nil } + +func (tp TxProof) ToProto() tmproto.TxProof { + + pbProof := tp.Proof.ToProto() + + pbtp := tmproto.TxProof{ + RootHash: tp.RootHash, + Data: tp.Data, + Proof: pbProof, + } + + return pbtp +} +func TxProofFromProto(pb tmproto.TxProof) (TxProof, error) { + + pbProof, err := merkle.ProofFromProto(pb.Proof) + if err != nil { + return TxProof{}, err + } + + pbtp := TxProof{ + RootHash: pb.RootHash, + Data: pb.Data, + Proof: *pbProof, + } + + return pbtp, nil +} diff --git a/types/tx_test.go b/types/tx_test.go index 969fed95c..8d04c8163 100644 --- a/types/tx_test.go +++ b/types/tx_test.go @@ -5,9 +5,11 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" tmrand "github.com/tendermint/tendermint/libs/rand" ctest "github.com/tendermint/tendermint/libs/test" + tmproto "github.com/tendermint/tendermint/proto/types" ) func makeTxs(cnt, size int) Txs { @@ -77,10 +79,18 @@ func TestValidTxProof(t *testing.T) { assert.NotNil(t, proof.Validate([]byte("foobar")), "%d: %d", h, i) // read-write must also work - var p2 TxProof - bin, err := cdc.MarshalBinaryLengthPrefixed(proof) - assert.Nil(t, err) - err = cdc.UnmarshalBinaryLengthPrefixed(bin, &p2) + var ( + p2 TxProof + pb2 tmproto.TxProof + ) + pbProof := proof.ToProto() + bin, err := pbProof.Marshal() + require.NoError(t, err) + + err = pb2.Unmarshal(bin) + require.NoError(t, err) + + p2, err = TxProofFromProto(pb2) if assert.Nil(t, err, "%d: %d: %+v", h, i, err) { assert.Nil(t, p2.Validate(root), "%d: %d", h, i) } @@ -104,8 +114,9 @@ func testTxProofUnchangable(t *testing.T) { // make sure it is valid to start with assert.Nil(t, proof.Validate(root)) - bin, err := cdc.MarshalBinaryLengthPrefixed(proof) - assert.Nil(t, err) + pbProof := proof.ToProto() + bin, err := pbProof.Marshal() + require.NoError(t, err) // try mutating the data and make sure nothing breaks for j := 0; j < 500; j++ { @@ -118,16 +129,23 @@ func testTxProofUnchangable(t *testing.T) { // This makes sure that the proof doesn't deserialize into something valid. func assertBadProof(t *testing.T, root []byte, bad []byte, good TxProof) { - var proof TxProof - err := cdc.UnmarshalBinaryLengthPrefixed(bad, &proof) + + var ( + proof TxProof + pbProof tmproto.TxProof + ) + err := pbProof.Unmarshal(bad) if err == nil { - err = proof.Validate(root) + proof, err = TxProofFromProto(pbProof) if err == nil { - // XXX Fix simple merkle proofs so the following is *not* OK. - // 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.Proof.Total, good.Proof.Total, "bad: %#v\ngood: %#v", proof, good) + err = proof.Validate(root) + if err == nil { + // XXX Fix simple merkle proofs so the following is *not* OK. + // 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.Proof.Total, good.Proof.Total, "bad: %#v\ngood: %#v", proof, good) + } } } } diff --git a/types/validator.go b/types/validator.go index e3970e766..0d10253b7 100644 --- a/types/validator.go +++ b/types/validator.go @@ -107,13 +107,21 @@ func ValidatorListString(vals []*Validator) string { // as its redundant with the pubkey. This also excludes ProposerPriority // which changes every round. func (v *Validator) Bytes() []byte { - return cdcEncode(struct { - PubKey crypto.PubKey - VotingPower int64 - }{ - v.PubKey, - v.VotingPower, - }) + pk, err := ce.PubKeyToProto(v.PubKey) + if err != nil { + panic(err) + } + + pbv := tmproto.SimpleValidator{ + PubKey: &pk, + VotingPower: v.VotingPower, + } + + bz, err := pbv.Marshal() + if err != nil { + panic(err) + } + return bz } // ToProto converts Valiator to protobuf diff --git a/types/validator_set_test.go b/types/validator_set_test.go index cb04177de..f01df4cc6 100644 --- a/types/validator_set_test.go +++ b/types/validator_set_test.go @@ -301,14 +301,17 @@ func TestProposerSelection2(t *testing.T) { func TestProposerSelection3(t *testing.T) { vset := NewValidatorSet([]*Validator{ - newValidator([]byte("a"), 1), - newValidator([]byte("b"), 1), - newValidator([]byte("c"), 1), - newValidator([]byte("d"), 1), + newValidator([]byte("avalidator_address12"), 1), + newValidator([]byte("bvalidator_address12"), 1), + newValidator([]byte("cvalidator_address12"), 1), + newValidator([]byte("dvalidator_address12"), 1), }) proposerOrder := make([]*Validator, 4) for i := 0; i < 4; i++ { + // need to give all validators to have keys + pk := ed25519.GenPrivKey().PubKey() + vset.Validators[i].PubKey = pk proposerOrder[i] = vset.GetProposer() vset.IncrementProposerPriority(1) } @@ -329,7 +332,7 @@ func TestProposerSelection3(t *testing.T) { // serialize, deserialize, check proposer b := vset.toBytes() - vset.fromBytes(b) + vset = vset.fromBytes(b) computed := vset.GetProposer() // findGetProposer() if i != 0 { @@ -388,19 +391,33 @@ func randValidatorSet(numValidators int) *ValidatorSet { } func (vals *ValidatorSet) toBytes() []byte { - bz, err := cdc.MarshalBinaryLengthPrefixed(vals) + pbvs, err := vals.ToProto() if err != nil { panic(err) } + + bz, err := pbvs.Marshal() + if err != nil { + panic(err) + } + return bz } -func (vals *ValidatorSet) fromBytes(b []byte) { - err := cdc.UnmarshalBinaryLengthPrefixed(b, &vals) +func (vals *ValidatorSet) fromBytes(b []byte) *ValidatorSet { + pbvs := new(tmproto.ValidatorSet) + err := pbvs.Unmarshal(b) if err != nil { // DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED panic(err) } + + vs, err := ValidatorSetFromProto(pbvs) + if err != nil { + panic(err) + } + + return vs } //-------------------------------------------------------------------