From 29930da52272b8fd644c38cc303ba6aa66e49182 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 28 Mar 2015 21:27:50 +0100 Subject: [PATCH 1/8] eth_getStorageAt output hex should begin with 0x --- rpc/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/api.go b/rpc/api.go index 78e464c99..05c264b6f 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -99,7 +99,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err state := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address) value := state.StorageString(args.Key) - *reply = common.Bytes2Hex(value.Bytes()) + *reply = common.ToHex(value.Bytes()) case "eth_getTransactionCount": args := new(GetTxCountArgs) if err := json.Unmarshal(req.Params, &args); err != nil { From e80ef9ff34562410fbab63ccf173b17508b026ed Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 28 Mar 2015 21:41:34 +0100 Subject: [PATCH 2/8] Cleanup --- rpc/api.go | 1 - rpc/args.go | 21 +++++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index 05c264b6f..502079177 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -13,7 +13,6 @@ import ( type EthereumApi struct { eth *xeth.XEth xethMu sync.RWMutex - db common.Database } func NewEthereumApi(xeth *xeth.XEth) *EthereumApi { diff --git a/rpc/args.go b/rpc/args.go index a075f1a59..25a6c7a4f 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -1,9 +1,7 @@ package rpc import ( - "bytes" "encoding/json" - // "errors" "fmt" "math/big" @@ -105,8 +103,8 @@ type GetBlockByHashArgs struct { func (args *GetBlockByHashArgs) UnmarshalJSON(b []byte) (err error) { var obj []interface{} - r := bytes.NewReader(b) - if err := json.NewDecoder(r).Decode(&obj); err != nil { + + if err := json.Unmarshal(b, &obj); err != nil { return NewDecodeParamError(err.Error()) } @@ -134,8 +132,7 @@ type GetBlockByNumberArgs struct { func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) { var obj []interface{} - r := bytes.NewReader(b) - if err := json.NewDecoder(r).Decode(&obj); err != nil { + if err := json.Unmarshal(b, &obj); err != nil { return NewDecodeParamError(err.Error()) } @@ -405,8 +402,7 @@ type BlockNumIndexArgs struct { func (args *BlockNumIndexArgs) UnmarshalJSON(b []byte) (err error) { var obj []interface{} - r := bytes.NewReader(b) - if err := json.NewDecoder(r).Decode(&obj); err != nil { + if err := json.Unmarshal(b, &obj); err != nil { return NewDecodeParamError(err.Error()) } @@ -436,8 +432,7 @@ type HashIndexArgs struct { func (args *HashIndexArgs) UnmarshalJSON(b []byte) (err error) { var obj []interface{} - r := bytes.NewReader(b) - if err := json.NewDecoder(r).Decode(&obj); err != nil { + if err := json.Unmarshal(b, &obj); err != nil { return NewDecodeParamError(err.Error()) } @@ -468,8 +463,7 @@ type Sha3Args struct { func (args *Sha3Args) UnmarshalJSON(b []byte) (err error) { var obj []interface{} - r := bytes.NewReader(b) - if err := json.NewDecoder(r).Decode(&obj); err != nil { + if err := json.Unmarshal(b, &obj); err != nil { return NewDecodeParamError(err.Error()) } @@ -798,8 +792,7 @@ type FilterStringArgs struct { func (args *FilterStringArgs) UnmarshalJSON(b []byte) (err error) { var obj []interface{} - r := bytes.NewReader(b) - if err := json.NewDecoder(r).Decode(&obj); err != nil { + if err := json.Unmarshal(b, &obj); err != nil { return NewDecodeParamError(err.Error()) } From d9f8b1e0c145e9bd46fe3a78570310ed3bd7d09d Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 28 Mar 2015 21:42:44 +0100 Subject: [PATCH 3/8] Report InvalidTypeError as -32602 to JSON RPC --- rpc/http.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/http.go b/rpc/http.go index 879ffce3b..919c567bd 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -76,7 +76,7 @@ func RpcResponse(api *EthereumApi, request *RpcRequest) *interface{} { case *NotImplementedError: jsonerr := &RpcErrorObject{-32601, reserr.Error()} response = &RpcErrorResponse{Jsonrpc: jsonrpcver, Id: request.Id, Error: jsonerr} - case *DecodeParamError, *InsufficientParamsError, *ValidationError: + case *DecodeParamError, *InsufficientParamsError, *ValidationError, *InvalidTypeError: jsonerr := &RpcErrorObject{-32602, reserr.Error()} response = &RpcErrorResponse{Jsonrpc: jsonrpcver, Id: request.Id, Error: jsonerr} default: From 129fabddb27e21e503240ee250b2cbeb9e396cdc Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 28 Mar 2015 21:47:16 +0100 Subject: [PATCH 4/8] Prefer hex prefixed with 0x --- rpc/responses.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc/responses.go b/rpc/responses.go index f5f3a33f3..d219ebd72 100644 --- a/rpc/responses.go +++ b/rpc/responses.go @@ -243,8 +243,8 @@ func (l *LogRes) MarshalJSON() ([]byte, error) { } ext.Address = l.Address.Hex() - ext.Data = common.Bytes2Hex(l.Data) - ext.Number = common.Bytes2Hex(big.NewInt(int64(l.Number)).Bytes()) + ext.Data = common.ToHex(l.Data) + ext.Number = common.ToHex(big.NewInt(int64(l.Number)).Bytes()) ext.Topics = make([]string, len(l.Topics)) for i, v := range l.Topics { ext.Topics[i] = v.Hex() From 82eeb5e02a4601edba05a2c7da7342a1fa808832 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 28 Mar 2015 22:04:36 +0100 Subject: [PATCH 5/8] Added Coveralls badges --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a163e67c7..dc965a15c 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ Ethereum Go Client © 2014 Jeffrey Wilcke. | Linux | OSX | Windows | Tests ----------|---------|-----|---------|------ -develop | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20develop%20branch)](https://build.ethdev.com/builders/Linux%20Go%20develop%20branch/builds/-1) | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20develop%20branch)](https://build.ethdev.com/builders/OSX%20Go%20develop%20branch/builds/-1) | N/A | [![Buildr+Status](https://travis-ci.org/ethereum/go-ethereum.svg?branch=develop)](https://travis-ci.org/ethereum/go-ethereum) -master | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20master%20branch)](https://build.ethdev.com/builders/Linux%20Go%20master%20branch/builds/-1) | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=OSX%20Go%20master%20branch)](https://build.ethdev.com/builders/OSX%20Go%20master%20branch/builds/-1) | N/A | [![Buildr+Status](https://travis-ci.org/ethereum/go-ethereum.svg?branch=master)](https://travis-ci.org/ethereum/go-ethereum) +develop | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20develop%20branch)](https://build.ethdev.com/builders/Linux%20Go%20develop%20branch/builds/-1) | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20develop%20branch)](https://build.ethdev.com/builders/OSX%20Go%20develop%20branch/builds/-1) | N/A | [![Buildr+Status](https://travis-ci.org/ethereum/go-ethereum.svg?branch=develop)](https://travis-ci.org/ethereum/go-ethereum) [![Coverage Status](https://coveralls.io/repos/ethereum/go-ethereum/badge.svg?branch=develop)](https://coveralls.io/r/ethereum/go-ethereum?branch=develop) +master | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20master%20branch)](https://build.ethdev.com/builders/Linux%20Go%20master%20branch/builds/-1) | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=OSX%20Go%20master%20branch)](https://build.ethdev.com/builders/OSX%20Go%20master%20branch/builds/-1) | N/A | [![Buildr+Status](https://travis-ci.org/ethereum/go-ethereum.svg?branch=master)](https://travis-ci.org/ethereum/go-ethereum) [![Coverage Status](https://coveralls.io/repos/ethereum/go-ethereum/badge.svg?branch=master)](https://coveralls.io/r/ethereum/go-ethereum?branch=master) [![Bugs](https://badge.waffle.io/ethereum/go-ethereum.png?label=bug&title=Bugs)](https://waffle.io/ethereum/go-ethereum) [![Stories in Ready](https://badge.waffle.io/ethereum/go-ethereum.png?label=ready&title=Ready)](https://waffle.io/ethereum/go-ethereum) From 2ca6a800adbb5c43f96df5918be0d55ed3aa1867 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 28 Mar 2015 22:16:04 +0100 Subject: [PATCH 6/8] Remove old go cover location --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7e47281cf..d6954e0cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ 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 - - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi + - go get golang.org/x/tools/cmd/cover - go get github.com/mattn/goveralls before_script: # - gofmt -l -w . From eb79938060fff279dbac5fc2a599bb27b52c085c Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 28 Mar 2015 22:17:08 +0100 Subject: [PATCH 7/8] Docker rename ethereum to geth --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 966614e71..fcd564a34 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,10 +30,10 @@ RUN mkdir -p $GOPATH/src/github.com/ethereum/ RUN git clone https://github.com/ethereum/go-ethereum $GOPATH/src/github.com/ethereum/go-ethereum WORKDIR $GOPATH/src/github.com/ethereum/go-ethereum RUN git checkout develop -RUN GOPATH=$GOPATH:$GOPATH/src/github.com/ethereum/go-ethereum/Godeps/_workspace go install -v ./cmd/ethereum +RUN GOPATH=$GOPATH:$GOPATH/src/github.com/ethereum/go-ethereum/Godeps/_workspace go install -v ./cmd/geth ## Run & expose JSON RPC -ENTRYPOINT ["ethereum", "-rpc=true", "-rpcport=8545"] +ENTRYPOINT ["geth", "-rpc=true", "-rpcport=8545"] EXPOSE 8545 From 391d79ef44ad2e76754ef8dfb5e9dfbdd5a69acd Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sun, 29 Mar 2015 12:08:52 +0200 Subject: [PATCH 8/8] Add ExtraData field to RPC output --- rpc/responses.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc/responses.go b/rpc/responses.go index d219ebd72..9767cac3b 100644 --- a/rpc/responses.go +++ b/rpc/responses.go @@ -70,7 +70,7 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) { ext.Difficulty = common.ToHex(b.Difficulty.Bytes()) ext.TotalDifficulty = common.ToHex(b.TotalDifficulty.Bytes()) ext.Size = common.ToHex(b.Size.Bytes()) - // ext.ExtraData = common.ToHex(b.ExtraData) + ext.ExtraData = common.ToHex(b.ExtraData) ext.GasLimit = common.ToHex(b.GasLimit.Bytes()) // ext.MinGasPrice = common.ToHex(big.NewInt(b.MinGasPrice).Bytes()) ext.GasUsed = common.ToHex(b.GasUsed.Bytes()) @@ -111,7 +111,7 @@ func NewBlockRes(block *types.Block) *BlockRes { res.Difficulty = block.Difficulty() res.TotalDifficulty = block.Td res.Size = big.NewInt(int64(block.Size())) - // res.ExtraData = + res.ExtraData = []byte(block.Header().Extra) res.GasLimit = block.GasLimit() // res.MinGasPrice = res.GasUsed = block.GasUsed()