Browse Source

abci.Info takes a struct; less merkleeyes

pull/675/head
Ethan Buchman 7 years ago
parent
commit
8311f5c611
14 changed files with 60 additions and 59 deletions
  1. +1
    -1
      consensus/mempool_test.go
  2. +3
    -2
      consensus/replay.go
  3. +4
    -3
      consensus/replay_test.go
  4. +7
    -8
      glide.lock
  5. +2
    -8
      glide.yaml
  6. +10
    -10
      proxy/app_conn.go
  7. +5
    -5
      proxy/app_conn_test.go
  8. +12
    -3
      rpc/client/event_test.go
  9. +3
    -3
      rpc/client/main_test.go
  10. +2
    -1
      rpc/client/mock/abci.go
  11. +5
    -6
      rpc/client/rpc_test.go
  12. +2
    -1
      rpc/core/abci.go
  13. +4
    -1
      state/execution.go
  14. +0
    -7
      test/p2p/data/data/init.sh

+ 1
- 1
consensus/mempool_test.go View File

@ -183,7 +183,7 @@ func NewCounterApplication() *CounterApplication {
return &CounterApplication{}
}
func (app *CounterApplication) Info() abci.ResponseInfo {
func (app *CounterApplication) Info(req abci.RequestInfo) abci.ResponseInfo {
return abci.ResponseInfo{Data: Fmt("txs:%v", app.txCount)}
}


+ 3
- 2
consensus/replay.go View File

@ -19,6 +19,7 @@ import (
"github.com/tendermint/tendermint/proxy"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
"github.com/tendermint/tendermint/version"
)
// Functionality to replay blocks and messages on recovery from a crash.
@ -199,7 +200,7 @@ func (h *Handshaker) NBlocks() int {
// TODO: retry the handshake/replay if it fails ?
func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error {
// handshake is done via info request on the query conn
res, err := proxyApp.Query().InfoSync()
res, err := proxyApp.Query().InfoSync(abci.RequestInfo{version.Version})
if err != nil {
return errors.New(cmn.Fmt("Error calling Info: %v", err))
}
@ -235,7 +236,7 @@ func (h *Handshaker) ReplayBlocks(appHash []byte, appBlockHeight int, proxyApp p
// If appBlockHeight == 0 it means that we are at genesis and hence should send InitChain
if appBlockHeight == 0 {
validators := types.TM2PB.Validators(h.state.Validators)
proxyApp.Consensus().InitChainSync(validators)
proxyApp.Consensus().InitChainSync(abci.RequestInitChain{validators})
}
// First handle edge cases and constraints on the storeBlockHeight


+ 4
- 3
consensus/replay_test.go View File

@ -13,6 +13,7 @@ import (
"time"
"github.com/tendermint/abci/example/dummy"
abci "github.com/tendermint/abci/types"
crypto "github.com/tendermint/go-crypto"
wire "github.com/tendermint/go-wire"
cmn "github.com/tendermint/tmlibs/common"
@ -358,7 +359,7 @@ func testHandshakeReplay(t *testing.T, nBlocks int, mode uint) {
}
// get the latest app hash from the app
res, err := proxyApp.Query().InfoSync()
res, err := proxyApp.Query().InfoSync(abci.RequestInfo{""})
if err != nil {
t.Fatal(err)
}
@ -396,7 +397,7 @@ func buildAppStateFromChain(proxyApp proxy.AppConns,
}
validators := types.TM2PB.Validators(state.Validators)
proxyApp.Consensus().InitChainSync(validators)
proxyApp.Consensus().InitChainSync(abci.RequestInitChain{validators})
defer proxyApp.Stop()
switch mode {
@ -430,7 +431,7 @@ func buildTMStateFromChain(config *cfg.Config, state *sm.State, chain []*types.B
defer proxyApp.Stop()
validators := types.TM2PB.Validators(state.Validators)
proxyApp.Consensus().InitChainSync(validators)
proxyApp.Consensus().InitChainSync(abci.RequestInitChain{validators})
var latestAppHash []byte


+ 7
- 8
glide.lock View File

@ -1,5 +1,5 @@
hash: 06ac555971ac41296cf6c869dfdf659ae911652d419e1a8c841aa791ff990556
updated: 2017-09-22T10:13:57.706322194-04:00
hash: b55559e3306e64b9cbd25456874e392ee3372778beb081190956864073aa8b88
updated: 2017-09-22T11:30:04.200558244-04:00
imports:
- name: github.com/btcsuite/btcd
version: b8df516b4b267acf2de46be593a9d948d1d2c420
@ -99,7 +99,7 @@ imports:
- leveldb/table
- leveldb/util
- name: github.com/tendermint/abci
version: 864d1f80b36b440bde030a5c18d8ac3aa8c2949d
version: 191c4b6d176169ffc7f9972d490fa362a3b7d940
subpackages:
- client
- example/counter
@ -112,19 +112,16 @@ imports:
- edwards25519
- extra25519
- name: github.com/tendermint/go-crypto
version: 95b7c9e09c49b91bfbb71bb63dd514eb55450f16
version: 311e8c1bf00fa5868daad4f8ea56dcad539182c0
- name: github.com/tendermint/go-wire
version: 5f88da3dbc1a72844e6dfaf274ce87f851d488eb
subpackages:
- data
- data/base58
- name: github.com/tendermint/merkleeyes
version: 102aaf5a8ffda1846413fb22805a94def2045b9f
version: 2f6e5d31e7a35045d8d0a5895cb1fec33dd4d32b
subpackages:
- app
- client
- iavl
- testutil
- name: github.com/tendermint/tmlibs
version: 2130c329eb56aca8509ee1fec40d766f6541d8e7
subpackages:
@ -209,3 +206,5 @@ testImports:
subpackages:
- assert
- require
- name: github.com/tendermint/iavl
version: 8fa7ec23377d7af91fa84b83a16abd24cc3acc71

+ 2
- 8
glide.yaml View File

@ -14,13 +14,13 @@ import:
- package: github.com/spf13/cobra
- package: github.com/spf13/viper
- package: github.com/tendermint/abci
version: v0.5.0
version: ~0.6.0
subpackages:
- client
- example/dummy
- types
- package: github.com/tendermint/go-crypto
version: ~0.2.2
version: ~0.3.0
- package: github.com/tendermint/go-wire
version: ~0.6.2
subpackages:
@ -46,12 +46,6 @@ import:
subpackages:
- context
- package: google.golang.org/grpc
- package: github.com/tendermint/merkleeyes
version: ~0.2.4
subpackages:
- app
- iavl
- testutil
testImport:
- package: github.com/go-kit/kit
subpackages:


+ 10
- 10
proxy/app_conn.go View File

@ -12,9 +12,9 @@ type AppConnConsensus interface {
SetResponseCallback(abcicli.Callback)
Error() error
InitChainSync(validators []*types.Validator) (err error)
InitChainSync(types.RequestInitChain) (err error)
BeginBlockSync(hash []byte, header *types.Header) (err error)
BeginBlockSync(types.RequestBeginBlock) (err error)
DeliverTxAsync(tx []byte) *abcicli.ReqRes
EndBlockSync(height uint64) (types.ResponseEndBlock, error)
CommitSync() (res types.Result)
@ -34,8 +34,8 @@ type AppConnQuery interface {
Error() error
EchoSync(string) (res types.Result)
InfoSync() (resInfo types.ResponseInfo, err error)
QuerySync(reqQuery types.RequestQuery) (resQuery types.ResponseQuery, err error)
InfoSync(types.RequestInfo) (types.ResponseInfo, error)
QuerySync(types.RequestQuery) (types.ResponseQuery, error)
// SetOptionSync(key string, value string) (res types.Result)
}
@ -61,12 +61,12 @@ func (app *appConnConsensus) Error() error {
return app.appConn.Error()
}
func (app *appConnConsensus) InitChainSync(validators []*types.Validator) (err error) {
return app.appConn.InitChainSync(validators)
func (app *appConnConsensus) InitChainSync(req types.RequestInitChain) (err error) {
return app.appConn.InitChainSync(req)
}
func (app *appConnConsensus) BeginBlockSync(hash []byte, header *types.Header) (err error) {
return app.appConn.BeginBlockSync(hash, header)
func (app *appConnConsensus) BeginBlockSync(req types.RequestBeginBlock) (err error) {
return app.appConn.BeginBlockSync(req)
}
func (app *appConnConsensus) DeliverTxAsync(tx []byte) *abcicli.ReqRes {
@ -135,8 +135,8 @@ func (app *appConnQuery) EchoSync(msg string) (res types.Result) {
return app.appConn.EchoSync(msg)
}
func (app *appConnQuery) InfoSync() (types.ResponseInfo, error) {
return app.appConn.InfoSync()
func (app *appConnQuery) InfoSync(req types.RequestInfo) (types.ResponseInfo, error) {
return app.appConn.InfoSync(req)
}
func (app *appConnQuery) QuerySync(reqQuery types.RequestQuery) (types.ResponseQuery, error) {


+ 5
- 5
proxy/app_conn_test.go View File

@ -17,7 +17,7 @@ import (
type AppConnTest interface {
EchoAsync(string) *abcicli.ReqRes
FlushSync() error
InfoSync() (types.ResponseInfo, error)
InfoSync(types.RequestInfo) (types.ResponseInfo, error)
}
type appConnTest struct {
@ -36,8 +36,8 @@ func (app *appConnTest) FlushSync() error {
return app.appConn.FlushSync()
}
func (app *appConnTest) InfoSync() (types.ResponseInfo, error) {
return app.appConn.InfoSync()
func (app *appConnTest) InfoSync(req types.RequestInfo) (types.ResponseInfo, error) {
return app.appConn.InfoSync(req)
}
//----------------------------------------
@ -109,7 +109,7 @@ func BenchmarkEcho(b *testing.B) {
proxy.FlushSync()
b.StopTimer()
// info := proxy.InfoSync()
// info := proxy.InfoSync(types.RequestInfo{""})
//b.Log("N: ", b.N, info)
}
@ -138,7 +138,7 @@ func TestInfo(t *testing.T) {
proxy := NewAppConnTest(cli)
t.Log("Connected")
resInfo, err := proxy.InfoSync()
resInfo, err := proxy.InfoSync(types.RequestInfo{""})
if err != nil {
t.Errorf("Unexpected error: %v", err)
}


+ 12
- 3
rpc/client/event_test.go View File

@ -5,11 +5,20 @@ import (
"time"
"github.com/stretchr/testify/require"
merktest "github.com/tendermint/merkleeyes/testutil"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/types"
)
// MakeTxKV returns a text transaction, allong with expected key, value pair
func MakeTxKV() ([]byte, []byte, []byte) {
k := []byte(cmn.RandStr(8))
v := []byte(cmn.RandStr(8))
return k, v, append(k, append([]byte("="), v...)...)
}
func TestHeaderEvents(t *testing.T) {
require := require.New(t)
for i, c := range GetClients() {
@ -76,7 +85,7 @@ func TestTxEventsSentWithBroadcastTxAsync(t *testing.T) {
}
// make the tx
_, _, tx := merktest.MakeTxKV()
_, _, tx := MakeTxKV()
evtTyp := types.EventStringTx(types.Tx(tx))
// send async
@ -109,7 +118,7 @@ func TestTxEventsSentWithBroadcastTxSync(t *testing.T) {
}
// make the tx
_, _, tx := merktest.MakeTxKV()
_, _, tx := MakeTxKV()
evtTyp := types.EventStringTx(types.Tx(tx))
// send async


+ 3
- 3
rpc/client/main_test.go View File

@ -4,7 +4,7 @@ import (
"os"
"testing"
meapp "github.com/tendermint/merkleeyes/app"
"github.com/tendermint/abci/example/dummy"
nm "github.com/tendermint/tendermint/node"
rpctest "github.com/tendermint/tendermint/rpc/test"
)
@ -12,8 +12,8 @@ import (
var node *nm.Node
func TestMain(m *testing.M) {
// start a tendermint node (and merkleeyes) in the background to test against
app := meapp.NewMerkleEyesApp("", 100)
// start a tendermint node (and dummy) in the background to test against
app := dummy.NewDummyApplication()
node = rpctest.StartTendermint(app)
code := m.Run()


+ 2
- 1
rpc/client/mock/abci.go View File

@ -6,6 +6,7 @@ import (
"github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types"
"github.com/tendermint/tendermint/version"
)
// ABCIApp will send all abci related request to the named app,
@ -20,7 +21,7 @@ func (a ABCIApp) _assertABCIClient() client.ABCIClient {
}
func (a ABCIApp) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
return &ctypes.ResultABCIInfo{a.App.Info()}, nil
return &ctypes.ResultABCIInfo{a.App.Info(abci.RequestInfo{version.Version})}, nil
}
func (a ABCIApp) ABCIQuery(path string, data data.Bytes, prove bool) (*ctypes.ResultABCIQuery, error) {


+ 5
- 6
rpc/client/rpc_test.go View File

@ -7,7 +7,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/merkleeyes/iavl"
merktest "github.com/tendermint/merkleeyes/testutil"
"github.com/tendermint/tendermint/rpc/client"
rpctest "github.com/tendermint/tendermint/rpc/test"
"github.com/tendermint/tendermint/types"
@ -49,7 +48,7 @@ func TestInfo(t *testing.T) {
require.Nil(t, err, "%d: %+v", i, err)
// TODO: this is not correct - fix merkleeyes!
// assert.EqualValues(t, status.LatestBlockHeight, info.Response.LastBlockHeight)
assert.True(t, strings.HasPrefix(info.Response.Data, "size"))
assert.True(t, strings.Contains(info.Response.Data, "size"))
}
}
@ -115,7 +114,7 @@ func TestAppCalls(t *testing.T) {
assert.NotNil(err) // no block yet
// write something
k, v, tx := merktest.MakeTxKV()
k, v, tx := MakeTxKV()
bres, err := c.BroadcastTxCommit(tx)
require.Nil(err, "%d: %+v", i, err)
require.True(bres.DeliverTx.Code.IsOK())
@ -193,7 +192,7 @@ func TestBroadcastTxSync(t *testing.T) {
initMempoolSize := mempool.Size()
for i, c := range GetClients() {
_, _, tx := merktest.MakeTxKV()
_, _, tx := MakeTxKV()
bres, err := c.BroadcastTxSync(tx)
require.Nil(err, "%d: %+v", i, err)
require.True(bres.Code.IsOK())
@ -211,7 +210,7 @@ func TestBroadcastTxCommit(t *testing.T) {
mempool := node.MempoolReactor().Mempool
for i, c := range GetClients() {
_, _, tx := merktest.MakeTxKV()
_, _, tx := MakeTxKV()
bres, err := c.BroadcastTxCommit(tx)
require.Nil(err, "%d: %+v", i, err)
require.True(bres.CheckTx.Code.IsOK())
@ -226,7 +225,7 @@ func TestTx(t *testing.T) {
// first we broadcast a tx
c := getHTTPClient()
_, _, tx := merktest.MakeTxKV()
_, _, tx := MakeTxKV()
bres, err := c.BroadcastTxCommit(tx)
require.Nil(err, "%+v", err)


+ 2
- 1
rpc/core/abci.go View File

@ -4,6 +4,7 @@ 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"
)
// Query the application for some information.
@ -86,7 +87,7 @@ func ABCIQuery(path string, data data.Bytes, prove bool) (*ctypes.ResultABCIQuer
// }
// ```
func ABCIInfo() (*ctypes.ResultABCIInfo, error) {
resInfo, err := proxyAppQuery.InfoSync()
resInfo, err := proxyAppQuery.InfoSync(abci.RequestInfo{version.Version})
if err != nil {
return nil, err
}


+ 4
- 1
state/execution.go View File

@ -83,7 +83,10 @@ func execBlockOnProxyApp(eventCache types.Fireable, proxyAppConn proxy.AppConnCo
proxyAppConn.SetResponseCallback(proxyCb)
// Begin block
err := proxyAppConn.BeginBlockSync(block.Hash(), types.TM2PB.Header(block.Header))
err := proxyAppConn.BeginBlockSync(abci.RequestBeginBlock{
block.Hash(),
types.TM2PB.Header(block.Header),
})
if err != nil {
logger.Error("Error in proxyAppConn.BeginBlock", "err", err)
return nil, err


+ 0
- 7
test/p2p/data/data/init.sh View File

@ -1,7 +0,0 @@
#! /bin/bash
# This is a sample bash script for MerkleEyes.
# NOTE: mintnet expects data.sock to be created
go get github.com/tendermint/merkleeyes/cmd/merkleeyes
merkleeyes server --address="unix:///data/tendermint/data/data.sock"

Loading…
Cancel
Save