From 6ae687d3c7419ee60976c623ddf150d454bf95b8 Mon Sep 17 00:00:00 2001 From: tycho garen Date: Fri, 17 Sep 2021 09:10:20 -0400 Subject: [PATCH] move client creator constructors --- docs/tutorials/go-built-in.md | 6 +- internal/blocksync/v0/reactor_test.go | 3 +- internal/blocksync/v2/reactor_test.go | 333 +++++++++++----------- internal/consensus/replay_stubs.go | 3 +- internal/consensus/replay_test.go | 11 +- internal/consensus/wal_generator.go | 3 +- internal/mempool/v0/bench_test.go | 10 +- internal/mempool/v0/cache_test.go | 4 +- internal/mempool/v0/clist_mempool_test.go | 21 +- internal/mempool/v0/reactor_test.go | 4 +- internal/mempool/v1/mempool_test.go | 4 +- internal/proxy/app_conn_test.go | 6 +- node/node_test.go | 8 +- rpc/test/helpers.go | 4 +- state/execution_test.go | 11 +- state/helpers_test.go | 3 +- test/e2e/app/main.go | 4 +- test/fuzz/mempool/v0/checktx.go | 4 +- test/fuzz/mempool/v1/checktx.go | 4 +- 19 files changed, 226 insertions(+), 220 deletions(-) diff --git a/docs/tutorials/go-built-in.md b/docs/tutorials/go-built-in.md index e94fe171e..befcef778 100644 --- a/docs/tutorials/go-built-in.md +++ b/docs/tutorials/go-built-in.md @@ -430,7 +430,7 @@ func newTendermint(app abci.Application, configFile string) (*nm.Node, error) { config, pv, nodeKey, - proxy.NewLocalClientCreator(app), + abcicli.NewLocalClientCreator(app), nm.DefaultGenesisDocProviderFunc(config), nm.DefaultDBProvider, nm.DefaultMetricsProvider(config.Instrumentation), @@ -482,7 +482,7 @@ node, err := nm.NewNode( config, pv, nodeKey, - proxy.NewLocalClientCreator(app), + abcicli.NewLocalClientCreator(app), nm.DefaultGenesisDocProviderFunc(config), nm.DefaultDBProvider, nm.DefaultMetricsProvider(config.Instrumentation), @@ -495,7 +495,7 @@ if err != nil { `NewNode` requires a few things including a configuration file, a private validator, a node key and a few others in order to construct the full node. -Note we use `proxy.NewLocalClientCreator` here to create a local client instead +Note we use `abcicli.NewLocalClientCreator` here to create a local client instead of one communicating through a socket or gRPC. [viper](https://github.com/spf13/viper) is being used for reading the config, diff --git a/internal/blocksync/v0/reactor_test.go b/internal/blocksync/v0/reactor_test.go index 4ce4a3d84..64ee7b702 100644 --- a/internal/blocksync/v0/reactor_test.go +++ b/internal/blocksync/v0/reactor_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + abcicli "github.com/tendermint/tendermint/abci/client" abci "github.com/tendermint/tendermint/abci/types" cfg "github.com/tendermint/tendermint/config" cons "github.com/tendermint/tendermint/internal/consensus" @@ -97,7 +98,7 @@ func (rts *reactorTestSuite) addNode(t *testing.T, t.Helper() rts.nodes = append(rts.nodes, nodeID) - rts.app[nodeID] = proxy.NewAppConns(proxy.NewLocalClientCreator(&abci.BaseApplication{})) + rts.app[nodeID] = proxy.NewAppConns(abcicli.NewLocalClientCreator(&abci.BaseApplication{})) require.NoError(t, rts.app[nodeID].Start()) blockDB := dbm.NewMemDB() diff --git a/internal/blocksync/v2/reactor_test.go b/internal/blocksync/v2/reactor_test.go index 8f7182d87..62a9c07b2 100644 --- a/internal/blocksync/v2/reactor_test.go +++ b/internal/blocksync/v2/reactor_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/require" dbm "github.com/tendermint/tm-db" + abcicli "github.com/tendermint/tendermint/abci/client" abci "github.com/tendermint/tendermint/abci/types" cfg "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/internal/blocksync/v2/internal/behavior" @@ -163,7 +164,7 @@ func newTestReactor(t *testing.T, p testReactorParams) *BlockchainReactor { appl = &mockBlockApplier{} } else { app := &testApp{} - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(cc) err := proxyApp.Start() require.NoError(t, err) @@ -187,176 +188,176 @@ func newTestReactor(t *testing.T, p testReactorParams) *BlockchainReactor { // future improvement in [#4482](https://github.com/tendermint/tendermint/issues/4482). // func TestReactorTerminationScenarios(t *testing.T) { -// config := cfg.ResetTestRoot("blockchain_reactor_v2_test") -// defer os.RemoveAll(config.RootDir) -// genDoc, privVals := randGenesisDoc(config.ChainID(), 1, false, 30) -// refStore, _, _ := newReactorStore(genDoc, privVals, 20) +// config := cfg.ResetTestRoot("blockchain_reactor_v2_test") +// defer os.RemoveAll(config.RootDir) +// genDoc, privVals := randGenesisDoc(config.ChainID(), 1, false, 30) +// refStore, _, _ := newReactorStore(genDoc, privVals, 20) -// params := testReactorParams{ -// logger: log.TestingLogger(), -// genDoc: genDoc, -// privVals: privVals, -// startHeight: 10, -// bufferSize: 100, -// mockA: true, -// } +// params := testReactorParams{ +// logger: log.TestingLogger(), +// genDoc: genDoc, +// privVals: privVals, +// startHeight: 10, +// bufferSize: 100, +// mockA: true, +// } -// type testEvent struct { -// evType string -// peer string -// height int64 -// } +// type testEvent struct { +// evType string +// peer string +// height int64 +// } -// tests := []struct { -// name string -// params testReactorParams -// msgs []testEvent -// }{ -// { -// name: "simple termination on max peer height - one peer", -// params: params, -// msgs: []testEvent{ -// {evType: "AddPeer", peer: "P1"}, -// {evType: "ReceiveS", peer: "P1", height: 13}, -// {evType: "BlockReq"}, -// {evType: "ReceiveB", peer: "P1", height: 11}, -// {evType: "BlockReq"}, -// {evType: "BlockReq"}, -// {evType: "ReceiveB", peer: "P1", height: 12}, -// {evType: "Process"}, -// {evType: "ReceiveB", peer: "P1", height: 13}, -// {evType: "Process"}, -// }, -// }, -// { -// name: "simple termination on max peer height - two peers", -// params: params, -// msgs: []testEvent{ -// {evType: "AddPeer", peer: "P1"}, -// {evType: "AddPeer", peer: "P2"}, -// {evType: "ReceiveS", peer: "P1", height: 13}, -// {evType: "ReceiveS", peer: "P2", height: 15}, -// {evType: "BlockReq"}, -// {evType: "BlockReq"}, -// {evType: "ReceiveB", peer: "P1", height: 11}, -// {evType: "ReceiveB", peer: "P2", height: 12}, -// {evType: "Process"}, -// {evType: "BlockReq"}, -// {evType: "BlockReq"}, -// {evType: "ReceiveB", peer: "P1", height: 13}, -// {evType: "Process"}, -// {evType: "ReceiveB", peer: "P2", height: 14}, -// {evType: "Process"}, -// {evType: "BlockReq"}, -// {evType: "ReceiveB", peer: "P2", height: 15}, -// {evType: "Process"}, -// }, -// }, -// { -// name: "termination on max peer height - two peers, noBlock error", -// params: params, -// msgs: []testEvent{ -// {evType: "AddPeer", peer: "P1"}, -// {evType: "AddPeer", peer: "P2"}, -// {evType: "ReceiveS", peer: "P1", height: 13}, -// {evType: "ReceiveS", peer: "P2", height: 15}, -// {evType: "BlockReq"}, -// {evType: "BlockReq"}, -// {evType: "ReceiveNB", peer: "P1", height: 11}, -// {evType: "BlockReq"}, -// {evType: "ReceiveB", peer: "P2", height: 12}, -// {evType: "ReceiveB", peer: "P2", height: 11}, -// {evType: "Process"}, -// {evType: "BlockReq"}, -// {evType: "BlockReq"}, -// {evType: "ReceiveB", peer: "P2", height: 13}, -// {evType: "Process"}, -// {evType: "ReceiveB", peer: "P2", height: 14}, -// {evType: "Process"}, -// {evType: "BlockReq"}, -// {evType: "ReceiveB", peer: "P2", height: 15}, -// {evType: "Process"}, -// }, -// }, -// { -// name: "termination on max peer height - two peers, remove one peer", -// params: params, -// msgs: []testEvent{ -// {evType: "AddPeer", peer: "P1"}, -// {evType: "AddPeer", peer: "P2"}, -// {evType: "ReceiveS", peer: "P1", height: 13}, -// {evType: "ReceiveS", peer: "P2", height: 15}, -// {evType: "BlockReq"}, -// {evType: "BlockReq"}, -// {evType: "RemovePeer", peer: "P1"}, -// {evType: "BlockReq"}, -// {evType: "ReceiveB", peer: "P2", height: 12}, -// {evType: "ReceiveB", peer: "P2", height: 11}, -// {evType: "Process"}, -// {evType: "BlockReq"}, -// {evType: "BlockReq"}, -// {evType: "ReceiveB", peer: "P2", height: 13}, -// {evType: "Process"}, -// {evType: "ReceiveB", peer: "P2", height: 14}, -// {evType: "Process"}, -// {evType: "BlockReq"}, -// {evType: "ReceiveB", peer: "P2", height: 15}, -// {evType: "Process"}, -// }, -// }, -// } +// tests := []struct { +// name string +// params testReactorParams +// msgs []testEvent +// }{ +// { +// name: "simple termination on max peer height - one peer", +// params: params, +// msgs: []testEvent{ +// {evType: "AddPeer", peer: "P1"}, +// {evType: "ReceiveS", peer: "P1", height: 13}, +// {evType: "BlockReq"}, +// {evType: "ReceiveB", peer: "P1", height: 11}, +// {evType: "BlockReq"}, +// {evType: "BlockReq"}, +// {evType: "ReceiveB", peer: "P1", height: 12}, +// {evType: "Process"}, +// {evType: "ReceiveB", peer: "P1", height: 13}, +// {evType: "Process"}, +// }, +// }, +// { +// name: "simple termination on max peer height - two peers", +// params: params, +// msgs: []testEvent{ +// {evType: "AddPeer", peer: "P1"}, +// {evType: "AddPeer", peer: "P2"}, +// {evType: "ReceiveS", peer: "P1", height: 13}, +// {evType: "ReceiveS", peer: "P2", height: 15}, +// {evType: "BlockReq"}, +// {evType: "BlockReq"}, +// {evType: "ReceiveB", peer: "P1", height: 11}, +// {evType: "ReceiveB", peer: "P2", height: 12}, +// {evType: "Process"}, +// {evType: "BlockReq"}, +// {evType: "BlockReq"}, +// {evType: "ReceiveB", peer: "P1", height: 13}, +// {evType: "Process"}, +// {evType: "ReceiveB", peer: "P2", height: 14}, +// {evType: "Process"}, +// {evType: "BlockReq"}, +// {evType: "ReceiveB", peer: "P2", height: 15}, +// {evType: "Process"}, +// }, +// }, +// { +// name: "termination on max peer height - two peers, noBlock error", +// params: params, +// msgs: []testEvent{ +// {evType: "AddPeer", peer: "P1"}, +// {evType: "AddPeer", peer: "P2"}, +// {evType: "ReceiveS", peer: "P1", height: 13}, +// {evType: "ReceiveS", peer: "P2", height: 15}, +// {evType: "BlockReq"}, +// {evType: "BlockReq"}, +// {evType: "ReceiveNB", peer: "P1", height: 11}, +// {evType: "BlockReq"}, +// {evType: "ReceiveB", peer: "P2", height: 12}, +// {evType: "ReceiveB", peer: "P2", height: 11}, +// {evType: "Process"}, +// {evType: "BlockReq"}, +// {evType: "BlockReq"}, +// {evType: "ReceiveB", peer: "P2", height: 13}, +// {evType: "Process"}, +// {evType: "ReceiveB", peer: "P2", height: 14}, +// {evType: "Process"}, +// {evType: "BlockReq"}, +// {evType: "ReceiveB", peer: "P2", height: 15}, +// {evType: "Process"}, +// }, +// }, +// { +// name: "termination on max peer height - two peers, remove one peer", +// params: params, +// msgs: []testEvent{ +// {evType: "AddPeer", peer: "P1"}, +// {evType: "AddPeer", peer: "P2"}, +// {evType: "ReceiveS", peer: "P1", height: 13}, +// {evType: "ReceiveS", peer: "P2", height: 15}, +// {evType: "BlockReq"}, +// {evType: "BlockReq"}, +// {evType: "RemovePeer", peer: "P1"}, +// {evType: "BlockReq"}, +// {evType: "ReceiveB", peer: "P2", height: 12}, +// {evType: "ReceiveB", peer: "P2", height: 11}, +// {evType: "Process"}, +// {evType: "BlockReq"}, +// {evType: "BlockReq"}, +// {evType: "ReceiveB", peer: "P2", height: 13}, +// {evType: "Process"}, +// {evType: "ReceiveB", peer: "P2", height: 14}, +// {evType: "Process"}, +// {evType: "BlockReq"}, +// {evType: "ReceiveB", peer: "P2", height: 15}, +// {evType: "Process"}, +// }, +// }, +// } -// for _, tt := range tests { -// tt := tt -// t.Run(tt.name, func(t *testing.T) { -// reactor := newTestReactor(params) -// reactor.Start() -// reactor.reporter = behavior.NewMockReporter() -// mockSwitch := &mockSwitchIo{switchedToConsensus: false} -// reactor.io = mockSwitch -// // time for go routines to start -// time.Sleep(time.Millisecond) +// for _, tt := range tests { +// tt := tt +// t.Run(tt.name, func(t *testing.T) { +// reactor := newTestReactor(params) +// reactor.Start() +// reactor.reporter = behavior.NewMockReporter() +// mockSwitch := &mockSwitchIo{switchedToConsensus: false} +// reactor.io = mockSwitch +// // time for go routines to start +// time.Sleep(time.Millisecond) -// for _, step := range tt.msgs { -// switch step.evType { -// case "AddPeer": -// reactor.scheduler.send(bcAddNewPeer{peerID: p2p.ID(step.peer)}) -// case "RemovePeer": -// reactor.scheduler.send(bcRemovePeer{peerID: p2p.ID(step.peer)}) -// case "ReceiveS": -// reactor.scheduler.send(bcStatusResponse{ -// peerID: p2p.ID(step.peer), -// height: step.height, -// time: time.Now(), -// }) -// case "ReceiveB": -// reactor.scheduler.send(bcBlockResponse{ -// peerID: p2p.ID(step.peer), -// block: refStore.LoadBlock(step.height), -// size: 10, -// time: time.Now(), -// }) -// case "ReceiveNB": -// reactor.scheduler.send(bcNoBlockResponse{ -// peerID: p2p.ID(step.peer), -// height: step.height, -// time: time.Now(), -// }) -// case "BlockReq": -// reactor.scheduler.send(rTrySchedule{time: time.Now()}) -// case "Process": -// reactor.processor.send(rProcessBlock{}) -// } -// // give time for messages to propagate between routines -// time.Sleep(time.Millisecond) -// } +// for _, step := range tt.msgs { +// switch step.evType { +// case "AddPeer": +// reactor.scheduler.send(bcAddNewPeer{peerID: p2p.ID(step.peer)}) +// case "RemovePeer": +// reactor.scheduler.send(bcRemovePeer{peerID: p2p.ID(step.peer)}) +// case "ReceiveS": +// reactor.scheduler.send(bcStatusResponse{ +// peerID: p2p.ID(step.peer), +// height: step.height, +// time: time.Now(), +// }) +// case "ReceiveB": +// reactor.scheduler.send(bcBlockResponse{ +// peerID: p2p.ID(step.peer), +// block: refStore.LoadBlock(step.height), +// size: 10, +// time: time.Now(), +// }) +// case "ReceiveNB": +// reactor.scheduler.send(bcNoBlockResponse{ +// peerID: p2p.ID(step.peer), +// height: step.height, +// time: time.Now(), +// }) +// case "BlockReq": +// reactor.scheduler.send(rTrySchedule{time: time.Now()}) +// case "Process": +// reactor.processor.send(rProcessBlock{}) +// } +// // give time for messages to propagate between routines +// time.Sleep(time.Millisecond) +// } -// // time for processor to finish and reactor to switch to consensus -// time.Sleep(20 * time.Millisecond) -// assert.True(t, mockSwitch.hasSwitchedToConsensus()) -// reactor.Stop() -// }) -// } +// // time for processor to finish and reactor to switch to consensus +// time.Sleep(20 * time.Millisecond) +// assert.True(t, mockSwitch.hasSwitchedToConsensus()) +// reactor.Stop() +// }) +// } // } func TestReactorHelperMode(t *testing.T) { @@ -482,7 +483,7 @@ func newReactorStore( require.Len(t, privVals, 1) app := &testApp{} - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(cc) err := proxyApp.Start() if err != nil { diff --git a/internal/consensus/replay_stubs.go b/internal/consensus/replay_stubs.go index 0fda8d270..ebcd536b9 100644 --- a/internal/consensus/replay_stubs.go +++ b/internal/consensus/replay_stubs.go @@ -3,6 +3,7 @@ package consensus import ( "context" + abcicli "github.com/tendermint/tendermint/abci/client" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/internal/libs/clist" mempl "github.com/tendermint/tendermint/internal/mempool" @@ -53,7 +54,7 @@ func (emptyMempool) CloseWAL() {} // the real app. func newMockProxyApp(appHash []byte, abciResponses *tmstate.ABCIResponses) proxy.AppConnConsensus { - clientCreator := proxy.NewLocalClientCreator(&mockProxyApp{ + clientCreator := abcicli.NewLocalClientCreator(&mockProxyApp{ appHash: appHash, abciResponses: abciResponses, }) diff --git a/internal/consensus/replay_test.go b/internal/consensus/replay_test.go index 6e2c2da3c..09620b8cf 100644 --- a/internal/consensus/replay_test.go +++ b/internal/consensus/replay_test.go @@ -19,6 +19,7 @@ import ( "github.com/stretchr/testify/require" dbm "github.com/tendermint/tm-db" + abcicli "github.com/tendermint/tendermint/abci/client" "github.com/tendermint/tendermint/abci/example/kvstore" abci "github.com/tendermint/tendermint/abci/types" cfg "github.com/tendermint/tendermint/config" @@ -740,7 +741,7 @@ func testHandshakeReplay(t *testing.T, sim *simulatorTestSuite, nBlocks int, mod filepath.Join(config.DBDir(), fmt.Sprintf("replay_test_%d_%d_a_r%d", nBlocks, mode, rand.Int()))) t.Cleanup(func() { require.NoError(t, kvstoreApp.Close()) }) - clientCreator2 := proxy.NewLocalClientCreator(kvstoreApp) + clientCreator2 := abcicli.NewLocalClientCreator(kvstoreApp) if nBlocks > 0 { // run nBlocks against a new client to build up the app state. // use a throwaway tendermint state @@ -890,7 +891,7 @@ func buildTMStateFromChain( kvstoreApp := kvstore.NewPersistentKVStoreApplication( filepath.Join(config.DBDir(), fmt.Sprintf("replay_test_%d_%d_t", nBlocks, mode))) defer kvstoreApp.Close() - clientCreator := proxy.NewLocalClientCreator(kvstoreApp) + clientCreator := abcicli.NewLocalClientCreator(kvstoreApp) proxyApp := proxy.NewAppConns(clientCreator) if err := proxyApp.Start(); err != nil { @@ -958,7 +959,7 @@ func TestHandshakePanicsIfAppReturnsWrongAppHash(t *testing.T) { // - 0x03 { app := &badApp{numBlocks: 3, allHashesAreWrong: true} - clientCreator := proxy.NewLocalClientCreator(app) + clientCreator := abcicli.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(clientCreator) err := proxyApp.Start() require.NoError(t, err) @@ -982,7 +983,7 @@ func TestHandshakePanicsIfAppReturnsWrongAppHash(t *testing.T) { // - RANDOM HASH { app := &badApp{numBlocks: 3, onlyLastHashIsWrong: true} - clientCreator := proxy.NewLocalClientCreator(app) + clientCreator := abcicli.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(clientCreator) err := proxyApp.Start() require.NoError(t, err) @@ -1225,7 +1226,7 @@ func TestHandshakeUpdatesValidators(t *testing.T) { val, _ := factory.RandValidator(true, 10) vals := types.NewValidatorSet([]*types.Validator{val}) app := &initChainApp{vals: types.TM2PB.ValidatorUpdates(vals)} - clientCreator := proxy.NewLocalClientCreator(app) + clientCreator := abcicli.NewLocalClientCreator(app) config := ResetConfig("handshake_test_") t.Cleanup(func() { _ = os.RemoveAll(config.RootDir) }) diff --git a/internal/consensus/wal_generator.go b/internal/consensus/wal_generator.go index 7e4cfa4ae..5234d17f6 100644 --- a/internal/consensus/wal_generator.go +++ b/internal/consensus/wal_generator.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/require" db "github.com/tendermint/tm-db" + abcicli "github.com/tendermint/tendermint/abci/client" "github.com/tendermint/tendermint/abci/example/kvstore" cfg "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/internal/proxy" @@ -64,7 +65,7 @@ func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { blockStore := store.NewBlockStore(blockStoreDB) - proxyApp := proxy.NewAppConns(proxy.NewLocalClientCreator(app)) + proxyApp := proxy.NewAppConns(abcicli.NewLocalClientCreator(app)) proxyApp.SetLogger(logger.With("module", "proxy")) if err := proxyApp.Start(); err != nil { return fmt.Errorf("failed to start proxy app connections: %w", err) diff --git a/internal/mempool/v0/bench_test.go b/internal/mempool/v0/bench_test.go index f5e0e9386..6b5853d3d 100644 --- a/internal/mempool/v0/bench_test.go +++ b/internal/mempool/v0/bench_test.go @@ -6,14 +6,14 @@ import ( "sync/atomic" "testing" + abcicli "github.com/tendermint/tendermint/abci/client" "github.com/tendermint/tendermint/abci/example/kvstore" "github.com/tendermint/tendermint/internal/mempool" - "github.com/tendermint/tendermint/internal/proxy" ) func BenchmarkReap(b *testing.B) { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) mp, cleanup := newMempoolWithApp(cc) defer cleanup() mp.config.Size = 100000 @@ -34,7 +34,7 @@ func BenchmarkReap(b *testing.B) { func BenchmarkCheckTx(b *testing.B) { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) mp, cleanup := newMempoolWithApp(cc) defer cleanup() @@ -56,7 +56,7 @@ func BenchmarkCheckTx(b *testing.B) { func BenchmarkParallelCheckTx(b *testing.B) { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) mp, cleanup := newMempoolWithApp(cc) defer cleanup() @@ -81,7 +81,7 @@ func BenchmarkParallelCheckTx(b *testing.B) { func BenchmarkCheckDuplicateTx(b *testing.B) { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) mp, cleanup := newMempoolWithApp(cc) defer cleanup() diff --git a/internal/mempool/v0/cache_test.go b/internal/mempool/v0/cache_test.go index de80c8303..93a848dc1 100644 --- a/internal/mempool/v0/cache_test.go +++ b/internal/mempool/v0/cache_test.go @@ -7,16 +7,16 @@ import ( "github.com/stretchr/testify/require" + abcicli "github.com/tendermint/tendermint/abci/client" "github.com/tendermint/tendermint/abci/example/kvstore" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/internal/mempool" - "github.com/tendermint/tendermint/internal/proxy" "github.com/tendermint/tendermint/types" ) func TestCacheAfterUpdate(t *testing.T) { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) mp, cleanup := newMempoolWithApp(cc) defer cleanup() diff --git a/internal/mempool/v0/clist_mempool_test.go b/internal/mempool/v0/clist_mempool_test.go index d04161324..774866836 100644 --- a/internal/mempool/v0/clist_mempool_test.go +++ b/internal/mempool/v0/clist_mempool_test.go @@ -21,7 +21,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" cfg "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/internal/mempool" - "github.com/tendermint/tendermint/internal/proxy" "github.com/tendermint/tendermint/libs/log" tmrand "github.com/tendermint/tendermint/libs/rand" "github.com/tendermint/tendermint/libs/service" @@ -93,7 +92,7 @@ func checkTxs(t *testing.T, mp mempool.Mempool, count int, peerID uint16) types. func TestReapMaxBytesMaxGas(t *testing.T) { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) mp, cleanup := newMempoolWithApp(cc) defer cleanup() @@ -142,7 +141,7 @@ func TestReapMaxBytesMaxGas(t *testing.T) { func TestMempoolFilters(t *testing.T) { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) mp, cleanup := newMempoolWithApp(cc) defer cleanup() emptyTxArr := []types.Tx{[]byte{}} @@ -181,7 +180,7 @@ func TestMempoolFilters(t *testing.T) { func TestMempoolUpdate(t *testing.T) { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) mp, cleanup := newMempoolWithApp(cc) defer cleanup() @@ -217,7 +216,7 @@ func TestMempoolUpdate(t *testing.T) { func TestMempool_KeepInvalidTxsInCache(t *testing.T) { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) wcfg := cfg.DefaultConfig() wcfg.Mempool.KeepInvalidTxsInCache = true mp, cleanup := newMempoolWithAppAndConfig(cc, wcfg) @@ -265,7 +264,7 @@ func TestMempool_KeepInvalidTxsInCache(t *testing.T) { func TestTxsAvailable(t *testing.T) { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) mp, cleanup := newMempoolWithApp(cc) defer cleanup() mp.EnableTxsAvailable() @@ -309,7 +308,7 @@ func TestTxsAvailable(t *testing.T) { func TestSerialReap(t *testing.T) { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) mp, cleanup := newMempoolWithApp(cc) defer cleanup() @@ -420,7 +419,7 @@ func TestSerialReap(t *testing.T) { func TestMempool_CheckTxChecksTxSize(t *testing.T) { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) mempl, cleanup := newMempoolWithApp(cc) defer cleanup() @@ -465,7 +464,7 @@ func TestMempool_CheckTxChecksTxSize(t *testing.T) { func TestMempoolTxsBytes(t *testing.T) { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) config := cfg.ResetTestRoot("mempool_test") config.Mempool.MaxTxsBytes = 10 mp, cleanup := newMempoolWithAppAndConfig(cc, config) @@ -508,7 +507,7 @@ func TestMempoolTxsBytes(t *testing.T) { // 6. zero after tx is rechecked and removed due to not being valid anymore app2 := kvstore.NewApplication() - cc = proxy.NewLocalClientCreator(app2) + cc = abcicli.NewLocalClientCreator(app2) mp, cleanup = newMempoolWithApp(cc) defer cleanup() @@ -601,7 +600,7 @@ func newRemoteApp( clientCreator abcicli.ClientCreator, server service.Service, ) { - clientCreator = proxy.NewRemoteClientCreator(addr, "socket", true) + clientCreator = abcicli.NewRemoteClientCreator(addr, "socket", true) // Start server server = abciserver.NewSocketServer(addr, app) diff --git a/internal/mempool/v0/reactor_test.go b/internal/mempool/v0/reactor_test.go index 0b4951f55..69bec1b8d 100644 --- a/internal/mempool/v0/reactor_test.go +++ b/internal/mempool/v0/reactor_test.go @@ -8,13 +8,13 @@ import ( "github.com/stretchr/testify/require" + abcicli "github.com/tendermint/tendermint/abci/client" "github.com/tendermint/tendermint/abci/example/kvstore" abci "github.com/tendermint/tendermint/abci/types" cfg "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/internal/mempool" "github.com/tendermint/tendermint/internal/p2p" "github.com/tendermint/tendermint/internal/p2p/p2ptest" - "github.com/tendermint/tendermint/internal/proxy" "github.com/tendermint/tendermint/libs/log" tmrand "github.com/tendermint/tendermint/libs/rand" protomem "github.com/tendermint/tendermint/proto/tendermint/mempool" @@ -55,7 +55,7 @@ func setup(t *testing.T, cfg *cfg.MempoolConfig, numNodes int, chBuf uint) *reac for nodeID := range rts.network.Nodes { rts.kvstores[nodeID] = kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(rts.kvstores[nodeID]) + cc := abcicli.NewLocalClientCreator(rts.kvstores[nodeID]) mempool, memCleanup := newMempoolWithApp(cc) t.Cleanup(memCleanup) diff --git a/internal/mempool/v1/mempool_test.go b/internal/mempool/v1/mempool_test.go index dae4e0e08..0da7ce7d8 100644 --- a/internal/mempool/v1/mempool_test.go +++ b/internal/mempool/v1/mempool_test.go @@ -15,12 +15,12 @@ import ( "time" "github.com/stretchr/testify/require" + abcicli "github.com/tendermint/tendermint/abci/client" "github.com/tendermint/tendermint/abci/example/code" "github.com/tendermint/tendermint/abci/example/kvstore" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/internal/mempool" - "github.com/tendermint/tendermint/internal/proxy" "github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/types" ) @@ -76,7 +76,7 @@ func setup(t testing.TB, cacheSize int, options ...TxMempoolOption) *TxMempool { t.Helper() app := &application{kvstore.NewApplication()} - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) cfg := config.ResetTestRoot(strings.ReplaceAll(t.Name(), "/", "|")) cfg.Mempool.CacheSize = cacheSize diff --git a/internal/proxy/app_conn_test.go b/internal/proxy/app_conn_test.go index 458088635..87a6f2d55 100644 --- a/internal/proxy/app_conn_test.go +++ b/internal/proxy/app_conn_test.go @@ -48,7 +48,7 @@ var SOCKET = "socket" func TestEcho(t *testing.T) { sockPath := fmt.Sprintf("unix:///tmp/echo_%v.sock", tmrand.Str(6)) - clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true) + clientCreator := abcicli.NewRemoteClientCreator(sockPath, SOCKET, true) // Start server s := server.NewSocketServer(sockPath, kvstore.NewApplication()) @@ -96,7 +96,7 @@ func TestEcho(t *testing.T) { func BenchmarkEcho(b *testing.B) { b.StopTimer() // Initialize sockPath := fmt.Sprintf("unix:///tmp/echo_%v.sock", tmrand.Str(6)) - clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true) + clientCreator := abcicli.NewRemoteClientCreator(sockPath, SOCKET, true) // Start server s := server.NewSocketServer(sockPath, kvstore.NewApplication()) @@ -149,7 +149,7 @@ func BenchmarkEcho(b *testing.B) { func TestInfo(t *testing.T) { sockPath := fmt.Sprintf("unix:///tmp/echo_%v.sock", tmrand.Str(6)) - clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true) + clientCreator := abcicli.NewRemoteClientCreator(sockPath, SOCKET, true) // Start server s := server.NewSocketServer(sockPath, kvstore.NewApplication()) diff --git a/node/node_test.go b/node/node_test.go index 67e417e91..31f15c336 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -16,12 +16,12 @@ import ( dbm "github.com/tendermint/tm-db" + abcicli "github.com/tendermint/tendermint/abci/client" "github.com/tendermint/tendermint/abci/example/kvstore" cfg "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/tmhash" - "github.com/tendermint/tendermint/internal/evidence" "github.com/tendermint/tendermint/internal/mempool" mempoolv0 "github.com/tendermint/tendermint/internal/mempool/v0" @@ -214,7 +214,7 @@ func testFreeAddr(t *testing.T) string { func TestCreateProposalBlock(t *testing.T) { config := cfg.ResetTestRoot("node_create_proposal") defer os.RemoveAll(config.RootDir) - cc := proxy.NewLocalClientCreator(kvstore.NewApplication()) + cc := abcicli.NewLocalClientCreator(kvstore.NewApplication()) proxyApp := proxy.NewAppConns(cc) err := proxyApp.Start() require.Nil(t, err) @@ -306,7 +306,7 @@ func TestCreateProposalBlock(t *testing.T) { func TestMaxTxsProposalBlockSize(t *testing.T) { config := cfg.ResetTestRoot("node_create_proposal") defer os.RemoveAll(config.RootDir) - cc := proxy.NewLocalClientCreator(kvstore.NewApplication()) + cc := abcicli.NewLocalClientCreator(kvstore.NewApplication()) proxyApp := proxy.NewAppConns(cc) err := proxyApp.Start() require.Nil(t, err) @@ -368,7 +368,7 @@ func TestMaxTxsProposalBlockSize(t *testing.T) { func TestMaxProposalBlockSize(t *testing.T) { config := cfg.ResetTestRoot("node_create_proposal") defer os.RemoveAll(config.RootDir) - cc := proxy.NewLocalClientCreator(kvstore.NewApplication()) + cc := abcicli.NewLocalClientCreator(kvstore.NewApplication()) proxyApp := proxy.NewAppConns(cc) err := proxyApp.Start() require.Nil(t, err) diff --git a/rpc/test/helpers.go b/rpc/test/helpers.go index 840cc4d05..a56258655 100644 --- a/rpc/test/helpers.go +++ b/rpc/test/helpers.go @@ -6,9 +6,9 @@ import ( "os" "time" + abcicli "github.com/tendermint/tendermint/abci/client" abci "github.com/tendermint/tendermint/abci/types" cfg "github.com/tendermint/tendermint/config" - "github.com/tendermint/tendermint/internal/proxy" "github.com/tendermint/tendermint/libs/log" tmnet "github.com/tendermint/tendermint/libs/net" "github.com/tendermint/tendermint/libs/service" @@ -100,7 +100,7 @@ func StartTendermint(ctx context.Context, } else { logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false) } - papp := proxy.NewLocalClientCreator(app) + papp := abcicli.NewLocalClientCreator(app) node, err := nm.New(conf, logger, papp, nil) if err != nil { return nil, func(_ context.Context) error { return nil }, err diff --git a/state/execution_test.go b/state/execution_test.go index 4e0c27449..952ef3308 100644 --- a/state/execution_test.go +++ b/state/execution_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + abcicli "github.com/tendermint/tendermint/abci/client" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" @@ -34,7 +35,7 @@ var ( func TestApplyBlock(t *testing.T) { app := &testApp{} - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(cc) err := proxyApp.Start() require.Nil(t, err) @@ -59,7 +60,7 @@ func TestApplyBlock(t *testing.T) { // TestBeginBlockValidators ensures we send absent validators list. func TestBeginBlockValidators(t *testing.T) { app := &testApp{} - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(cc) err := proxyApp.Start() require.Nil(t, err) @@ -122,7 +123,7 @@ func TestBeginBlockValidators(t *testing.T) { // TestBeginBlockByzantineValidators ensures we send byzantine validators list. func TestBeginBlockByzantineValidators(t *testing.T) { app := &testApp{} - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(cc) err := proxyApp.Start() require.Nil(t, err) @@ -347,7 +348,7 @@ func TestUpdateValidators(t *testing.T) { // TestEndBlockValidatorUpdates ensures we update validator set and send an event. func TestEndBlockValidatorUpdates(t *testing.T) { app := &testApp{} - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(cc) err := proxyApp.Start() require.Nil(t, err) @@ -420,7 +421,7 @@ func TestEndBlockValidatorUpdates(t *testing.T) { // would result in empty set causes no panic, an error is raised and NextValidators is not updated func TestEndBlockValidatorUpdatesResultingInEmptySet(t *testing.T) { app := &testApp{} - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(cc) err := proxyApp.Start() require.Nil(t, err) diff --git a/state/helpers_test.go b/state/helpers_test.go index e9064baac..855ebbf9a 100644 --- a/state/helpers_test.go +++ b/state/helpers_test.go @@ -7,6 +7,7 @@ import ( dbm "github.com/tendermint/tm-db" + abcicli "github.com/tendermint/tendermint/abci/client" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" @@ -29,7 +30,7 @@ type paramsChangeTestCase struct { func newTestApp() proxy.AppConns { app := &testApp{} - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) return proxy.NewAppConns(cc) } diff --git a/test/e2e/app/main.go b/test/e2e/app/main.go index 0b0554f23..200280f6b 100644 --- a/test/e2e/app/main.go +++ b/test/e2e/app/main.go @@ -14,11 +14,11 @@ import ( "github.com/spf13/viper" "google.golang.org/grpc" + abcicli "github.com/tendermint/tendermint/abci/client" "github.com/tendermint/tendermint/abci/server" "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/internal/p2p" - "github.com/tendermint/tendermint/internal/proxy" "github.com/tendermint/tendermint/libs/log" tmnet "github.com/tendermint/tendermint/libs/net" "github.com/tendermint/tendermint/light" @@ -130,7 +130,7 @@ func startNode(cfg *Config) error { n, err := node.New(tmcfg, nodeLogger, - proxy.NewLocalClientCreator(app), + abcicli.NewLocalClientCreator(app), nil, ) if err != nil { diff --git a/test/fuzz/mempool/v0/checktx.go b/test/fuzz/mempool/v0/checktx.go index e795c3606..a764a43c2 100644 --- a/test/fuzz/mempool/v0/checktx.go +++ b/test/fuzz/mempool/v0/checktx.go @@ -3,18 +3,18 @@ package v0 import ( "context" + abcicli "github.com/tendermint/tendermint/abci/client" "github.com/tendermint/tendermint/abci/example/kvstore" "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/internal/mempool" mempoolv0 "github.com/tendermint/tendermint/internal/mempool/v0" - "github.com/tendermint/tendermint/internal/proxy" ) var mp mempool.Mempool func init() { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) appConnMem, _ := cc.NewABCIClient() err := appConnMem.Start() if err != nil { diff --git a/test/fuzz/mempool/v1/checktx.go b/test/fuzz/mempool/v1/checktx.go index 913cdf774..4e9e35be2 100644 --- a/test/fuzz/mempool/v1/checktx.go +++ b/test/fuzz/mempool/v1/checktx.go @@ -3,18 +3,18 @@ package v1 import ( "context" + abcicli "github.com/tendermint/tendermint/abci/client" "github.com/tendermint/tendermint/abci/example/kvstore" "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/internal/mempool" mempoolv1 "github.com/tendermint/tendermint/internal/mempool/v0" - "github.com/tendermint/tendermint/internal/proxy" ) var mp mempool.Mempool func init() { app := kvstore.NewApplication() - cc := proxy.NewLocalClientCreator(app) + cc := abcicli.NewLocalClientCreator(app) appConnMem, _ := cc.NewABCIClient() err := appConnMem.Start() if err != nil {