From ecb1f02f770eeb52bb85e16998f66e552296bf86 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 8 Nov 2017 17:18:42 -0500 Subject: [PATCH 01/12] add version cmd (Refs #124) --- cmd/abci-cli/abci-cli.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/abci-cli/abci-cli.go b/cmd/abci-cli/abci-cli.go index 1beb08507..9962380b4 100644 --- a/cmd/abci-cli/abci-cli.go +++ b/cmd/abci-cli/abci-cli.go @@ -15,6 +15,7 @@ import ( "github.com/tendermint/abci/example/dummy" "github.com/tendermint/abci/server" "github.com/tendermint/abci/types" + "github.com/tendermint/abci/version" cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/log" @@ -71,8 +72,9 @@ var RootCmd = &cobra.Command{ PersistentPreRunE: func(cmd *cobra.Command, args []string) error { switch cmd.Use { - // for the examples apps, don't pre-run - case "counter", "dummy": + case "counter", "dummy": // for the examples apps, don't pre-run + return nil + case "version": // skip running for version command return nil } @@ -130,6 +132,7 @@ func addCommands() { RootCmd.AddCommand(deliverTxCmd) RootCmd.AddCommand(checkTxCmd) RootCmd.AddCommand(commitCmd) + RootCmd.AddCommand(versionCmd) addQueryFlags() RootCmd.AddCommand(queryCmd) @@ -219,6 +222,17 @@ var commitCmd = &cobra.Command{ }, } +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Print abci console version", + Long: "", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + fmt.Println(version.Version) + return nil + }, +} + var queryCmd = &cobra.Command{ Use: "query", Short: "Query the application state", From 5efe88cd107080d032ba8c73dd4e857e13cc2bd2 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 8 Nov 2017 17:18:52 -0500 Subject: [PATCH 02/12] simplify Makefile install and build commands --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 588e12df5..a22a2e902 100644 --- a/Makefile +++ b/Makefile @@ -15,10 +15,10 @@ protoc: @ protoc --go_out=plugins=grpc:. types/*.proto install: - @ go install github.com/tendermint/abci/cmd/... + @ go install ./cmd/... build: - @ go build -i github.com/tendermint/abci/cmd/... + @ go build -i ./cmd/... dist: @ bash scripts/dist.sh From 430c49ea143b76cc419b2f2c6c0779ea715db823 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 8 Nov 2017 17:19:35 -0500 Subject: [PATCH 03/12] update deps --- glide.lock | 11 +++++------ glide.yaml | 8 ++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/glide.lock b/glide.lock index 2a992d724..755521863 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: 3c8680f0a289567a29f737be5f1d5f242c7e2afd84bdd023dd74596b88508fc2 -updated: 2017-10-27T12:12:58.940745472-04:00 +hash: 5501ab3d7136aa8fb425c995d45221849b33aefab76c5d2c192e721dad28da38 +updated: 2017-11-08T22:19:19.433856551Z imports: - name: github.com/btcsuite/btcd version: b8df516b4b267acf2de46be593a9d948d1d2c420 @@ -66,20 +66,19 @@ imports: - edwards25519 - extra25519 - name: github.com/tendermint/go-crypto - version: db5603e37435933c13665a708055fadd18222f5f + version: b4f04f196cd719660e43b91202cd60d9a95b1837 - name: github.com/tendermint/go-wire - version: 8ee84b5b2581530168daf66fc89c548d27403c57 + version: 2baffcb6b690057568bc90ef1d457efb150b979a subpackages: - data - name: github.com/tendermint/iavl version: 595f3dcd5b6cd4a292e90757ae6d367fd7a6e653 - name: github.com/tendermint/tmlibs - version: 092eb701c7276907cdbed258750e22ce895b6735 + version: 176c2ceed611d7735e39131e312bd973afb41b7b subpackages: - common - db - log - - merkle - process - name: golang.org/x/crypto version: c7af5bf2638a1164f2eb5467c39c6cffbd13a02e diff --git a/glide.yaml b/glide.yaml index ccd41cdc3..ce8057234 100644 --- a/glide.yaml +++ b/glide.yaml @@ -3,11 +3,13 @@ import: - package: github.com/golang/protobuf subpackages: - proto -- package: github.com/pkg/errors +- package: github.com/spf13/cobra - package: github.com/tendermint/go-crypto version: develop - package: github.com/tendermint/go-wire version: develop + subpackages: + - data - package: github.com/tendermint/iavl version: develop - package: github.com/tendermint/tmlibs @@ -16,10 +18,7 @@ import: - common - db - log - - merkle - process -- package: github.com/spf13/cobra - version: master - package: golang.org/x/net subpackages: - context @@ -27,4 +26,5 @@ import: testImport: - package: github.com/stretchr/testify subpackages: + - assert - require From 10e1233f1420e6b244ee1366485e18d58ef981fb Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 8 Nov 2017 17:29:15 -0500 Subject: [PATCH 04/12] fix megacheck issues --- example/dummy/dummy_test.go | 6 +++--- example/example_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/example/dummy/dummy_test.go b/example/dummy/dummy_test.go index 751a2e910..efbc5af77 100644 --- a/example/dummy/dummy_test.go +++ b/example/dummy/dummy_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" abcicli "github.com/tendermint/abci/client" - "github.com/tendermint/abci/server" + abciserver "github.com/tendermint/abci/server" "github.com/tendermint/abci/types" "github.com/tendermint/iavl" cmn "github.com/tendermint/tmlibs/common" @@ -210,7 +210,7 @@ func makeSocketClientServer(app types.Application, name string) (abcicli.Client, socket := cmn.Fmt("unix://%s.sock", name) logger := log.TestingLogger() - server := server.NewSocketServer(socket, app) + server := abciserver.NewSocketServer(socket, app) server.SetLogger(logger.With("module", "abci-server")) if _, err := server.Start(); err != nil { return nil, nil, err @@ -233,7 +233,7 @@ func makeGRPCClientServer(app types.Application, name string) (abcicli.Client, c logger := log.TestingLogger() gapp := types.NewGRPCApplication(app) - server := server.NewGRPCServer(socket, gapp) + server := abciserver.NewGRPCServer(socket, gapp) server.SetLogger(logger.With("module", "abci-server")) if _, err := server.Start(); err != nil { return nil, nil, err diff --git a/example/example_test.go b/example/example_test.go index e9505f223..496ed3d3f 100644 --- a/example/example_test.go +++ b/example/example_test.go @@ -13,7 +13,7 @@ import ( abcicli "github.com/tendermint/abci/client" "github.com/tendermint/abci/example/dummy" - "github.com/tendermint/abci/server" + abciserver "github.com/tendermint/abci/server" "github.com/tendermint/abci/types" cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/log" @@ -38,7 +38,7 @@ func testStream(t *testing.T, app types.Application) { numDeliverTxs := 200000 // Start the listener - server := server.NewSocketServer("unix://test.sock", app) + server := abciserver.NewSocketServer("unix://test.sock", app) server.SetLogger(log.TestingLogger().With("module", "abci-server")) if _, err := server.Start(); err != nil { t.Fatalf("Error starting socket server: %v", err.Error()) @@ -111,7 +111,7 @@ func testGRPCSync(t *testing.T, app *types.GRPCApplication) { numDeliverTxs := 2000 // Start the listener - server := server.NewGRPCServer("unix://test.sock", app) + server := abciserver.NewGRPCServer("unix://test.sock", app) server.SetLogger(log.TestingLogger().With("module", "abci-server")) if _, err := server.Start(); err != nil { t.Fatalf("Error starting GRPC server: %v", err.Error()) From 43c64163d8f97d7db49dea353782ff51d49b83c1 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 9 Nov 2017 13:16:35 -0400 Subject: [PATCH 05/12] Update socket_server.go This is likely related to #125 --- server/socket_server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/socket_server.go b/server/socket_server.go index adc7516c6..55227e7dc 100644 --- a/server/socket_server.go +++ b/server/socket_server.go @@ -117,7 +117,7 @@ func (s *SocketServer) acceptConnectionsRoutine() { go func() { // Wait until signal to close connection errClose := <-closeConn - if err == io.EOF { + if errClose == io.EOF { s.Logger.Error("Connection was closed by client") } else if errClose != nil { s.Logger.Error("Connection error", "error", errClose) From 64c756de477b33ddecf4bdcbe776f5ebc1615066 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Sun, 12 Nov 2017 22:30:41 -0500 Subject: [PATCH 06/12] use Makefile commands in readme [ci skip] --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 33b037da0..aedebee60 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ to manage an application state running in another. ``` go get github.com/tendermint/abci cd $GOPATH/src/github.com/tendermint/abci -glide install -go install ./cmd/... +make get_vendor_deps +make install ``` For background information on ABCI, motivations, and tendermint, please visit [the documentation](http://tendermint.readthedocs.io/en/master/). From 3bd8782ab211f2fec1f7302b9d931f8e3d56e7be Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Tue, 14 Nov 2017 17:03:23 +0000 Subject: [PATCH 07/12] server: minor refactor --- server/socket_server.go | 59 +++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/server/socket_server.go b/server/socket_server.go index 55227e7dc..2396c556d 100644 --- a/server/socket_server.go +++ b/server/socket_server.go @@ -59,11 +59,11 @@ func (s *SocketServer) OnStop() { s.listener.Close() s.connsMtx.Lock() + defer s.connsMtx.Unlock() for id, conn := range s.conns { delete(s.conns, id) conn.Close() } - s.connsMtx.Unlock() } func (s *SocketServer) addConn(conn net.Conn) int { @@ -78,20 +78,21 @@ func (s *SocketServer) addConn(conn net.Conn) int { } // deletes conn even if close errs -func (s *SocketServer) rmConn(connID int, conn net.Conn) error { +func (s *SocketServer) rmConn(connID int) error { s.connsMtx.Lock() defer s.connsMtx.Unlock() + conn, ok := s.conns[connID] + if !ok { + return fmt.Errorf("Connection %d does not exist", connID) + } + delete(s.conns, connID) return conn.Close() } func (s *SocketServer) acceptConnectionsRoutine() { - // semaphore := make(chan struct{}, maxNumberConnections) - for { - // semaphore <- struct{}{} - // Accept a connection s.Logger.Info("Waiting for new connection...") conn, err := s.listener.Accept() @@ -100,10 +101,11 @@ func (s *SocketServer) acceptConnectionsRoutine() { return // Ignore error from listener closing. } s.Logger.Error("Failed to accept connection: " + err.Error()) - } else { - s.Logger.Info("Accepted a new connection") + continue } + s.Logger.Info("Accepted a new connection") + connID := s.addConn(conn) closeConn := make(chan error, 2) // Push to signal connection closed @@ -112,28 +114,27 @@ func (s *SocketServer) acceptConnectionsRoutine() { // Read requests from conn and deal with them go s.handleRequests(closeConn, conn, responses) // Pull responses from 'responses' and write them to conn. - go s.handleResponses(closeConn, responses, conn) - - go func() { - // Wait until signal to close connection - errClose := <-closeConn - if errClose == io.EOF { - s.Logger.Error("Connection was closed by client") - } else if errClose != nil { - s.Logger.Error("Connection error", "error", errClose) - } else { - // never happens - s.Logger.Error("Connection was closed.") - } + go s.handleResponses(closeConn, conn, responses) - // Close the connection - err := s.rmConn(connID, conn) - if err != nil { - s.Logger.Error("Error in closing connection", "error", err) - } + // Wait until signal to close connection + go s.waitForClose(closeConn, connID) + } +} + +func (s *SocketServer) waitForClose(closeConn chan error, connID int) { + err := <-closeConn + if err == io.EOF { + s.Logger.Error("Connection was closed by client") + } else if err != nil { + s.Logger.Error("Connection error", "error", err) + } else { + // never happens + s.Logger.Error("Connection was closed.") + } - // <-semaphore - }() + // Close the connection + if err := s.rmConn(connID); err != nil { + s.Logger.Error("Error in closing connection", "error", err) } } @@ -200,7 +201,7 @@ func (s *SocketServer) handleRequest(req *types.Request, responses chan<- *types } // Pull responses from 'responses' and write them to conn. -func (s *SocketServer) handleResponses(closeConn chan error, responses <-chan *types.Response, conn net.Conn) { +func (s *SocketServer) handleResponses(closeConn chan error, conn net.Conn, responses <-chan *types.Response) { var count int var bufWriter = bufio.NewWriter(conn) for { From a52b98c70e84b3fee37e6b0122e3283a8e7d603f Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 14 Nov 2017 12:25:52 -0600 Subject: [PATCH 08/12] update deps --- glide.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/glide.lock b/glide.lock index 755521863..80dbc4835 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ hash: 5501ab3d7136aa8fb425c995d45221849b33aefab76c5d2c192e721dad28da38 -updated: 2017-11-08T22:19:19.433856551Z +updated: 2017-11-14T18:23:41.2024073Z imports: - name: github.com/btcsuite/btcd version: b8df516b4b267acf2de46be593a9d948d1d2c420 @@ -68,13 +68,13 @@ imports: - name: github.com/tendermint/go-crypto version: b4f04f196cd719660e43b91202cd60d9a95b1837 - name: github.com/tendermint/go-wire - version: 2baffcb6b690057568bc90ef1d457efb150b979a + version: 1c96861c03231361546944d883d99593b2e6b408 subpackages: - data - name: github.com/tendermint/iavl version: 595f3dcd5b6cd4a292e90757ae6d367fd7a6e653 - name: github.com/tendermint/tmlibs - version: 176c2ceed611d7735e39131e312bd973afb41b7b + version: 2442a0a698d271d5cf5d6a8e7c1db20335e959c1 subpackages: - common - db From f2bf7d1b2d2552391ad1ea999346e7772d5d6cff Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 14 Nov 2017 12:26:01 -0600 Subject: [PATCH 09/12] update go version to 1.9.2 --- scripts/abci-builder/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/abci-builder/Dockerfile b/scripts/abci-builder/Dockerfile index c56fb2ea8..1182085b4 100644 --- a/scripts/abci-builder/Dockerfile +++ b/scripts/abci-builder/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.7.4 +FROM golang:1.9.2 RUN apt-get update && apt-get install -y --no-install-recommends \ zip \ From 1d49453ffb63dab9568d8333b75b8fd8b0f4b177 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 14 Nov 2017 12:53:40 -0600 Subject: [PATCH 10/12] fix integration tests (Fixes #131) --- Makefile | 6 +++--- tests/test_app/app.go | 2 +- tests/test_app/test.sh | 2 +- tests/test_cli/test.sh | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index a22a2e902..6c99e3639 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ GOTOOLS = \ all: protoc install test -NOVENDOR = go list github.com/tendermint/abci/... | grep -v /vendor/ +PACKAGES=$(shell go list ./... | grep -v '/vendor/') install-protoc: # Download: https://github.com/google/protobuf/releases @@ -27,7 +27,7 @@ dist: # test.sh requires that we run the installed cmds, must not be out of date test: install find . -path ./vendor -prune -o -name *.sock -exec rm {} \; - @ go test -p 1 `${NOVENDOR}` + @ go test $(PACKAGES) @ bash tests/test.sh fmt: @@ -36,7 +36,7 @@ fmt: test_integrations: get_vendor_deps install test get_deps: - @ go get -d `${NOVENDOR}` + @ go get -d $(PACKAGES) tools: go get -u -v $(GOTOOLS) diff --git a/tests/test_app/app.go b/tests/test_app/app.go index 7fc3ace0a..127ba78f7 100644 --- a/tests/test_app/app.go +++ b/tests/test_app/app.go @@ -18,7 +18,7 @@ func startApp(abciApp string) *process.Process { proc, err := process.StartProcess("abci_app", "", "bash", - []string{"-c", abciApp}, + []string{"-c", fmt.Sprintf("abci-cli %s", abciApp)}, nil, os.Stdout, ) diff --git a/tests/test_app/test.sh b/tests/test_app/test.sh index 0620b4767..5b523fefe 100755 --- a/tests/test_app/test.sh +++ b/tests/test_app/test.sh @@ -15,7 +15,7 @@ cd "$DIR" ABCI_APP="counter" go run ./*.go # test golang counter via grpc -ABCI_APP="counter -abci=grpc" ABCI="grpc" go run ./*.go +ABCI_APP="counter --abci=grpc" ABCI="grpc" go run ./*.go # test nodejs counter # TODO: fix node app diff --git a/tests/test_cli/test.sh b/tests/test_cli/test.sh index 81b06a0ec..ea4ea4fa9 100644 --- a/tests/test_cli/test.sh +++ b/tests/test_cli/test.sh @@ -17,7 +17,7 @@ function testExample() { $APP &> /dev/null & sleep 2 abci-cli --verbose batch < "$INPUT" > "${INPUT}.out.new" - killall $3 + killall "$3" pre=$(shasum < "${INPUT}.out") post=$(shasum < "${INPUT}.out.new") From f808dd55966831b345089c57a6b7fc1772c983ec Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 14 Nov 2017 13:09:19 -0600 Subject: [PATCH 11/12] update CHANGELOG --- CHANGELOG.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ed93b91c..0cd5046c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.7.1 (November 14, 2017) + +IMPROVEMENTS: + - [cli] added version command + +BUG FIXES: + - [server] fix "Connection error module=abci-server error=EOF" + ## 0.7.0 (October 27, 2017) BREAKING CHANGES: @@ -43,7 +51,7 @@ IMPROVEMENTS: - Update imports for new `tmlibs` repository - Use the new logger - [abci-cli] Add flags to the query command for `path`, `height`, and `prove` -- [types] use `data.Bytes` and `json` tags in the `Result` struct +- [types] use `data.Bytes` and `json` tags in the `Result` struct BUG FIXES: @@ -55,9 +63,9 @@ IMPROVEMENTS: ## 0.4.0 (March 6, 2017) -BREAKING CHANGES: +BREAKING CHANGES: -- Query takes RequestQuery and returns ResponseQuery. The request is split into `data` and `path`, +- Query takes RequestQuery and returns ResponseQuery. The request is split into `data` and `path`, can specify a height to query the state from, and whether or not the response should come with a proof. The response returns the corresponding key-value pair, with proof if requested. @@ -66,7 +74,7 @@ message RequestQuery{ bytes data = 1; string path = 2; uint64 height = 3; - bool prove = 4; + bool prove = 4; } message ResponseQuery{ @@ -142,7 +150,7 @@ message Header { bytes last_commit_hash = 6; bytes data_hash = 7; bytes validators_hash = 8; - bytes app_hash = 9; + bytes app_hash = 9; } message BlockID { From bac924e3990fe9f769b813771ee1e4d9e7cb60f7 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 14 Nov 2017 13:09:27 -0600 Subject: [PATCH 12/12] update version --- version/version.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version/version.go b/version/version.go index bbea51bcb..e02653d83 100644 --- a/version/version.go +++ b/version/version.go @@ -4,6 +4,6 @@ package version const Maj = "0" const Min = "7" -const Fix = "0" +const Fix = "1" -const Version = "0.7.0" +const Version = "0.7.1"