From 8311f5c6116efe3aa6157582104c664c887534f7 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Fri, 22 Sep 2017 11:42:40 -0400 Subject: [PATCH] abci.Info takes a struct; less merkleeyes --- consensus/mempool_test.go | 2 +- consensus/replay.go | 5 +++-- consensus/replay_test.go | 7 ++++--- glide.lock | 15 +++++++-------- glide.yaml | 10 ++-------- proxy/app_conn.go | 20 ++++++++++---------- proxy/app_conn_test.go | 10 +++++----- rpc/client/event_test.go | 15 ++++++++++++--- rpc/client/main_test.go | 6 +++--- rpc/client/mock/abci.go | 3 ++- rpc/client/rpc_test.go | 11 +++++------ rpc/core/abci.go | 3 ++- state/execution.go | 5 ++++- test/p2p/data/data/init.sh | 7 ------- 14 files changed, 60 insertions(+), 59 deletions(-) delete mode 100755 test/p2p/data/data/init.sh diff --git a/consensus/mempool_test.go b/consensus/mempool_test.go index 0f726b39e..f17d19f52 100644 --- a/consensus/mempool_test.go +++ b/consensus/mempool_test.go @@ -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)} } diff --git a/consensus/replay.go b/consensus/replay.go index 2104ffd5e..c5cb42191 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -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 diff --git a/consensus/replay_test.go b/consensus/replay_test.go index 765434677..c478a0958 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -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 diff --git a/glide.lock b/glide.lock index 90a648419..20d7166c3 100644 --- a/glide.lock +++ b/glide.lock @@ -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 diff --git a/glide.yaml b/glide.yaml index 0a57ff599..7b924aacc 100644 --- a/glide.yaml +++ b/glide.yaml @@ -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: diff --git a/proxy/app_conn.go b/proxy/app_conn.go index 8b007737c..9121e8db8 100644 --- a/proxy/app_conn.go +++ b/proxy/app_conn.go @@ -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) { diff --git a/proxy/app_conn_test.go b/proxy/app_conn_test.go index 159e0b3e1..0c700140b 100644 --- a/proxy/app_conn_test.go +++ b/proxy/app_conn_test.go @@ -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) } diff --git a/rpc/client/event_test.go b/rpc/client/event_test.go index ad5522e49..a10021821 100644 --- a/rpc/client/event_test.go +++ b/rpc/client/event_test.go @@ -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 diff --git a/rpc/client/main_test.go b/rpc/client/main_test.go index 5ec911e5d..7c5acd390 100644 --- a/rpc/client/main_test.go +++ b/rpc/client/main_test.go @@ -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() diff --git a/rpc/client/mock/abci.go b/rpc/client/mock/abci.go index 71fa90b2a..db3fa4f1d 100644 --- a/rpc/client/mock/abci.go +++ b/rpc/client/mock/abci.go @@ -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) { diff --git a/rpc/client/rpc_test.go b/rpc/client/rpc_test.go index 33cd4b432..77de9f6e8 100644 --- a/rpc/client/rpc_test.go +++ b/rpc/client/rpc_test.go @@ -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) diff --git a/rpc/core/abci.go b/rpc/core/abci.go index 21508caf7..06275a9e3 100644 --- a/rpc/core/abci.go +++ b/rpc/core/abci.go @@ -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 } diff --git a/state/execution.go b/state/execution.go index 1785f6025..b917bfbe8 100644 --- a/state/execution.go +++ b/state/execution.go @@ -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 diff --git a/test/p2p/data/data/init.sh b/test/p2p/data/data/init.sh deleted file mode 100755 index 41122a547..000000000 --- a/test/p2p/data/data/init.sh +++ /dev/null @@ -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" \ No newline at end of file