Browse Source

upgrade tendermint to v0.19.0 (#88)

* upgrade tendermint to v0.19.0

* rm test

* typo fix

* rm test
pull/1943/head
Yelong Zhang 7 years ago
committed by Anton Kaliaev
parent
commit
92102a84dc
9 changed files with 80 additions and 40 deletions
  1. +20
    -25
      tm-monitor/Gopkg.lock
  2. +8
    -4
      tm-monitor/Gopkg.toml
  3. +10
    -0
      tm-monitor/mock/eventmeter.go
  4. +5
    -2
      tm-monitor/monitor/monitor_test.go
  5. +6
    -5
      tm-monitor/monitor/node.go
  6. +6
    -3
      tm-monitor/monitor/node_test.go
  7. +12
    -0
      tm-monitor/monitor/wire.go
  8. +1
    -1
      tm-monitor/rpc.go
  9. +12
    -0
      tm-monitor/wire.go

+ 20
- 25
tm-monitor/Gopkg.lock View File

@ -106,7 +106,7 @@
branch = "master"
name = "github.com/rcrowley/go-metrics"
packages = ["."]
revision = "8732c616f52954686704c8645fe1a9d59e9df7c1"
revision = "d932a24a8ccb8fcadc993e5c6c58f93dac168294"
[[projects]]
name = "github.com/stretchr/testify"
@ -144,8 +144,8 @@
"example/kvstore",
"types"
]
revision = "46686763ba8ea595ede16530ed4a40fb38f49f94"
version = "v0.10.2"
revision = "78a8905690ef54f9d57e3b2b0ee7ad3a04ef3f1f"
version = "v0.10.3"
[[projects]]
branch = "master"
@ -158,26 +158,21 @@
revision = "d8387025d2b9d158cf4efb07e7ebf814bcce2057"
[[projects]]
name = "github.com/tendermint/go-crypto"
name = "github.com/tendermint/go-amino"
packages = ["."]
revision = "c3e19f3ea26f5c3357e0bcbb799b0761ef923755"
version = "v0.5.0"
revision = "42246108ff925a457fb709475070a03dfd3e2b5c"
version = "0.9.6"
[[projects]]
name = "github.com/tendermint/go-wire"
packages = [
".",
"data"
]
revision = "fa721242b042ecd4c6ed1a934ee740db4f74e45c"
source = "github.com/tendermint/go-amino"
version = "v0.7.3"
name = "github.com/tendermint/go-crypto"
packages = ["."]
revision = "915416979bf70efa4bcbf1c6cd5d64c5fff9fc19"
version = "v0.6.2"
[[projects]]
name = "github.com/tendermint/tendermint"
packages = [
"config",
"consensus/types",
"p2p",
"p2p/conn",
"p2p/upnp",
@ -187,11 +182,10 @@
"rpc/lib/server",
"rpc/lib/types",
"state",
"types",
"wire"
"types"
]
revision = "6f9956990c444d53f62f2a3905ed410cfe9afe77"
version = "v0.17.1"
revision = "d0beaba7e8a5652506a34b5fab299cc2dc274c02"
version = "v0.19.0"
[[projects]]
name = "github.com/tendermint/tmlibs"
@ -205,8 +199,8 @@
"pubsub",
"pubsub/query"
]
revision = "24da7009c3d8c019b40ba4287495749e3160caca"
version = "v0.7.1"
revision = "737154202faf75c70437f59ba5303f2eb09f5636"
version = "0.8.2-rc1"
[[projects]]
branch = "master"
@ -221,13 +215,14 @@
"ripemd160",
"salsa20/salsa"
]
revision = "12892e8c234f4fe6f6803f052061de9057903bb2"
revision = "d6449816ce06963d9d136eee5a56fca5b0616e7e"
[[projects]]
branch = "master"
name = "golang.org/x/net"
packages = [
"context",
"http/httpguts",
"http2",
"http2/hpack",
"idna",
@ -235,7 +230,7 @@
"lex/httplex",
"trace"
]
revision = "b68f30494add4df6bd8ef5e82803f308e7f7c59c"
revision = "8d16fa6dc9a85c1cd3ed24ad08ff21cf94f10888"
[[projects]]
name = "golang.org/x/text"
@ -262,7 +257,7 @@
branch = "master"
name = "google.golang.org/genproto"
packages = ["googleapis/rpc/status"]
revision = "ab0870e398d5dd054b868c0db1481ab029b9a9f2"
revision = "7fd901a49ba6a7f87732eb344f6e3c5b19d1b200"
[[projects]]
name = "google.golang.org/grpc"
@ -291,6 +286,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "55767d07c0e1fddf98d5fa04eb583bb6e32d48cd5582f8c141ed79602a5bc75a"
inputs-digest = "c445a659655eae3fbc1355e7d3431aa7f4b78f2f052ecba723cf8dcefd6350c4"
solver-name = "gps-cdcl"
solver-version = 1

