mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-18 15:41:20 +00:00
update for sdk2 libs. need to fix kv test
NOTE we only updating for tmlibs and abci
This commit is contained in:
@ -254,7 +254,7 @@ func (bsj BlockStoreStateJSON) Save(db dbm.DB) {
|
|||||||
// If no BlockStoreStateJSON was previously persisted, it returns the zero value.
|
// If no BlockStoreStateJSON was previously persisted, it returns the zero value.
|
||||||
func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON {
|
func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON {
|
||||||
bytes := db.Get(blockStoreKey)
|
bytes := db.Get(blockStoreKey)
|
||||||
if bytes == nil {
|
if len(bytes) == 0 {
|
||||||
return BlockStoreStateJSON{
|
return BlockStoreStateJSON{
|
||||||
Height: 0,
|
Height: 0,
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ func TestNewBlockStore(t *testing.T) {
|
|||||||
wantErr string
|
wantErr string
|
||||||
}{
|
}{
|
||||||
{[]byte("artful-doger"), "not unmarshal bytes"},
|
{[]byte("artful-doger"), "not unmarshal bytes"},
|
||||||
{[]byte(""), "unmarshal bytes"},
|
|
||||||
{[]byte(" "), "unmarshal bytes"},
|
{[]byte(" "), "unmarshal bytes"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +75,7 @@ func TestBlockStoreGetReader(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
0: {key: []byte("Foo"), want: []byte("Bar")},
|
0: {key: []byte("Foo"), want: []byte("Bar")},
|
||||||
1: {key: []byte("KnoxNonExistent"), want: nil},
|
1: {key: []byte("KnoxNonExistent"), want: nil},
|
||||||
2: {key: []byte("Foo1"), want: nil},
|
2: {key: []byte("Foo1"), want: []byte{}},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tt := range tests {
|
for i, tt := range tests {
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
crypto "github.com/tendermint/go-crypto"
|
crypto "github.com/tendermint/go-crypto"
|
||||||
data "github.com/tendermint/go-wire/data"
|
|
||||||
"github.com/tendermint/tendermint/p2p"
|
"github.com/tendermint/tendermint/p2p"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
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()
|
return privVal.pv.GetAddress()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ func TestMempoolRmBadTx(t *testing.T) {
|
|||||||
assert.False(t, resDeliver.IsErr(), cmn.Fmt("expected no error. got %v", resDeliver))
|
assert.False(t, resDeliver.IsErr(), cmn.Fmt("expected no error. got %v", resDeliver))
|
||||||
|
|
||||||
resCommit := app.Commit()
|
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{})
|
emptyMempoolCh := make(chan struct{})
|
||||||
checkTxRespCh := make(chan struct{})
|
checkTxRespCh := make(chan struct{})
|
||||||
@ -223,10 +223,10 @@ func txAsUint64(tx []byte) uint64 {
|
|||||||
func (app *CounterApplication) Commit() abci.ResponseCommit {
|
func (app *CounterApplication) Commit() abci.ResponseCommit {
|
||||||
app.mempoolTxCount = app.txCount
|
app.mempoolTxCount = app.txCount
|
||||||
if app.txCount == 0 {
|
if app.txCount == 0 {
|
||||||
return abci.ResponseCommit{Code: code.CodeTypeOK}
|
return abci.ResponseCommit{}
|
||||||
} else {
|
} else {
|
||||||
hash := make([]byte, 8)
|
hash := make([]byte, 8)
|
||||||
binary.BigEndian.PutUint64(hash, uint64(app.txCount))
|
binary.BigEndian.PutUint64(hash, uint64(app.txCount))
|
||||||
return abci.ResponseCommit{Code: code.CodeTypeOK, Data: hash}
|
return abci.ResponseCommit{Data: hash}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,5 +423,5 @@ func (mock *mockProxyApp) EndBlock(req abci.RequestEndBlock) abci.ResponseEndBlo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mock *mockProxyApp) Commit() abci.ResponseCommit {
|
func (mock *mockProxyApp) Commit() abci.ResponseCommit {
|
||||||
return abci.ResponseCommit{Code: abci.CodeTypeOK, Data: mock.appHash}
|
return abci.ResponseCommit{Data: mock.appHash}
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,8 @@ func (store *EvidenceStore) PendingEvidence() (evidence []types.Evidence) {
|
|||||||
// ListEvidence lists the evidence for the given prefix key.
|
// ListEvidence lists the evidence for the given prefix key.
|
||||||
// It is wrapped by PriorityEvidence and PendingEvidence for convenience.
|
// It is wrapped by PriorityEvidence and PendingEvidence for convenience.
|
||||||
func (store *EvidenceStore) ListEvidence(prefixKey string) (evidence []types.Evidence) {
|
func (store *EvidenceStore) ListEvidence(prefixKey string) (evidence []types.Evidence) {
|
||||||
iter := store.db.IteratorPrefix([]byte(prefixKey))
|
iter := dbm.IteratePrefix(store.db, []byte(prefixKey))
|
||||||
for iter.Next() {
|
for ; iter.Valid(); iter.Next() {
|
||||||
val := iter.Value()
|
val := iter.Value()
|
||||||
|
|
||||||
var ei EvidenceInfo
|
var ei EvidenceInfo
|
||||||
|
205
glide.lock
generated
205
glide.lock
generated
@ -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
|
|
@ -24,9 +24,9 @@ import:
|
|||||||
- example/dummy
|
- example/dummy
|
||||||
- types
|
- types
|
||||||
- package: github.com/tendermint/go-crypto
|
- package: github.com/tendermint/go-crypto
|
||||||
version: ~0.4.1
|
version: master
|
||||||
- package: github.com/tendermint/go-wire
|
- package: github.com/tendermint/go-wire
|
||||||
version: ~0.7.2
|
version: master
|
||||||
subpackages:
|
subpackages:
|
||||||
- data
|
- data
|
||||||
- package: github.com/tendermint/tmlibs
|
- package: github.com/tendermint/tmlibs
|
||||||
|
@ -86,11 +86,16 @@ func GetWithProofOptions(path string, key []byte, opts rpcclient.ABCIQueryOption
|
|||||||
// https://github.com/tendermint/tendermint/issues/1183
|
// https://github.com/tendermint/tendermint/issues/1183
|
||||||
if len(resp.Value) > 0 {
|
if len(resp.Value) > 0 {
|
||||||
// The key was found, construct a proof of existence.
|
// The key was found, construct a proof of existence.
|
||||||
eproof, err := iavl.ReadKeyExistsProof(resp.Proof)
|
proof, err := iavl.ReadKeyProof(resp.Proof)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Wrap(err, "Error reading proof")
|
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.
|
// Validate the proof against the certified header to ensure data integrity.
|
||||||
err = eproof.Verify(resp.Key, resp.Value, commit.Header.AppHash)
|
err = eproof.Verify(resp.Key, resp.Value, commit.Header.AppHash)
|
||||||
if err != nil {
|
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.
|
// The key wasn't found, construct a proof of non-existence.
|
||||||
var aproof *iavl.KeyAbsentProof
|
proof, err := iavl.ReadKeyProof(resp.Proof)
|
||||||
aproof, err = iavl.ReadKeyAbsentProof(resp.Proof)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Wrap(err, "Error reading proof")
|
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.
|
// Validate the proof against the certified header to ensure data integrity.
|
||||||
err = aproof.Verify(resp.Key, nil, commit.Header.AppHash)
|
err = aproof.Verify(resp.Key, nil, commit.Header.AppHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -185,7 +185,7 @@ func TestSerialReap(t *testing.T) {
|
|||||||
t.Errorf("Client error committing: %v", err)
|
t.Errorf("Client error committing: %v", err)
|
||||||
}
|
}
|
||||||
if len(res.Data) != 8 {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ func NewNode(config *cfg.Config,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if resQuery.IsErr() {
|
if resQuery.IsErr() {
|
||||||
return resQuery
|
return fmt.Errorf("Error querying abci app: %v", resQuery)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -284,7 +284,7 @@ func NewNode(config *cfg.Config,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if resQuery.IsErr() {
|
if resQuery.IsErr() {
|
||||||
return resQuery
|
return fmt.Errorf("Error querying abci app: %v", resQuery)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
@ -141,13 +141,7 @@ func (blockExec *BlockExecutor) Commit(block *types.Block) ([]byte, error) {
|
|||||||
blockExec.logger.Error("Client error during proxyAppConn.CommitSync", "err", err)
|
blockExec.logger.Error("Client error during proxyAppConn.CommitSync", "err", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if res.IsErr() {
|
// ResponseCommit has no error code - just data
|
||||||
blockExec.logger.Error("Error in proxyAppConn.CommitSync", "err", res)
|
|
||||||
return nil, res
|
|
||||||
}
|
|
||||||
if res.Log != "" {
|
|
||||||
blockExec.logger.Debug("Commit.Log: " + res.Log)
|
|
||||||
}
|
|
||||||
|
|
||||||
blockExec.logger.Info("Committed state", "height", block.Height, "txs", block.NumTxs, "appHash", res.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 {
|
for i, ev := range block.Evidence.Evidence {
|
||||||
byzantineVals[i] = &abci.Evidence{
|
byzantineVals[i] = abci.Evidence{
|
||||||
PubKey: ev.Address(), // XXX/TODO
|
PubKey: ev.Address(), // XXX
|
||||||
Height: ev.Height(),
|
Height: ev.Height(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,7 +238,7 @@ func execBlockOnProxyApp(logger log.Logger, proxyAppConn proxy.AppConnConsensus,
|
|||||||
return abciResponses, nil
|
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
|
// 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
|
// a light client could never prove the transition externally. See
|
||||||
// ./lite/doc.go for details on how a light client tracks validators.
|
// ./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
|
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
|
threshold := currentSet.TotalVotingPower() * 1 / 3
|
||||||
acc := int64(0)
|
acc := int64(0)
|
||||||
|
|
||||||
@ -424,12 +419,6 @@ func ExecCommitBlock(appConnConsensus proxy.AppConnConsensus, block *types.Block
|
|||||||
logger.Error("Client error during proxyAppConn.CommitSync", "err", res)
|
logger.Error("Client error during proxyAppConn.CommitSync", "err", res)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if res.IsErr() {
|
// ResponseCommit has no error or log, just data
|
||||||
logger.Error("Error in proxyAppConn.CommitSync", "err", res)
|
|
||||||
return nil, res
|
|
||||||
}
|
|
||||||
if res.Log != "" {
|
|
||||||
logger.Info("Commit.Log: " + res.Log)
|
|
||||||
}
|
|
||||||
return res.Data, nil
|
return res.Data, nil
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
crypto "github.com/tendermint/go-crypto"
|
crypto "github.com/tendermint/go-crypto"
|
||||||
"github.com/tendermint/tendermint/proxy"
|
"github.com/tendermint/tendermint/proxy"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
dbm "github.com/tendermint/tmlibs/db"
|
dbm "github.com/tendermint/tmlibs/db"
|
||||||
"github.com/tendermint/tmlibs/log"
|
"github.com/tendermint/tmlibs/log"
|
||||||
)
|
)
|
||||||
@ -105,11 +106,11 @@ func TestBeginBlockByzantineValidators(t *testing.T) {
|
|||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
desc string
|
desc string
|
||||||
evidence []types.Evidence
|
evidence []types.Evidence
|
||||||
expectedByzantineValidators []*abci.Evidence
|
expectedByzantineValidators []abci.Evidence
|
||||||
}{
|
}{
|
||||||
{"none byzantine", []types.Evidence{}, []*abci.Evidence{}},
|
{"none byzantine", []types.Evidence{}, []abci.Evidence{}},
|
||||||
{"one byzantine", []types.Evidence{ev1}, []*abci.Evidence{{ev1.Address(), ev1.Height()}}},
|
{"one byzantine", []types.Evidence{ev1}, []abci.Evidence{{ev1.Address(), ev1.Height()}}},
|
||||||
{"multiple byzantine", []types.Evidence{ev1, ev2}, []*abci.Evidence{
|
{"multiple byzantine", []types.Evidence{ev1, ev2}, []abci.Evidence{
|
||||||
{ev1.Address(), ev1.Height()},
|
{ev1.Address(), ev1.Height()},
|
||||||
{ev2.Address(), ev2.Height()}}},
|
{ev2.Address(), ev2.Height()}}},
|
||||||
}
|
}
|
||||||
@ -161,7 +162,7 @@ type testApp struct {
|
|||||||
abci.BaseApplication
|
abci.BaseApplication
|
||||||
|
|
||||||
AbsentValidators []int32
|
AbsentValidators []int32
|
||||||
ByzantineValidators []*abci.Evidence
|
ByzantineValidators []abci.Evidence
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDummyApplication() *testApp {
|
func NewDummyApplication() *testApp {
|
||||||
@ -179,7 +180,7 @@ func (app *testApp) BeginBlock(req abci.RequestBeginBlock) abci.ResponseBeginBlo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (app *testApp) DeliverTx(tx []byte) abci.ResponseDeliverTx {
|
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 {
|
func (app *testApp) CheckTx(tx []byte) abci.ResponseCheckTx {
|
||||||
|
@ -77,9 +77,9 @@ func TestABCIResponsesSaveLoad1(t *testing.T) {
|
|||||||
// build mock responses
|
// build mock responses
|
||||||
block := makeBlock(state, 2)
|
block := makeBlock(state, 2)
|
||||||
abciResponses := NewABCIResponses(block)
|
abciResponses := NewABCIResponses(block)
|
||||||
abciResponses.DeliverTx[0] = &abci.ResponseDeliverTx{Data: []byte("foo"), Tags: []*abci.KVPair{}}
|
abciResponses.DeliverTx[0] = &abci.ResponseDeliverTx{Data: []byte("foo"), Tags: []cmn.KVPair{}}
|
||||||
abciResponses.DeliverTx[1] = &abci.ResponseDeliverTx{Data: []byte("bar"), Log: "ok", Tags: []*abci.KVPair{}}
|
abciResponses.DeliverTx[1] = &abci.ResponseDeliverTx{Data: []byte("bar"), Log: "ok", Tags: []cmn.KVPair{}}
|
||||||
abciResponses.EndBlock = &abci.ResponseEndBlock{ValidatorUpdates: []*abci.Validator{
|
abciResponses.EndBlock = &abci.ResponseEndBlock{ValidatorUpdates: []abci.Validator{
|
||||||
{
|
{
|
||||||
PubKey: crypto.GenPrivKeyEd25519().PubKey().Bytes(),
|
PubKey: crypto.GenPrivKeyEd25519().PubKey().Bytes(),
|
||||||
Power: 10,
|
Power: 10,
|
||||||
@ -122,9 +122,9 @@ func TestABCIResponsesSaveLoad2(t *testing.T) {
|
|||||||
[]*abci.ResponseDeliverTx{
|
[]*abci.ResponseDeliverTx{
|
||||||
{Code: 383},
|
{Code: 383},
|
||||||
{Data: []byte("Gotcha!"),
|
{Data: []byte("Gotcha!"),
|
||||||
Tags: []*abci.KVPair{
|
Tags: []cmn.KVPair{
|
||||||
abci.KVPairInt("a", 1),
|
cmn.KVPair{[]byte("a"), []byte{1}},
|
||||||
abci.KVPairString("build", "stuff"),
|
cmn.KVPair{[]byte("build"), []byte("stuff")},
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
types.ABCIResults{
|
types.ABCIResults{
|
||||||
@ -378,44 +378,44 @@ func TestLessThanOneThirdOfVotingPowerPerBlockEnforced(t *testing.T) {
|
|||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
initialValSetSize int
|
initialValSetSize int
|
||||||
shouldErr bool
|
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 ////////////////////////
|
///////////// 1 val (vp: 10) => less than 3 is ok ////////////////////////
|
||||||
// adding 1 validator => 10
|
// adding 1 validator => 10
|
||||||
0: {1, false, func(vals *types.ValidatorSet) []*abci.Validator {
|
0: {1, false, func(vals *types.ValidatorSet) []abci.Validator {
|
||||||
return []*abci.Validator{
|
return []abci.Validator{
|
||||||
{PubKey: pk(), Power: 2},
|
{PubKey: pk(), Power: 2},
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
1: {1, true, func(vals *types.ValidatorSet) []*abci.Validator {
|
1: {1, true, func(vals *types.ValidatorSet) []abci.Validator {
|
||||||
return []*abci.Validator{
|
return []abci.Validator{
|
||||||
{PubKey: pk(), Power: 3},
|
{PubKey: pk(), Power: 3},
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
2: {1, true, func(vals *types.ValidatorSet) []*abci.Validator {
|
2: {1, true, func(vals *types.ValidatorSet) []abci.Validator {
|
||||||
return []*abci.Validator{
|
return []abci.Validator{
|
||||||
{PubKey: pk(), Power: 100},
|
{PubKey: pk(), Power: 100},
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
|
||||||
///////////// 3 val (vp: 30) => less than 10 is ok ////////////////////////
|
///////////// 3 val (vp: 30) => less than 10 is ok ////////////////////////
|
||||||
// adding and removing validator => 20
|
// 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)
|
_, firstVal := vals.GetByIndex(0)
|
||||||
return []*abci.Validator{
|
return []abci.Validator{
|
||||||
{PubKey: firstVal.PubKey.Bytes(), Power: 0},
|
{PubKey: firstVal.PubKey.Bytes(), Power: 0},
|
||||||
{PubKey: pk(), Power: 10},
|
{PubKey: pk(), Power: 10},
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
// adding 1 validator => 10
|
// adding 1 validator => 10
|
||||||
4: {3, true, func(vals *types.ValidatorSet) []*abci.Validator {
|
4: {3, true, func(vals *types.ValidatorSet) []abci.Validator {
|
||||||
return []*abci.Validator{
|
return []abci.Validator{
|
||||||
{PubKey: pk(), Power: 10},
|
{PubKey: pk(), Power: 10},
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
// adding 2 validators => 8
|
// adding 2 validators => 8
|
||||||
5: {3, false, func(vals *types.ValidatorSet) []*abci.Validator {
|
5: {3, false, func(vals *types.ValidatorSet) []abci.Validator {
|
||||||
return []*abci.Validator{
|
return []abci.Validator{
|
||||||
{PubKey: pk(), Power: 4},
|
{PubKey: pk(), Power: 4},
|
||||||
{PubKey: pk(), Power: 4},
|
{PubKey: pk(), Power: 4},
|
||||||
}
|
}
|
||||||
@ -450,20 +450,20 @@ func TestApplyUpdates(t *testing.T) {
|
|||||||
|
|
||||||
cases := [...]struct {
|
cases := [...]struct {
|
||||||
init types.ConsensusParams
|
init types.ConsensusParams
|
||||||
updates *abci.ConsensusParams
|
updates abci.ConsensusParams
|
||||||
expected types.ConsensusParams
|
expected types.ConsensusParams
|
||||||
}{
|
}{
|
||||||
0: {initParams, nil, initParams},
|
0: {initParams, abci.ConsensusParams{}, initParams},
|
||||||
1: {initParams, &abci.ConsensusParams{}, initParams},
|
1: {initParams, abci.ConsensusParams{}, initParams},
|
||||||
2: {initParams,
|
2: {initParams,
|
||||||
&abci.ConsensusParams{
|
abci.ConsensusParams{
|
||||||
TxSize: &abci.TxSize{
|
TxSize: &abci.TxSize{
|
||||||
MaxBytes: 123,
|
MaxBytes: 123,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
makeParams(1, 2, 3, 123, 5, 6)},
|
makeParams(1, 2, 3, 123, 5, 6)},
|
||||||
3: {initParams,
|
3: {initParams,
|
||||||
&abci.ConsensusParams{
|
abci.ConsensusParams{
|
||||||
BlockSize: &abci.BlockSize{
|
BlockSize: &abci.BlockSize{
|
||||||
MaxTxs: 44,
|
MaxTxs: 44,
|
||||||
MaxGas: 55,
|
MaxGas: 55,
|
||||||
@ -471,7 +471,7 @@ func TestApplyUpdates(t *testing.T) {
|
|||||||
},
|
},
|
||||||
makeParams(1, 44, 55, 4, 5, 6)},
|
makeParams(1, 44, 55, 4, 5, 6)},
|
||||||
4: {initParams,
|
4: {initParams,
|
||||||
&abci.ConsensusParams{
|
abci.ConsensusParams{
|
||||||
BlockSize: &abci.BlockSize{
|
BlockSize: &abci.BlockSize{
|
||||||
MaxTxs: 789,
|
MaxTxs: 789,
|
||||||
},
|
},
|
||||||
@ -486,7 +486,7 @@ func TestApplyUpdates(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range cases {
|
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)
|
assert.Equal(t, tc.expected, res, "case %d", i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -496,14 +496,14 @@ func makeHeaderPartsResponsesValPubKeyChange(state State, height int64,
|
|||||||
|
|
||||||
block := makeBlock(state, height)
|
block := makeBlock(state, height)
|
||||||
abciResponses := &ABCIResponses{
|
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
|
// if the pubkey is new, remove the old and add the new
|
||||||
_, val := state.Validators.GetByIndex(0)
|
_, val := state.Validators.GetByIndex(0)
|
||||||
if !bytes.Equal(pubkey.Bytes(), val.PubKey.Bytes()) {
|
if !bytes.Equal(pubkey.Bytes(), val.PubKey.Bytes()) {
|
||||||
abciResponses.EndBlock = &abci.ResponseEndBlock{
|
abciResponses.EndBlock = &abci.ResponseEndBlock{
|
||||||
ValidatorUpdates: []*abci.Validator{
|
ValidatorUpdates: []abci.Validator{
|
||||||
{val.PubKey.Bytes(), 0},
|
{val.PubKey.Bytes(), 0},
|
||||||
{pubkey.Bytes(), 10},
|
{pubkey.Bytes(), 10},
|
||||||
},
|
},
|
||||||
@ -518,14 +518,14 @@ func makeHeaderPartsResponsesValPowerChange(state State, height int64,
|
|||||||
|
|
||||||
block := makeBlock(state, height)
|
block := makeBlock(state, height)
|
||||||
abciResponses := &ABCIResponses{
|
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
|
// if the pubkey is new, remove the old and add the new
|
||||||
_, val := state.Validators.GetByIndex(0)
|
_, val := state.Validators.GetByIndex(0)
|
||||||
if val.VotingPower != power {
|
if val.VotingPower != power {
|
||||||
abciResponses.EndBlock = &abci.ResponseEndBlock{
|
abciResponses.EndBlock = &abci.ResponseEndBlock{
|
||||||
ValidatorUpdates: []*abci.Validator{
|
ValidatorUpdates: []abci.Validator{
|
||||||
{val.PubKey.Bytes(), power},
|
{val.PubKey.Bytes(), power},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,13 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
abci "github.com/tendermint/abci/types"
|
|
||||||
wire "github.com/tendermint/go-wire"
|
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/state/txindex"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
|
||||||
db "github.com/tendermint/tmlibs/db"
|
|
||||||
"github.com/tendermint/tmlibs/pubsub/query"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -27,13 +27,13 @@ var _ txindex.TxIndexer = (*TxIndex)(nil)
|
|||||||
|
|
||||||
// TxIndex is the simplest possible indexer, backed by key-value storage (levelDB).
|
// TxIndex is the simplest possible indexer, backed by key-value storage (levelDB).
|
||||||
type TxIndex struct {
|
type TxIndex struct {
|
||||||
store db.DB
|
store dbm.DB
|
||||||
tagsToIndex []string
|
tagsToIndex []string
|
||||||
indexAllTags bool
|
indexAllTags bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTxIndex creates new KV indexer.
|
// 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}
|
txi := &TxIndex{store: store, tagsToIndex: make([]string, 0), indexAllTags: false}
|
||||||
for _, o := range options {
|
for _, o := range options {
|
||||||
o(txi)
|
o(txi)
|
||||||
@ -87,7 +87,7 @@ func (txi *TxIndex) AddBatch(b *txindex.Batch) error {
|
|||||||
|
|
||||||
// index tx by tags
|
// index tx by tags
|
||||||
for _, tag := range result.Result.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)
|
storeBatch.Set(keyForTag(tag, result), hash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ func (txi *TxIndex) Index(result *types.TxResult) error {
|
|||||||
|
|
||||||
// index tx by tags
|
// index tx by tags
|
||||||
for _, tag := range result.Result.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)
|
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) {
|
func (txi *TxIndex) match(c query.Condition, startKey []byte) (hashes [][]byte) {
|
||||||
if c.Op == query.OpEqual {
|
if c.Op == query.OpEqual {
|
||||||
it := txi.store.IteratorPrefix(startKey)
|
it := dbm.IteratePrefix(txi.store, startKey)
|
||||||
defer it.Release()
|
defer it.Close()
|
||||||
for it.Next() {
|
for ; it.Valid(); it.Next() {
|
||||||
hashes = append(hashes, it.Value())
|
hashes = append(hashes, it.Value())
|
||||||
}
|
}
|
||||||
} else if c.Op == query.OpContains {
|
} else if c.Op == query.OpContains {
|
||||||
// XXX: doing full scan because startKey does not apply here
|
// XXX: doing full scan because startKey does not apply here
|
||||||
// For example, if startKey = "account.owner=an" and search query = "accoutn.owner CONSISTS an"
|
// 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"
|
// we can't iterate with prefix "account.owner=an" because we might miss keys like "account.owner=Ulan"
|
||||||
it := txi.store.Iterator()
|
it := txi.store.Iterator(nil, nil)
|
||||||
defer it.Release()
|
defer it.Close()
|
||||||
for it.Next() {
|
for ; it.Valid(); it.Next() {
|
||||||
if !isTagKey(it.Key()) {
|
if !isTagKey(it.Key()) {
|
||||||
continue
|
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) {
|
func (txi *TxIndex) matchRange(r queryRange, startKey []byte) (hashes [][]byte) {
|
||||||
it := txi.store.IteratorPrefix(startKey)
|
it := dbm.IteratePrefix(txi.store, startKey)
|
||||||
defer it.Release()
|
defer it.Close()
|
||||||
LOOP:
|
LOOP:
|
||||||
for it.Next() {
|
for ; it.Valid(); it.Next() {
|
||||||
if !isTagKey(it.Key()) {
|
if !isTagKey(it.Key()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -376,17 +376,8 @@ func extractValueFromKey(key []byte) string {
|
|||||||
return parts[1]
|
return parts[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func keyForTag(tag *abci.KVPair, result *types.TxResult) []byte {
|
func keyForTag(tag cmn.KVPair, result *types.TxResult) []byte {
|
||||||
switch tag.ValueType {
|
return []byte(fmt.Sprintf("%s/%d/%d", tag.Key, result.Height, result.Index))
|
||||||
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))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/tendermint/state/txindex"
|
"github.com/tendermint/tendermint/state/txindex"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
db "github.com/tendermint/tmlibs/db"
|
db "github.com/tendermint/tmlibs/db"
|
||||||
"github.com/tendermint/tmlibs/pubsub/query"
|
"github.com/tendermint/tmlibs/pubsub/query"
|
||||||
)
|
)
|
||||||
@ -19,7 +20,7 @@ func TestTxIndex(t *testing.T) {
|
|||||||
indexer := NewTxIndex(db.NewMemDB())
|
indexer := NewTxIndex(db.NewMemDB())
|
||||||
|
|
||||||
tx := types.Tx("HELLO WORLD")
|
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()
|
hash := tx.Hash()
|
||||||
|
|
||||||
batch := txindex.NewBatch(1)
|
batch := txindex.NewBatch(1)
|
||||||
@ -34,7 +35,7 @@ func TestTxIndex(t *testing.T) {
|
|||||||
assert.Equal(t, txResult, loadedTxResult)
|
assert.Equal(t, txResult, loadedTxResult)
|
||||||
|
|
||||||
tx2 := types.Tx("BYE BYE WORLD")
|
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()
|
hash2 := tx2.Hash()
|
||||||
|
|
||||||
err = indexer.Index(txResult2)
|
err = indexer.Index(txResult2)
|
||||||
@ -49,10 +50,10 @@ func TestTxSearch(t *testing.T) {
|
|||||||
allowedTags := []string{"account.number", "account.owner", "account.date"}
|
allowedTags := []string{"account.number", "account.owner", "account.date"}
|
||||||
indexer := NewTxIndex(db.NewMemDB(), IndexTags(allowedTags))
|
indexer := NewTxIndex(db.NewMemDB(), IndexTags(allowedTags))
|
||||||
|
|
||||||
txResult := txResultWithTags([]*abci.KVPair{
|
txResult := txResultWithTags([]cmn.KVPair{
|
||||||
{Key: "account.number", ValueType: abci.KVPair_INT, ValueInt: 1},
|
{Key: []byte("account.number"), Value: []byte{1}},
|
||||||
{Key: "account.owner", ValueType: abci.KVPair_STRING, ValueString: "Ivan"},
|
{Key: []byte("account.owner"), Value: []byte("Ivan")},
|
||||||
{Key: "not_allowed", ValueType: abci.KVPair_STRING, ValueString: "Vlad"},
|
{Key: []byte("not_allowed"), Value: []byte("Vlad")},
|
||||||
})
|
})
|
||||||
hash := txResult.Tx.Hash()
|
hash := txResult.Tx.Hash()
|
||||||
|
|
||||||
@ -106,9 +107,9 @@ func TestTxSearchOneTxWithMultipleSameTagsButDifferentValues(t *testing.T) {
|
|||||||
allowedTags := []string{"account.number"}
|
allowedTags := []string{"account.number"}
|
||||||
indexer := NewTxIndex(db.NewMemDB(), IndexTags(allowedTags))
|
indexer := NewTxIndex(db.NewMemDB(), IndexTags(allowedTags))
|
||||||
|
|
||||||
txResult := txResultWithTags([]*abci.KVPair{
|
txResult := txResultWithTags([]cmn.KVPair{
|
||||||
{Key: "account.number", ValueType: abci.KVPair_INT, ValueInt: 1},
|
{Key: []byte("account.number"), Value: []byte{1}},
|
||||||
{Key: "account.number", ValueType: abci.KVPair_INT, ValueInt: 2},
|
{Key: []byte("account.number"), Value: []byte{2}},
|
||||||
})
|
})
|
||||||
|
|
||||||
err := indexer.Index(txResult)
|
err := indexer.Index(txResult)
|
||||||
@ -124,9 +125,9 @@ func TestTxSearchOneTxWithMultipleSameTagsButDifferentValues(t *testing.T) {
|
|||||||
func TestIndexAllTags(t *testing.T) {
|
func TestIndexAllTags(t *testing.T) {
|
||||||
indexer := NewTxIndex(db.NewMemDB(), IndexAllTags())
|
indexer := NewTxIndex(db.NewMemDB(), IndexAllTags())
|
||||||
|
|
||||||
txResult := txResultWithTags([]*abci.KVPair{
|
txResult := txResultWithTags([]cmn.KVPair{
|
||||||
abci.KVPairString("account.owner", "Ivan"),
|
cmn.KVPair{[]byte("account.owner"), []byte("Ivan")},
|
||||||
abci.KVPairInt("account.number", 1),
|
cmn.KVPair{[]byte("account.number"), []byte{1}},
|
||||||
})
|
})
|
||||||
|
|
||||||
err := indexer.Index(txResult)
|
err := indexer.Index(txResult)
|
||||||
@ -143,14 +144,14 @@ func TestIndexAllTags(t *testing.T) {
|
|||||||
assert.Equal(t, []*types.TxResult{txResult}, results)
|
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")
|
tx := types.Tx("HELLO WORLD")
|
||||||
return &types.TxResult{1, 0, tx, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: tags}}
|
return &types.TxResult{1, 0, tx, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: tags}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func benchmarkTxIndex(txsCount int, b *testing.B) {
|
func benchmarkTxIndex(txsCount int, b *testing.B) {
|
||||||
tx := types.Tx("HELLO WORLD")
|
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")
|
dir, err := ioutil.TempDir("", "tx_index_db")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -40,11 +40,11 @@ type CanonicalJSONVote struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CanonicalJSONHeartbeat struct {
|
type CanonicalJSONHeartbeat struct {
|
||||||
Height int64 `json:"height"`
|
Height int64 `json:"height"`
|
||||||
Round int `json:"round"`
|
Round int `json:"round"`
|
||||||
Sequence int `json:"sequence"`
|
Sequence int `json:"sequence"`
|
||||||
ValidatorAddress data.Bytes `json:"validator_address"`
|
ValidatorAddress Address `json:"validator_address"`
|
||||||
ValidatorIndex int `json:"validator_index"`
|
ValidatorIndex int `json:"validator_index"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
"github.com/tendermint/go-crypto"
|
"github.com/tendermint/go-crypto"
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
"github.com/tendermint/go-wire/data"
|
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,7 +15,7 @@ import (
|
|||||||
// json field tags because we always want the JSON
|
// json field tags because we always want the JSON
|
||||||
// representation to be in its canonical form.
|
// representation to be in its canonical form.
|
||||||
type Heartbeat struct {
|
type Heartbeat struct {
|
||||||
ValidatorAddress data.Bytes `json:"validator_address"`
|
ValidatorAddress Address `json:"validator_address"`
|
||||||
ValidatorIndex int `json:"validator_index"`
|
ValidatorIndex int `json:"validator_index"`
|
||||||
Height int64 `json:"height"`
|
Height int64 `json:"height"`
|
||||||
Round int `json:"round"`
|
Round int `json:"round"`
|
||||||
|
@ -38,7 +38,7 @@ func voteToStep(vote *Vote) int8 {
|
|||||||
// PrivValidator defines the functionality of a local Tendermint validator
|
// PrivValidator defines the functionality of a local Tendermint validator
|
||||||
// that signs votes, proposals, and heartbeats, and never double signs.
|
// that signs votes, proposals, and heartbeats, and never double signs.
|
||||||
type PrivValidator interface {
|
type PrivValidator interface {
|
||||||
GetAddress() data.Bytes // redundant since .PubKey().Address()
|
GetAddress() Address // redundant since .PubKey().Address()
|
||||||
GetPubKey() crypto.PubKey
|
GetPubKey() crypto.PubKey
|
||||||
|
|
||||||
SignVote(chainID string, vote *Vote) error
|
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
|
// to prevent double signing. The Signer itself can be mutated to use
|
||||||
// something besides the default, for instance a hardware signer.
|
// something besides the default, for instance a hardware signer.
|
||||||
type PrivValidatorFS struct {
|
type PrivValidatorFS struct {
|
||||||
Address data.Bytes `json:"address"`
|
Address Address `json:"address"`
|
||||||
PubKey crypto.PubKey `json:"pub_key"`
|
PubKey crypto.PubKey `json:"pub_key"`
|
||||||
LastHeight int64 `json:"last_height"`
|
LastHeight int64 `json:"last_height"`
|
||||||
LastRound int `json:"last_round"`
|
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.
|
// GetAddress returns the address of the validator.
|
||||||
// Implements PrivValidator.
|
// Implements PrivValidator.
|
||||||
func (pv *PrivValidatorFS) GetAddress() data.Bytes {
|
func (pv *PrivValidatorFS) GetAddress() Address {
|
||||||
return pv.Address
|
return pv.Address
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
crypto "github.com/tendermint/go-crypto"
|
crypto "github.com/tendermint/go-crypto"
|
||||||
"github.com/tendermint/go-wire/data"
|
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
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{
|
return &Vote{
|
||||||
ValidatorAddress: addr,
|
ValidatorAddress: addr,
|
||||||
ValidatorIndex: idx,
|
ValidatorIndex: idx,
|
||||||
|
@ -10,8 +10,8 @@ var TM2PB = tm2pb{}
|
|||||||
|
|
||||||
type tm2pb struct{}
|
type tm2pb struct{}
|
||||||
|
|
||||||
func (tm2pb) Header(header *Header) *types.Header {
|
func (tm2pb) Header(header *Header) types.Header {
|
||||||
return &types.Header{
|
return types.Header{
|
||||||
ChainID: header.ChainID,
|
ChainID: header.ChainID,
|
||||||
Height: header.Height,
|
Height: header.Height,
|
||||||
Time: header.Time.Unix(),
|
Time: header.Time.Unix(),
|
||||||
@ -37,15 +37,15 @@ func (tm2pb) PartSetHeader(partSetHeader PartSetHeader) types.PartSetHeader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tm2pb) Validator(val *Validator) *types.Validator {
|
func (tm2pb) Validator(val *Validator) types.Validator {
|
||||||
return &types.Validator{
|
return types.Validator{
|
||||||
PubKey: val.PubKey.Bytes(),
|
PubKey: val.PubKey.Bytes(),
|
||||||
Power: val.VotingPower,
|
Power: val.VotingPower,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tm2pb) Validators(vals *ValidatorSet) []*types.Validator {
|
func (tm2pb) Validators(vals *ValidatorSet) []types.Validator {
|
||||||
validators := make([]*types.Validator, len(vals.Validators))
|
validators := make([]types.Validator, len(vals.Validators))
|
||||||
for i, val := range vals.Validators {
|
for i, val := range vals.Validators {
|
||||||
validators[i] = TM2PB.Validator(val)
|
validators[i] = TM2PB.Validator(val)
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
"github.com/tendermint/go-crypto"
|
"github.com/tendermint/go-crypto"
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
"github.com/tendermint/go-wire/data"
|
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,9 +14,9 @@ import (
|
|||||||
// NOTE: The Accum is not included in Validator.Hash();
|
// NOTE: The Accum is not included in Validator.Hash();
|
||||||
// make sure to update that method if changes are made here
|
// make sure to update that method if changes are made here
|
||||||
type Validator struct {
|
type Validator struct {
|
||||||
Address data.Bytes `json:"address"`
|
Address Address `json:"address"`
|
||||||
PubKey crypto.PubKey `json:"pub_key"`
|
PubKey crypto.PubKey `json:"pub_key"`
|
||||||
VotingPower int64 `json:"voting_power"`
|
VotingPower int64 `json:"voting_power"`
|
||||||
|
|
||||||
Accum int64 `json:"accum"`
|
Accum int64 `json:"accum"`
|
||||||
}
|
}
|
||||||
@ -74,7 +73,7 @@ func (v *Validator) String() string {
|
|||||||
// It excludes the Accum value, which changes with every round.
|
// It excludes the Accum value, which changes with every round.
|
||||||
func (v *Validator) Hash() []byte {
|
func (v *Validator) Hash() []byte {
|
||||||
return wire.BinaryRipemd160(struct {
|
return wire.BinaryRipemd160(struct {
|
||||||
Address data.Bytes
|
Address Address
|
||||||
PubKey crypto.PubKey
|
PubKey crypto.PubKey
|
||||||
VotingPower int64
|
VotingPower int64
|
||||||
}{
|
}{
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
|
|
||||||
"github.com/tendermint/go-crypto"
|
"github.com/tendermint/go-crypto"
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
"github.com/tendermint/go-wire/data"
|
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
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.
|
// Represents a prevote, precommit, or commit vote from validators for consensus.
|
||||||
type Vote struct {
|
type Vote struct {
|
||||||
ValidatorAddress data.Bytes `json:"validator_address"`
|
ValidatorAddress Address `json:"validator_address"`
|
||||||
ValidatorIndex int `json:"validator_index"`
|
ValidatorIndex int `json:"validator_index"`
|
||||||
Height int64 `json:"height"`
|
Height int64 `json:"height"`
|
||||||
Round int `json:"round"`
|
Round int `json:"round"`
|
||||||
|
Reference in New Issue
Block a user