diff --git a/DOCKER/Dockerfile b/DOCKER/Dockerfile index 67f488afb04359841dce3d5231175b094f2c4ac2..96ef6ef5e715517288906517e2444a993d0756d2 100644 --- a/DOCKER/Dockerfile +++ b/DOCKER/Dockerfile @@ -1,5 +1,5 @@ # Pull base image. -FROM eris/base +FROM quay.io/eris/base MAINTAINER Eris Industries <support@erisindustries.com> #----------------------------------------------------------------------------- @@ -9,29 +9,15 @@ RUN apt-get update && \ libgmp3-dev jq && \ rm -rf /var/lib/apt/lists/* -#----------------------------------------------------------------------------- -# install tendermint - -# set the repo and install tendermint -- should track vendored commit -ENV REPO_ALIAS github.com/tendermint/tendermint -ENV REPO github.com/eris-ltd/tendermint -#ENV COMMIT 4ee387d0770ed379e2d524f7077938517b38cd7c -ENV COMMIT working -# note, we want to lock in the same commit number -# as eris-db has vendored. -RUN mkdir --parents $GOPATH/src/$REPO -WORKDIR $GOPATH/src/$REPO_ALIAS -RUN git clone --quiet https://$REPO . && \ - git checkout --quiet $COMMIT && \ - go build -o /usr/local/bin/tendermint ./cmd/tendermint - #----------------------------------------------------------------------------- # install erisdb +# +ENV GO15VENDOREXPERIMENT 1 # set the repo and install erisdb ENV REPO $GOPATH/src/github.com/eris-ltd/eris-db -COPY . $REPO WORKDIR $REPO +COPY . $REPO RUN cd ./cmd/erisdb && go build -o /usr/local/bin/erisdb && \ cd ../erisdbss && go build -o /usr/local/bin/erisdbss && cd ../.. @@ -39,15 +25,15 @@ RUN cd ./cmd/erisdb && go build -o /usr/local/bin/erisdb && \ # install mint-client tools # set the repo and install mint-client -ENV REPO github.com/eris-ltd/mint-client -ENV BRANCH develop -RUN mkdir --parents $GOPATH/src/$REPO -WORKDIR $GOPATH/src/$REPO -RUN git clone --quiet https://$REPO . && \ - git checkout --quiet $BRANCH && \ - go install ./... && \ - mv $GOPATH/bin/mint* /usr/local/bin && \ - mv ./mint-client /usr/local/bin/ +#ENV REPO github.com/eris-ltd/mint-client +#ENV BRANCH develop +#RUN mkdir --parents $GOPATH/src/$REPO +#WORKDIR $GOPATH/src/$REPO +#RUN git clone --quiet https://$REPO . && \ +# git checkout --quiet $BRANCH && \ +# go install ./... && \ +# mv $GOPATH/bin/mint* /usr/local/bin && \ +# mv ./mint-client /usr/local/bin/ #----------------------------------------------------------------------------- # cleanup @@ -92,4 +78,4 @@ ENV TMROOT /home/$USER/.eris/blockchains/tendermint EXPOSE 1337 EXPOSE 46656 EXPOSE 46657 -ENTRYPOINT ["erisdb-wrapper"] +ENTRYPOINT ["erisdb"] diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 4df4cf80991706277da5e5a4ff0d150dd2a0bf62..8d38546120c9fd94694f9dde5595d3846eb5211c 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -151,7 +151,7 @@ }, { "ImportPath": "github.com/tendermint/go-rpc", - "Rev": "1370f89864b10518e9753078dc2d7f769685e9a0" + "Rev": "6607232a5daf1b474c4578836750e71943793c48" }, { "ImportPath": "github.com/tendermint/go-wire", diff --git a/erisdb/serve.go b/erisdb/serve.go index 09496a968c206b72b84a785e98d75a9fd5892808..813e9ce4b637875afe64510055d98760908a9397 100644 --- a/erisdb/serve.go +++ b/erisdb/serve.go @@ -108,7 +108,7 @@ func ServeErisDB(workDir string) (*server.ServeProcess, error) { // Start the tmsp listener for state update commands go func() { // TODO config - _, err := tmsp.StartListener("tcp://0.0.0.0:46658", app) + _, err := tmsp.StartListener(sConf.Consensus.TMSPListener, app) if err != nil { // TODO: play nice Exit(err.Error()) diff --git a/server/config.go b/server/config.go index 9a4e1ed926ecb93817fa9ea13d704333e9bb562e..7354408ff26e997e04da58191c5fb41ee86f449c 100644 --- a/server/config.go +++ b/server/config.go @@ -57,7 +57,8 @@ type ( } Consensus struct { - TendermintHost string `toml"tendermint_host"` + TendermintHost string `toml:"tendermint_host"` + TMSPListener string `toml:"tmsp_listener"` } ) @@ -88,6 +89,7 @@ func DefaultServerConfig() *ServerConfig { }, Consensus: Consensus{ TendermintHost: "0.0.0.0:46657", + TMSPListener: "tcp://0.0.0.0:46658", }, } } diff --git a/tmsp/erisdb.go b/tmsp/erisdb.go index 849b1d92a98b4d4c34139414c71ebffda064d446..8ab9db62455a95962e1c258fbb65f9da2c4b16cc 100644 --- a/tmsp/erisdb.go +++ b/tmsp/erisdb.go @@ -57,7 +57,7 @@ func (app *ErisDBApp) ResetCheckCache() { func (app *ErisDBApp) SetHostAddress(host string) { app.host = host - app.client = client.NewClientURI(fmt.Sprintf("http://%s", host)) + app.client = client.NewClientURI(host) //fmt.Sprintf("http://%s", host)) } // Broadcast a tx to the tendermint core diff --git a/vendor/github.com/tendermint/go-rpc/client/http_client.go b/vendor/github.com/tendermint/go-rpc/client/http_client.go index 6bb746d2e48810029e1493cd4091ecaa237f315e..100507196693e6157a5b04e23d87d94945c9d365 100644 --- a/vendor/github.com/tendermint/go-rpc/client/http_client.go +++ b/vendor/github.com/tendermint/go-rpc/client/http_client.go @@ -5,45 +5,63 @@ import ( "encoding/json" "errors" "io/ioutil" + "net" "net/http" "net/url" - "strings" . "github.com/tendermint/go-common" "github.com/tendermint/go-rpc/types" "github.com/tendermint/go-wire" ) -// JSON rpc takes params as a slice -type ClientJSONRPC struct { - remote string +// Set the net.Dial manually so we can do http over tcp or unix. +// Get/Post require a dummyDomain but it's over written by the Transport +var dummyDomain = "http://dummyDomain/" + +func unixDial(remote string) func(string, string) (net.Conn, error) { + return func(proto, addr string) (conn net.Conn, err error) { + return net.Dial("unix", remote) + } } -func NewClientJSONRPC(remote string) *ClientJSONRPC { - return &ClientJSONRPC{remote} +func tcpDial(remote string) func(string, string) (net.Conn, error) { + return func(proto, addr string) (conn net.Conn, err error) { + return net.Dial("tcp", remote) + } } -func (c *ClientJSONRPC) Call(method string, params []interface{}, result interface{}) (interface{}, error) { - return CallHTTP_JSONRPC(c.remote, method, params, result) +func socketTransport(remote string) *http.Transport { + if rpctypes.SocketType(remote) == "unix" { + return &http.Transport{ + Dial: unixDial(remote), + } + } else { + return &http.Transport{ + Dial: tcpDial(remote), + } + } } -// URI takes params as a map -type ClientURI struct { +//------------------------------------------------------------------------------------ + +// JSON rpc takes params as a slice +type ClientJSONRPC struct { remote string + client *http.Client } -func NewClientURI(remote string) *ClientURI { - if !strings.HasSuffix(remote, "/") { - remote = remote + "/" +func NewClientJSONRPC(remote string) *ClientJSONRPC { + return &ClientJSONRPC{ + remote: remote, + client: &http.Client{Transport: socketTransport(remote)}, } - return &ClientURI{remote} } -func (c *ClientURI) Call(method string, params map[string]interface{}, result interface{}) (interface{}, error) { - return CallHTTP_URI(c.remote, method, params, result) +func (c *ClientJSONRPC) Call(method string, params []interface{}, result interface{}) (interface{}, error) { + return c.call(method, params, result) } -func CallHTTP_JSONRPC(remote string, method string, params []interface{}, result interface{}) (interface{}, error) { +func (c *ClientJSONRPC) call(method string, params []interface{}, result interface{}) (interface{}, error) { // Make request and get responseBytes request := rpctypes.RPCRequest{ JSONRPC: "2.0", @@ -53,8 +71,8 @@ func CallHTTP_JSONRPC(remote string, method string, params []interface{}, result } requestBytes := wire.JSONBytes(request) requestBuf := bytes.NewBuffer(requestBytes) - log.Info(Fmt("RPC request to %v (%v): %v", remote, method, string(requestBytes))) - httpResponse, err := http.Post(remote, "text/json", requestBuf) + log.Info(Fmt("RPC request to %v (%v): %v", c.remote, method, string(requestBytes))) + httpResponse, err := c.client.Post(dummyDomain, "text/json", requestBuf) if err != nil { return nil, err } @@ -63,17 +81,36 @@ func CallHTTP_JSONRPC(remote string, method string, params []interface{}, result if err != nil { return nil, err } - log.Info(Fmt("RPC response: %v", string(responseBytes))) + // log.Info(Fmt("RPC response: %v", string(responseBytes))) return unmarshalResponseBytes(responseBytes, result) } -func CallHTTP_URI(remote string, method string, params map[string]interface{}, result interface{}) (interface{}, error) { +//------------------------------------------------------------- + +// URI takes params as a map +type ClientURI struct { + remote string + client *http.Client +} + +func NewClientURI(remote string) *ClientURI { + return &ClientURI{ + remote: remote, + client: &http.Client{Transport: socketTransport(remote)}, + } +} + +func (c *ClientURI) Call(method string, params map[string]interface{}, result interface{}) (interface{}, error) { + return c.call(method, params, result) +} + +func (c *ClientURI) call(method string, params map[string]interface{}, result interface{}) (interface{}, error) { values, err := argsToURLValues(params) if err != nil { return nil, err } - log.Info(Fmt("URI request to %v (%v): %v", remote, method, values)) - resp, err := http.PostForm(remote+method, values) + log.Info(Fmt("URI request to %v (%v): %v", c.remote, method, values)) + resp, err := c.client.PostForm(dummyDomain+method, values) if err != nil { return nil, err } diff --git a/vendor/github.com/tendermint/go-rpc/server/http_server.go b/vendor/github.com/tendermint/go-rpc/server/http_server.go index 1271d073bb6b4791c49ee65c04b02e1e7c7c1834..beec9bcc277d579eeb269c88460e7f1b963b4962 100644 --- a/vendor/github.com/tendermint/go-rpc/server/http_server.go +++ b/vendor/github.com/tendermint/go-rpc/server/http_server.go @@ -17,11 +17,14 @@ import ( ) func StartHTTPServer(listenAddr string, handler http.Handler) (net.Listener, error) { - log.Notice(Fmt("Starting RPC HTTP server on %v", listenAddr)) - listener, err := net.Listen("tcp", listenAddr) + // listenAddr is `IP:PORT` or /path/to/socket + socketType := SocketType(listenAddr) + log.Notice(Fmt("Starting RPC HTTP server on %s socket %v", socketType, listenAddr)) + listener, err := net.Listen(socketType, listenAddr) if err != nil { - return nil, fmt.Errorf("Failed to listen to %v", listenAddr) + return nil, fmt.Errorf("Failed to listen to %v: %v", listenAddr, err) } + go func() { res := http.Serve( listener, diff --git a/vendor/github.com/tendermint/go-rpc/types/types.go b/vendor/github.com/tendermint/go-rpc/types/types.go index a35e3dae84b7ffeae72d0091a150531cda930e7c..d7461f4e1bb0222d30ce06da0bf0c6fdaae50860 100644 --- a/vendor/github.com/tendermint/go-rpc/types/types.go +++ b/vendor/github.com/tendermint/go-rpc/types/types.go @@ -2,6 +2,7 @@ package rpctypes import ( "encoding/json" + "strings" "github.com/tendermint/go-events" "github.com/tendermint/go-wire" @@ -77,3 +78,16 @@ type WSRPCContext struct { Request RPCRequest WSRPCConnection } + +//---------------------------------------- +// sockets +// +// Determine if its a unix or tcp socket. +// If tcp, must specify the port; `0.0.0.0` will return incorrectly as "unix" since there's no port +func SocketType(listenAddr string) string { + socketType := "unix" + if len(strings.Split(listenAddr, ":")) == 2 { + socketType = "tcp" + } + return socketType +}