From bc3b406bffc9c6f38420f1504cb7eba0b92cad3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 4 May 2016 19:45:50 +0300 Subject: [PATCH 1/6] travis: run CI builds against multiple Go versions --- .travis.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c1d545c548..24486d4a0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,12 @@ language: go go: - 1.4.2 + - 1.5.4 + - 1.6.2 install: # - go get code.google.com/p/go.tools/cmd/goimports # - go get github.com/golang/lint/golint - # - go get golang.org/x/tools/cmd/vet + # - go get golang.org/x/tools/cmd/vet - go get golang.org/x/tools/cmd/cover before_script: # - gofmt -l -w . @@ -24,6 +26,6 @@ notifications: webhooks: urls: - https://webhooks.gitter.im/e/e09ccdce1048c5e03445 - on_success: change + on_success: change on_failure: always - on_start: false + on_start: false From a824c3f02f74eb11b4382abbb92aa8babc5d685c Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 10 May 2016 13:35:01 +0200 Subject: [PATCH 2/6] miner: fixed pending state by not shutting down update loop --- miner/worker.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index 3d1928bf63..fe759560c2 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -145,7 +145,6 @@ func newWorker(config *core.ChainConfig, coinbase common.Address, eth core.Backe fullValidation: false, } worker.events = worker.mux.Subscribe(core.ChainHeadEvent{}, core.ChainSideEvent{}, core.TxPreEvent{}) - worker.wg.Add(1) go worker.update() go worker.wait() @@ -188,8 +187,6 @@ func (self *worker) start() { } func (self *worker) stop() { - // Quit update. - self.events.Unsubscribe() self.wg.Wait() self.mu.Lock() @@ -224,7 +221,6 @@ func (self *worker) unregister(agent Agent) { } func (self *worker) update() { - defer self.wg.Done() for event := range self.events.Chan() { // A real event arrived, process interesting content switch ev := event.Data.(type) { From 54790977904cd51671ab57d926d83175dbc2ca55 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Tue, 10 May 2016 18:01:58 +0200 Subject: [PATCH 3/6] rpc: HTTP origin case insensitive --- rpc/websocket.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rpc/websocket.go b/rpc/websocket.go index 1303f98db1..fe9354d946 100644 --- a/rpc/websocket.go +++ b/rpc/websocket.go @@ -61,22 +61,22 @@ func wsHandshakeValidator(allowedOrigins []string) func(*websocket.Config, *http allowAllOrigins = true } if origin != "" { - origins.Add(origin) + origins.Add(strings.ToLower(origin)) } } - // allow localhost if no allowedOrigins are specified + // allow localhost if no allowedOrigins are specified. if len(origins.List()) == 0 { origins.Add("http://localhost") if hostname, err := os.Hostname(); err == nil { - origins.Add("http://" + hostname) + origins.Add("http://" + strings.ToLower(hostname)) } } glog.V(logger.Debug).Infof("Allowed origin(s) for WS RPC interface %v\n", origins.List()) f := func(cfg *websocket.Config, req *http.Request) error { - origin := req.Header.Get("Origin") + origin := strings.ToLower(req.Header.Get("Origin")) if allowAllOrigins || origins.Has(origin) { return nil } From bc6fdad786706019fc5aeb9605f1d23b3c5b7522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 11 May 2016 11:49:44 +0300 Subject: [PATCH 4/6] cmd/geth, internal/web3ext, rpc: surface rpc module, fix shh, fix miner --- cmd/geth/js.go | 2 +- internal/web3ext/web3ext.go | 247 +++++++++++++++++++----------------- rpc/server.go | 5 +- rpc/utils.go | 2 +- 4 files changed, 136 insertions(+), 120 deletions(-) diff --git a/cmd/geth/js.go b/cmd/geth/js.go index 2b64303b2b..25c4d1a21e 100644 --- a/cmd/geth/js.go +++ b/cmd/geth/js.go @@ -199,7 +199,7 @@ func (js *jsre) apiBindings() error { // load only supported API's in javascript runtime shortcuts := "var eth = web3.eth; var personal = web3.personal; " for _, apiName := range apiNames { - if apiName == "web3" || apiName == "rpc" { + if apiName == "web3" { continue // manually mapped or ignore } diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go index 64c1b5044b..9ce106cb8f 100644 --- a/internal/web3ext/web3ext.go +++ b/internal/web3ext/web3ext.go @@ -18,44 +18,17 @@ package web3ext var Modules = map[string]string{ - "txpool": TxPool_JS, "admin": Admin_JS, - "personal": Personal_JS, + "debug": Debug_JS, "eth": Eth_JS, "miner": Miner_JS, - "debug": Debug_JS, "net": Net_JS, + "personal": Personal_JS, + "rpc": RPC_JS, + "shh": Shh_JS, + "txpool": TxPool_JS, } -const TxPool_JS = ` -web3._extend({ - property: 'txpool', - methods: - [ - ], - properties: - [ - new web3._extend.Property({ - name: 'content', - getter: 'txpool_content' - }), - new web3._extend.Property({ - name: 'inspect', - getter: 'txpool_inspect' - }), - new web3._extend.Property({ - name: 'status', - getter: 'txpool_status', - outputFormatter: function(status) { - status.pending = web3._extend.utils.toDecimal(status.pending); - status.queued = web3._extend.utils.toDecimal(status.queued); - return status; - } - }) - ] -}); -` - const Admin_JS = ` web3._extend({ property: 'admin', @@ -176,88 +149,6 @@ web3._extend({ }); ` -const Personal_JS = ` -web3._extend({ - property: 'personal', - methods: - [ - new web3._extend.Method({ - name: 'importRawKey', - call: 'personal_importRawKey', - params: 2 - }) - ] -}); -` - -const Eth_JS = ` -web3._extend({ - property: 'eth', - methods: - [ - new web3._extend.Method({ - name: 'sign', - call: 'eth_sign', - params: 2, - inputFormatter: [web3._extend.formatters.inputAddressFormatter, null] - }), - new web3._extend.Method({ - name: 'resend', - call: 'eth_resend', - params: 3, - inputFormatter: [web3._extend.formatters.inputTransactionFormatter, web3._extend.utils.fromDecimal, web3._extend.utils.fromDecimal] - }), - new web3._extend.Method({ - name: 'getNatSpec', - call: 'eth_getNatSpec', - params: 1, - inputFormatter: [web3._extend.formatters.inputTransactionFormatter] - }), - new web3._extend.Method({ - name: 'signTransaction', - call: 'eth_signTransaction', - params: 1, - inputFormatter: [web3._extend.formatters.inputTransactionFormatter] - }), - new web3._extend.Method({ - name: 'submitTransaction', - call: 'eth_submitTransaction', - params: 1, - inputFormatter: [web3._extend.formatters.inputTransactionFormatter] - }) - ], - properties: - [ - new web3._extend.Property({ - name: 'pendingTransactions', - getter: 'eth_pendingTransactions', - outputFormatter: function(txs) { - var formatted = []; - for (var i = 0; i < txs.length; i++) { - formatted.push(web3._extend.formatters.outputTransactionFormatter(txs[i])); - formatted[i].blockHash = null; - } - return formatted; - } - }) - ] -}); -` - -const Net_JS = ` -web3._extend({ - property: 'net', - methods: [], - properties: - [ - new web3._extend.Property({ - name: 'version', - getter: 'net_version' - }) - ] -}); -` - const Debug_JS = ` web3._extend({ property: 'debug', @@ -410,6 +301,60 @@ web3._extend({ }); ` +const Eth_JS = ` +web3._extend({ + property: 'eth', + methods: + [ + new web3._extend.Method({ + name: 'sign', + call: 'eth_sign', + params: 2, + inputFormatter: [web3._extend.formatters.inputAddressFormatter, null] + }), + new web3._extend.Method({ + name: 'resend', + call: 'eth_resend', + params: 3, + inputFormatter: [web3._extend.formatters.inputTransactionFormatter, web3._extend.utils.fromDecimal, web3._extend.utils.fromDecimal] + }), + new web3._extend.Method({ + name: 'getNatSpec', + call: 'eth_getNatSpec', + params: 1, + inputFormatter: [web3._extend.formatters.inputTransactionFormatter] + }), + new web3._extend.Method({ + name: 'signTransaction', + call: 'eth_signTransaction', + params: 1, + inputFormatter: [web3._extend.formatters.inputTransactionFormatter] + }), + new web3._extend.Method({ + name: 'submitTransaction', + call: 'eth_submitTransaction', + params: 1, + inputFormatter: [web3._extend.formatters.inputTransactionFormatter] + }) + ], + properties: + [ + new web3._extend.Property({ + name: 'pendingTransactions', + getter: 'eth_pendingTransactions', + outputFormatter: function(txs) { + var formatted = []; + for (var i = 0; i < txs.length; i++) { + formatted.push(web3._extend.formatters.outputTransactionFormatter(txs[i])); + formatted[i].blockHash = null; + } + return formatted; + } + }) + ] +}); +` + const Miner_JS = ` web3._extend({ property: 'miner', @@ -440,7 +385,7 @@ web3._extend({ name: 'setGasPrice', call: 'miner_setGasPrice', params: 1, - inputFormatter: [web3._extend.utils.fromDecial] + inputFormatter: [web3._extend.utils.fromDecimal] }), new web3._extend.Method({ name: 'startAutoDAG', @@ -463,6 +408,48 @@ web3._extend({ }); ` +const Net_JS = ` +web3._extend({ + property: 'net', + methods: [], + properties: + [ + new web3._extend.Property({ + name: 'version', + getter: 'net_version' + }) + ] +}); +` + +const Personal_JS = ` +web3._extend({ + property: 'personal', + methods: + [ + new web3._extend.Method({ + name: 'importRawKey', + call: 'personal_importRawKey', + params: 2 + }) + ] +}); +` + +const RPC_JS = ` +web3._extend({ + property: 'rpc', + methods: [], + properties: + [ + new web3._extend.Property({ + name: 'modules', + getter: 'rpc_modules' + }) + ] +}); +` + const Shh_JS = ` web3._extend({ property: 'shh', @@ -471,7 +458,35 @@ web3._extend({ [ new web3._extend.Property({ name: 'version', - getter: 'shh_version' + getter: 'shh_version', + outputFormatter: web3._extend.utils.toDecimal + }) + ] +}); +` + +const TxPool_JS = ` +web3._extend({ + property: 'txpool', + methods: [], + properties: + [ + new web3._extend.Property({ + name: 'content', + getter: 'txpool_content' + }), + new web3._extend.Property({ + name: 'inspect', + getter: 'txpool_inspect' + }), + new web3._extend.Property({ + name: 'status', + getter: 'txpool_status', + outputFormatter: function(status) { + status.pending = web3._extend.utils.toDecimal(status.pending); + status.queued = web3._extend.utils.toDecimal(status.queued); + return status; + } }) ] }); diff --git a/rpc/server.go b/rpc/server.go index 001107a1b7..69f3271e8e 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -34,7 +34,8 @@ const ( notificationBufferSize = 10000 // max buffered notifications before codec is closed - DefaultIPCApis = "admin,eth,debug,miner,net,shh,txpool,personal,web3" + MetadataApi = "rpc" + DefaultIPCApis = "admin,debug,eth,miner,net,personal,shh,txpool,web3" DefaultHTTPApis = "eth,net,web3" ) @@ -61,7 +62,7 @@ func NewServer() *Server { // register a default service which will provide meta information about the RPC service such as the services and // methods it offers. rpcService := &RPCService{server} - server.RegisterName("rpc", rpcService) + server.RegisterName(MetadataApi, rpcService) return server } diff --git a/rpc/utils.go b/rpc/utils.go index 86938e9b37..fe482e19dd 100644 --- a/rpc/utils.go +++ b/rpc/utils.go @@ -234,7 +234,7 @@ func SupportedModules(client Client) (map[string]string, error) { req := JSONRequest{ Id: []byte("1"), Version: "2.0", - Method: "rpc_modules", + Method: MetadataApi + "_modules", } if err := client.Send(req); err != nil { return nil, err From 284f1d6beb589d240a18e9b63560266041fa9798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 11 May 2016 11:58:48 +0300 Subject: [PATCH 5/6] cmd/geth: use text/templates in the tester, not html --- cmd/geth/run_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/geth/run_test.go b/cmd/geth/run_test.go index a82eb9d68a..ba4ce0c60f 100644 --- a/cmd/geth/run_test.go +++ b/cmd/geth/run_test.go @@ -20,7 +20,6 @@ import ( "bufio" "bytes" "fmt" - "html/template" "io" "io/ioutil" "os" @@ -28,6 +27,7 @@ import ( "regexp" "sync" "testing" + "text/template" "time" ) From 8aaaa7bd15859e7157f0688b588dea3decc50ca6 Mon Sep 17 00:00:00 2001 From: Changhoon Lee <6londe@gmail.com> Date: Thu, 12 May 2016 17:21:19 +0900 Subject: [PATCH 6/6] Typo fixed README typo fixed --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index aaf44997d6..bdd85b3fa4 100644 --- a/README.md +++ b/README.md @@ -58,14 +58,14 @@ anyone on the internet, and are grateful for even the smallest of fixes! If you'd like to contribute to go-ethereum, please fork, fix, commit and send a pull request for the maintainers to review and merge into the main code base. If you wish to submit more complex changes though, please check up with the core devs first on [our gitter channel](https://gitter.im/ethereum/go-ethereum) -to ensure those changes are in line with the general philosopy of the project and/or get some +to ensure those changes are in line with the general philosophy of the project and/or get some early feedback which can make both your efforts much lighter as well as our review and merge procedures quick and simple. -Please make sure your contributions adhere to our coding guidlines: +Please make sure your contributions adhere to our coding guidelines: * Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)). - * Code must be documented adherign to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines. + * Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines. * Pull requests need to be based on and opened against the `develop` branch. * Commit messages should be prefixed with the package(s) they modify. * E.g. "eth, rpc: make trace configs optional"