aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Dockerfile39
-rw-r--r--cmd/geth/main.go2
-rw-r--r--docker/Dockerfile31
-rw-r--r--docker/supervisord.conf23
-rw-r--r--rpc/api.go8
-rw-r--r--rpc/args.go16
-rw-r--r--rpc/args_test.go56
7 files changed, 122 insertions, 53 deletions
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index fcd564a34..000000000
--- a/Dockerfile
+++ /dev/null
@@ -1,39 +0,0 @@
-FROM ubuntu:14.04.2
-
-## Environment setup
-ENV HOME /root
-ENV GOPATH /root/go
-ENV PATH /root/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
-
-RUN mkdir -p /root/go
-ENV DEBIAN_FRONTEND noninteractive
-
-## Install base dependencies
-RUN apt-get update && apt-get upgrade -y
-RUN apt-get install -y git mercurial build-essential software-properties-common wget pkg-config libgmp3-dev libreadline6-dev libpcre3-dev libpcre++-dev
-
-## Install Qt5.4.1 (not required for CLI)
-# RUN add-apt-repository ppa:beineri/opt-qt541-trusty -y
-# RUN apt-get update -y
-# RUN apt-get install -y qt54quickcontrols qt54webengine mesa-common-dev libglu1-mesa-dev
-# ENV PKG_CONFIG_PATH /opt/qt54/lib/pkgconfig
-
-# Install Golang
-RUN wget https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz
-RUN tar -C /usr/local -xzf go*.tar.gz && go version
-
-# this is a workaround, to make sure that docker's cache is invalidated whenever the git repo changes
-ADD https://api.github.com/repos/ethereum/go-ethereum/git/refs/heads/develop file_does_not_exist
-
-## Fetch and install go-ethereum
-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/geth
-
-## Run & expose JSON RPC
-ENTRYPOINT ["geth", "-rpc=true", "-rpcport=8545"]
-EXPOSE 8545
-
-
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index ddbd1f129..e399731e7 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -268,7 +268,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
}
func main() {
- fmt.Printf("Welcome to the FRONTIER\n")
+ fmt.Printf("\n\n█ █ █ █ █ █ ███ █ █\n█ █ █ ███ █ ███ ███ ███ ███ ███ ███ ███ ███ ███ █ ███ ███ ██ ███ ███ ███ \n█ █ █ ██ █ █ █ █ ███ ██ █ █ █ █ █ █ ██ ██ █ █ █ █ █ █ █ ██ █ \n█████ ███ ██ ███ ███ █ █ ███ ██ ███ ██ █ █ ███ █ █ ███ █ █ ██ ██ ███ █ \n\n")
runtime.GOMAXPROCS(runtime.NumCPU())
defer logger.Flush()
if err := app.Run(os.Args); err != nil {
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 000000000..b608e4ab6
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,31 @@
+FROM ubuntu:utopic
+MAINTAINER caktux
+
+ENV DEBIAN_FRONTEND noninteractive
+
+# Usual update / upgrade
+RUN apt-get update
+RUN apt-get upgrade -q -y
+RUN apt-get dist-upgrade -q -y
+
+# Let our containers upgrade themselves
+RUN apt-get install -q -y unattended-upgrades
+
+# Install Ethereum
+RUN apt-get install -q -y software-properties-common
+RUN add-apt-repository ppa:ethereum/ethereum
+RUN add-apt-repository ppa:ethereum/ethereum-dev
+RUN apt-get update
+RUN apt-get install -q -y geth
+
+# Install supervisor
+RUN apt-get install -q -y supervisor
+
+# Add supervisor configs
+ADD supervisord.conf supervisord.conf
+
+EXPOSE 8545
+EXPOSE 30303
+
+CMD ["-n", "-c", "/supervisord.conf"]
+ENTRYPOINT ["/usr/bin/supervisord"]
diff --git a/docker/supervisord.conf b/docker/supervisord.conf
new file mode 100644
index 000000000..33cba0c14
--- /dev/null
+++ b/docker/supervisord.conf
@@ -0,0 +1,23 @@
+[supervisord]
+nodaemon=false
+
+[program:geth]
+priority=30
+directory=/
+command=geth --rpc
+user=root
+autostart=true
+autorestart=true
+startsecs=10
+stopsignal=QUIT
+stdout_logfile=/var/log/geth.log
+stderr_logfile=/var/log/geth.err
+
+[unix_http_server]
+file=%(here)s/supervisor.sock
+
+[supervisorctl]
+serverurl=unix://%(here)s/supervisor.sock
+
+[rpcinterface:supervisor]
+supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface \ No newline at end of file
diff --git a/rpc/api.go b/rpc/api.go
index 66283752b..085d8cf27 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -56,7 +56,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
*reply = api.xeth().IsListening()
case "net_peerCount":
*reply = newHexNum(api.xeth().PeerCount())
- case "eth_version":
+ case "eth_protocolVersion":
*reply = api.xeth().EthVersion()
case "eth_coinbase":
*reply = newHexData(api.xeth().Coinbase())
@@ -189,7 +189,11 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return err
}
// TODO unwrap the parent method's ToHex call
- *reply = newHexData(common.FromHex(v))
+ if v == "0x0" {
+ *reply = newHexData([]byte{})
+ } else {
+ *reply = newHexData(common.FromHex(v))
+ }
case "eth_flush":
return NewNotImplementedError(req.Method)
case "eth_getBlockByHash":
diff --git a/rpc/args.go b/rpc/args.go
index d31773ff7..7694a3d3f 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -145,12 +145,8 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
return NewInsufficientParamsError(len(obj), 2)
}
- if v, ok := obj[0].(float64); ok {
- args.BlockNumber = int64(v)
- } else if v, ok := obj[0].(string); ok {
- args.BlockNumber = common.Big(v).Int64()
- } else {
- return NewInvalidTypeError("blockNumber", "not a number or string")
+ if err := blockHeight(obj[0], &args.BlockNumber); err != nil {
+ return err
}
args.IncludeTxs = obj[1].(bool)
@@ -539,11 +535,11 @@ func (args *BlockNumIndexArgs) UnmarshalJSON(b []byte) (err error) {
return err
}
- arg1, ok := obj[1].(string)
- if !ok {
- return NewInvalidTypeError("index", "not a string")
+ var arg1 *big.Int
+ if arg1, err = numString(obj[1]); err != nil {
+ return err
}
- args.Index = common.Big(arg1).Int64()
+ args.Index = arg1.Int64()
return nil
}
diff --git a/rpc/args_test.go b/rpc/args_test.go
index cfe6c0c45..2f011bfd9 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -355,6 +355,25 @@ func TestGetBlockByNumberArgsBlockHex(t *testing.T) {
t.Errorf("IncludeTxs should be %v but is %v", expected.IncludeTxs, args.IncludeTxs)
}
}
+func TestGetBlockByNumberArgsWords(t *testing.T) {
+ input := `["earliest", true]`
+ expected := new(GetBlockByNumberArgs)
+ expected.BlockNumber = 0
+ expected.IncludeTxs = true
+
+ args := new(GetBlockByNumberArgs)
+ if err := json.Unmarshal([]byte(input), &args); err != nil {
+ t.Error(err)
+ }
+
+ if args.BlockNumber != expected.BlockNumber {
+ t.Errorf("BlockNumber should be %v but is %v", expected.BlockNumber, args.BlockNumber)
+ }
+
+ if args.IncludeTxs != expected.IncludeTxs {
+ t.Errorf("IncludeTxs should be %v but is %v", expected.IncludeTxs, args.IncludeTxs)
+ }
+}
func TestGetBlockByNumberEmpty(t *testing.T) {
input := `[]`
@@ -2165,6 +2184,21 @@ func TestBlockNumArgs(t *testing.T) {
}
}
+func TestBlockNumArgsWord(t *testing.T) {
+ input := `["pending"]`
+ expected := new(BlockNumIndexArgs)
+ expected.BlockNumber = -2
+
+ args := new(BlockNumArg)
+ if err := json.Unmarshal([]byte(input), &args); err != nil {
+ t.Error(err)
+ }
+
+ if expected.BlockNumber != args.BlockNumber {
+ t.Errorf("BlockNumber shoud be %#v but is %#v", expected.BlockNumber, args.BlockNumber)
+ }
+}
+
func TestBlockNumArgsInvalid(t *testing.T) {
input := `{}`
@@ -2214,6 +2248,26 @@ func TestBlockNumIndexArgs(t *testing.T) {
}
}
+func TestBlockNumIndexArgsWord(t *testing.T) {
+ input := `["latest", 67]`
+ expected := new(BlockNumIndexArgs)
+ expected.BlockNumber = -1
+ expected.Index = 67
+
+ args := new(BlockNumIndexArgs)
+ if err := json.Unmarshal([]byte(input), &args); err != nil {
+ t.Error(err)
+ }
+
+ if expected.BlockNumber != args.BlockNumber {
+ t.Errorf("BlockNumber shoud be %#v but is %#v", expected.BlockNumber, args.BlockNumber)
+ }
+
+ if expected.Index != args.Index {
+ t.Errorf("Index shoud be %#v but is %#v", expected.Index, args.Index)
+ }
+}
+
func TestBlockNumIndexArgsEmpty(t *testing.T) {
input := `[]`
@@ -2245,7 +2299,7 @@ func TestBlockNumIndexArgsBlocknumInvalid(t *testing.T) {
}
func TestBlockNumIndexArgsIndexInvalid(t *testing.T) {
- input := `["0x29a", 1]`
+ input := `["0x29a", true]`
args := new(BlockNumIndexArgs)
str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), &args))