From cfe037028081ebb84ee35caa5b16fed5d125b58a Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sun, 1 Mar 2015 16:19:06 +0100 Subject: [PATCH 1/6] Remove Websockets RPC transport --- cmd/ethereum/flags.go | 3 -- cmd/ethereum/main.go | 4 -- cmd/mist/flags.go | 3 -- cmd/mist/main.go | 4 -- cmd/utils/cmd.go | 13 ----- eth/backend.go | 5 +- rpc/ws/server.go | 121 ------------------------------------------ 7 files changed, 1 insertion(+), 152 deletions(-) delete mode 100644 rpc/ws/server.go diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index 7d410c8e4..fd8aee90b 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -44,7 +44,6 @@ var ( StartRpc bool StartWebSockets bool RpcPort int - WsPort int OutboundPort string ShowGenesis bool AddPeer string @@ -94,9 +93,7 @@ func Init() { flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") - flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on") flag.BoolVar(&StartRpc, "rpc", false, "start rpc server") - flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server") flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)") flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key") flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)") diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 45e6f7b93..63585b0f5 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -131,10 +131,6 @@ func main() { utils.StartRpc(ethereum, RpcPort) } - if StartWebSockets { - utils.StartWebSockets(ethereum, WsPort) - } - utils.StartEthereum(ethereum) if StartJsConsole { diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index 0010df826..06768657d 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -43,7 +43,6 @@ var ( StartRpc bool StartWebSockets bool RpcPort int - WsPort int OutboundPort string ShowGenesis bool AddPeer string @@ -80,9 +79,7 @@ func Init() { flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") - flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on") flag.BoolVar(&StartRpc, "rpc", true, "start rpc server") - flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server") flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)") flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key") flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)") diff --git a/cmd/mist/main.go b/cmd/mist/main.go index 3abe16767..a330bbcb1 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -76,10 +76,6 @@ func run() error { utils.StartRpc(ethereum, RpcPort) } - if StartWebSockets { - utils.StartWebSockets(ethereum, WsPort) - } - gui := NewWindow(ethereum, config, KeyRing, LogLevel) utils.RegisterInterrupt(func(os.Signal) { diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index a36c10e3b..20165fa97 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -35,7 +35,6 @@ import ( "github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/rlp" rpchttp "github.com/ethereum/go-ethereum/rpc/http" - rpcws "github.com/ethereum/go-ethereum/rpc/ws" "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/xeth" ) @@ -170,18 +169,6 @@ func StartRpc(ethereum *eth.Ethereum, RpcPort int) { } } -func StartWebSockets(eth *eth.Ethereum, wsPort int) { - clilogger.Infoln("Starting WebSockets") - - var err error - eth.WsServer, err = rpcws.NewWebSocketServer(xeth.New(eth), wsPort) - if err != nil { - clilogger.Errorf("Could not start RPC interface (port %v): %v", wsPort, err) - } else { - go eth.WsServer.Start() - } -} - var gminer *miner.Miner func GetMiner() *miner.Miner { diff --git a/eth/backend.go b/eth/backend.go index f67f9c78b..3490fb386 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -127,7 +127,6 @@ type Ethereum struct { miner *miner.Miner RpcServer rpc.RpcServer - WsServer rpc.RpcServer keyManager *crypto.KeyManager logger ethlogger.LogSystem @@ -285,9 +284,7 @@ func (s *Ethereum) Stop() { if s.RpcServer != nil { s.RpcServer.Stop() } - if s.WsServer != nil { - s.WsServer.Stop() - } + s.txPool.Stop() s.eventMux.Stop() s.blockPool.Stop() diff --git a/rpc/ws/server.go b/rpc/ws/server.go deleted file mode 100644 index 2c2988f5d..000000000 --- a/rpc/ws/server.go +++ /dev/null @@ -1,121 +0,0 @@ -/* - This file is part of go-ethereum - - go-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - go-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with go-ethereum. If not, see . -*/ -package rpcws - -import ( - "fmt" - "net" - "net/http" - - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/rpc" - "github.com/ethereum/go-ethereum/xeth" - "golang.org/x/net/websocket" -) - -var wslogger = logger.NewLogger("RPC-WS") -var JSON rpc.JsonWrapper - -type WebSocketServer struct { - pipe *xeth.XEth - port int - doneCh chan bool - listener net.Listener -} - -func NewWebSocketServer(pipe *xeth.XEth, port int) (*WebSocketServer, error) { - sport := fmt.Sprintf(":%d", port) - l, err := net.Listen("tcp", sport) - if err != nil { - return nil, err - } - - return &WebSocketServer{ - pipe, - port, - make(chan bool), - l, - }, nil -} - -func (self *WebSocketServer) handlerLoop() { - for { - select { - case <-self.doneCh: - wslogger.Infoln("Shutdown RPC-WS server") - return - } - } -} - -func (self *WebSocketServer) Stop() { - close(self.doneCh) -} - -func (self *WebSocketServer) Start() { - wslogger.Infof("Starting RPC-WS server on port %d", self.port) - go self.handlerLoop() - - api := rpc.NewEthereumApi(self.pipe) - h := self.apiHandler(api) - http.Handle("/ws", h) - - err := http.Serve(self.listener, nil) - if err != nil { - wslogger.Errorln("Error on RPC-WS interface:", err) - } -} - -func (s *WebSocketServer) apiHandler(api *rpc.EthereumApi) http.Handler { - fn := func(w http.ResponseWriter, req *http.Request) { - h := sockHandler(api) - s := websocket.Server{Handler: h} - s.ServeHTTP(w, req) - } - - return http.HandlerFunc(fn) -} - -func sockHandler(api *rpc.EthereumApi) websocket.Handler { - var jsonrpcver string = "2.0" - fn := func(conn *websocket.Conn) { - for { - wslogger.Debugln("Handling connection") - var reqParsed rpc.RpcRequest - - // reqParsed, reqerr := JSON.ParseRequestBody(conn.Request()) - if err := websocket.JSON.Receive(conn, &reqParsed); err != nil { - jsonerr := &rpc.RpcErrorObject{-32700, "Error: Could not parse request"} - JSON.Send(conn, &rpc.RpcErrorResponse{JsonRpc: jsonrpcver, ID: nil, Error: jsonerr}) - continue - } - - var response interface{} - reserr := api.GetRequestReply(&reqParsed, &response) - if reserr != nil { - wslogger.Warnln(reserr) - jsonerr := &rpc.RpcErrorObject{-32603, reserr.Error()} - JSON.Send(conn, &rpc.RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr}) - continue - } - - wslogger.Debugf("Generated response: %T %s", response, response) - JSON.Send(conn, &rpc.RpcSuccessResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Result: response}) - } - } - return websocket.Handler(fn) -} From c1bae042038091b67163beba13b57edca95c9017 Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 3 Mar 2015 01:44:29 +0700 Subject: [PATCH 2/6] update README - TLDR for godep install - update executable section - cleanup - add several links to wiki --- README.md | 83 +++++++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 18392816a..a1e39e8fa 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,25 @@ Ethereum (CLI): `go get github.com/ethereum/go-ethereum/cmd/ethereum` -For further, detailed, build instruction please see the [Wiki](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum(Go)) +As of POC-8, go-ethereum uses [Godep](https://github.com/tools/godep) to manage dependencies. Assuming you have [your environment all set up](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum(Go)), switch to the go-ethereum repository root folder, and build/install the executable you need: + +Mist (GUI): + +``` +godep go build -v ./cmd/mist +``` + +Ethereum (CLI): + +``` +godep go build -v ./cmd/ethereum +``` + +Instead of `build`, you can use `install` which will also install the resulting binary. + +For prerequisites and detailed build instructions please see the [Wiki](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum(Go)) + +If you intend to develop on go-ethereum, check the [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide) Automated (dev) builds ====================== @@ -34,68 +52,49 @@ Automated (dev) builds * [Windows] Coming soon™ * [Linux] Coming soon™ -Binaries -======== +Executables +=========== -Go Ethereum comes with several binaries found in -[cmd](https://github.com/ethereum/go-ethereum/tree/master/cmd): +Go Ethereum comes with several wrappers/executables found in +[the `cmd` directory](https://github.com/ethereum/go-ethereum/tree/develop/cmd): -* `mist` Official Ethereum Browser -* `ethereum` Ethereum CLI -* `ethtest` test tool which runs with the [tests](https://github.com/ethereum/testes) suit: +* `mist` Official Ethereum Browser (ethereum GUI client) +* `ethereum` Ethereum CLI (ethereum command line interface client) +* `bootnode` runs a bootstrap node for the Discovery Protocol +* `ethtest` test tool which runs with the [tests](https://github.com/ethereum/testes) suite: `cat file | ethtest`. * `evm` is a generic Ethereum Virtual Machine: `evm -code 60ff60ff -gas 10000 -price 0 -dump`. See `-h` for a detailed description. -* `rlpdump` converts a rlp stream to `interface{}`. -* `peerserver` simple P2P (noi-ethereum) peer server. * `disasm` disassembles EVM code: `echo "6001" | disasm` +* `rlpdump` converts a rlp stream to `interface{}`. -General command line options +Command line options ============================ +Both `mist` and `ethereum` can be configured via command line options, environment variables and config files. + +To get the options available: + ``` -== Shared between ethereum and Mist == - -= Settings --id Set the custom identifier of the client (shows up on other clients) --port Port on which the server will accept incomming connections --upnp Enable UPnP --maxpeer Desired amount of peers --rpc Start JSON RPC --dir Data directory used to store configs and databases - -= Utility --h This --import Import a private key --genaddr Generates a new address and private key (destructive action) --dump Dump a specific state of a block to stdout given the -number or -hash --difftool Supress all output and prints VM output to stdout --diff vm=only vm output, all=all output including state storage - -Ethereum only -ethereum [options] [filename] --js Start the JavaScript REPL -filename Load the given file and interpret as JavaScript --m Start mining blocks - -== Mist only == - --asset_path absolute path to GUI assets directory +ethereum -help ``` +For further details on options, see the [wiki](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options) + Contribution ============ -If you'd like to contribute to Ethereum please fork, fix, commit and +If you'd like to contribute to go-ethereum please fork, fix, commit and send a pull request. Commits who do not comply with the coding standards are ignored (use gofmt!). If you send pull requests make absolute sure that you commit on the `develop` branch and that you do not merge to master. Commits that are directly based on master are simply ignored. -For dependency management, we use [godep](https://github.com/tools/godep). After installing with `go get github.com/tools/godep`, run `godep restore` to ensure that changes to other repositories do not break the build. To update a dependency version (for example, to include a new upstream fix), run `go get -u ` then `godep update `. To track a new dependency, add it to the project as normal than run `godep save ./...`. Changes to the Godeps folder should be manually verified then commited. +For dependency management, we use [godep](https://github.com/tools/godep). After installing with `go get github.com/tools/godep`, run `godep restore` to ensure that changes to other repositories do not break the build. To update a dependency version (for example, to include a new upstream fix), run `go get -u ` then `godep update `. To track a new dependency, add it to the project as normal than run `godep save ./...`. Changes to the [Godeps folder](https://github.com/ethereum/go-ethereum/tree/develop/Godeps): should be manually verified then commited. -To make life easier try [git flow](http://nvie.com/posts/a-successful-git-branching-model/) it sets -this all up and streamlines your work flow. +To make life easier try [git flow](http://nvie.com/posts/a-successful-git-branching-model/) it sets this all up and streamlines your work flow. + +See [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide) Coding standards ================ From deb2e50296658d356c47f8382331193b180b29d4 Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 3 Mar 2015 01:45:50 +0700 Subject: [PATCH 3/6] minor cleanup --- cmd/ethereum/flags.go | 9 +++++---- cmd/mist/flags.go | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index 356571a23..d7a6427eb 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -94,7 +94,7 @@ func Init() { flag.IntVar(&VmType, "vm", 0, "Virtual Machine type: 0-1: standard, debug") flag.StringVar(&Identifier, "id", "", "Custom client identifier") flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") - flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") + flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file") flag.StringVar(&RpcListenAddress, "rpcaddr", "127.0.0.1", "address for json-rpc server to listen on") flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") @@ -109,8 +109,8 @@ func Init() { flag.StringVar(&Datadir, "datadir", ethutil.DefaultDataDir(), "specifies the datadir to use") flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file") flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)") - flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)") - flag.StringVar(&LogFormat, "logformat", "std", "logformat: std,raw)") + flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5 (= silent,error,warn,info,debug,debug detail)") + flag.StringVar(&LogFormat, "logformat", "std", "logformat: std,raw") flag.BoolVar(&DiffTool, "difftool", false, "creates output for diff'ing. Sets LogLevel=0") flag.StringVar(&DiffType, "diff", "all", "sets the level of diff output [vm, all]. Has no effect if difftool=false") flag.BoolVar(&ShowGenesis, "genesis", false, "Dump the genesis block") @@ -120,7 +120,7 @@ func Init() { flag.StringVar(&DumpHash, "hash", "", "specify arg in hex") flag.IntVar(&DumpNumber, "number", -1, "specify arg in number") - flag.BoolVar(&StartMining, "mine", false, "start dagger mining") + flag.BoolVar(&StartMining, "mine", false, "start mining") flag.BoolVar(&StartJsConsole, "js", false, "launches javascript console") flag.BoolVar(&PrintVersion, "version", false, "prints version number") flag.IntVar(&MinerThreads, "minerthreads", runtime.NumCPU(), "number of miner threads") @@ -137,6 +137,7 @@ func Init() { flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap") flag.IntVar(&MaxPeer, "maxpeer", 30, "maximum desired peers") + flag.IntVar(&MinerThreads, "minerthreads", runtime.NumCPU(), "number of miner threads") flag.Parse() diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index 1ffeb1915..2bbd1f416 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -79,7 +79,7 @@ func Init() { flag.IntVar(&VmType, "vm", 0, "Virtual Machine type: 0-1: standard, debug") flag.StringVar(&Identifier, "id", "", "Custom client identifier") flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") - flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") + flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file") flag.StringVar(&RpcListenAddress, "rpcaddr", "127.0.0.1", "address for json-rpc server to listen on") flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on") @@ -93,7 +93,7 @@ func Init() { flag.StringVar(&Datadir, "datadir", ethutil.DefaultDataDir(), "specifies the datadir to use") flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file") flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)") - flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)") + flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5 (= silent,error,warn,info,debug,debug detail)") flag.StringVar(&AssetPath, "asset_path", ethutil.DefaultAssetPath(), "absolute path to GUI assets directory") From 1d8a427753f068a7d066583a25a59232f6ecb71a Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 3 Mar 2015 01:46:25 +0700 Subject: [PATCH 4/6] remove obsolete install script --- install.sh | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100755 install.sh diff --git a/install.sh b/install.sh deleted file mode 100755 index 30a3802e4..000000000 --- a/install.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -if [ "$1" == "" ]; then - echo "Usage $0 executable branch" - echo "executable ethereum | mist" - echo "branch develop | master" - exit -fi - -exe=$1 -path=$exe -branch=$2 - -if [ "$branch" == "develop" ]; then - path="cmd/$exe" -fi - -# Test if go is installed -command -v go >/dev/null 2>&1 || { echo >&2 "Unable to find 'go'. This script requires go."; exit 1; } - -# Test if $GOPATH is set -if [ "$GOPATH" == "" ]; then - echo "\$GOPATH not set" - exit -fi - -echo "changing branch to $branch" -cd $GOPATH/src/github.com/ethereum/go-ethereum -git checkout $branch - -# installing package dependencies doesn't work for develop -# branch as go get always pulls from master head -# so build will continue to fail, but this installs locally -# for people who git clone since go install will manage deps - -#echo "go get -u -d github.com/ethereum/go-ethereum/$path" -#go get -v -u -d github.com/ethereum/go-ethereum/$path -#if [ $? != 0 ]; then -# echo "go get failed" -# exit -#fi - -cd $GOPATH/src/github.com/ethereum/go-ethereum/$path - -if [ "$exe" == "mist" ]; then - echo "Building Mist GUI. Assuming Qt is installed. If this step" - echo "fails; please refer to: https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum(Go)" -else - echo "Building ethereum CLI." -fi - -go install -echo "done. Please run $exe :-)" From 2dc1b7282a7218d637e9964b34afb7afe350279d Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 3 Mar 2015 01:51:00 +0700 Subject: [PATCH 5/6] remove threatening coding standards section from README --- README.md | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/README.md b/README.md index a1e39e8fa..bf4bf341b 100644 --- a/README.md +++ b/README.md @@ -96,34 +96,3 @@ To make life easier try [git flow](http://nvie.com/posts/a-successful-git-branch See [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide) -Coding standards -================ - -Sources should be formatted according to the [Go Formatting -Style](http://golang.org/doc/effective_go.html#formatting). - -Unless structs fields are supposed to be directly accesible, provide -Getters and hide the fields through Go's exporting facility. - -When you comment put meaningful comments. Describe in detail what you -want to achieve. - -*wrong* - -```go -// Check if the value at x is greater than y -if x > y { - // It's greater! -} -``` - -Everyone reading the source probably know what you wanted to achieve -with above code. Those are **not** meaningful comments. - -While the project isn't 100% tested I want you to write tests non the -less. I haven't got time to evaluate everyone's code in detail so I -expect you to write tests for me so I don't have to test your code -manually. (If you want to contribute by just writing tests that's fine -too!) - - From 7e224b683457884c3837967c34744c0a0996abd5 Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 3 Mar 2015 13:22:19 +0700 Subject: [PATCH 6/6] db name database -> blockchain in backend error message --- eth/backend.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/backend.go b/eth/backend.go index f67f9c78b..b79f6fc30 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -147,7 +147,7 @@ func New(config *Config) (*Ethereum, error) { d, _ := db.Get([]byte("ProtocolVersion")) protov := ethutil.NewValue(d).Uint() if protov != ProtocolVersion && protov != 0 { - path := path.Join(config.DataDir, "database") + path := path.Join(config.DataDir, "blockchain") return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, ProtocolVersion, path) }