From 2679b7554b0358e39bae4dae5845cedd4479c896 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 3 Feb 2018 03:02:49 -0500 Subject: [PATCH 01/10] lite: comment out iavl code - TODO #1183 --- lite/proxy/query.go | 24 +++++++++++++++++++++--- rpc/client/rpc_test.go | 13 ++----------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lite/proxy/query.go b/lite/proxy/query.go index 72c3ed297..ed4ad9136 100644 --- a/lite/proxy/query.go +++ b/lite/proxy/query.go @@ -4,7 +4,6 @@ import ( "github.com/pkg/errors" "github.com/tendermint/go-wire/data" - "github.com/tendermint/iavl" "github.com/tendermint/tendermint/lite" "github.com/tendermint/tendermint/lite/client" @@ -13,6 +12,20 @@ import ( ctypes "github.com/tendermint/tendermint/rpc/core/types" ) +// KeyProof represents a proof of existence or absence of a single key. +// Copied from iavl repo. TODO +type KeyProof interface { + // Verify verfies the proof is valid. To verify absence, + // the value should be nil. + Verify(key, value, root []byte) error + + // Root returns the root hash of the proof. + Root() []byte + + // Serialize itself + Bytes() []byte +} + // GetWithProof will query the key on the given node, and verify it has // a valid proof, as defined by the certifier. // @@ -21,7 +34,7 @@ import ( // If val is empty, proof should be KeyMissingProof func GetWithProof(key []byte, reqHeight int64, node rpcclient.Client, cert lite.Certifier) ( - val data.Bytes, height int64, proof iavl.KeyProof, err error) { + val data.Bytes, height int64, proof KeyProof, err error) { if reqHeight < 0 { err = errors.Errorf("Height cannot be negative") @@ -41,7 +54,7 @@ func GetWithProof(key []byte, reqHeight int64, node rpcclient.Client, // GetWithProofOptions is useful if you want full access to the ABCIQueryOptions func GetWithProofOptions(path string, key []byte, opts rpcclient.ABCIQueryOptions, node rpcclient.Client, cert lite.Certifier) ( - *ctypes.ResultABCIQuery, iavl.KeyProof, error) { + *ctypes.ResultABCIQuery, KeyProof, error) { _resp, err := node.ABCIQueryWithOptions(path, key, opts) if err != nil { @@ -67,6 +80,10 @@ func GetWithProofOptions(path string, key []byte, opts rpcclient.ABCIQueryOption return nil, nil, err } + return &ctypes.ResultABCIQuery{Response: resp}, nil, nil + + /* // TODO refactor so iavl stuff is not in tendermint core + // https://github.com/tendermint/tendermint/issues/1183 if len(resp.Value) > 0 { // The key was found, construct a proof of existence. eproof, err := iavl.ReadKeyExistsProof(resp.Proof) @@ -94,6 +111,7 @@ func GetWithProofOptions(path string, key []byte, opts rpcclient.ABCIQueryOption return nil, nil, errors.Wrap(err, "Couldn't verify proof") } return &ctypes.ResultABCIQuery{Response: resp}, aproof, ErrNoData() + */ } // GetCertifiedCommit gets the signed header for a given height diff --git a/rpc/client/rpc_test.go b/rpc/client/rpc_test.go index 9b956803e..165e4ec26 100644 --- a/rpc/client/rpc_test.go +++ b/rpc/client/rpc_test.go @@ -9,7 +9,6 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/abci/types" - "github.com/tendermint/iavl" "github.com/tendermint/tendermint/rpc/client" rpctest "github.com/tendermint/tendermint/rpc/test" @@ -204,16 +203,8 @@ func TestAppCalls(t *testing.T) { // and we got a proof that works! _pres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Trusted: false}) pres := _pres.Response - if assert.Nil(err) && assert.True(pres.IsOK()) { - proof, err := iavl.ReadKeyExistsProof(pres.Proof) - if assert.Nil(err) { - key := pres.Key - value := pres.Value - assert.EqualValues(appHash, proof.RootHash) - valid := proof.Verify(key, value, appHash) - assert.Nil(valid) - } - } + assert.Nil(err) + assert.True(pres.IsOK()) } } From 061ad355bbaaaafedf452eba6803133aee87aee5 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 3 Feb 2018 03:22:56 -0500 Subject: [PATCH 02/10] update glide --- glide.lock | 61 +++++++++++++++++++++--------------------------------- glide.yaml | 11 ++++------ 2 files changed, 28 insertions(+), 44 deletions(-) diff --git a/glide.lock b/glide.lock index 383772f05..f663a732f 100644 --- a/glide.lock +++ b/glide.lock @@ -1,32 +1,26 @@ -hash: 9399a10e80d255104f8ec07b5d495c41d8a3f7a421f9da97ebd78c65189f381d -updated: 2018-01-18T23:11:10.703734578-05:00 +hash: da486c9bf3e31f481a2b704f0602fe395001e03dbbab580ef13241aa452f1b37 +updated: 2018-02-03T03:00:02.112396533-05:00 imports: - name: github.com/btcsuite/btcd - version: 2e60448ffcc6bf78332d1fe590260095f554dd78 + version: 50de9da05b50eb15658bb350f6ea24368a111ab7 subpackages: - btcec - name: github.com/ebuchman/fail-test version: 95f809107225be108efcf10a3509e4ea6ceef3c4 - name: github.com/fsnotify/fsnotify - version: 4da3e2cfbabc9f751898f250b49f2439785783a1 + version: c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9 - name: github.com/go-kit/kit - version: 53f10af5d5c7375d4655a3d6852457ed17ab5cc7 + version: 4dc7be5d2d12881735283bcab7352178e190fc71 subpackages: - log - log/level - log/term - name: github.com/go-logfmt/logfmt version: 390ab7935ee28ec6b286364bba9b4dd6410cb3d5 -- name: github.com/go-playground/locales - version: e4cbcb5d0652150d40ad0646651076b6bd2be4f6 - subpackages: - - currency -- name: github.com/go-playground/universal-translator - version: 71201497bace774495daed26a3874fd339e0b538 - name: github.com/go-stack/stack version: 259ab82a6cad3992b4e21ff5cac294ccb06474bc - name: github.com/gogo/protobuf - version: 342cbe0a04158f6dcb03ca0079991a51a4248c02 + version: 1adfc126b41513cc696b209667c8656ea7aac67c subpackages: - gogoproto - jsonpb @@ -35,7 +29,7 @@ imports: - sortkeys - types - name: github.com/golang/protobuf - version: 1e59b77b52bf8e4b449a57e6f79f21226d571845 + version: bbd03ef6da3a115852eaf24c8a1c46aeb39aa175 subpackages: - proto - ptypes @@ -66,15 +60,15 @@ imports: - name: github.com/magiconair/properties version: 49d762b9817ba1c2e9d0c69183c2b4a8b8f1d934 - name: github.com/mitchellh/mapstructure - version: 06020f85339e21b2478f756a78e295255ffa4d6a + version: b4575eea38cca1123ec2dc90c26529b5c5acfcff - name: github.com/pelletier/go-toml - version: 4e9e0ee19b60b13eb79915933f44d8ed5f268bdd + version: acdc4509485b587f5e675510c4f2c63e90ff68a8 - name: github.com/pkg/errors version: 645ef00459ed84a119197bfb8d8205042c6df63d - name: github.com/rcrowley/go-metrics - version: e181e095bae94582363434144c61a9653aff6e50 + version: 8732c616f52954686704c8645fe1a9d59e9df7c1 - name: github.com/spf13/afero - version: 8d919cbe7e2627e417f3e45c3c0e489a5b7e2536 + version: bb8f1927f2a9d3ab41c9340aa034f6b803f4359c subpackages: - mem - name: github.com/spf13/cast @@ -82,13 +76,13 @@ imports: - name: github.com/spf13/cobra version: 7b2c5ac9fc04fc5efafb60700713d4fa609b777b - name: github.com/spf13/jwalterweatherman - version: 12bd96e66386c1960ab0f74ced1362f66f552f7b + version: 7c0cea34c8ece3fbeb2b27ab9b59511d360fb394 - name: github.com/spf13/pflag version: 4c012f6dcd9546820e378d0bdda4d8fc772cdfea - name: github.com/spf13/viper version: 25b30aa063fc18e48662b86996252eabdcf2f0c7 - name: github.com/syndtr/goleveldb - version: adf24ef3f94bd13ec4163060b21a5678f22b429b + version: 211f780988068502fe874c44dae530528ebd840f subpackages: - leveldb - leveldb/cache @@ -103,7 +97,7 @@ imports: - leveldb/table - leveldb/util - name: github.com/tendermint/abci - version: 5d5ea6869b91cadb55dbc4211ad7b326f053a33e + version: 5a4f56056e23cdfd5f3733db056968e016468508 subpackages: - client - example/code @@ -122,14 +116,9 @@ imports: version: b6fc872b42d41158a60307db4da051dd6f179415 subpackages: - data - - data/base58 - nowriter/tmlegacy -- name: github.com/tendermint/iavl - version: 594cc0c062a7174475f0ab654384038d77067917 - subpackages: - - iavl - name: github.com/tendermint/tmlibs - version: 15e51fa76086a3c505f227679c2478043ae7261b + version: deaaf014d8b8d1095054380a38b1b00e293f725f subpackages: - autofile - cli @@ -144,7 +133,7 @@ imports: - pubsub/query - test - name: golang.org/x/crypto - version: 94eea52f7b742c7cbe0b03b22f0c4c8631ece122 + version: 1875d0a70c90e57f11972aefd42276df65e895b9 subpackages: - curve25519 - nacl/box @@ -155,7 +144,7 @@ imports: - ripemd160 - salsa20/salsa - name: golang.org/x/net - version: d866cfc389cec985d6fda2859936a575a55a3ab6 + version: 2fb46b16b8dda405028c50f7c7f0f9dd1fa6bfb1 subpackages: - context - http2 @@ -165,18 +154,18 @@ imports: - lex/httplex - trace - name: golang.org/x/sys - version: 8b4580aae2a0dd0c231a45d3ccb8434ff533b840 + version: 37707fdb30a5b38865cfb95e5aab41707daec7fd subpackages: - unix - name: golang.org/x/text - version: 57961680700a5336d15015c8c50686ca5ba362a4 + version: e19ae1496984b1c655b8044a65c0300a3c878dd3 subpackages: - secure/bidirule - transform - unicode/bidi - unicode/norm - name: google.golang.org/genproto - version: a8101f21cf983e773d0c1133ebc5424792003214 + version: 4eb30f4778eed4c258ba66527a0d4f9ec8a36c45 subpackages: - googleapis/rpc/status - name: google.golang.org/grpc @@ -198,21 +187,19 @@ imports: - status - tap - transport -- name: gopkg.in/go-playground/validator.v9 - version: 61caf9d3038e1af346dbf5c2e16f6678e1548364 - name: gopkg.in/yaml.v2 - version: 287cf08546ab5e7e37d55a84f7ed3fd1db036de5 + version: d670f9405373e636a5a2765eea47fac0c9bc91a4 testImports: - name: github.com/davecgh/go-spew - version: 04cdfd42973bb9c8589fd6a731800cf222fde1a9 + version: 87df7c60d5820d0f8ae11afede5aa52325c09717 subpackages: - spew - name: github.com/pmezard/go-difflib - version: d8ed2627bdf02c080bf22230dbb337003b7aba2d + version: 792786c7400a136282c1664665ae0a8db921c6c2 subpackages: - difflib - name: github.com/stretchr/testify - version: 2aa2c176b9dab406a6970f6a55f513e8a8c8b18f + version: a726187e3128d0a0ec37f73ca7c4d3e508e6c2e5 subpackages: - assert - require diff --git a/glide.yaml b/glide.yaml index 2302a6dcf..90b845e1c 100644 --- a/glide.yaml +++ b/glide.yaml @@ -2,7 +2,7 @@ package: github.com/tendermint/tendermint import: - package: github.com/ebuchman/fail-test - package: github.com/gogo/protobuf - version: v0.5 + version: ^1.0.0 subpackages: - proto - package: github.com/golang/protobuf @@ -18,7 +18,7 @@ import: - package: github.com/spf13/viper version: v1.0.0 - package: github.com/tendermint/abci - version: v0.9.0 + version: develop subpackages: - client - example/dummy @@ -29,12 +29,8 @@ import: version: ~0.7.2 subpackages: - data -- package: github.com/tendermint/iavl - version: ~0.2.0 - subpackages: - - iavl - package: github.com/tendermint/tmlibs - version: v0.6.1 + version: develop subpackages: - autofile - cli @@ -58,6 +54,7 @@ import: version: v1.7.3 testImport: - package: github.com/go-kit/kit + version: ^0.6.0 subpackages: - log/term - package: github.com/stretchr/testify From 4e3488c677689ee48530c1f6088c771e8afb935d Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 3 Feb 2018 03:23:10 -0500 Subject: [PATCH 03/10] update types --- types/block.go | 55 +++++++++++++++++++++++++++++------------- types/event_bus.go | 11 ++------- types/evidence.go | 6 +++-- types/params.go | 14 +++++------ types/part_set.go | 4 +-- types/protobuf.go | 8 +++--- types/results.go | 12 ++++----- types/signable.go | 6 ----- types/tx.go | 8 +++--- types/validator_set.go | 8 +++--- 10 files changed, 71 insertions(+), 61 deletions(-) diff --git a/types/block.go b/types/block.go index 6aa97c2d6..b9b541a96 100644 --- a/types/block.go +++ b/types/block.go @@ -12,6 +12,7 @@ import ( "github.com/tendermint/go-wire/data" cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/merkle" + "golang.org/x/crypto/ripemd160" ) // Block defines the atomic unit of a Tendermint blockchain. @@ -179,20 +180,20 @@ func (h *Header) Hash() data.Bytes { if len(h.ValidatorsHash) == 0 { return nil } - return merkle.SimpleHashFromMap(map[string]interface{}{ - "ChainID": h.ChainID, - "Height": h.Height, - "Time": h.Time, - "NumTxs": h.NumTxs, - "TotalTxs": h.TotalTxs, - "LastBlockID": h.LastBlockID, - "LastCommit": h.LastCommitHash, - "Data": h.DataHash, - "Validators": h.ValidatorsHash, - "App": h.AppHash, - "Consensus": h.ConsensusHash, - "Results": h.LastResultsHash, - "Evidence": h.EvidenceHash, + return merkle.SimpleHashFromMap(map[string]merkle.Hasher{ + "ChainID": wireHasher(h.ChainID), + "Height": wireHasher(h.Height), + "Time": wireHasher(h.Time), + "NumTxs": wireHasher(h.NumTxs), + "TotalTxs": wireHasher(h.TotalTxs), + "LastBlockID": wireHasher(h.LastBlockID), + "LastCommit": wireHasher(h.LastCommitHash), + "Data": wireHasher(h.DataHash), + "Validators": wireHasher(h.ValidatorsHash), + "App": wireHasher(h.AppHash), + "Consensus": wireHasher(h.ConsensusHash), + "Results": wireHasher(h.LastResultsHash), + "Evidence": wireHasher(h.EvidenceHash), }) } @@ -356,11 +357,11 @@ func (commit *Commit) ValidateBasic() error { // Hash returns the hash of the commit func (commit *Commit) Hash() data.Bytes { if commit.hash == nil { - bs := make([]interface{}, len(commit.Precommits)) + bs := make([]merkle.Hasher, len(commit.Precommits)) for i, precommit := range commit.Precommits { - bs[i] = precommit + bs[i] = wireHasher(precommit) } - commit.hash = merkle.SimpleHashFromBinaries(bs) + commit.hash = merkle.SimpleHashFromHashers(bs) } return commit.hash } @@ -510,3 +511,23 @@ func (blockID BlockID) WriteSignBytes(w io.Writer, n *int, err *error) { func (blockID BlockID) String() string { return fmt.Sprintf(`%v:%v`, blockID.Hash, blockID.PartsHeader) } + +//------------------------------------------------------- + +type hasher struct { + item interface{} +} + +func (h hasher) Hash() []byte { + hasher, n, err := ripemd160.New(), new(int), new(error) + wire.WriteBinary(h.item, hasher, n, err) + if *err != nil { + panic(err) + } + return hasher.Sum(nil) + +} + +func wireHasher(item interface{}) merkle.Hasher { + return hasher{item} +} diff --git a/types/event_bus.go b/types/event_bus.go index 6b6069b90..4edaea588 100644 --- a/types/event_bus.go +++ b/types/event_bus.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - abci "github.com/tendermint/abci/types" cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/log" tmpubsub "github.com/tendermint/tmlibs/pubsub" @@ -98,17 +97,11 @@ func (b *EventBus) PublishEventTx(event EventDataTx) error { // validate and fill tags from tx result for _, tag := range event.Result.Tags { // basic validation - if tag.Key == "" { + if len(tag.Key) == 0 { b.Logger.Info("Got tag with an empty key (skipping)", "tag", tag, "tx", event.Tx) continue } - - switch tag.ValueType { - case abci.KVPair_STRING: - tags[tag.Key] = tag.ValueString - case abci.KVPair_INT: - tags[tag.Key] = tag.ValueInt - } + tags[string(tag.Key)] = tag.Value } // add predefined tags diff --git a/types/evidence.go b/types/evidence.go index 3ae3e40b1..9973c62e6 100644 --- a/types/evidence.go +++ b/types/evidence.go @@ -120,7 +120,7 @@ func (dve *DuplicateVoteEvidence) Index() int { // Hash returns the hash of the evidence. func (dve *DuplicateVoteEvidence) Hash() []byte { - return merkle.SimpleHashFromBinary(dve) + return wireHasher(dve).Hash() } // Verify returns an error if the two votes aren't conflicting. @@ -165,7 +165,9 @@ func (dve *DuplicateVoteEvidence) Equal(ev Evidence) bool { } // just check their hashes - return bytes.Equal(merkle.SimpleHashFromBinary(dve), merkle.SimpleHashFromBinary(ev)) + dveHash := wireHasher(dve).Hash() + evHash := wireHasher(ev).Hash() + return bytes.Equal(dveHash, evHash) } //----------------------------------------------------------------- diff --git a/types/params.go b/types/params.go index 90ab5f659..0e8ac577f 100644 --- a/types/params.go +++ b/types/params.go @@ -106,13 +106,13 @@ func (params *ConsensusParams) Validate() error { // Hash returns a merkle hash of the parameters to store // in the block header func (params *ConsensusParams) Hash() []byte { - return merkle.SimpleHashFromMap(map[string]interface{}{ - "block_gossip_part_size_bytes": params.BlockGossip.BlockPartSizeBytes, - "block_size_max_bytes": params.BlockSize.MaxBytes, - "block_size_max_gas": params.BlockSize.MaxGas, - "block_size_max_txs": params.BlockSize.MaxTxs, - "tx_size_max_bytes": params.TxSize.MaxBytes, - "tx_size_max_gas": params.TxSize.MaxGas, + return merkle.SimpleHashFromMap(map[string]merkle.Hasher{ + "block_gossip_part_size_bytes": wireHasher(params.BlockGossip.BlockPartSizeBytes), + "block_size_max_bytes": wireHasher(params.BlockSize.MaxBytes), + "block_size_max_gas": wireHasher(params.BlockSize.MaxGas), + "block_size_max_txs": wireHasher(params.BlockSize.MaxTxs), + "tx_size_max_bytes": wireHasher(params.TxSize.MaxBytes), + "tx_size_max_gas": wireHasher(params.TxSize.MaxGas), }) } diff --git a/types/part_set.go b/types/part_set.go index e8a0997c0..d922e34d6 100644 --- a/types/part_set.go +++ b/types/part_set.go @@ -96,7 +96,7 @@ func NewPartSetFromData(data []byte, partSize int) *PartSet { // divide data into 4kb parts. total := (len(data) + partSize - 1) / partSize parts := make([]*Part, total) - parts_ := make([]merkle.Hashable, total) + parts_ := make([]merkle.Hasher, total) partsBitArray := cmn.NewBitArray(total) for i := 0; i < total; i++ { part := &Part{ @@ -108,7 +108,7 @@ func NewPartSetFromData(data []byte, partSize int) *PartSet { partsBitArray.SetIndex(i, true) } // Compute merkle proofs - root, proofs := merkle.SimpleProofsFromHashables(parts_) + root, proofs := merkle.SimpleProofsFromHashers(parts_) for i := 0; i < total; i++ { parts[i].Proof = *proofs[i] } diff --git a/types/protobuf.go b/types/protobuf.go index 43c8f4505..bac5b799e 100644 --- a/types/protobuf.go +++ b/types/protobuf.go @@ -23,15 +23,15 @@ func (tm2pb) Header(header *Header) *types.Header { } } -func (tm2pb) BlockID(blockID BlockID) *types.BlockID { - return &types.BlockID{ +func (tm2pb) BlockID(blockID BlockID) types.BlockID { + return types.BlockID{ Hash: blockID.Hash, Parts: TM2PB.PartSetHeader(blockID.PartsHeader), } } -func (tm2pb) PartSetHeader(partSetHeader PartSetHeader) *types.PartSetHeader { - return &types.PartSetHeader{ +func (tm2pb) PartSetHeader(partSetHeader PartSetHeader) types.PartSetHeader { + return types.PartSetHeader{ Total: int32(partSetHeader.Total), // XXX: overflow Hash: partSetHeader.Hash, } diff --git a/types/results.go b/types/results.go index 29420fbc0..8e79e1ac7 100644 --- a/types/results.go +++ b/types/results.go @@ -47,20 +47,20 @@ func (a ABCIResults) Bytes() []byte { // Hash returns a merkle hash of all results func (a ABCIResults) Hash() []byte { - return merkle.SimpleHashFromHashables(a.toHashables()) + return merkle.SimpleHashFromHashers(a.toHashers()) } // ProveResult returns a merkle proof of one result from the set func (a ABCIResults) ProveResult(i int) merkle.SimpleProof { - _, proofs := merkle.SimpleProofsFromHashables(a.toHashables()) + _, proofs := merkle.SimpleProofsFromHashers(a.toHashers()) return *proofs[i] } -func (a ABCIResults) toHashables() []merkle.Hashable { +func (a ABCIResults) toHashers() []merkle.Hasher { l := len(a) - hashables := make([]merkle.Hashable, l) + hashers := make([]merkle.Hasher, l) for i := 0; i < l; i++ { - hashables[i] = a[i] + hashers[i] = a[i] } - return hashables + return hashers } diff --git a/types/signable.go b/types/signable.go index 2134f6300..bfdf9faa1 100644 --- a/types/signable.go +++ b/types/signable.go @@ -5,7 +5,6 @@ import ( "io" cmn "github.com/tendermint/tmlibs/common" - "github.com/tendermint/tmlibs/merkle" ) // Signable is an interface for all signable things. @@ -23,8 +22,3 @@ func SignBytes(chainID string, o Signable) []byte { } return buf.Bytes() } - -// HashSignBytes is a convenience method for getting the hash of the bytes of a signable -func HashSignBytes(chainID string, o Signable) []byte { - return merkle.SimpleHashFromBinary(SignBytes(chainID, o)) -} diff --git a/types/tx.go b/types/tx.go index 4cf5843ae..db42ed8e7 100644 --- a/types/tx.go +++ b/types/tx.go @@ -18,7 +18,7 @@ type Tx []byte // Hash computes the RIPEMD160 hash of the go-wire encoded transaction. func (tx Tx) Hash() []byte { - return merkle.SimpleHashFromBinary(tx) + return wireHasher(tx).Hash() } // String returns the hex-encoded transaction as a string. @@ -72,11 +72,11 @@ func (txs Txs) IndexByHash(hash []byte) int { // TODO: optimize this! func (txs Txs) Proof(i int) TxProof { l := len(txs) - hashables := make([]merkle.Hashable, l) + hashers := make([]merkle.Hasher, l) for i := 0; i < l; i++ { - hashables[i] = txs[i] + hashers[i] = txs[i] } - root, proofs := merkle.SimpleProofsFromHashables(hashables) + root, proofs := merkle.SimpleProofsFromHashers(hashers) return TxProof{ Index: i, diff --git a/types/validator_set.go b/types/validator_set.go index 7e895aba0..0d6c3249e 100644 --- a/types/validator_set.go +++ b/types/validator_set.go @@ -54,7 +54,7 @@ func (valSet *ValidatorSet) IncrementAccum(times int) { for _, val := range valSet.Validators { // check for overflow both multiplication and sum val.Accum = safeAddClip(val.Accum, safeMulClip(val.VotingPower, int64(times))) - validatorsHeap.Push(val, accumComparable{val}) + validatorsHeap.PushComparable(val, accumComparable{val}) } // Decrement the validator with most accum times times @@ -150,11 +150,11 @@ func (valSet *ValidatorSet) Hash() []byte { if len(valSet.Validators) == 0 { return nil } - hashables := make([]merkle.Hashable, len(valSet.Validators)) + hashers := make([]merkle.Hasher, len(valSet.Validators)) for i, val := range valSet.Validators { - hashables[i] = val + hashers[i] = val } - return merkle.SimpleHashFromHashables(hashables) + return merkle.SimpleHashFromHashers(hashers) } func (valSet *ValidatorSet) Add(val *Validator) (added bool) { From cd0fd06b0d8eaecfc33fa64c664eda22ec54307e Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 6 Jan 2018 01:26:51 -0500 Subject: [PATCH 04/10] update for sdk2 libs. need to fix kv test NOTE we only updating for tmlibs and abci --- blockchain/store.go | 2 +- blockchain/store_test.go | 3 +- consensus/byzantine_test.go | 3 +- consensus/mempool_test.go | 6 +- consensus/replay.go | 2 +- evidence/store.go | 4 +- glide.lock | 205 ----------------------------------- glide.yaml | 4 +- lite/proxy/query.go | 16 ++- mempool/mempool_test.go | 2 +- node/node.go | 4 +- state/execution.go | 27 ++--- state/execution_test.go | 13 ++- state/state_test.go | 60 +++++----- state/txindex/kv/kv.go | 47 ++++---- state/txindex/kv/kv_test.go | 29 ++--- types/canonical_json.go | 10 +- types/heartbeat.go | 3 +- types/priv_validator.go | 6 +- types/priv_validator_test.go | 3 +- types/protobuf.go | 12 +- types/validator.go | 9 +- types/vote.go | 6 +- 23 files changed, 130 insertions(+), 346 deletions(-) delete mode 100644 glide.lock diff --git a/blockchain/store.go b/blockchain/store.go index 91d2b220f..a9a543436 100644 --- a/blockchain/store.go +++ b/blockchain/store.go @@ -254,7 +254,7 @@ func (bsj BlockStoreStateJSON) Save(db dbm.DB) { // If no BlockStoreStateJSON was previously persisted, it returns the zero value. func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON { bytes := db.Get(blockStoreKey) - if bytes == nil { + if len(bytes) == 0 { return BlockStoreStateJSON{ Height: 0, } diff --git a/blockchain/store_test.go b/blockchain/store_test.go index 933329c4b..16185ca0d 100644 --- a/blockchain/store_test.go +++ b/blockchain/store_test.go @@ -42,7 +42,6 @@ func TestNewBlockStore(t *testing.T) { wantErr string }{ {[]byte("artful-doger"), "not unmarshal bytes"}, - {[]byte(""), "unmarshal bytes"}, {[]byte(" "), "unmarshal bytes"}, } @@ -76,7 +75,7 @@ func TestBlockStoreGetReader(t *testing.T) { }{ 0: {key: []byte("Foo"), want: []byte("Bar")}, 1: {key: []byte("KnoxNonExistent"), want: nil}, - 2: {key: []byte("Foo1"), want: nil}, + 2: {key: []byte("Foo1"), want: []byte{}}, } for i, tt := range tests { diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index 38df1ecc1..faf65ecd1 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" crypto "github.com/tendermint/go-crypto" - data "github.com/tendermint/go-wire/data" "github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/types" cmn "github.com/tendermint/tmlibs/common" @@ -281,7 +280,7 @@ func NewByzantinePrivValidator(pv types.PrivValidator) *ByzantinePrivValidator { } } -func (privVal *ByzantinePrivValidator) GetAddress() data.Bytes { +func (privVal *ByzantinePrivValidator) GetAddress() crypto.Address { return privVal.pv.GetAddress() } diff --git a/consensus/mempool_test.go b/consensus/mempool_test.go index 97bc050fa..d1714a741 100644 --- a/consensus/mempool_test.go +++ b/consensus/mempool_test.go @@ -129,7 +129,7 @@ func TestMempoolRmBadTx(t *testing.T) { assert.False(t, resDeliver.IsErr(), cmn.Fmt("expected no error. got %v", resDeliver)) resCommit := app.Commit() - assert.False(t, resCommit.IsErr(), cmn.Fmt("expected no error. got %v", resCommit)) + assert.True(t, len(resCommit.Data) > 0) emptyMempoolCh := make(chan struct{}) checkTxRespCh := make(chan struct{}) @@ -223,10 +223,10 @@ func txAsUint64(tx []byte) uint64 { func (app *CounterApplication) Commit() abci.ResponseCommit { app.mempoolTxCount = app.txCount if app.txCount == 0 { - return abci.ResponseCommit{Code: code.CodeTypeOK} + return abci.ResponseCommit{} } else { hash := make([]byte, 8) binary.BigEndian.PutUint64(hash, uint64(app.txCount)) - return abci.ResponseCommit{Code: code.CodeTypeOK, Data: hash} + return abci.ResponseCommit{Data: hash} } } diff --git a/consensus/replay.go b/consensus/replay.go index 881571077..ac7fcdec9 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -423,5 +423,5 @@ func (mock *mockProxyApp) EndBlock(req abci.RequestEndBlock) abci.ResponseEndBlo } func (mock *mockProxyApp) Commit() abci.ResponseCommit { - return abci.ResponseCommit{Code: abci.CodeTypeOK, Data: mock.appHash} + return abci.ResponseCommit{Data: mock.appHash} } diff --git a/evidence/store.go b/evidence/store.go index fd40b5338..7c8becd02 100644 --- a/evidence/store.go +++ b/evidence/store.go @@ -99,8 +99,8 @@ func (store *EvidenceStore) PendingEvidence() (evidence []types.Evidence) { // ListEvidence lists the evidence for the given prefix key. // It is wrapped by PriorityEvidence and PendingEvidence for convenience. func (store *EvidenceStore) ListEvidence(prefixKey string) (evidence []types.Evidence) { - iter := store.db.IteratorPrefix([]byte(prefixKey)) - for iter.Next() { + iter := dbm.IteratePrefix(store.db, []byte(prefixKey)) + for ; iter.Valid(); iter.Next() { val := iter.Value() var ei EvidenceInfo diff --git a/glide.lock b/glide.lock deleted file mode 100644 index f663a732f..000000000 --- a/glide.lock +++ /dev/null @@ -1,205 +0,0 @@ -hash: da486c9bf3e31f481a2b704f0602fe395001e03dbbab580ef13241aa452f1b37 -updated: 2018-02-03T03:00:02.112396533-05:00 -imports: -- name: github.com/btcsuite/btcd - version: 50de9da05b50eb15658bb350f6ea24368a111ab7 - subpackages: - - btcec -- name: github.com/ebuchman/fail-test - version: 95f809107225be108efcf10a3509e4ea6ceef3c4 -- name: github.com/fsnotify/fsnotify - version: c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9 -- name: github.com/go-kit/kit - version: 4dc7be5d2d12881735283bcab7352178e190fc71 - subpackages: - - log - - log/level - - log/term -- name: github.com/go-logfmt/logfmt - version: 390ab7935ee28ec6b286364bba9b4dd6410cb3d5 -- name: github.com/go-stack/stack - version: 259ab82a6cad3992b4e21ff5cac294ccb06474bc -- name: github.com/gogo/protobuf - version: 1adfc126b41513cc696b209667c8656ea7aac67c - subpackages: - - gogoproto - - jsonpb - - proto - - protoc-gen-gogo/descriptor - - sortkeys - - types -- name: github.com/golang/protobuf - version: bbd03ef6da3a115852eaf24c8a1c46aeb39aa175 - subpackages: - - proto - - ptypes - - ptypes/any - - ptypes/duration - - ptypes/timestamp -- name: github.com/golang/snappy - version: 553a641470496b2327abcac10b36396bd98e45c9 -- name: github.com/gorilla/websocket - version: ea4d1f681babbce9545c9c5f3d5194a789c89f5b -- name: github.com/hashicorp/hcl - version: 23c074d0eceb2b8a5bfdbb271ab780cde70f05a8 - subpackages: - - hcl/ast - - hcl/parser - - hcl/scanner - - hcl/strconv - - hcl/token - - json/parser - - json/scanner - - json/token -- name: github.com/inconshreveable/mousetrap - version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 -- name: github.com/jmhodges/levigo - version: c42d9e0ca023e2198120196f842701bb4c55d7b9 -- name: github.com/kr/logfmt - version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0 -- name: github.com/magiconair/properties - version: 49d762b9817ba1c2e9d0c69183c2b4a8b8f1d934 -- name: github.com/mitchellh/mapstructure - version: b4575eea38cca1123ec2dc90c26529b5c5acfcff -- name: github.com/pelletier/go-toml - version: acdc4509485b587f5e675510c4f2c63e90ff68a8 -- name: github.com/pkg/errors - version: 645ef00459ed84a119197bfb8d8205042c6df63d -- name: github.com/rcrowley/go-metrics - version: 8732c616f52954686704c8645fe1a9d59e9df7c1 -- name: github.com/spf13/afero - version: bb8f1927f2a9d3ab41c9340aa034f6b803f4359c - subpackages: - - mem -- name: github.com/spf13/cast - version: acbeb36b902d72a7a4c18e8f3241075e7ab763e4 -- name: github.com/spf13/cobra - version: 7b2c5ac9fc04fc5efafb60700713d4fa609b777b -- name: github.com/spf13/jwalterweatherman - version: 7c0cea34c8ece3fbeb2b27ab9b59511d360fb394 -- name: github.com/spf13/pflag - version: 4c012f6dcd9546820e378d0bdda4d8fc772cdfea -- name: github.com/spf13/viper - version: 25b30aa063fc18e48662b86996252eabdcf2f0c7 -- name: github.com/syndtr/goleveldb - version: 211f780988068502fe874c44dae530528ebd840f - subpackages: - - leveldb - - leveldb/cache - - leveldb/comparer - - leveldb/errors - - leveldb/filter - - leveldb/iterator - - leveldb/journal - - leveldb/memdb - - leveldb/opt - - leveldb/storage - - leveldb/table - - leveldb/util -- name: github.com/tendermint/abci - version: 5a4f56056e23cdfd5f3733db056968e016468508 - subpackages: - - client - - example/code - - example/counter - - example/dummy - - server - - types -- name: github.com/tendermint/ed25519 - version: d8387025d2b9d158cf4efb07e7ebf814bcce2057 - subpackages: - - edwards25519 - - extra25519 -- name: github.com/tendermint/go-crypto - version: dd20358a264c772b4a83e477b0cfce4c88a7001d -- name: github.com/tendermint/go-wire - version: b6fc872b42d41158a60307db4da051dd6f179415 - subpackages: - - data - - nowriter/tmlegacy -- name: github.com/tendermint/tmlibs - version: deaaf014d8b8d1095054380a38b1b00e293f725f - subpackages: - - autofile - - cli - - cli/flags - - clist - - common - - db - - flowrate - - log - - merkle - - pubsub - - pubsub/query - - test -- name: golang.org/x/crypto - version: 1875d0a70c90e57f11972aefd42276df65e895b9 - subpackages: - - curve25519 - - nacl/box - - nacl/secretbox - - openpgp/armor - - openpgp/errors - - poly1305 - - ripemd160 - - salsa20/salsa -- name: golang.org/x/net - version: 2fb46b16b8dda405028c50f7c7f0f9dd1fa6bfb1 - subpackages: - - context - - http2 - - http2/hpack - - idna - - internal/timeseries - - lex/httplex - - trace -- name: golang.org/x/sys - version: 37707fdb30a5b38865cfb95e5aab41707daec7fd - subpackages: - - unix -- name: golang.org/x/text - version: e19ae1496984b1c655b8044a65c0300a3c878dd3 - subpackages: - - secure/bidirule - - transform - - unicode/bidi - - unicode/norm -- name: google.golang.org/genproto - version: 4eb30f4778eed4c258ba66527a0d4f9ec8a36c45 - subpackages: - - googleapis/rpc/status -- name: google.golang.org/grpc - version: 401e0e00e4bb830a10496d64cd95e068c5bf50de - subpackages: - - balancer - - codes - - connectivity - - credentials - - grpclb/grpc_lb_v1/messages - - grpclog - - internal - - keepalive - - metadata - - naming - - peer - - resolver - - stats - - status - - tap - - transport -- name: gopkg.in/yaml.v2 - version: d670f9405373e636a5a2765eea47fac0c9bc91a4 -testImports: -- name: github.com/davecgh/go-spew - version: 87df7c60d5820d0f8ae11afede5aa52325c09717 - subpackages: - - spew -- name: github.com/pmezard/go-difflib - version: 792786c7400a136282c1664665ae0a8db921c6c2 - subpackages: - - difflib -- name: github.com/stretchr/testify - version: a726187e3128d0a0ec37f73ca7c4d3e508e6c2e5 - subpackages: - - assert - - require diff --git a/glide.yaml b/glide.yaml index 90b845e1c..c2726708f 100644 --- a/glide.yaml +++ b/glide.yaml @@ -24,9 +24,9 @@ import: - example/dummy - types - package: github.com/tendermint/go-crypto - version: ~0.4.1 + version: master - package: github.com/tendermint/go-wire - version: ~0.7.2 + version: master subpackages: - data - package: github.com/tendermint/tmlibs diff --git a/lite/proxy/query.go b/lite/proxy/query.go index ed4ad9136..06d7880a0 100644 --- a/lite/proxy/query.go +++ b/lite/proxy/query.go @@ -86,11 +86,16 @@ func GetWithProofOptions(path string, key []byte, opts rpcclient.ABCIQueryOption // https://github.com/tendermint/tendermint/issues/1183 if len(resp.Value) > 0 { // The key was found, construct a proof of existence. - eproof, err := iavl.ReadKeyExistsProof(resp.Proof) + proof, err := iavl.ReadKeyProof(resp.Proof) if err != nil { return nil, nil, errors.Wrap(err, "Error reading proof") } + eproof, ok := proof.(*iavl.KeyExistsProof) + if !ok { + return nil, nil, errors.New("Expected KeyExistsProof for non-empty value") + } + // Validate the proof against the certified header to ensure data integrity. err = eproof.Verify(resp.Key, resp.Value, commit.Header.AppHash) if err != nil { @@ -100,11 +105,16 @@ func GetWithProofOptions(path string, key []byte, opts rpcclient.ABCIQueryOption } // The key wasn't found, construct a proof of non-existence. - var aproof *iavl.KeyAbsentProof - aproof, err = iavl.ReadKeyAbsentProof(resp.Proof) + proof, err := iavl.ReadKeyProof(resp.Proof) if err != nil { return nil, nil, errors.Wrap(err, "Error reading proof") } + + aproof, ok := proof.(*iavl.KeyAbsentProof) + if !ok { + return nil, nil, errors.New("Expected KeyAbsentProof for empty Value") + } + // Validate the proof against the certified header to ensure data integrity. err = aproof.Verify(resp.Key, nil, commit.Header.AppHash) if err != nil { diff --git a/mempool/mempool_test.go b/mempool/mempool_test.go index 6dfb5984b..5b04e9493 100644 --- a/mempool/mempool_test.go +++ b/mempool/mempool_test.go @@ -185,7 +185,7 @@ func TestSerialReap(t *testing.T) { t.Errorf("Client error committing: %v", err) } if len(res.Data) != 8 { - t.Errorf("Error committing. Hash:%X log:%v", res.Data, res.Log) + t.Errorf("Error committing. Hash:%X", res.Data) } } diff --git a/node/node.go b/node/node.go index b02012f98..cd1248f49 100644 --- a/node/node.go +++ b/node/node.go @@ -274,7 +274,7 @@ func NewNode(config *cfg.Config, return err } if resQuery.IsErr() { - return resQuery + return fmt.Errorf("Error querying abci app: %v", resQuery) } return nil }) @@ -284,7 +284,7 @@ func NewNode(config *cfg.Config, return err } if resQuery.IsErr() { - return resQuery + return fmt.Errorf("Error querying abci app: %v", resQuery) } return nil }) diff --git a/state/execution.go b/state/execution.go index 8104c58b8..8d54840a6 100644 --- a/state/execution.go +++ b/state/execution.go @@ -141,13 +141,7 @@ func (blockExec *BlockExecutor) Commit(block *types.Block) ([]byte, error) { blockExec.logger.Error("Client error during proxyAppConn.CommitSync", "err", err) return nil, err } - if res.IsErr() { - blockExec.logger.Error("Error in proxyAppConn.CommitSync", "err", res) - return nil, res - } - if res.Log != "" { - blockExec.logger.Debug("Commit.Log: " + res.Log) - } + // ResponseCommit has no error code - just data blockExec.logger.Info("Committed state", "height", block.Height, "txs", block.NumTxs, "appHash", res.Data) @@ -198,10 +192,11 @@ func execBlockOnProxyApp(logger log.Logger, proxyAppConn proxy.AppConnConsensus, } } - byzantineVals := make([]*abci.Evidence, len(block.Evidence.Evidence)) + // TODO: determine which validators were byzantine + byzantineVals := make([]abci.Evidence, len(block.Evidence.Evidence)) for i, ev := range block.Evidence.Evidence { - byzantineVals[i] = &abci.Evidence{ - PubKey: ev.Address(), // XXX/TODO + byzantineVals[i] = abci.Evidence{ + PubKey: ev.Address(), // XXX Height: ev.Height(), } } @@ -243,7 +238,7 @@ func execBlockOnProxyApp(logger log.Logger, proxyAppConn proxy.AppConnConsensus, return abciResponses, nil } -func updateValidators(currentSet *types.ValidatorSet, updates []*abci.Validator) error { +func updateValidators(currentSet *types.ValidatorSet, updates []abci.Validator) error { // If more or equal than 1/3 of total voting power changed in one block, then // a light client could never prove the transition externally. See // ./lite/doc.go for details on how a light client tracks validators. @@ -293,7 +288,7 @@ func updateValidators(currentSet *types.ValidatorSet, updates []*abci.Validator) return nil } -func changeInVotingPowerMoreOrEqualToOneThird(currentSet *types.ValidatorSet, updates []*abci.Validator) (bool, error) { +func changeInVotingPowerMoreOrEqualToOneThird(currentSet *types.ValidatorSet, updates []abci.Validator) (bool, error) { threshold := currentSet.TotalVotingPower() * 1 / 3 acc := int64(0) @@ -424,12 +419,6 @@ func ExecCommitBlock(appConnConsensus proxy.AppConnConsensus, block *types.Block logger.Error("Client error during proxyAppConn.CommitSync", "err", res) return nil, err } - if res.IsErr() { - logger.Error("Error in proxyAppConn.CommitSync", "err", res) - return nil, res - } - if res.Log != "" { - logger.Info("Commit.Log: " + res.Log) - } + // ResponseCommit has no error or log, just data return res.Data, nil } diff --git a/state/execution_test.go b/state/execution_test.go index ffb10f17b..25d88fe41 100644 --- a/state/execution_test.go +++ b/state/execution_test.go @@ -12,6 +12,7 @@ import ( crypto "github.com/tendermint/go-crypto" "github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/types" + cmn "github.com/tendermint/tmlibs/common" dbm "github.com/tendermint/tmlibs/db" "github.com/tendermint/tmlibs/log" ) @@ -105,11 +106,11 @@ func TestBeginBlockByzantineValidators(t *testing.T) { testCases := []struct { desc string evidence []types.Evidence - expectedByzantineValidators []*abci.Evidence + expectedByzantineValidators []abci.Evidence }{ - {"none byzantine", []types.Evidence{}, []*abci.Evidence{}}, - {"one byzantine", []types.Evidence{ev1}, []*abci.Evidence{{ev1.Address(), ev1.Height()}}}, - {"multiple byzantine", []types.Evidence{ev1, ev2}, []*abci.Evidence{ + {"none byzantine", []types.Evidence{}, []abci.Evidence{}}, + {"one byzantine", []types.Evidence{ev1}, []abci.Evidence{{ev1.Address(), ev1.Height()}}}, + {"multiple byzantine", []types.Evidence{ev1, ev2}, []abci.Evidence{ {ev1.Address(), ev1.Height()}, {ev2.Address(), ev2.Height()}}}, } @@ -161,7 +162,7 @@ type testApp struct { abci.BaseApplication AbsentValidators []int32 - ByzantineValidators []*abci.Evidence + ByzantineValidators []abci.Evidence } func NewDummyApplication() *testApp { @@ -179,7 +180,7 @@ func (app *testApp) BeginBlock(req abci.RequestBeginBlock) abci.ResponseBeginBlo } func (app *testApp) DeliverTx(tx []byte) abci.ResponseDeliverTx { - return abci.ResponseDeliverTx{Tags: []*abci.KVPair{}} + return abci.ResponseDeliverTx{Tags: []cmn.KVPair{}} } func (app *testApp) CheckTx(tx []byte) abci.ResponseCheckTx { diff --git a/state/state_test.go b/state/state_test.go index 61b3167b3..ff17eac9c 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -77,9 +77,9 @@ func TestABCIResponsesSaveLoad1(t *testing.T) { // build mock responses block := makeBlock(state, 2) abciResponses := NewABCIResponses(block) - abciResponses.DeliverTx[0] = &abci.ResponseDeliverTx{Data: []byte("foo"), Tags: []*abci.KVPair{}} - abciResponses.DeliverTx[1] = &abci.ResponseDeliverTx{Data: []byte("bar"), Log: "ok", Tags: []*abci.KVPair{}} - abciResponses.EndBlock = &abci.ResponseEndBlock{ValidatorUpdates: []*abci.Validator{ + abciResponses.DeliverTx[0] = &abci.ResponseDeliverTx{Data: []byte("foo"), Tags: []cmn.KVPair{}} + abciResponses.DeliverTx[1] = &abci.ResponseDeliverTx{Data: []byte("bar"), Log: "ok", Tags: []cmn.KVPair{}} + abciResponses.EndBlock = &abci.ResponseEndBlock{ValidatorUpdates: []abci.Validator{ { PubKey: crypto.GenPrivKeyEd25519().PubKey().Bytes(), Power: 10, @@ -122,9 +122,9 @@ func TestABCIResponsesSaveLoad2(t *testing.T) { []*abci.ResponseDeliverTx{ {Code: 383}, {Data: []byte("Gotcha!"), - Tags: []*abci.KVPair{ - abci.KVPairInt("a", 1), - abci.KVPairString("build", "stuff"), + Tags: []cmn.KVPair{ + cmn.KVPair{[]byte("a"), []byte{1}}, + cmn.KVPair{[]byte("build"), []byte("stuff")}, }}, }, types.ABCIResults{ @@ -378,44 +378,44 @@ func TestLessThanOneThirdOfVotingPowerPerBlockEnforced(t *testing.T) { testCases := []struct { initialValSetSize int shouldErr bool - valUpdatesFn func(vals *types.ValidatorSet) []*abci.Validator + valUpdatesFn func(vals *types.ValidatorSet) []abci.Validator }{ ///////////// 1 val (vp: 10) => less than 3 is ok //////////////////////// // adding 1 validator => 10 - 0: {1, false, func(vals *types.ValidatorSet) []*abci.Validator { - return []*abci.Validator{ + 0: {1, false, func(vals *types.ValidatorSet) []abci.Validator { + return []abci.Validator{ {PubKey: pk(), Power: 2}, } }}, - 1: {1, true, func(vals *types.ValidatorSet) []*abci.Validator { - return []*abci.Validator{ + 1: {1, true, func(vals *types.ValidatorSet) []abci.Validator { + return []abci.Validator{ {PubKey: pk(), Power: 3}, } }}, - 2: {1, true, func(vals *types.ValidatorSet) []*abci.Validator { - return []*abci.Validator{ + 2: {1, true, func(vals *types.ValidatorSet) []abci.Validator { + return []abci.Validator{ {PubKey: pk(), Power: 100}, } }}, ///////////// 3 val (vp: 30) => less than 10 is ok //////////////////////// // adding and removing validator => 20 - 3: {3, true, func(vals *types.ValidatorSet) []*abci.Validator { + 3: {3, true, func(vals *types.ValidatorSet) []abci.Validator { _, firstVal := vals.GetByIndex(0) - return []*abci.Validator{ + return []abci.Validator{ {PubKey: firstVal.PubKey.Bytes(), Power: 0}, {PubKey: pk(), Power: 10}, } }}, // adding 1 validator => 10 - 4: {3, true, func(vals *types.ValidatorSet) []*abci.Validator { - return []*abci.Validator{ + 4: {3, true, func(vals *types.ValidatorSet) []abci.Validator { + return []abci.Validator{ {PubKey: pk(), Power: 10}, } }}, // adding 2 validators => 8 - 5: {3, false, func(vals *types.ValidatorSet) []*abci.Validator { - return []*abci.Validator{ + 5: {3, false, func(vals *types.ValidatorSet) []abci.Validator { + return []abci.Validator{ {PubKey: pk(), Power: 4}, {PubKey: pk(), Power: 4}, } @@ -450,20 +450,20 @@ func TestApplyUpdates(t *testing.T) { cases := [...]struct { init types.ConsensusParams - updates *abci.ConsensusParams + updates abci.ConsensusParams expected types.ConsensusParams }{ - 0: {initParams, nil, initParams}, - 1: {initParams, &abci.ConsensusParams{}, initParams}, + 0: {initParams, abci.ConsensusParams{}, initParams}, + 1: {initParams, abci.ConsensusParams{}, initParams}, 2: {initParams, - &abci.ConsensusParams{ + abci.ConsensusParams{ TxSize: &abci.TxSize{ MaxBytes: 123, }, }, makeParams(1, 2, 3, 123, 5, 6)}, 3: {initParams, - &abci.ConsensusParams{ + abci.ConsensusParams{ BlockSize: &abci.BlockSize{ MaxTxs: 44, MaxGas: 55, @@ -471,7 +471,7 @@ func TestApplyUpdates(t *testing.T) { }, makeParams(1, 44, 55, 4, 5, 6)}, 4: {initParams, - &abci.ConsensusParams{ + abci.ConsensusParams{ BlockSize: &abci.BlockSize{ MaxTxs: 789, }, @@ -486,7 +486,7 @@ func TestApplyUpdates(t *testing.T) { } for i, tc := range cases { - res := tc.init.Update(tc.updates) + res := tc.init.Update(&(tc.updates)) assert.Equal(t, tc.expected, res, "case %d", i) } } @@ -496,14 +496,14 @@ func makeHeaderPartsResponsesValPubKeyChange(state State, height int64, block := makeBlock(state, height) abciResponses := &ABCIResponses{ - EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: []*abci.Validator{}}, + EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: []abci.Validator{}}, } // if the pubkey is new, remove the old and add the new _, val := state.Validators.GetByIndex(0) if !bytes.Equal(pubkey.Bytes(), val.PubKey.Bytes()) { abciResponses.EndBlock = &abci.ResponseEndBlock{ - ValidatorUpdates: []*abci.Validator{ + ValidatorUpdates: []abci.Validator{ {val.PubKey.Bytes(), 0}, {pubkey.Bytes(), 10}, }, @@ -518,14 +518,14 @@ func makeHeaderPartsResponsesValPowerChange(state State, height int64, block := makeBlock(state, height) abciResponses := &ABCIResponses{ - EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: []*abci.Validator{}}, + EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: []abci.Validator{}}, } // if the pubkey is new, remove the old and add the new _, val := state.Validators.GetByIndex(0) if val.VotingPower != power { abciResponses.EndBlock = &abci.ResponseEndBlock{ - ValidatorUpdates: []*abci.Validator{ + ValidatorUpdates: []abci.Validator{ {val.PubKey.Bytes(), power}, }, } diff --git a/state/txindex/kv/kv.go b/state/txindex/kv/kv.go index b70f3699f..90e64043a 100644 --- a/state/txindex/kv/kv.go +++ b/state/txindex/kv/kv.go @@ -10,13 +10,13 @@ import ( "github.com/pkg/errors" - abci "github.com/tendermint/abci/types" wire "github.com/tendermint/go-wire" + cmn "github.com/tendermint/tmlibs/common" + dbm "github.com/tendermint/tmlibs/db" + "github.com/tendermint/tmlibs/pubsub/query" + "github.com/tendermint/tendermint/state/txindex" "github.com/tendermint/tendermint/types" - cmn "github.com/tendermint/tmlibs/common" - db "github.com/tendermint/tmlibs/db" - "github.com/tendermint/tmlibs/pubsub/query" ) const ( @@ -27,13 +27,13 @@ var _ txindex.TxIndexer = (*TxIndex)(nil) // TxIndex is the simplest possible indexer, backed by key-value storage (levelDB). type TxIndex struct { - store db.DB + store dbm.DB tagsToIndex []string indexAllTags bool } // NewTxIndex creates new KV indexer. -func NewTxIndex(store db.DB, options ...func(*TxIndex)) *TxIndex { +func NewTxIndex(store dbm.DB, options ...func(*TxIndex)) *TxIndex { txi := &TxIndex{store: store, tagsToIndex: make([]string, 0), indexAllTags: false} for _, o := range options { o(txi) @@ -87,7 +87,7 @@ func (txi *TxIndex) AddBatch(b *txindex.Batch) error { // index tx by tags for _, tag := range result.Result.Tags { - if txi.indexAllTags || cmn.StringInSlice(tag.Key, txi.tagsToIndex) { + if txi.indexAllTags || cmn.StringInSlice(string(tag.Key), txi.tagsToIndex) { storeBatch.Set(keyForTag(tag, result), hash) } } @@ -109,7 +109,7 @@ func (txi *TxIndex) Index(result *types.TxResult) error { // index tx by tags for _, tag := range result.Result.Tags { - if txi.indexAllTags || cmn.StringInSlice(tag.Key, txi.tagsToIndex) { + if txi.indexAllTags || cmn.StringInSlice(string(tag.Key), txi.tagsToIndex) { b.Set(keyForTag(tag, result), hash) } } @@ -270,18 +270,18 @@ func isRangeOperation(op query.Operator) bool { func (txi *TxIndex) match(c query.Condition, startKey []byte) (hashes [][]byte) { if c.Op == query.OpEqual { - it := txi.store.IteratorPrefix(startKey) - defer it.Release() - for it.Next() { + it := dbm.IteratePrefix(txi.store, startKey) + defer it.Close() + for ; it.Valid(); it.Next() { hashes = append(hashes, it.Value()) } } else if c.Op == query.OpContains { // XXX: doing full scan because startKey does not apply here // For example, if startKey = "account.owner=an" and search query = "accoutn.owner CONSISTS an" // we can't iterate with prefix "account.owner=an" because we might miss keys like "account.owner=Ulan" - it := txi.store.Iterator() - defer it.Release() - for it.Next() { + it := txi.store.Iterator(nil, nil) + defer it.Close() + for ; it.Valid(); it.Next() { if !isTagKey(it.Key()) { continue } @@ -296,10 +296,10 @@ func (txi *TxIndex) match(c query.Condition, startKey []byte) (hashes [][]byte) } func (txi *TxIndex) matchRange(r queryRange, startKey []byte) (hashes [][]byte) { - it := txi.store.IteratorPrefix(startKey) - defer it.Release() + it := dbm.IteratePrefix(txi.store, startKey) + defer it.Close() LOOP: - for it.Next() { + for ; it.Valid(); it.Next() { if !isTagKey(it.Key()) { continue } @@ -376,17 +376,8 @@ func extractValueFromKey(key []byte) string { return parts[1] } -func keyForTag(tag *abci.KVPair, result *types.TxResult) []byte { - switch tag.ValueType { - case abci.KVPair_STRING: - return []byte(fmt.Sprintf("%s/%v/%d/%d", tag.Key, tag.ValueString, result.Height, result.Index)) - case abci.KVPair_INT: - return []byte(fmt.Sprintf("%s/%v/%d/%d", tag.Key, tag.ValueInt, result.Height, result.Index)) - // case abci.KVPair_TIME: - // return []byte(fmt.Sprintf("%s/%d/%d/%d", tag.Key, tag.ValueTime.Unix(), result.Height, result.Index)) - default: - panic(fmt.Sprintf("Undefined value type: %v", tag.ValueType)) - } +func keyForTag(tag cmn.KVPair, result *types.TxResult) []byte { + return []byte(fmt.Sprintf("%s/%d/%d", tag.Key, result.Height, result.Index)) } /////////////////////////////////////////////////////////////////////////////// diff --git a/state/txindex/kv/kv_test.go b/state/txindex/kv/kv_test.go index 0eac17607..4fdb71a04 100644 --- a/state/txindex/kv/kv_test.go +++ b/state/txindex/kv/kv_test.go @@ -11,6 +11,7 @@ import ( abci "github.com/tendermint/abci/types" "github.com/tendermint/tendermint/state/txindex" "github.com/tendermint/tendermint/types" + cmn "github.com/tendermint/tmlibs/common" db "github.com/tendermint/tmlibs/db" "github.com/tendermint/tmlibs/pubsub/query" ) @@ -19,7 +20,7 @@ func TestTxIndex(t *testing.T) { indexer := NewTxIndex(db.NewMemDB()) tx := types.Tx("HELLO WORLD") - txResult := &types.TxResult{1, 0, tx, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: []*abci.KVPair{}}} + txResult := &types.TxResult{1, 0, tx, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: []cmn.KVPair{}}} hash := tx.Hash() batch := txindex.NewBatch(1) @@ -34,7 +35,7 @@ func TestTxIndex(t *testing.T) { assert.Equal(t, txResult, loadedTxResult) tx2 := types.Tx("BYE BYE WORLD") - txResult2 := &types.TxResult{1, 0, tx2, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: []*abci.KVPair{}}} + txResult2 := &types.TxResult{1, 0, tx2, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: []cmn.KVPair{}}} hash2 := tx2.Hash() err = indexer.Index(txResult2) @@ -49,10 +50,10 @@ func TestTxSearch(t *testing.T) { allowedTags := []string{"account.number", "account.owner", "account.date"} indexer := NewTxIndex(db.NewMemDB(), IndexTags(allowedTags)) - txResult := txResultWithTags([]*abci.KVPair{ - {Key: "account.number", ValueType: abci.KVPair_INT, ValueInt: 1}, - {Key: "account.owner", ValueType: abci.KVPair_STRING, ValueString: "Ivan"}, - {Key: "not_allowed", ValueType: abci.KVPair_STRING, ValueString: "Vlad"}, + txResult := txResultWithTags([]cmn.KVPair{ + {Key: []byte("account.number"), Value: []byte{1}}, + {Key: []byte("account.owner"), Value: []byte("Ivan")}, + {Key: []byte("not_allowed"), Value: []byte("Vlad")}, }) hash := txResult.Tx.Hash() @@ -106,9 +107,9 @@ func TestTxSearchOneTxWithMultipleSameTagsButDifferentValues(t *testing.T) { allowedTags := []string{"account.number"} indexer := NewTxIndex(db.NewMemDB(), IndexTags(allowedTags)) - txResult := txResultWithTags([]*abci.KVPair{ - {Key: "account.number", ValueType: abci.KVPair_INT, ValueInt: 1}, - {Key: "account.number", ValueType: abci.KVPair_INT, ValueInt: 2}, + txResult := txResultWithTags([]cmn.KVPair{ + {Key: []byte("account.number"), Value: []byte{1}}, + {Key: []byte("account.number"), Value: []byte{2}}, }) err := indexer.Index(txResult) @@ -124,9 +125,9 @@ func TestTxSearchOneTxWithMultipleSameTagsButDifferentValues(t *testing.T) { func TestIndexAllTags(t *testing.T) { indexer := NewTxIndex(db.NewMemDB(), IndexAllTags()) - txResult := txResultWithTags([]*abci.KVPair{ - abci.KVPairString("account.owner", "Ivan"), - abci.KVPairInt("account.number", 1), + txResult := txResultWithTags([]cmn.KVPair{ + cmn.KVPair{[]byte("account.owner"), []byte("Ivan")}, + cmn.KVPair{[]byte("account.number"), []byte{1}}, }) err := indexer.Index(txResult) @@ -143,14 +144,14 @@ func TestIndexAllTags(t *testing.T) { assert.Equal(t, []*types.TxResult{txResult}, results) } -func txResultWithTags(tags []*abci.KVPair) *types.TxResult { +func txResultWithTags(tags []cmn.KVPair) *types.TxResult { tx := types.Tx("HELLO WORLD") return &types.TxResult{1, 0, tx, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: tags}} } func benchmarkTxIndex(txsCount int, b *testing.B) { tx := types.Tx("HELLO WORLD") - txResult := &types.TxResult{1, 0, tx, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: []*abci.KVPair{}}} + txResult := &types.TxResult{1, 0, tx, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: []cmn.KVPair{}}} dir, err := ioutil.TempDir("", "tx_index_db") if err != nil { diff --git a/types/canonical_json.go b/types/canonical_json.go index 41c67c24b..d3b7cf2fb 100644 --- a/types/canonical_json.go +++ b/types/canonical_json.go @@ -40,11 +40,11 @@ type CanonicalJSONVote struct { } type CanonicalJSONHeartbeat struct { - Height int64 `json:"height"` - Round int `json:"round"` - Sequence int `json:"sequence"` - ValidatorAddress data.Bytes `json:"validator_address"` - ValidatorIndex int `json:"validator_index"` + Height int64 `json:"height"` + Round int `json:"round"` + Sequence int `json:"sequence"` + ValidatorAddress Address `json:"validator_address"` + ValidatorIndex int `json:"validator_index"` } //------------------------------------ diff --git a/types/heartbeat.go b/types/heartbeat.go index da9b342b4..a4ff0d217 100644 --- a/types/heartbeat.go +++ b/types/heartbeat.go @@ -6,7 +6,6 @@ import ( "github.com/tendermint/go-crypto" "github.com/tendermint/go-wire" - "github.com/tendermint/go-wire/data" cmn "github.com/tendermint/tmlibs/common" ) @@ -16,7 +15,7 @@ import ( // json field tags because we always want the JSON // representation to be in its canonical form. type Heartbeat struct { - ValidatorAddress data.Bytes `json:"validator_address"` + ValidatorAddress Address `json:"validator_address"` ValidatorIndex int `json:"validator_index"` Height int64 `json:"height"` Round int `json:"round"` diff --git a/types/priv_validator.go b/types/priv_validator.go index 628f58cfc..020fbc43c 100644 --- a/types/priv_validator.go +++ b/types/priv_validator.go @@ -38,7 +38,7 @@ func voteToStep(vote *Vote) int8 { // PrivValidator defines the functionality of a local Tendermint validator // that signs votes, proposals, and heartbeats, and never double signs. type PrivValidator interface { - GetAddress() data.Bytes // redundant since .PubKey().Address() + GetAddress() Address // redundant since .PubKey().Address() GetPubKey() crypto.PubKey SignVote(chainID string, vote *Vote) error @@ -50,7 +50,7 @@ type PrivValidator interface { // to prevent double signing. The Signer itself can be mutated to use // something besides the default, for instance a hardware signer. type PrivValidatorFS struct { - Address data.Bytes `json:"address"` + Address Address `json:"address"` PubKey crypto.PubKey `json:"pub_key"` LastHeight int64 `json:"last_height"` LastRound int `json:"last_round"` @@ -96,7 +96,7 @@ func (ds *DefaultSigner) Sign(msg []byte) (crypto.Signature, error) { // GetAddress returns the address of the validator. // Implements PrivValidator. -func (pv *PrivValidatorFS) GetAddress() data.Bytes { +func (pv *PrivValidatorFS) GetAddress() Address { return pv.Address } diff --git a/types/priv_validator_test.go b/types/priv_validator_test.go index dd0ebff71..08b58273a 100644 --- a/types/priv_validator_test.go +++ b/types/priv_validator_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" crypto "github.com/tendermint/go-crypto" - "github.com/tendermint/go-wire/data" cmn "github.com/tendermint/tmlibs/common" ) @@ -225,7 +224,7 @@ func TestDifferByTimestamp(t *testing.T) { } } -func newVote(addr data.Bytes, idx int, height int64, round int, typ byte, blockID BlockID) *Vote { +func newVote(addr Address, idx int, height int64, round int, typ byte, blockID BlockID) *Vote { return &Vote{ ValidatorAddress: addr, ValidatorIndex: idx, diff --git a/types/protobuf.go b/types/protobuf.go index bac5b799e..e7ae20e39 100644 --- a/types/protobuf.go +++ b/types/protobuf.go @@ -10,8 +10,8 @@ var TM2PB = tm2pb{} type tm2pb struct{} -func (tm2pb) Header(header *Header) *types.Header { - return &types.Header{ +func (tm2pb) Header(header *Header) types.Header { + return types.Header{ ChainID: header.ChainID, Height: header.Height, Time: header.Time.Unix(), @@ -37,15 +37,15 @@ func (tm2pb) PartSetHeader(partSetHeader PartSetHeader) types.PartSetHeader { } } -func (tm2pb) Validator(val *Validator) *types.Validator { - return &types.Validator{ +func (tm2pb) Validator(val *Validator) types.Validator { + return types.Validator{ PubKey: val.PubKey.Bytes(), Power: val.VotingPower, } } -func (tm2pb) Validators(vals *ValidatorSet) []*types.Validator { - validators := make([]*types.Validator, len(vals.Validators)) +func (tm2pb) Validators(vals *ValidatorSet) []types.Validator { + validators := make([]types.Validator, len(vals.Validators)) for i, val := range vals.Validators { validators[i] = TM2PB.Validator(val) } diff --git a/types/validator.go b/types/validator.go index c5d064e01..dfe575515 100644 --- a/types/validator.go +++ b/types/validator.go @@ -7,7 +7,6 @@ import ( "github.com/tendermint/go-crypto" "github.com/tendermint/go-wire" - "github.com/tendermint/go-wire/data" cmn "github.com/tendermint/tmlibs/common" ) @@ -15,9 +14,9 @@ import ( // NOTE: The Accum is not included in Validator.Hash(); // make sure to update that method if changes are made here type Validator struct { - Address data.Bytes `json:"address"` - PubKey crypto.PubKey `json:"pub_key"` - VotingPower int64 `json:"voting_power"` + Address Address `json:"address"` + PubKey crypto.PubKey `json:"pub_key"` + VotingPower int64 `json:"voting_power"` Accum int64 `json:"accum"` } @@ -74,7 +73,7 @@ func (v *Validator) String() string { // It excludes the Accum value, which changes with every round. func (v *Validator) Hash() []byte { return wire.BinaryRipemd160(struct { - Address data.Bytes + Address Address PubKey crypto.PubKey VotingPower int64 }{ diff --git a/types/vote.go b/types/vote.go index 4397152c7..7b069f2f6 100644 --- a/types/vote.go +++ b/types/vote.go @@ -9,7 +9,6 @@ import ( "github.com/tendermint/go-crypto" "github.com/tendermint/go-wire" - "github.com/tendermint/go-wire/data" cmn "github.com/tendermint/tmlibs/common" ) @@ -59,9 +58,12 @@ func IsVoteTypeValid(type_ byte) bool { } } +// Address is hex bytes. TODO: crypto.Address +type Address = cmn.HexBytes + // Represents a prevote, precommit, or commit vote from validators for consensus. type Vote struct { - ValidatorAddress data.Bytes `json:"validator_address"` + ValidatorAddress Address `json:"validator_address"` ValidatorIndex int `json:"validator_index"` Height int64 `json:"height"` Round int `json:"round"` From 426379dc47b8d179583f97305c21b4731dbefe04 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 3 Feb 2018 03:39:14 -0500 Subject: [PATCH 05/10] remove use of wire/nowriter --- p2p/conn/connection.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/p2p/conn/connection.go b/p2p/conn/connection.go index 83d87e58f..451f35bbe 100644 --- a/p2p/conn/connection.go +++ b/p2p/conn/connection.go @@ -11,14 +11,11 @@ import ( "time" wire "github.com/tendermint/go-wire" - tmlegacy "github.com/tendermint/go-wire/nowriter/tmlegacy" cmn "github.com/tendermint/tmlibs/common" flow "github.com/tendermint/tmlibs/flowrate" "github.com/tendermint/tmlibs/log" ) -var legacy = tmlegacy.TMEncoderLegacy{} - const ( numBatchMsgPackets = 10 minReadBufferSize = 1024 @@ -316,12 +313,12 @@ FOR_LOOP: } case <-c.pingTimer.Chan(): c.Logger.Debug("Send Ping") - legacy.WriteOctet(packetTypePing, c.bufWriter, &n, &err) + wire.WriteByte(packetTypePing, c.bufWriter, &n, &err) c.sendMonitor.Update(int(n)) c.flush() case <-c.pong: c.Logger.Debug("Send Pong") - legacy.WriteOctet(packetTypePong, c.bufWriter, &n, &err) + wire.WriteByte(packetTypePong, c.bufWriter, &n, &err) c.sendMonitor.Update(int(n)) c.flush() case <-c.quit: @@ -681,7 +678,7 @@ func (ch *Channel) writeMsgPacketTo(w io.Writer) (n int, err error) { } func writeMsgPacketTo(packet msgPacket, w io.Writer, n *int, err *error) { - legacy.WriteOctet(packetTypeMsg, w, n, err) + wire.WriteByte(packetTypeMsg, w, n, err) wire.WriteBinary(packet, w, n, err) } From 7a5060dc520e1b014570bd15e3f15c4f6f3f8d66 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 3 Feb 2018 03:42:59 -0500 Subject: [PATCH 06/10] replace data.Bytes with cmn.HexBytes --- lite/proxy/query.go | 4 +--- lite/proxy/wrapper.go | 6 ++---- rpc/client/httpclient.go | 5 ++--- rpc/client/interface.go | 5 ++--- rpc/client/localclient.go | 6 +++--- rpc/client/mock/abci.go | 16 ++++++++-------- rpc/client/mock/abci_test.go | 10 +++++----- rpc/client/mock/client.go | 5 ++--- rpc/client/mock/status_test.go | 6 +++--- rpc/core/abci.go | 4 ++-- rpc/core/mempool.go | 4 ++-- rpc/core/status.go | 6 +++--- rpc/core/types/responses.go | 15 +++++++-------- rpc/lib/rpc_test.go | 9 ++++----- rpc/lib/server/parse_test.go | 20 ++++++++++---------- types/block.go | 33 ++++++++++++++++----------------- types/canonical_json.go | 8 ++++---- types/genesis.go | 3 +-- types/part_set.go | 7 +++---- types/priv_validator.go | 5 ++--- types/results.go | 6 +++--- types/tx.go | 4 ++-- 22 files changed, 87 insertions(+), 100 deletions(-) diff --git a/lite/proxy/query.go b/lite/proxy/query.go index 06d7880a0..1da2a0cce 100644 --- a/lite/proxy/query.go +++ b/lite/proxy/query.go @@ -3,8 +3,6 @@ package proxy import ( "github.com/pkg/errors" - "github.com/tendermint/go-wire/data" - "github.com/tendermint/tendermint/lite" "github.com/tendermint/tendermint/lite/client" certerr "github.com/tendermint/tendermint/lite/errors" @@ -34,7 +32,7 @@ type KeyProof interface { // If val is empty, proof should be KeyMissingProof func GetWithProof(key []byte, reqHeight int64, node rpcclient.Client, cert lite.Certifier) ( - val data.Bytes, height int64, proof KeyProof, err error) { + val cmn.HexBytes, height int64, proof KeyProof, err error) { if reqHeight < 0 { err = errors.Errorf("Height cannot be negative") diff --git a/lite/proxy/wrapper.go b/lite/proxy/wrapper.go index 7d504217d..02f2f318b 100644 --- a/lite/proxy/wrapper.go +++ b/lite/proxy/wrapper.go @@ -1,8 +1,6 @@ package proxy import ( - "github.com/tendermint/go-wire/data" - "github.com/tendermint/tendermint/lite" certclient "github.com/tendermint/tendermint/lite/client" rpcclient "github.com/tendermint/tendermint/rpc/client" @@ -34,7 +32,7 @@ func SecureClient(c rpcclient.Client, cert *lite.InquiringCertifier) Wrapper { } // ABCIQueryWithOptions exposes all options for the ABCI query and verifies the returned proof -func (w Wrapper) ABCIQueryWithOptions(path string, data data.Bytes, +func (w Wrapper) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts rpcclient.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { res, _, err := GetWithProofOptions(path, data, opts, w.Client, w.cert) @@ -42,7 +40,7 @@ func (w Wrapper) ABCIQueryWithOptions(path string, data data.Bytes, } // ABCIQuery uses default options for the ABCI query and verifies the returned proof -func (w Wrapper) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) { +func (w Wrapper) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) { return w.ABCIQueryWithOptions(path, data, rpcclient.DefaultABCIQueryOptions) } diff --git a/rpc/client/httpclient.go b/rpc/client/httpclient.go index 838fa5249..2b3f5ab28 100644 --- a/rpc/client/httpclient.go +++ b/rpc/client/httpclient.go @@ -7,7 +7,6 @@ import ( "github.com/pkg/errors" - data "github.com/tendermint/go-wire/data" ctypes "github.com/tendermint/tendermint/rpc/core/types" rpcclient "github.com/tendermint/tendermint/rpc/lib/client" "github.com/tendermint/tendermint/types" @@ -64,11 +63,11 @@ func (c *HTTP) ABCIInfo() (*ctypes.ResultABCIInfo, error) { return result, nil } -func (c *HTTP) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) { +func (c *HTTP) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) { return c.ABCIQueryWithOptions(path, data, DefaultABCIQueryOptions) } -func (c *HTTP) ABCIQueryWithOptions(path string, data data.Bytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { +func (c *HTTP) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { result := new(ctypes.ResultABCIQuery) _, err := c.rpc.Call("abci_query", map[string]interface{}{"path": path, "data": data, "height": opts.Height, "trusted": opts.Trusted}, diff --git a/rpc/client/interface.go b/rpc/client/interface.go index 6e798c379..6715b64b5 100644 --- a/rpc/client/interface.go +++ b/rpc/client/interface.go @@ -20,7 +20,6 @@ implementation. package client import ( - data "github.com/tendermint/go-wire/data" ctypes "github.com/tendermint/tendermint/rpc/core/types" "github.com/tendermint/tendermint/types" cmn "github.com/tendermint/tmlibs/common" @@ -32,8 +31,8 @@ import ( type ABCIClient interface { // reading from abci app ABCIInfo() (*ctypes.ResultABCIInfo, error) - ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) - ABCIQueryWithOptions(path string, data data.Bytes, + ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) + ABCIQueryWithOptions(path string, data cmn.HexBytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) // writing to abci app diff --git a/rpc/client/localclient.go b/rpc/client/localclient.go index 5e0573a1b..be989ee1c 100644 --- a/rpc/client/localclient.go +++ b/rpc/client/localclient.go @@ -3,11 +3,11 @@ package client import ( "context" - data "github.com/tendermint/go-wire/data" nm "github.com/tendermint/tendermint/node" "github.com/tendermint/tendermint/rpc/core" ctypes "github.com/tendermint/tendermint/rpc/core/types" "github.com/tendermint/tendermint/types" + cmn "github.com/tendermint/tmlibs/common" tmpubsub "github.com/tendermint/tmlibs/pubsub" ) @@ -56,11 +56,11 @@ func (Local) ABCIInfo() (*ctypes.ResultABCIInfo, error) { return core.ABCIInfo() } -func (c *Local) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) { +func (c *Local) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) { return c.ABCIQueryWithOptions(path, data, DefaultABCIQueryOptions) } -func (Local) ABCIQueryWithOptions(path string, data data.Bytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { +func (Local) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { return core.ABCIQuery(path, data, opts.Height, opts.Trusted) } diff --git a/rpc/client/mock/abci.go b/rpc/client/mock/abci.go index 4593d059a..7f4c45df3 100644 --- a/rpc/client/mock/abci.go +++ b/rpc/client/mock/abci.go @@ -2,11 +2,11 @@ package mock import ( abci "github.com/tendermint/abci/types" - data "github.com/tendermint/go-wire/data" "github.com/tendermint/tendermint/rpc/client" ctypes "github.com/tendermint/tendermint/rpc/core/types" "github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/version" + cmn "github.com/tendermint/tmlibs/common" ) // ABCIApp will send all abci related request to the named app, @@ -26,11 +26,11 @@ func (a ABCIApp) ABCIInfo() (*ctypes.ResultABCIInfo, error) { return &ctypes.ResultABCIInfo{a.App.Info(abci.RequestInfo{version.Version})}, nil } -func (a ABCIApp) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) { +func (a ABCIApp) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) { return a.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions) } -func (a ABCIApp) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { +func (a ABCIApp) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { q := a.App.Query(abci.RequestQuery{data, path, opts.Height, opts.Trusted}) return &ctypes.ResultABCIQuery{q}, nil } @@ -81,11 +81,11 @@ func (m ABCIMock) ABCIInfo() (*ctypes.ResultABCIInfo, error) { return &ctypes.ResultABCIInfo{res.(abci.ResponseInfo)}, nil } -func (m ABCIMock) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) { +func (m ABCIMock) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) { return m.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions) } -func (m ABCIMock) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { +func (m ABCIMock) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { res, err := m.Query.GetResponse(QueryArgs{path, data, opts.Height, opts.Trusted}) if err != nil { return nil, err @@ -134,7 +134,7 @@ func NewABCIRecorder(client client.ABCIClient) *ABCIRecorder { type QueryArgs struct { Path string - Data data.Bytes + Data cmn.HexBytes Height int64 Trusted bool } @@ -153,11 +153,11 @@ func (r *ABCIRecorder) ABCIInfo() (*ctypes.ResultABCIInfo, error) { return res, err } -func (r *ABCIRecorder) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) { +func (r *ABCIRecorder) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) { return r.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions) } -func (r *ABCIRecorder) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { +func (r *ABCIRecorder) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { res, err := r.Client.ABCIQueryWithOptions(path, data, opts) r.addCall(Call{ Name: "abci_query", diff --git a/rpc/client/mock/abci_test.go b/rpc/client/mock/abci_test.go index 0f83cc5f2..5a66c997a 100644 --- a/rpc/client/mock/abci_test.go +++ b/rpc/client/mock/abci_test.go @@ -11,11 +11,11 @@ import ( "github.com/tendermint/abci/example/dummy" abci "github.com/tendermint/abci/types" - data "github.com/tendermint/go-wire/data" "github.com/tendermint/tendermint/rpc/client" "github.com/tendermint/tendermint/rpc/client/mock" ctypes "github.com/tendermint/tendermint/rpc/core/types" "github.com/tendermint/tendermint/types" + cmn "github.com/tendermint/tmlibs/common" ) func TestABCIMock(t *testing.T) { @@ -37,8 +37,8 @@ func TestABCIMock(t *testing.T) { BroadcastCommit: mock.Call{ Args: goodTx, Response: &ctypes.ResultBroadcastTxCommit{ - CheckTx: abci.ResponseCheckTx{Data: data.Bytes("stand")}, - DeliverTx: abci.ResponseDeliverTx{Data: data.Bytes("deliver")}, + CheckTx: abci.ResponseCheckTx{Data: cmn.HexBytes("stand")}, + DeliverTx: abci.ResponseDeliverTx{Data: cmn.HexBytes("deliver")}, }, Error: errors.New("bad tx"), }, @@ -98,7 +98,7 @@ func TestABCIRecorder(t *testing.T) { _, err := r.ABCIInfo() assert.Nil(err, "expected no err on info") - _, err = r.ABCIQueryWithOptions("path", data.Bytes("data"), client.ABCIQueryOptions{Trusted: false}) + _, err = r.ABCIQueryWithOptions("path", cmn.HexBytes("data"), client.ABCIQueryOptions{Trusted: false}) assert.NotNil(err, "expected error on query") require.Equal(2, len(r.Calls)) @@ -174,7 +174,7 @@ func TestABCIApp(t *testing.T) { assert.True(res.DeliverTx.IsOK()) // check the key - _qres, err := m.ABCIQueryWithOptions("/key", data.Bytes(key), client.ABCIQueryOptions{Trusted: true}) + _qres, err := m.ABCIQueryWithOptions("/key", cmn.HexBytes(key), client.ABCIQueryOptions{Trusted: true}) qres := _qres.Response require.Nil(err) assert.EqualValues(value, qres.Value) diff --git a/rpc/client/mock/client.go b/rpc/client/mock/client.go index 6c4728986..6af9abb27 100644 --- a/rpc/client/mock/client.go +++ b/rpc/client/mock/client.go @@ -16,7 +16,6 @@ package mock import ( "reflect" - data "github.com/tendermint/go-wire/data" "github.com/tendermint/tendermint/rpc/client" "github.com/tendermint/tendermint/rpc/core" ctypes "github.com/tendermint/tendermint/rpc/core/types" @@ -83,11 +82,11 @@ func (c Client) ABCIInfo() (*ctypes.ResultABCIInfo, error) { return core.ABCIInfo() } -func (c Client) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) { +func (c Client) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) { return c.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions) } -func (c Client) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { +func (c Client) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { return core.ABCIQuery(path, data, opts.Height, opts.Trusted) } diff --git a/rpc/client/mock/status_test.go b/rpc/client/mock/status_test.go index 80ffe7b7d..b3827fb13 100644 --- a/rpc/client/mock/status_test.go +++ b/rpc/client/mock/status_test.go @@ -6,9 +6,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - data "github.com/tendermint/go-wire/data" "github.com/tendermint/tendermint/rpc/client/mock" ctypes "github.com/tendermint/tendermint/rpc/core/types" + cmn "github.com/tendermint/tmlibs/common" ) func TestStatus(t *testing.T) { @@ -17,8 +17,8 @@ func TestStatus(t *testing.T) { m := &mock.StatusMock{ Call: mock.Call{ Response: &ctypes.ResultStatus{ - LatestBlockHash: data.Bytes("block"), - LatestAppHash: data.Bytes("app"), + LatestBlockHash: cmn.HexBytes("block"), + LatestAppHash: cmn.HexBytes("app"), LatestBlockHeight: 10, }}, } diff --git a/rpc/core/abci.go b/rpc/core/abci.go index a49b52b6e..874becae3 100644 --- a/rpc/core/abci.go +++ b/rpc/core/abci.go @@ -2,9 +2,9 @@ package core import ( abci "github.com/tendermint/abci/types" - data "github.com/tendermint/go-wire/data" ctypes "github.com/tendermint/tendermint/rpc/core/types" "github.com/tendermint/tendermint/version" + cmn "github.com/tendermint/tmlibs/common" ) // Query the application for some information. @@ -47,7 +47,7 @@ import ( // | data | []byte | false | true | Data | // | height | int64 | 0 | false | Height (0 means latest) | // | trusted | bool | false | false | Does not include a proof of the data inclusion | -func ABCIQuery(path string, data data.Bytes, height int64, trusted bool) (*ctypes.ResultABCIQuery, error) { +func ABCIQuery(path string, data cmn.HexBytes, height int64, trusted bool) (*ctypes.ResultABCIQuery, error) { resQuery, err := proxyAppQuery.QuerySync(abci.RequestQuery{ Path: path, Data: data, diff --git a/rpc/core/mempool.go b/rpc/core/mempool.go index 3f663c376..1dbdd8012 100644 --- a/rpc/core/mempool.go +++ b/rpc/core/mempool.go @@ -8,9 +8,9 @@ import ( "github.com/pkg/errors" abci "github.com/tendermint/abci/types" - data "github.com/tendermint/go-wire/data" ctypes "github.com/tendermint/tendermint/rpc/core/types" "github.com/tendermint/tendermint/types" + cmn "github.com/tendermint/tmlibs/common" ) //----------------------------------------------------------------------------- @@ -192,7 +192,7 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) { deliverTxRes := deliverTxResMsg.(types.TMEventData).Unwrap().(types.EventDataTx) // The tx was included in a block. deliverTxR := deliverTxRes.Result - logger.Info("DeliverTx passed ", "tx", data.Bytes(tx), "response", deliverTxR) + logger.Info("DeliverTx passed ", "tx", cmn.HexBytes(tx), "response", deliverTxR) return &ctypes.ResultBroadcastTxCommit{ CheckTx: *checkTxR, DeliverTx: deliverTxR, diff --git a/rpc/core/status.go b/rpc/core/status.go index 653c37f50..a8771c8f7 100644 --- a/rpc/core/status.go +++ b/rpc/core/status.go @@ -3,9 +3,9 @@ package core import ( "time" - data "github.com/tendermint/go-wire/data" ctypes "github.com/tendermint/tendermint/rpc/core/types" "github.com/tendermint/tendermint/types" + cmn "github.com/tendermint/tmlibs/common" ) // Get Tendermint status including node info, pubkey, latest block @@ -59,8 +59,8 @@ func Status() (*ctypes.ResultStatus, error) { latestHeight := blockStore.Height() var ( latestBlockMeta *types.BlockMeta - latestBlockHash data.Bytes - latestAppHash data.Bytes + latestBlockHash cmn.HexBytes + latestAppHash cmn.HexBytes latestBlockTimeNano int64 ) if latestHeight != 0 { diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index 233b44e93..79904efa7 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -6,7 +6,6 @@ import ( abci "github.com/tendermint/abci/types" crypto "github.com/tendermint/go-crypto" - "github.com/tendermint/go-wire/data" cstypes "github.com/tendermint/tendermint/consensus/types" "github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/state" @@ -56,8 +55,8 @@ func NewResultCommit(header *types.Header, commit *types.Commit, type ResultStatus struct { NodeInfo p2p.NodeInfo `json:"node_info"` PubKey crypto.PubKey `json:"pub_key"` - LatestBlockHash data.Bytes `json:"latest_block_hash"` - LatestAppHash data.Bytes `json:"latest_app_hash"` + LatestBlockHash cmn.HexBytes `json:"latest_block_hash"` + LatestAppHash cmn.HexBytes `json:"latest_app_hash"` LatestBlockHeight int64 `json:"latest_block_height"` LatestBlockTime time.Time `json:"latest_block_time"` Syncing bool `json:"syncing"` @@ -107,17 +106,17 @@ type ResultDumpConsensusState struct { } type ResultBroadcastTx struct { - Code uint32 `json:"code"` - Data data.Bytes `json:"data"` - Log string `json:"log"` + Code uint32 `json:"code"` + Data cmn.HexBytes `json:"data"` + Log string `json:"log"` - Hash data.Bytes `json:"hash"` + Hash cmn.HexBytes `json:"hash"` } type ResultBroadcastTxCommit struct { CheckTx abci.ResponseCheckTx `json:"check_tx"` DeliverTx abci.ResponseDeliverTx `json:"deliver_tx"` - Hash data.Bytes `json:"hash"` + Hash cmn.HexBytes `json:"hash"` Height int64 `json:"height"` } diff --git a/rpc/lib/rpc_test.go b/rpc/lib/rpc_test.go index be170985f..8c8b57612 100644 --- a/rpc/lib/rpc_test.go +++ b/rpc/lib/rpc_test.go @@ -17,7 +17,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tendermint/go-wire/data" client "github.com/tendermint/tendermint/rpc/lib/client" server "github.com/tendermint/tendermint/rpc/lib/server" types "github.com/tendermint/tendermint/rpc/lib/types" @@ -47,7 +46,7 @@ type ResultEchoBytes struct { } type ResultEchoDataBytes struct { - Value data.Bytes `json:"value"` + Value cmn.HexBytes `json:"value"` } // Define some routes @@ -75,7 +74,7 @@ func EchoBytesResult(v []byte) (*ResultEchoBytes, error) { return &ResultEchoBytes{v}, nil } -func EchoDataBytesResult(v data.Bytes) (*ResultEchoDataBytes, error) { +func EchoDataBytesResult(v cmn.HexBytes) (*ResultEchoDataBytes, error) { return &ResultEchoDataBytes{v}, nil } @@ -174,7 +173,7 @@ func echoBytesViaHTTP(cl client.HTTPClient, bytes []byte) ([]byte, error) { return result.Value, nil } -func echoDataBytesViaHTTP(cl client.HTTPClient, bytes data.Bytes) (data.Bytes, error) { +func echoDataBytesViaHTTP(cl client.HTTPClient, bytes cmn.HexBytes) (cmn.HexBytes, error) { params := map[string]interface{}{ "arg": bytes, } @@ -196,7 +195,7 @@ func testWithHTTPClient(t *testing.T, cl client.HTTPClient) { require.Nil(t, err) assert.Equal(t, got2, val2) - val3 := data.Bytes(randBytes(t)) + val3 := cmn.HexBytes(randBytes(t)) got3, err := echoDataBytesViaHTTP(cl, val3) require.Nil(t, err) assert.Equal(t, got3, val3) diff --git a/rpc/lib/server/parse_test.go b/rpc/lib/server/parse_test.go index a86226f2c..0703d50ed 100644 --- a/rpc/lib/server/parse_test.go +++ b/rpc/lib/server/parse_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/tendermint/go-wire/data" + cmn "github.com/tendermint/tmlibs/common" ) func TestParseJSONMap(t *testing.T) { @@ -31,7 +31,7 @@ func TestParseJSONMap(t *testing.T) { // preloading map with values doesn't help tmp := 0 p2 := map[string]interface{}{ - "value": &data.Bytes{}, + "value": &cmn.HexBytes{}, "height": &tmp, } err = json.Unmarshal(input, &p2) @@ -54,7 +54,7 @@ func TestParseJSONMap(t *testing.T) { Height interface{} `json:"height"` }{ Height: &tmp, - Value: &data.Bytes{}, + Value: &cmn.HexBytes{}, } err = json.Unmarshal(input, &p3) if assert.Nil(err) { @@ -62,7 +62,7 @@ func TestParseJSONMap(t *testing.T) { if assert.True(ok, "%#v", p3.Height) { assert.Equal(22, *h) } - v, ok := p3.Value.(*data.Bytes) + v, ok := p3.Value.(*cmn.HexBytes) if assert.True(ok, "%#v", p3.Value) { assert.EqualValues([]byte{0x12, 0x34}, *v) } @@ -70,8 +70,8 @@ func TestParseJSONMap(t *testing.T) { // simplest solution, but hard-coded p4 := struct { - Value data.Bytes `json:"value"` - Height int `json:"height"` + Value cmn.HexBytes `json:"value"` + Height int `json:"height"` }{} err = json.Unmarshal(input, &p4) if assert.Nil(err) { @@ -90,10 +90,10 @@ func TestParseJSONMap(t *testing.T) { assert.Equal(22, h) } - var v data.Bytes + var v cmn.HexBytes err = json.Unmarshal(*p5["value"], &v) if assert.Nil(err) { - assert.Equal(data.Bytes{0x12, 0x34}, v) + assert.Equal(cmn.HexBytes{0x12, 0x34}, v) } } } @@ -119,10 +119,10 @@ func TestParseJSONArray(t *testing.T) { // preloading map with values helps here (unlike map - p2 above) tmp := 0 - p2 := []interface{}{&data.Bytes{}, &tmp} + p2 := []interface{}{&cmn.HexBytes{}, &tmp} err = json.Unmarshal(input, &p2) if assert.Nil(err) { - v, ok := p2[0].(*data.Bytes) + v, ok := p2[0].(*cmn.HexBytes) if assert.True(ok, "%#v", p2[0]) { assert.EqualValues([]byte{0x12, 0x34}, *v) } diff --git a/types/block.go b/types/block.go index b9b541a96..3e800e722 100644 --- a/types/block.go +++ b/types/block.go @@ -9,7 +9,6 @@ import ( "time" wire "github.com/tendermint/go-wire" - "github.com/tendermint/go-wire/data" cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/merkle" "golang.org/x/crypto/ripemd160" @@ -86,7 +85,7 @@ func (b *Block) FillHeader() { // Hash computes and returns the block hash. // If the block is incomplete, block hash is nil for safety. -func (b *Block) Hash() data.Bytes { +func (b *Block) Hash() cmn.HexBytes { if b == nil || b.Header == nil || b.Data == nil || b.LastCommit == nil { return nil } @@ -161,22 +160,22 @@ type Header struct { TotalTxs int64 `json:"total_txs"` // hashes of block data - LastCommitHash data.Bytes `json:"last_commit_hash"` // commit from validators from the last block - DataHash data.Bytes `json:"data_hash"` // transactions + LastCommitHash cmn.HexBytes `json:"last_commit_hash"` // commit from validators from the last block + DataHash cmn.HexBytes `json:"data_hash"` // transactions // hashes from the app output from the prev block - ValidatorsHash data.Bytes `json:"validators_hash"` // validators for the current block - ConsensusHash data.Bytes `json:"consensus_hash"` // consensus params for current block - AppHash data.Bytes `json:"app_hash"` // state after txs from the previous block - LastResultsHash data.Bytes `json:"last_results_hash"` // root hash of all results from the txs from the previous block + ValidatorsHash cmn.HexBytes `json:"validators_hash"` // validators for the current block + ConsensusHash cmn.HexBytes `json:"consensus_hash"` // consensus params for current block + AppHash cmn.HexBytes `json:"app_hash"` // state after txs from the previous block + LastResultsHash cmn.HexBytes `json:"last_results_hash"` // root hash of all results from the txs from the previous block // consensus info - EvidenceHash data.Bytes `json:"evidence_hash"` // evidence included in the block + EvidenceHash cmn.HexBytes `json:"evidence_hash"` // evidence included in the block } // Hash returns the hash of the header. // Returns nil if ValidatorHash is missing. -func (h *Header) Hash() data.Bytes { +func (h *Header) Hash() cmn.HexBytes { if len(h.ValidatorsHash) == 0 { return nil } @@ -246,7 +245,7 @@ type Commit struct { // Volatile firstPrecommit *Vote - hash data.Bytes + hash cmn.HexBytes bitArray *cmn.BitArray } @@ -355,7 +354,7 @@ func (commit *Commit) ValidateBasic() error { } // Hash returns the hash of the commit -func (commit *Commit) Hash() data.Bytes { +func (commit *Commit) Hash() cmn.HexBytes { if commit.hash == nil { bs := make([]merkle.Hasher, len(commit.Precommits)) for i, precommit := range commit.Precommits { @@ -403,11 +402,11 @@ type Data struct { Txs Txs `json:"txs"` // Volatile - hash data.Bytes + hash cmn.HexBytes } // Hash returns the hash of the data -func (data *Data) Hash() data.Bytes { +func (data *Data) Hash() cmn.HexBytes { if data.hash == nil { data.hash = data.Txs.Hash() // NOTE: leaves of merkle tree are TxIDs } @@ -441,11 +440,11 @@ type EvidenceData struct { Evidence EvidenceList `json:"evidence"` // Volatile - hash data.Bytes + hash cmn.HexBytes } // Hash returns the hash of the data. -func (data *EvidenceData) Hash() data.Bytes { +func (data *EvidenceData) Hash() cmn.HexBytes { if data.hash == nil { data.hash = data.Evidence.Hash() } @@ -477,7 +476,7 @@ func (data *EvidenceData) StringIndented(indent string) string { // BlockID defines the unique ID of a block as its Hash and its PartSetHeader type BlockID struct { - Hash data.Bytes `json:"hash"` + Hash cmn.HexBytes `json:"hash"` PartsHeader PartSetHeader `json:"parts"` } diff --git a/types/canonical_json.go b/types/canonical_json.go index d3b7cf2fb..45d12b45f 100644 --- a/types/canonical_json.go +++ b/types/canonical_json.go @@ -4,7 +4,7 @@ import ( "time" wire "github.com/tendermint/go-wire" - "github.com/tendermint/go-wire/data" + cmn "github.com/tendermint/tmlibs/common" ) // canonical json is go-wire's json for structs with fields in alphabetical order @@ -13,13 +13,13 @@ import ( const timeFormat = wire.RFC3339Millis type CanonicalJSONBlockID struct { - Hash data.Bytes `json:"hash,omitempty"` + Hash cmn.HexBytes `json:"hash,omitempty"` PartsHeader CanonicalJSONPartSetHeader `json:"parts,omitempty"` } type CanonicalJSONPartSetHeader struct { - Hash data.Bytes `json:"hash"` - Total int `json:"total"` + Hash cmn.HexBytes `json:"hash"` + Total int `json:"total"` } type CanonicalJSONProposal struct { diff --git a/types/genesis.go b/types/genesis.go index e33f60258..b7e4f6452 100644 --- a/types/genesis.go +++ b/types/genesis.go @@ -8,7 +8,6 @@ import ( "github.com/pkg/errors" crypto "github.com/tendermint/go-crypto" - "github.com/tendermint/go-wire/data" cmn "github.com/tendermint/tmlibs/common" ) @@ -28,7 +27,7 @@ type GenesisDoc struct { ChainID string `json:"chain_id"` ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"` Validators []GenesisValidator `json:"validators"` - AppHash data.Bytes `json:"app_hash"` + AppHash cmn.HexBytes `json:"app_hash"` AppOptions interface{} `json:"app_options,omitempty"` } diff --git a/types/part_set.go b/types/part_set.go index d922e34d6..ff11f7d35 100644 --- a/types/part_set.go +++ b/types/part_set.go @@ -10,7 +10,6 @@ import ( "golang.org/x/crypto/ripemd160" "github.com/tendermint/go-wire" - "github.com/tendermint/go-wire/data" cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/merkle" ) @@ -22,7 +21,7 @@ var ( type Part struct { Index int `json:"index"` - Bytes data.Bytes `json:"bytes"` + Bytes cmn.HexBytes `json:"bytes"` Proof merkle.SimpleProof `json:"proof"` // Cache @@ -58,8 +57,8 @@ func (part *Part) StringIndented(indent string) string { //------------------------------------- type PartSetHeader struct { - Total int `json:"total"` - Hash data.Bytes `json:"hash"` + Total int `json:"total"` + Hash cmn.HexBytes `json:"hash"` } func (psh PartSetHeader) String() string { diff --git a/types/priv_validator.go b/types/priv_validator.go index 020fbc43c..062fe09d2 100644 --- a/types/priv_validator.go +++ b/types/priv_validator.go @@ -11,7 +11,6 @@ import ( "time" crypto "github.com/tendermint/go-crypto" - data "github.com/tendermint/go-wire/data" cmn "github.com/tendermint/tmlibs/common" ) @@ -50,13 +49,13 @@ type PrivValidator interface { // to prevent double signing. The Signer itself can be mutated to use // something besides the default, for instance a hardware signer. type PrivValidatorFS struct { - Address Address `json:"address"` + Address Address `json:"address"` PubKey crypto.PubKey `json:"pub_key"` LastHeight int64 `json:"last_height"` LastRound int `json:"last_round"` LastStep int8 `json:"last_step"` LastSignature crypto.Signature `json:"last_signature,omitempty"` // so we dont lose signatures - LastSignBytes data.Bytes `json:"last_signbytes,omitempty"` // so we dont lose signatures + LastSignBytes cmn.HexBytes `json:"last_signbytes,omitempty"` // so we dont lose signatures // PrivKey should be empty if a Signer other than the default is being used. PrivKey crypto.PrivKey `json:"priv_key"` diff --git a/types/results.go b/types/results.go index 8e79e1ac7..4a02f2857 100644 --- a/types/results.go +++ b/types/results.go @@ -3,7 +3,7 @@ package types import ( abci "github.com/tendermint/abci/types" wire "github.com/tendermint/go-wire" - "github.com/tendermint/go-wire/data" + cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/merkle" ) @@ -12,8 +12,8 @@ import ( // ABCIResult is the deterministic component of a ResponseDeliverTx. // TODO: add Tags type ABCIResult struct { - Code uint32 `json:"code"` - Data data.Bytes `json:"data"` + Code uint32 `json:"code"` + Data cmn.HexBytes `json:"data"` } // Hash returns the canonical hash of the ABCIResult diff --git a/types/tx.go b/types/tx.go index db42ed8e7..d9e2e2ebd 100644 --- a/types/tx.go +++ b/types/tx.go @@ -6,7 +6,7 @@ import ( "fmt" abci "github.com/tendermint/abci/types" - "github.com/tendermint/go-wire/data" + cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/merkle" ) @@ -90,7 +90,7 @@ func (txs Txs) Proof(i int) TxProof { // TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree. type TxProof struct { Index, Total int - RootHash data.Bytes + RootHash cmn.HexBytes Data Tx Proof merkle.SimpleProof } From e7747f7d6633451b637fd26321728b13af297900 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 3 Feb 2018 03:50:59 -0500 Subject: [PATCH 07/10] it compiles --- consensus/replay_file.go | 5 +++-- lite/proxy/query.go | 3 +++ lite/proxy/wrapper.go | 2 ++ node/node.go | 3 ++- rpc/core/types/responses.go | 2 ++ 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/consensus/replay_file.go b/consensus/replay_file.go index 26b8baebf..979425f87 100644 --- a/consensus/replay_file.go +++ b/consensus/replay_file.go @@ -280,12 +280,13 @@ func (pb *playback) replayConsoleLoop() int { // convenience for replay mode func newConsensusStateForReplay(config cfg.BaseConfig, csConfig *cfg.ConsensusConfig) *ConsensusState { + dbType := dbm.DBBackendType(config.DBBackend) // Get BlockStore - blockStoreDB := dbm.NewDB("blockstore", config.DBBackend, config.DBDir()) + blockStoreDB := dbm.NewDB("blockstore", dbType, config.DBDir()) blockStore := bc.NewBlockStore(blockStoreDB) // Get State - stateDB := dbm.NewDB("state", config.DBBackend, config.DBDir()) + stateDB := dbm.NewDB("state", dbType, config.DBDir()) state, err := sm.MakeGenesisStateFromFile(config.GenesisFile()) if err != nil { cmn.Exit(err.Error()) diff --git a/lite/proxy/query.go b/lite/proxy/query.go index 1da2a0cce..9c9557f8f 100644 --- a/lite/proxy/query.go +++ b/lite/proxy/query.go @@ -3,6 +3,8 @@ package proxy import ( "github.com/pkg/errors" + cmn "github.com/tendermint/tmlibs/common" + "github.com/tendermint/tendermint/lite" "github.com/tendermint/tendermint/lite/client" certerr "github.com/tendermint/tendermint/lite/errors" @@ -78,6 +80,7 @@ func GetWithProofOptions(path string, key []byte, opts rpcclient.ABCIQueryOption return nil, nil, err } + _ = commit return &ctypes.ResultABCIQuery{Response: resp}, nil, nil /* // TODO refactor so iavl stuff is not in tendermint core diff --git a/lite/proxy/wrapper.go b/lite/proxy/wrapper.go index 02f2f318b..e8aa011e1 100644 --- a/lite/proxy/wrapper.go +++ b/lite/proxy/wrapper.go @@ -1,6 +1,8 @@ package proxy import ( + cmn "github.com/tendermint/tmlibs/common" + "github.com/tendermint/tendermint/lite" certclient "github.com/tendermint/tendermint/lite/client" rpcclient "github.com/tendermint/tendermint/rpc/client" diff --git a/node/node.go b/node/node.go index cd1248f49..acf51a908 100644 --- a/node/node.go +++ b/node/node.go @@ -53,7 +53,8 @@ type DBProvider func(*DBContext) (dbm.DB, error) // DefaultDBProvider returns a database using the DBBackend and DBDir // specified in the ctx.Config. func DefaultDBProvider(ctx *DBContext) (dbm.DB, error) { - return dbm.NewDB(ctx.ID, ctx.Config.DBBackend, ctx.Config.DBDir()), nil + dbType := dbm.DBBackendType(ctx.Config.DBBackend) + return dbm.NewDB(ctx.ID, dbType, ctx.Config.DBDir()), nil } // GenesisDocProvider returns a GenesisDoc. diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index 79904efa7..e13edc843 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -6,6 +6,8 @@ import ( abci "github.com/tendermint/abci/types" crypto "github.com/tendermint/go-crypto" + cmn "github.com/tendermint/tmlibs/common" + cstypes "github.com/tendermint/tendermint/consensus/types" "github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/state" From bb2bdbc0e1297fa5624f331bfdeab9a42bfe36f6 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 15 Jan 2018 10:52:17 -0500 Subject: [PATCH 08/10] add missing element (tag.Value) to keyForTag encoded as %s. not sure this will work with raw bytes --- state/txindex/kv/kv.go | 2 +- state/txindex/kv/kv_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/state/txindex/kv/kv.go b/state/txindex/kv/kv.go index 90e64043a..ed4fcc8a6 100644 --- a/state/txindex/kv/kv.go +++ b/state/txindex/kv/kv.go @@ -377,7 +377,7 @@ func extractValueFromKey(key []byte) string { } func keyForTag(tag cmn.KVPair, result *types.TxResult) []byte { - return []byte(fmt.Sprintf("%s/%d/%d", tag.Key, result.Height, result.Index)) + return []byte(fmt.Sprintf("%s/%s/%d/%d", tag.Key, tag.Value, result.Height, result.Index)) } /////////////////////////////////////////////////////////////////////////////// diff --git a/state/txindex/kv/kv_test.go b/state/txindex/kv/kv_test.go index 4fdb71a04..ba2830e81 100644 --- a/state/txindex/kv/kv_test.go +++ b/state/txindex/kv/kv_test.go @@ -51,7 +51,7 @@ func TestTxSearch(t *testing.T) { indexer := NewTxIndex(db.NewMemDB(), IndexTags(allowedTags)) txResult := txResultWithTags([]cmn.KVPair{ - {Key: []byte("account.number"), Value: []byte{1}}, + {Key: []byte("account.number"), Value: []byte("1")}, {Key: []byte("account.owner"), Value: []byte("Ivan")}, {Key: []byte("not_allowed"), Value: []byte("Vlad")}, }) @@ -108,8 +108,8 @@ func TestTxSearchOneTxWithMultipleSameTagsButDifferentValues(t *testing.T) { indexer := NewTxIndex(db.NewMemDB(), IndexTags(allowedTags)) txResult := txResultWithTags([]cmn.KVPair{ - {Key: []byte("account.number"), Value: []byte{1}}, - {Key: []byte("account.number"), Value: []byte{2}}, + {Key: []byte("account.number"), Value: []byte("1")}, + {Key: []byte("account.number"), Value: []byte("2")}, }) err := indexer.Index(txResult) @@ -127,7 +127,7 @@ func TestIndexAllTags(t *testing.T) { txResult := txResultWithTags([]cmn.KVPair{ cmn.KVPair{[]byte("account.owner"), []byte("Ivan")}, - cmn.KVPair{[]byte("account.number"), []byte{1}}, + cmn.KVPair{[]byte("account.number"), []byte("1")}, }) err := indexer.Index(txResult) From d34286c421db76c4d4ff2b17f80a66386563c621 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 3 Feb 2018 03:54:49 -0500 Subject: [PATCH 09/10] minor fixes - tests pass --- consensus/byzantine_test.go | 2 +- rpc/lib/rpc_test.go | 4 +++- state/state_test.go | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index faf65ecd1..38bb37474 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -280,7 +280,7 @@ func NewByzantinePrivValidator(pv types.PrivValidator) *ByzantinePrivValidator { } } -func (privVal *ByzantinePrivValidator) GetAddress() crypto.Address { +func (privVal *ByzantinePrivValidator) GetAddress() types.Address { return privVal.pv.GetAddress() } diff --git a/rpc/lib/rpc_test.go b/rpc/lib/rpc_test.go index 8c8b57612..cadc68f8e 100644 --- a/rpc/lib/rpc_test.go +++ b/rpc/lib/rpc_test.go @@ -17,10 +17,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + cmn "github.com/tendermint/tmlibs/common" + "github.com/tendermint/tmlibs/log" + client "github.com/tendermint/tendermint/rpc/lib/client" server "github.com/tendermint/tendermint/rpc/lib/server" types "github.com/tendermint/tendermint/rpc/lib/types" - "github.com/tendermint/tmlibs/log" ) // Client and Server should work over tcp or unix sockets diff --git a/state/state_test.go b/state/state_test.go index ff17eac9c..76b713aee 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -22,7 +22,8 @@ import ( // setupTestCase does setup common to all test cases func setupTestCase(t *testing.T) (func(t *testing.T), dbm.DB, State) { config := cfg.ResetTestRoot("state_") - stateDB := dbm.NewDB("state", config.DBBackend, config.DBDir()) + dbType := dbm.DBBackendType(config.DBBackend) + stateDB := dbm.NewDB("state", dbType, config.DBDir()) state, err := LoadStateFromDBOrGenesisFile(stateDB, config.GenesisFile()) assert.NoError(t, err, "expected no error on LoadStateFromDBOrGenesisFile") From abca9a2d6134206e0e145a675c2bad6c15fec155 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 3 Feb 2018 03:59:16 -0500 Subject: [PATCH 10/10] woops - bring back glide.lock file --- glide.lock | 205 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 glide.lock diff --git a/glide.lock b/glide.lock new file mode 100644 index 000000000..801c9f4d6 --- /dev/null +++ b/glide.lock @@ -0,0 +1,205 @@ +hash: 78f23456c3ca7af06fc26e59107de92a7b208776643bda398b0a05348153da1b +updated: 2018-02-03T03:31:46.976175875-05:00 +imports: +- name: github.com/btcsuite/btcd + version: 50de9da05b50eb15658bb350f6ea24368a111ab7 + subpackages: + - btcec +- name: github.com/ebuchman/fail-test + version: 95f809107225be108efcf10a3509e4ea6ceef3c4 +- name: github.com/fsnotify/fsnotify + version: c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9 +- name: github.com/go-kit/kit + version: 4dc7be5d2d12881735283bcab7352178e190fc71 + subpackages: + - log + - log/level + - log/term +- name: github.com/go-logfmt/logfmt + version: 390ab7935ee28ec6b286364bba9b4dd6410cb3d5 +- name: github.com/go-stack/stack + version: 259ab82a6cad3992b4e21ff5cac294ccb06474bc +- name: github.com/gogo/protobuf + version: 1adfc126b41513cc696b209667c8656ea7aac67c + subpackages: + - gogoproto + - jsonpb + - proto + - protoc-gen-gogo/descriptor + - sortkeys + - types +- name: github.com/golang/protobuf + version: bbd03ef6da3a115852eaf24c8a1c46aeb39aa175 + subpackages: + - proto + - ptypes + - ptypes/any + - ptypes/duration + - ptypes/timestamp +- name: github.com/golang/snappy + version: 553a641470496b2327abcac10b36396bd98e45c9 +- name: github.com/gorilla/websocket + version: ea4d1f681babbce9545c9c5f3d5194a789c89f5b +- name: github.com/hashicorp/hcl + version: 23c074d0eceb2b8a5bfdbb271ab780cde70f05a8 + subpackages: + - hcl/ast + - hcl/parser + - hcl/scanner + - hcl/strconv + - hcl/token + - json/parser + - json/scanner + - json/token +- name: github.com/inconshreveable/mousetrap + version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 +- name: github.com/jmhodges/levigo + version: c42d9e0ca023e2198120196f842701bb4c55d7b9 +- name: github.com/kr/logfmt + version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0 +- name: github.com/magiconair/properties + version: 49d762b9817ba1c2e9d0c69183c2b4a8b8f1d934 +- name: github.com/mitchellh/mapstructure + version: b4575eea38cca1123ec2dc90c26529b5c5acfcff +- name: github.com/pelletier/go-toml + version: acdc4509485b587f5e675510c4f2c63e90ff68a8 +- name: github.com/pkg/errors + version: 645ef00459ed84a119197bfb8d8205042c6df63d +- name: github.com/rcrowley/go-metrics + version: 8732c616f52954686704c8645fe1a9d59e9df7c1 +- name: github.com/spf13/afero + version: bb8f1927f2a9d3ab41c9340aa034f6b803f4359c + subpackages: + - mem +- name: github.com/spf13/cast + version: acbeb36b902d72a7a4c18e8f3241075e7ab763e4 +- name: github.com/spf13/cobra + version: 7b2c5ac9fc04fc5efafb60700713d4fa609b777b +- name: github.com/spf13/jwalterweatherman + version: 7c0cea34c8ece3fbeb2b27ab9b59511d360fb394 +- name: github.com/spf13/pflag + version: 4c012f6dcd9546820e378d0bdda4d8fc772cdfea +- name: github.com/spf13/viper + version: 25b30aa063fc18e48662b86996252eabdcf2f0c7 +- name: github.com/syndtr/goleveldb + version: 211f780988068502fe874c44dae530528ebd840f + subpackages: + - leveldb + - leveldb/cache + - leveldb/comparer + - leveldb/errors + - leveldb/filter + - leveldb/iterator + - leveldb/journal + - leveldb/memdb + - leveldb/opt + - leveldb/storage + - leveldb/table + - leveldb/util +- name: github.com/tendermint/abci + version: 5a4f56056e23cdfd5f3733db056968e016468508 + subpackages: + - client + - example/code + - example/counter + - example/dummy + - server + - types +- name: github.com/tendermint/ed25519 + version: d8387025d2b9d158cf4efb07e7ebf814bcce2057 + subpackages: + - edwards25519 + - extra25519 +- name: github.com/tendermint/go-crypto + version: dd20358a264c772b4a83e477b0cfce4c88a7001d +- name: github.com/tendermint/go-wire + version: b6fc872b42d41158a60307db4da051dd6f179415 + subpackages: + - data + - nowriter/tmlegacy +- name: github.com/tendermint/tmlibs + version: deaaf014d8b8d1095054380a38b1b00e293f725f + subpackages: + - autofile + - cli + - cli/flags + - clist + - common + - db + - flowrate + - log + - merkle + - pubsub + - pubsub/query + - test +- name: golang.org/x/crypto + version: 1875d0a70c90e57f11972aefd42276df65e895b9 + subpackages: + - curve25519 + - nacl/box + - nacl/secretbox + - openpgp/armor + - openpgp/errors + - poly1305 + - ripemd160 + - salsa20/salsa +- name: golang.org/x/net + version: 2fb46b16b8dda405028c50f7c7f0f9dd1fa6bfb1 + subpackages: + - context + - http2 + - http2/hpack + - idna + - internal/timeseries + - lex/httplex + - trace +- name: golang.org/x/sys + version: 37707fdb30a5b38865cfb95e5aab41707daec7fd + subpackages: + - unix +- name: golang.org/x/text + version: e19ae1496984b1c655b8044a65c0300a3c878dd3 + subpackages: + - secure/bidirule + - transform + - unicode/bidi + - unicode/norm +- name: google.golang.org/genproto + version: 4eb30f4778eed4c258ba66527a0d4f9ec8a36c45 + subpackages: + - googleapis/rpc/status +- name: google.golang.org/grpc + version: 401e0e00e4bb830a10496d64cd95e068c5bf50de + subpackages: + - balancer + - codes + - connectivity + - credentials + - grpclb/grpc_lb_v1/messages + - grpclog + - internal + - keepalive + - metadata + - naming + - peer + - resolver + - stats + - status + - tap + - transport +- name: gopkg.in/yaml.v2 + version: d670f9405373e636a5a2765eea47fac0c9bc91a4 +testImports: +- name: github.com/davecgh/go-spew + version: 346938d642f2ec3594ed81d874461961cd0faa76 + subpackages: + - spew +- name: github.com/pmezard/go-difflib + version: 792786c7400a136282c1664665ae0a8db921c6c2 + subpackages: + - difflib +- name: github.com/stretchr/testify + version: a726187e3128d0a0ec37f73ca7c4d3e508e6c2e5 + subpackages: + - assert + - require