+ 8
- 4
tm-monitor/Gopkg.toml View File

@ -39,15 +39,19 @@
[[constraint]]
name = "github.com/tendermint/go-crypto"
version = "0.5.0"
version = "~0.6.2"
[[constraint]]
name = "github.com/tendermint/tendermint"
version = "0.17.1"
name = "github.com/tendermint/go-amino"
version = "~0.9.6"
[[constraint]]
name = "github.com/tendermint/tendermint"
version = "0.19.0"
[[override]]
name = "github.com/tendermint/tmlibs"
version = "0.7.1"
version = "~0.8.2-rc1"
[prune]
go-tests = true


+ 10
- 0
tm-monitor/mock/eventmeter.go View File

@ -6,6 +6,7 @@ import (
"github.com/tendermint/tmlibs/log"
em "github.com/tendermint/tools/tm-monitor/eventmeter"
"github.com/tendermint/go-amino"
)
type EventMeter struct {
@ -43,6 +44,7 @@ func (e *EventMeter) Call(callback string, args ...interface{}) {
type RpcClient struct {
Stubs map[string]interface{}
cdc *amino.Codec
}
func (c *RpcClient) Call(method string, params map[string]interface{}, result interface{}) (interface{}, error) {
@ -57,3 +59,11 @@ func (c *RpcClient) Call(method string, params map[string]interface{}, result in
return s, nil
}
func (c *RpcClient) Codec() *amino.Codec {
return c.cdc
}
func (c *RpcClient) SetCodec(cdc *amino.Codec) {
c.cdc = cdc
}

+ 5
- 2
tm-monitor/monitor/monitor_test.go View File

@ -12,6 +12,7 @@ import (
tmtypes "github.com/tendermint/tendermint/types"
mock "github.com/tendermint/tools/tm-monitor/mock"
monitor "github.com/tendermint/tools/tm-monitor/monitor"
"github.com/tendermint/go-amino"
)
func TestMonitorUpdatesNumberOfValidators(t *testing.T) {
@ -61,8 +62,10 @@ func createValidatorNode(t *testing.T) (n *monitor.Node, emMock *mock.EventMeter
stubs := make(map[string]interface{})
pubKey := crypto.GenPrivKeyEd25519().PubKey()
stubs["validators"] = ctypes.ResultValidators{BlockHeight: blockHeight, Validators: []*tmtypes.Validator{tmtypes.NewValidator(pubKey, 0)}}
stubs["status"] = ctypes.ResultStatus{PubKey: pubKey}
rpcClientMock := &mock.RpcClient{stubs}
stubs["status"] = ctypes.ResultStatus{ValidatorInfo: ctypes.ValidatorInfo{PubKey: pubKey}}
cdc := amino.NewCodec()
rpcClientMock := &mock.RpcClient{Stubs: stubs}
rpcClientMock.SetCodec(cdc)
n = monitor.NewNodeWithEventMeterAndRpcClient("tcp://127.0.0.1:46657", emMock, rpcClientMock)
return


+ 6
- 5
tm-monitor/monitor/node.go View File

@ -48,6 +48,7 @@ type Node struct {
func NewNode(rpcAddr string, options ...func(*Node)) *Node {
em := em.NewEventMeter(rpcAddr, UnmarshalEvent)
rpcClient := rpc_client.NewURIClient(rpcAddr) // HTTP client by default
rpcClient.SetCodec(cdc)
return NewNodeWithEventMeterAndRpcClient(rpcAddr, em, rpcClient, options...)
}
@ -126,7 +127,7 @@ func (n *Node) Stop() {
// implements eventmeter.EventCallbackFunc
func newBlockCallback(n *Node) em.EventCallbackFunc {
return func(metric *em.EventMetric, data interface{}) {
block := data.(tmtypes.TMEventData).Unwrap().(tmtypes.EventDataNewBlockHeader).Header
block := data.(tmtypes.TMEventData).(tmtypes.EventDataNewBlockHeader).Header
n.Height = block.Height
n.logger.Info("new block", "height", block.Height, "numTxs", block.NumTxs)
@ -226,16 +227,16 @@ func (n *Node) checkIsValidator() {
}
func (n *Node) getPubKey() (crypto.PubKey, error) {
if !n.pubKey.Empty() {
if n.pubKey != nil {
return n.pubKey, nil
}
status := new(ctypes.ResultStatus)
_, err := n.rpcClient.Call("status", nil, status)
if err != nil {
return crypto.PubKey{}, err
return nil, err
}
n.pubKey = status.PubKey
n.pubKey = status.ValidatorInfo.PubKey
return n.pubKey, nil
}
@ -252,7 +253,7 @@ type eventMeter interface {
// UnmarshalEvent unmarshals a json event
func UnmarshalEvent(b json.RawMessage) (string, events.EventData, error) {
event := new(ctypes.ResultEvent)
if err := json.Unmarshal(b, event); err != nil {
if err := cdc.UnmarshalJSON(b, event); err != nil {
return "", nil, err
}
return event.Query, event.Data, nil


+ 6
- 3
tm-monitor/monitor/node_test.go View File

@ -12,6 +12,7 @@ import (
em "github.com/tendermint/tools/tm-monitor/eventmeter"
mock "github.com/tendermint/tools/tm-monitor/mock"
monitor "github.com/tendermint/tools/tm-monitor/monitor"
"github.com/tendermint/go-amino"
)
const (
@ -33,7 +34,7 @@ func TestNodeNewBlockReceived(t *testing.T) {
n.SendBlocksTo(blockCh)
blockHeader := &tmtypes.Header{Height: 5}
emMock.Call("eventCallback", &em.EventMetric{}, tmtypes.TMEventData{tmtypes.EventDataNewBlockHeader{blockHeader}})
emMock.Call("eventCallback", &em.EventMetric{}, tmtypes.EventDataNewBlockHeader{blockHeader})
assert.Equal(t, int64(5), n.Height)
assert.Equal(t, *blockHeader, <-blockCh)
@ -79,8 +80,10 @@ func startValidatorNode(t *testing.T) (n *monitor.Node, emMock *mock.EventMeter)
stubs := make(map[string]interface{})
pubKey := crypto.GenPrivKeyEd25519().PubKey()
stubs["validators"] = ctypes.ResultValidators{BlockHeight: blockHeight, Validators: []*tmtypes.Validator{tmtypes.NewValidator(pubKey, 0)}}
stubs["status"] = ctypes.ResultStatus{PubKey: pubKey}
rpcClientMock := &mock.RpcClient{stubs}
stubs["status"] = ctypes.ResultStatus{ValidatorInfo: ctypes.ValidatorInfo{PubKey: pubKey}}
cdc := amino.NewCodec()
rpcClientMock := &mock.RpcClient{Stubs: stubs}
rpcClientMock.SetCodec(cdc)
n = monitor.NewNodeWithEventMeterAndRpcClient("tcp://127.0.0.1:46657", emMock, rpcClientMock)


+ 12
- 0
tm-monitor/monitor/wire.go View File

@ -0,0 +1,12 @@
package monitor
import (
amino "github.com/tendermint/go-amino"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
)
var cdc = amino.NewCodec()
func init() {
ctypes.RegisterAmino(cdc)
}

+ 1
- 1
tm-monitor/rpc.go View File

@ -15,7 +15,7 @@ func startRPC(listenAddr string, m *monitor.Monitor, logger log.Logger) {
mux := http.NewServeMux()
wm := rpc.NewWebsocketManager(routes, nil)
mux.HandleFunc("/websocket", wm.WebsocketHandler)
rpc.RegisterRPCFuncs(mux, routes, logger)
rpc.RegisterRPCFuncs(mux, routes, cdc, logger)
if _, err := rpc.StartHTTPServer(listenAddr, mux, logger); err != nil {
panic(err)
}


+ 12
- 0
tm-monitor/wire.go View File

@ -0,0 +1,12 @@
package main
import (
amino "github.com/tendermint/go-amino"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
)
var cdc = amino.NewCodec()
func init() {
ctypes.RegisterAmino(cdc)
}

Loading…
Cancel
Save